查看单个帖子
旧 2009-05-06, 10:01 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】pline and pxform

pline and pxform
pline and pxform
i am using vectorization in dd 1.13.02.
how do i interpret the odgematrix3d* pxform parameter passed into pline() proc during vectorization. no other function(polylineproc, circleproc etc.) get the matrix parameter.
is the view direction not considered when some entity gets vectorized as pline(eg. donut) ??
i use the following code to read plines:
code:
void exgssimpledevice:lineproc(const odgipolyline& lwbuf,
const odgematrix3d* pxform,
oduint32 i,
oduint32 numsegs){

if(numsegs == 0)
numsegs = lwbuf.numverts() - 1;
//double lwidth;

oduint32 nbpoints = numsegs + 1;

odgevector3d normal = lwbuf.normal();
odgipolyline::segtype segtype = lwbuf.segtype(fromindex);
for(oduint32 segindex = fromindex+1; segindex < nbpoints; ++segindex)
{
//segtype = lwbuf.segtype(segindex);
if(segtype == oddbpolyline::karc)
{
odgecircarc3d arc;
lwbuf.getarcsegat(segindex - 1, arc);
odgepoint3darray bezier;
beziercurve::arctobezier(bezier, arc);
//draw bezier
}
else
{
odgepoint2d pt;
lwbuf.getpointat(segindex, pt);
pathsegment segm;
segm.in.h = segm.out.h = segm.p.h = pt.x;
segm.in.v = segm.out.v = segm.p.v = pt.y;
//draw segm
}
segtype = lwbuf.segtype(segindex);

}
//segtype = lwbuf.segtype(segindex);
if(segtype == oddbpolyline::karc)
{
odgecircarc3d arc;
lwbuf.getarcsegat(segindex - 1, arc);
odgepoint3darray bezier;
beziercurve::arctobezier(bezier, arc);
//draw bezier
}
if(lwbuf.isclosed())
m_isclosed = true;
}

pxform is transform that you must apply to pline geometry before drawing (if exists).
this parameter was introduced to pline primitive only to reach compatibility of our rendering with autocad's one - linetype should be applied to pline primitive before any transforms. for other primitives linetype and xform are applied in order of corresponding conveyor nodes.
sincerely yours,
george udov

are the line segments in view coordinates?
i don't want to handle linetypes. can i simply get the correct results by applying pxform to each line segment?
something like:
plineproc(...)
{
// loop for all segments
{
// get segment type
// call correct lwbuf.get*segat() to get appropriate segment
// do {odgecircarc3d/odgepoint3d}.transformby(*pxform)
// map to app's native entity
}

but you should also take widths into account.
btw, odgigeometrysimplifer:lineproc was implemented exactly for turning this primitive to ones that simpler.
sincerely yours,
george udov
but plineproc() in odgigeometrysimplifer converts arcs into polyline also. something which we don't want.
on the original point, do we need to apply any other transform or is what i wrote earlier sufficent (except widths, of course)?
also, most of the get*segat() have 2 versions. one which returns a 2d parameter and one which returns a 3d parameters.
is the 3d one in view coordinates and 2d one in ocs?

quote:
on the original point, do we need to apply any other transform or is what i wrote earlier sufficent (except widths, of course)?
after transforming by xform you will get geometry in same coordinates with other primitives you get to this conveyor node.
what these coordinates are (world, view, device, etc) depends on conveyor.
sincerely yours,
george udov

quote:
originally posted by varunsnair
also, most of the get*segat() have 2 versions. one which returns a 2d parameter and one which returns a 3d parameters.
is the 3d one in view coordinates and 2d one in ocs?
2d are in ocs. 3d are those i written in previous message.
you can get 3d from 2d by adding elevation and transforming by matrix planetoworld(normal).
sincerely yours,
george udov
that explains it. i've been using some 2d one's and getting unexpected results.
thanks.
i noticed that there is no getpointat() variant with 3d parameter. does that mean that the point we get (2d) will always be in ucs?
if i get what you're suggesting, then we have to do:
1. get 2d point
2. make point 3d (p3d.x = p2d.x; p3d.y = p2d.y; p3d.z = pline.elevation()
3. apply planetoworld transform to the 3d point.
am i correct?
also in that case what is the order of applications of transforms? do we apply pxform first or the planetoworld transformation first?

yes, it always will be in ocs (you seems to be misprinted).
quote:
if i get what you're suggesting, then we have to do:
1. get 2d point
2. make point 3d (p3d.x = p2d.x; p3d.y = p2d.y; p3d.z = pline.elevation()
3. apply planetoworld transform to the 3d point.
am i correct?
yes.
quote:
also in that case what is the order of applications of transforms? do we apply pxform first or the planetoworld transformation first?
of course, planetoworld transformation first. then pxform.
sincerely yours,
george udov
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)