几何尺寸与公差论坛------致力于产品几何量公差标准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)
-   -   【转帖】ransformations Using Worlddraw (http://www.dimcax.com/hust/showthread.php?t=18803)

yang686526 2009-05-07 05:12 PM

【转帖】ransformations Using Worlddraw
 
transformations using worlddraw
transformations using worlddraw
hi there,
i wish to read a file and obtain the data (& attributes like colour etc) of all the entities in world co-ordinates. reading the documentation & mails of the forum it seems that the library can handle matrix stacks and manage all the transformations.
so in the code below when i find an insert i push the transformation, process all entities in the block, and then pop the transformation.
each entity is processed by worlddraw, and this i assume introduces this entity into a vectorisation context, and therefore as your document states "the current model transformation is applied to all geometry introduced into this vectorization context.". i.e all the transformation are done by the library.
however, elsewhere you say: "the oddbentity class defines a virtual oddbentity::worlddraw() function, which is used for vectorization. each class derived from oddbentity overrides this function in order to perform custom vectorization. this function provides a convenient method for extracting the geometric representation of an entity in a generic manner."
does this mean that entity transformation is the responsibility of my application. ??
when i read a simple file of a rectangular insert with a translation, no entity transformation takes place.
or is there something wrong with my implementation ??
regards
gerry
//set up the dumper
worlddrawdumper wdd;
contextdumper ctx(idblock.database());
wdd.setcontext(&ctx);
short processblock (oddbobjectid idblock)
{
oddbblocktablerecordptr pblock;
oddbobjectiteratorptr pents;
pblock = idblock.openobject();
pents = pblock->newiterator();
//loop around all the entities
while (!pents->done())
{
oddbentityptr pent = pents->entity();
pents->step();
// is this an insert ?
if (pent->iskindof(oddbblockreference::desc()))
{
odgematrix3d odmatrix;
odmatrix = ((oddbblockreferenceptr)pent)->blocktransform ();
wdd.geometry().pushmodeltransform (odmatrix);
// process nested block recursively
processblock (((oddbblockreferenceptr)pent)->blocktablerecord());
wdd.geometry().popmodeltransform ();
else
{ //process non-insert entity
ret = pent->worlddraw(&wdd);
}
}
you need not treat block reference entity differently from others.
oddbblockrefernce::worldraw() performs:
1. push transformation (taking into account block's base point - your code does not honour it).
2. push clip boundary (if spatial filter is applied to block reference)
3. call geometry->draw(oddbblocktablerecord)
4. pop clip boundary (if was applied)
5. pop transform
6. iterate through attributes and draw them.
oddbblocktablerecord::worlddraw() iterates through block entities (taking into account sortents) and draw them.
"...all transformations are performed by library..."
this depends on point of view. if you are implementing worlddraw() function for your custom entity it's absolutely right.
the entity does not have to worry about outer transformations. they will be performed "by library" - rendering engine.
but it's not the case if you implement vectorization context as odgiworlddraw inheritor and call entity's worlddraw() passing your odgiworlddraw object. it will recieve not transformed primitives directly as they are called from entity's worlddraw().
if you implement your device class - you'll get transformed to device coordinates geometry.
see odvectorizeex sample.
sergey slezkin


所有的时间均为北京时间。 现在的时间是 06:54 PM.