明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 3584|回复: 7

SOS!如何判断多边形是否是自交的?

[复制链接]
发表于 2004-11-16 22:16:00 | 显示全部楼层 |阅读模式
如何判断多边形是否是自交的?比如对顶角三角形的多边形;顶点走回头路的多边形等都属于自交的情况。怎样用lisp来快速的找出这样的多边形来并指出具体的自交位置?还望各位老师指点迷津.谢谢!
发表于 2004-11-17 06:36:00 | 显示全部楼层

Here is a routine from NG Autodesk, for closed LWPOLYLINE, you can use it. If it is not closed, close it first.

The error message, here is "Automation Error. Invalid input", might be different in Chinese version. You got to modify it.

;;f:pline_intersects returns T if given a self-intersecting lwpolyline

;;

(defun f:pline_intersects (en / sa rg)

(setq sa (vlax-make-safearray vlax-vbObject '(0 . 0))

sa (vlax-make-variant

(vlax-safearray-fill sa (list (f:enx en))))

) ;setq

(if (vl-catch-all-error-p

(setq rg (vl-catch-all-apply

'vla-addregion

(list (fx:active_space) sa))))

(if (wcmatch (vl-catch-all-error-message rg) "Automation Error. Invalid input")

;"*UNGÜLTIGE*")

T)

(vla-Delete

(car (vlax-safearray->list (vlax-variant-value rg))))

)

)

(defun fx:active_space ()

(if (zerop (getvar "TILEMODE"))

(vla-get-PaperSpace (fx:doc))

(vla-get-ModelSpace (fx:doc))

)

)

(defun f:enx (en)

(if (= (type en) 'ENAME)

(vlax-ename->vla-object en)

en

)

)

(defun fx:doc() (vla-get-activedocument (vlax-get-acad-object)))

发表于 2004-11-17 12:39:00 | 显示全部楼层
用intersectwith method 找(自身)交点,看顶点数与交点来判定是否自交(注意交点不包含首尾点)
发表于 2004-11-17 13:30:00 | 显示全部楼层
楼上正解
发表于 2004-11-17 14:31:00 | 显示全部楼层
龙龙仔发表于2004-11-17 12:39:00用intersectwith method 找(自身)交点,看顶点数与交点来判定是否自交(注意交点不包含首尾点)

I'd like to know your completed answer.
发表于 2004-11-17 17:22:00 | 显示全部楼层
找(自身)交点= 求交点时选择同一条线试试
发表于 2004-11-17 17:39:00 | 显示全部楼层
问题是有时顶点重合
发表于 2004-11-24 01:01:00 | 显示全部楼层
龙龙仔发表于2004-11-17 12:39:00用intersectwith method 找(自身)交点,看顶点数与交点来判定是否自交(注意交点不包含首尾点)
自相交,不一定有交点的(按楼主的意思,是走了回头路) 如果是回头的话,应该是去掉某一定义点,面积不会变。(以前想了很久的问题,答案不很全面,不过有些问题还是可以解决的)
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-9-30 04:15 , Processed in 0.166531 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表