高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】bug exporting oddbline objects
bug exporting oddbline objects?
transformby works for oddbline, doesn't appear to transform other objects
hi,
we have come across a problem whilst exporting .dgw files from our software.
we work in metre units, but sometimes we recieve dwg files with millimetre coordinates. when we import those files, we apply a scaling matrix to each object, that converts the objects to use metre coordinates. the scaling elements of the matrix are, in this case, 0.001 and 0.001.
when exporting the scaled objects, we export them by setting their unscalled coordinates and then calling the transformby method with our scaling matrix. this is an example of the code we use to create a polyline for export:
oddbpolylineptr splwpolyline;
odcmcolor colour(odcmentitycolor::kbycolor);
colour.setrgb(pcadlwpolyline->getcolour().m_rgba.r,pcadlwpolyline->getcolour().m_rgba.g,pcadlwpolyline->getcolour().m_rgba.b);
splwpolyline = oddbpolyline::createobject();
spmodelspace->appendoddbentity(splwpolyline);
splwpolyline->setconstantwidth(pcadlwpolyline->constant_width);
splwpolyline->setelevation(pcadlwpolyline->elevation);
splwpolyline->setthickness(pcadlwpolyline->thickness);
splwpolyline->setnormal( odgevector3d( pcadlwpolyline->extrusion.x, pcadlwpolyline->extrusion.y,pcadlwpolyline->extrusion.z));
splwpolyline->setclosed( (pcadlwpolyline->type_flags & 1) ? true : false);
//
// set individual vertices and their attributes
for(unsigned int nindex = 0; nindex < static_cast<unsigned int>(pcadlwpolyline->num_vertices); ++nindex)
{
splwpolyline->addvertexat(nindex,odgepoint2d(pcadlwpolyline->vectors[nindex].x,pcadlwpolyline->vectors[nindex].y),pcadlwpolyline->bulge[nindex],pcadlwpolyline->start_width[nindex],pcadlwpolyline->end_width[nindex]);
}
splwpolyline->setlayer(dblayerid, false);
splwpolyline->setcolor(colour);
splwpolyline->transformby(transform);
we add all our cad entities to the model-space block table, then write the dwg database to a file.
loading the exported .dwg into autocad shows lines with the correctly scaled coordinates - that is their start and end points are now in metres and not millimeters. however other objects, like lightweight polylines and circles, still have the original millimetre coordinates.
i added some code to check the polyline vertices before and after calling transformby:
std::vector< vector3 > verticesbefore;
for( nindex = 0; nindex < static_cast<unsigned int>(pcadlwpolyline->num_vertices); ++nindex )
{
odgepoint2d polypoint;
splwpolyline->getpointat( nindex, polypoint );
verticesbefore.push_back( vector3( polypoint.x, polypoint.y ) );
}
splwpolyline->transformby(transform);
std::vector< vector3 > verticesafter;
for( nindex = 0; nindex < static_cast<unsigned int>(pcadlwpolyline->num_vertices); ++nindex )
{
odgepoint2d polypoint;
splwpolyline->getpointat( nindex, polypoint );
verticesafter.push_back( vector3( polypoint.x, polypoint.y ) );
}
vector3 is our native object for storing a point.
examining the contents of the before and after std::vectors shows the points to be exactly the same. it appears that no transformation has been applied.
is this a bug in the behaviour of transformby or is this designed behaviour? are there special criteria that need to be met to correctly apply transformby to any object?
indeed can transformby be used universally, or is better to use gettransformedcopy?
thanks,
james stewart
senior developer, legion ltd.
last edited by legion; 25th may 2006 at 05:03 amfff">. reason: change of bug description
|