![]() |
【转帖】incorrect mirroring on 2d polylines
incorrect mirroring on 2d polylines ?
incorrect mirroring on 2d polylines ? in the attached file there are numerous 2d polylines that are mirrored about the x and/or y axis. my application is creating the transformation matrix, applying it to the entity, and then exploding the result into the individual entities. it seems that after the transformation and mirroring about an axis the arc entities within the polyline are not being reversed. all the arc normals remain at 0,0,1. the code below illustrates the issue: i am using version 2.01 static void debug11314 (oddbdatabaseptr pdb) { oddbentityptr pentinsert, pent, pentcopy; v_entity_type entitytype; odgematrix3d odobjectmatrix; odresult odret; oddb::poly2dtype polytype; //blockref pentinsert = pdb->getoddbobjectid(oddbhandle("4f697")).openobject() ; //get the transformation matrix if (getobjecttransform (pentinsert, entitytype, &odobjectmatrix) == false) return; //entity pent = pdb->getoddbobjectid(oddbhandle("4f5d0")).openobject() ; odret = pent->gettransformedcopy (odobjectmatrix, pentcopy); // print out arc data for original & transformed entity debug11314readbyexplosion (pent); debug11314readbyexplosion (pentcopy); return; } static void debug11314readbyexplosion (oddbentityptr pent) { odrxobjectptrarray entityset; odresult odret; odret = ((oddb2dpolylineptr)pent)->explode (entityset); noentries = entityset.length (); if (noentries == 0) return; odrxobjectptrarray::iterator pit = entityset.begin(); for(; pit != entityset.end(); ++pit) { pobj = pit->get(); if (pobj->iskindof(oddbarc::desc()) == false) continue; parc = pobj; as = parc->startangle (); af = parc->endangle (); debug_printf ("angles = %f, %f \n", as, af); normal = parc->normal(); debug_printf ("normal = %f, %f, %f \n", normal.x, normal.y, normal.z); } } regards gerry as i am unable to upload file i will mail separately mirroring transformation about x or y does not reverse normal. explode produces arcs having the same normal as original polyline entity. this causes direction of clock-wise segents to be changed (start and end points are exchanged). this is intended behavior (like autocad does). sergey slezkin thank you. i did not realise that mirroring retained the same normal, and in effect reversed the polyline. nevertheless in this example the mirroring on arcs does seem to be incorrect. to simplify the data i have used the same transformation matrix (handle 4f697), but set the translation co-ordinates to zero, using the statements n.x = 0.0; n.y = n.z = 0.0; odobjectmatrix.settranslation (n); the matrix now represents a mirroring about the x axis. if i explode the polyline (handle 4f5d0) and examine the 2nd line and 5th arc (because they are physically close to each other) of the original and transformed polylines i get the following results. all z co-ordinates are 0.0 for the 2nd line from the original polyline start x-12.711 y35.094 end x-44.526 y0.387 for the 2nd line from the transformed polyline start x-12.711 y-35.094 end x-44.526 y-0.387 these results show a mirroring around the x axis. for the 5th arc from the original polyline centre x-55.055 y-0.000000 rad 9.0 (y is actually -6e-11) start x-58.797 y8.185 end x-46.576 y-3.018 normal x0.000000 y0.000000 z1.000000 for the 5th arc from the transformed polyline centre x-50.318 y-5.167 rad 9.0 start x-58.797 y-8.185 end x-46.576 y3.018 normal x0.000000 y0.000000 z1.000000 clearly not mirrored about the axis. the centre co-ordinates should not change in x, and if the centre y co-ordinate is 0.0, then the mirrored object co-ordinate should also be zero. regards gerry i reproduced the problem. the defect is in oddb2dpolyline::transformby(). it should negate bulge value if tranformation is mirroring. sergey slezkin is this a bug that is going to be fixed? is this a bug that is going to be fixed? what is the best workaround? this bug was fixed in 2.3.1 sergey slezkin |
所有的时间均为北京时间。 现在的时间是 12:56 PM. |