几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   DirectDWG (http://www.dimcax.com/hust/forumdisplay.php?f=89)
-   -   【转帖】oddbblockreference and transformation matri (http://www.dimcax.com/hust/showthread.php?t=17479)

yang686526 2009-05-06 07:25 PM

【转帖】oddbblockreference and transformation matri
 
oddbblockreference and transformation matrix
oddbblockreference and transformation matrix
hello,
i would like to build my own data structure from the oddbdatabase structure, and particularly the block references...
in fact, i am facing the problem to get the oddbblockreference referenced entity's geometry without any transformation, to get the transformation matrix and to build my own data structure that instantiate the geometry with a transformation matrix...
in order to get the geometry of the entities, i use the same code as in the vectorizer sample...
i think this code is too heavy because it duplicates the whole referenced entity in order to get it untouched by the transformation matrix and it can be dangerous because i am not sure that the inverted transformation matrix exists...
is there a simpler way to do the job?
thank you for your help
guilhem
code:
/* here, i have
* odstaticrxobject<vectorizer> * vectorizer,
* oddbentityptr dwg_entity */
if (dwg_entity->isa() == oddbblockreference::desc() &&
dwg_entity->iskindof (odgidrawable::desc()) ) {
oddbblockreferenceptr ref = dwg_entity;
oddbblocktablerecordptr record = ref->blocktablerecord().safeopenobject();

/* get the dwg matrix */
odgematrix3d dwg_matrix = ref->blocktransform();
odgepoint3d basept (record->origin());
dwg_matrix *= odgematrix3d::translation (odgepoint3d::korigin - basept);
/* try to get the object associated to the entity */
if (i have not already encounrered this entity, i need to build its
geometry in order to reuse it) {
oddbentityptr dwg_copy;
odgematrix3d dwg_matrix_copy = dwg_matrix;
ref->gettransformedcopy (dwg_matrix_copy.invert(), dwg_copy);
# if 0
/* the idea here does not work and cause an assertion error
* in dd libs : the idea was to set the transformation matrix
* of this entity to the identity matrix in order to get its
* geometry untouched. so i try the code above with duplication */
/* set the transformation matrix to the identity */
//test1=crash ref->transformby (odgematrix3d::kidentity);
//test2=crash ref->setblocktransform (odgematrix3d::kidentity);
# endif
/* capture the geometry */
vectorizer->draw (dwg_copy);
}
/* here i instanciate my entity structure in my object */
...


所有的时间均为北京时间。 现在的时间是 07:12 AM.