![]() |
【转帖】ransformby
transformby
transformby an exception is thrown everytime "pent->transformby(blocktransformmatrix)" is called. does anybody know why? if it helps, pent is a oddbpolyline. odgematrix3d blocktransformmatrix = pblockref->blocktransform(); oddbblocktablerecordptr pblocktablerecordptr = pblockref->blocktablerecord().safeopenobject(); oddbobjectiteratorptr pobjectiteratorptr = pblocktablerecordptr->newiterator(); oddbentityptr pent; while(!pobjectiteratorptr->done()) { pent = pobjectiteratorptr->entity(); pent->transformby(blocktransformmatrix); ... pobjectiteratorptr->step(); } the base class (oddbentity) definition of transformby is not to be used. you must use the derived method for that object as: oddbentityptr pent; while(!pobjectiteratorptr->done()) { pent = pobjectiteratorptr->entity(); if(pent->iskindof(oddbpolyline::desc())) { oddbpolylineptr ppoly = pent; ppoly->transformby(blocktransformmatrix); }else .... ... pobjectiteratorptr->step(); } i still get an exception with this new code. "ppoly->transformby(blocktransformmatrix)" now throws the excpetion. odgematrix3d blocktransformmatrix = pblockref->blocktransform(); oddbblocktablerecordptr pblocktablerecordptr = pblockref->blocktablerecord().safeopenobject(); oddbobjectiteratorptr pobjectiteratorptr = pblocktablerecordptr->newiterator(); oddbentityptr pent; while(!pobjectiteratorptr->done()) { pent = pobjectiteratorptr->entity(); if (pent->iskindof(oddbpolyline::desc())) { oddbpolylineptr ppoly = pent; ppoly->transformby(blocktransformmatrix); } probably you haven't opened the entity for write - pobjectiteratorptr->entity(); should be pobjectiteratorptr->entity(oddb::kforwrite); also be aware that in objecarx (i don't know how it is in dwgdirect), the block transform can have different scales for x, y, and z, while the transformby() function usually needs equal values for the scale. i.e. a circle scaled x=1.5,y=3 as seen through a block reference, would be rendered as ellipse, but a oddbcircle cannot be transformed to oddbellipse in this way. regards chudomir transformby() is virtual function so pent->transformby(matrix) is ok. chudomir is absolutely right. 1. iterators entity() method has parameter open mode. default is for read. to modify entity piter->entity(oddb::kforwrite) should be used. 2. not all entities can be transformed by non-uniform scale matrix. sometimes gettransformedcopy() can be used. for example oddbtext can't be transformed by non-uniform scale matrix but gettransformedcopy() works for it. oddbcircle can't be transformed non-uniformly but gettransformedcopy() returns oddbellipse. as for oddbpolyline both functions fail if scale is non-uniform (because of possible bulges). sergey slezkin how can i treat nonuniform scaled block with "3d circle"? hello. i need help to read dwg-file (see into attachment). in dwg-file i create cirlce with thickness = 100 (it looks as 3d surface). put it into a block. then transorm block with nonuniform scale( scale x = 1.5, scale y = 1, scale z = 1). gettransformedcopy() function return oddbellips object. but oddbellips haven't got thickness (it look as 2d curve, but i want to get 3d shape). i have got other attempt. i use oddbentity.worlddraw(); but in odgiworldgeometrydumper class (derived from odgiworldgeometry) i have only one function call: virtual void circle( const odgepoint3d & center, double radius, const odgevector3d & normal ); it is flat (plane) curve. odamfc draw it excelent, so i throw into dismay. what i may do wrong? how can i treat nonuniform scaled block with 3d circle? i'm using dwgdirect 2.6.3 and vc 6.0. best regards, andrey. attached files (49.3 kb, 0 views) the circle you get is not flat. at this moment thickness in traits is non-zero. if you call base class circle() in this situation you'll get shell(). sergey slezkin hello, sergey. could you explain one thing, please. i'm using odgiworldgeometrydumper class as an example (giworlddrawdumper.h & .cpp files) "class odgiworldgeometrydumper : public odstaticrxobject<odgiworldgeometry>" but odgigeometry class hasn't an implementation of circle(). which class should i use to inherit odgiworldgeometrydumper class from? could you describe in detail? best regards, andrey it seems you started from wrong sample (if you need vectorization). look at odvectorizeex sample. it uses odgigeometrysimplifier as a base class. sergey slezkin |
所有的时间均为北京时间。 现在的时间是 09:49 PM. |