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


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » AutoCAD二次开发 » DirectDWG
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


回复
 
主题工具 搜索本主题 显示模式
旧 2009-05-05, 12:07 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】help with odgiworldgeometrydumperpline

help with odgiworldgeometrydumper:line
help with odgiworldgeometrydumper:line
i'm hoping someone can point out what i am missing in my implementation. the attached dwg file has two line in it, which when drawn in autocad and in the sample viewer provided with the dwgdirect libraries draw correctly, yet in my application one of the lines is in the wrong location. when i look at the vertices for each line, they are all positive in both the x and y position. when i walk through the pline method one line has all the x's negated. the only difference i can tell from looking in autocad is that one line has a positive elevation, and the one drawing in the wrong location has a negative elevation. i've stripped this method down to the bare essentials and am just printing points.
code:
void odgiworldgeometrydumper:line(const odgipolyline& lwbuf, oduint32 fromindex, oduint32 numsegs)
{
printf("odgiworldgeometrydumper:line(const odgipolyline& lwbuf, oduint32 fromindex, oduint32 numsegs)\n");
odgepoint3d tranpoint3d;
for (unsigned int i = 0; i < lwbuf.numverts(); i++) {
double bulge = lwbuf.getbulgeat(i);
if (bulge != 0.0) {
// <snip code to handle bulges>
}
else {
odgepoint2d pt;
lwbuf.getpointat(i, pt);
if (!transformationmatrices.empty()) {
const odgematrix3d &tranmatrix = this->transformationmatrices.top();
tranpoint3d.x = pt.x;
tranpoint3d.y = pt.y;
tranpoint3d.z = 0;
tranpoint3d.transformby(tranmatrix);
fprintf(f,"transforming point (%f,%f) to (%f,%f)\n",pt.x,pt.y,tranpoint3d.x,tranpoint3d.x);
}
else {
printf("no transform: (%f,%f)\n",pt.x,pt.y);
}
}
}
// handle case of lwbuf.isclosed() == true here....
}
when walking through with the debugger, neither line has a transformation matrix available.
nether line
a sample of the outout i get is:
odgiworldgeometrydumper:line(const odgipolyline& lwbuf, oduint32 fromindex, oduint32 numsegs)
no transform: (5151.730000,6974.130000)
no transform: (5151.344926,6973.008073)
no transform: (5151.136486,6972.637777)
no transform: (5150.145891,6971.881780)
<snip rest of points....they all look good>
odgiworldgeometrydumper:line(const odgipolyline& lwbuf, oduint32 fromindex, oduint32 numsegs)
no transform: (-5152.180000,7071.630000)
no transform: (-5151.856777,7071.135259)
no transform: (-5149.646174,7067.999632)
no transform: (-5149.480483,7067.894589)
thanks for any help you can provide.
steve
attached files
both odgipolyline and oddbpolyline have methods returning 2d and 3d geometry (point, line segment, arc segment).
3d methods return geometry in world coordinate system (wcs). 2d methods return geometry in object coordinate system (ocs).
ocs is defined by polyline's normal. and elevation z in ocs.
to get transformation matrices between ocs and wcs you can use odgematrix3d:lanetoworld(normal) and odgematrix3d::worldtoplane(normal).
or you can use 3d methods but this is less efficient. coordinates are stored in ocs and transformation matrix will be calculated each time you call getpointat(n, odgepoint3d&).
sergey slezkin
is doing the following valid? it works in this particular case, but i just want to verify that i won't be messing something else up.
at the start of the method, i added:
code:
if (lwbuf.elevation() != 0) {
this->pushmodeltransform(odgematrix3d::worldtoplane(lwbuf.normal()));
}
then at the end:
code:
if (lwbuf.elevation() != 0) {
this->popmodeltransform();
}
thanks,
steve
this is incorrect. for example if polyline's plane contains wcs point (0,0,0) elevation will be zero.
ocs plane differs from xy plane if normal is not equal to z axis. and elevation is distance from from (0,0,0) to ocs plane.
so you need to push transform is normal is not equal to (0,0,1). and make 3d point from 2d one using elevation as z coordinate.
sergey slezkin
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭



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


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多