找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 1445|回复: 4

[教学] XDGE几何库应用(17)--AcGeCurve3d类方法介绍

[复制链接]

已领礼包: 1268个

财富等级: 财源广进

发表于 2014-9-27 07:04:32 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
本帖最后由 st788796 于 2014-11-1 08:07 编辑

(setq ge (xdge::constructor (car (entsel))))构造一个 AcGeCurve3d

一、 boundBlock 返回 AcGeBoundBlock3d 边界体

1 无参数时整根曲线
_$ (setq bd (xdge::getpropertyvalue ge "boundBlock"))
<图元名: 904a410>
_$ (xdge::getpropertyvalue bd "getMinMaxPoints")
((1319.45 225.837 -1.0e-008) (2650.51 1318.85 1.0e-008))

2 加入参数 Interval 可以返回区间内曲线的 boundBlock
_$ (setq in (xdge::constructor "AcGeInterval" 0.0 100.))
<图元名: 1d74da8>
_$ (xdge::getpropertyvalue ge "boundBlock" in)
<图元名: 1d74dc8>

二、closestPointTo 最近点

1 两曲线间最近点
(xdge::getpropertyvalue thisCrv3d "closestPointTo" ortherCrv3d)

2 曲线外点在曲线上的最近点(对于 Db 的 vlax-curve-getclosestpointto)
(xdge::getpropertyvalue thisCrv3d "closestPointTo" pnt)

三、distanceTo 两曲线间最近距离或点到曲线上最近点间距离

1 两曲线间最近距离
(xdge::getpropertyvalue thisCrv3d "distanceTo" ortherCrv3d)

2 点到曲线最小距离
(xdge::getpropertyvalue crv3d "distanceTo" pnt)
对应vlax-curve 方法 (distance pnt (vlax-curve-getclosestpointto cv pnt))

四、evalPoint 指定参数出点

1 指定参数处点
(xdge::getpropertyvalue crv3d "evalPoint" param)

2

五、getClosestPointTo 最近点

1 两曲线间最近点,同 closestPointTo 方法1,返回值为表 AcGePointOnCurve3d
(xdge::getpropertyvalue thisCrv3d "getClosestPointTo" ortherCrv3d)

2 返回与输入点对应的曲线上点,同 closetPointTo 方法2 ,返回值为 AcGePointOnCurve3d
(xdge::getpropertyvalue crv3d "getClosestPointTo" pnt)

六、getInterval 获取曲线的区间
(xdge::getpropertyvalue ge "getInterval")
返回值表:(AcGeInrervar startpoint endpoint)
_$ (xdge::getpropertyvalue ge "getInterval")
(<图元名: 909ab30> (2650.51 954.588 0.0) (1563.71 225.837 0.0))

七、getLocalClosestPoints

(待续)

本帖被以下淘专辑推荐:

论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!

已领礼包: 1268个

财富等级: 财源广进

 楼主| 发表于 2014-9-27 08:03:08 | 显示全部楼层
本帖最后由 st788796 于 2014-9-27 08:06 编辑

判断类

一、isClosed 判断曲线起点和端点是否相等,这个和 vlax-curve-isclosed 不同,
(xdge::getpropertyvalue ge "isClosed")

二、hasStartPoint 如果有起点返回起点(vlax-curve-getstartpoint),没有返回 nil
(xdge::getpropertyvalue ge "hasStartPoint")
_$ (xdge::getpropertyvalue ge "hasStartPoint")
(2650.51 954.588 0.0)

三、hasEndPoint 如果有端点返回端点(vlax-curve-getendpoint),没有返回nil
(xdge::getpropertyvalue ge "hasEndPoint")
_$ (xdge::getpropertyvalue ge "hasendPoint")
(1563.71 225.837 0.0)

四、reverseParam 反转曲线(对 arc ellispse circle 反转无效)
(xdge::setpropertyvalue ge "reverseParam")

五、length 指定参数间曲线长度
(xdge::getpropertyvalue ge from to)
_$ (xdge::getpropertyvalue ge "length" 0.0 100.)
4068.52
整线长度

_$ (xdge::getpropertyvalue ge "length" 0.0 (xdge::getpropertyvalue ge "paramOf" (xdge::getpropertyvalue ge"hasendpoint")))
2364.18


六、paramOf 指定点的参数值(注意点必须位于曲线上,求参数前对点进行 closestPointTo )
(xdge::getpropertyvalue ge "paramOf" pnt)
_$ (xdge::getpropertyvalue ge "paramOf" (getpoint))
2.57533


七、area 获取指定参数间面积
(xdge::getpropertyvalue ge "area" from to)
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 1268个

财富等级: 财源广进

 楼主| 发表于 2014-9-28 00:30:37 | 显示全部楼层
测试下一阶导数
  1. (defun c:tt (/ e ge p pam ss vec)
  2.   (if (and (setq e (car (entsel)))
  3.            (setq ge (xdge::constructor e))
  4.       )
  5.     (progn
  6.       (setq ss (ssadd))
  7.       (sssetfirst nil (ssadd e ss))
  8.       (while (setq p (getpoint "\ntest point: "))
  9.         (setq p          (xdge::getpropertyvalue ge "closestPointTo" p)
  10.               pam (xdge::getpropertyvalue ge "paramOf" p)
  11.         )
  12.         (princ "\n")
  13.         (princ pam)
  14.         (princ "\n")
  15.         (princ
  16.           (setq vec (xdge::getpropertyvalue ge "evalPoint" pam 1)) ;_一阶导数
  17.         )
  18.         (princ "\n")
  19.         (princ p)
  20.         (if vec
  21.           (progn
  22.             (pnt:drawarrow (car vec) (caadr vec) 1)
  23.             (pnt:drawarrow
  24.               (car vec)
  25.               (xdrx_vector_perpvector (caadr vec))
  26.               2
  27.             )
  28.           )
  29.         )
  30.       )
  31.     )
  32.   )
  33.   (xdge::free)
  34.   (princ)
  35. )
  36. (defun Pnt:DrawArrow (p v col / an p1 p2 p3)
  37.   (setq        an (angle '(0. 0. 0.) v)
  38.         p1 (polar p an (* 0.25 (getvar "viewsize")))
  39.         p2 (polar p1 (+ an (* 0.833333 pi)) (/ (distance p p1) 6.))
  40.         p3 (polar p1 (- an (* 0.833333 pi)) (/ (distance p p1) 6.))
  41.   )
  42.   (grvecs (list col p p1 col p1 p2 col p1 p3))
  43.   t
  44. )
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 1268个

财富等级: 财源广进

 楼主| 发表于 2014-9-28 02:07:44 | 显示全部楼层
getLocalClosestPointTo 的一个测试,由指定的两点做参考,在指定区间内查找两曲线上最近距离的点对,参数 interval 为可选,如果不给区间的 lower 是0.0, upperBound 是点的位置

这个函数在指定范围内求最近距离会更加方便

  1. (defun c:tt (/ e1 e2 gel gp1 gp2 l in1 in2 low1 low2)
  2.   (if (and (setq e1 (entsel));_选择曲线1
  3.            (setq e2 (entsel));_选择曲线2
  4.            (setq gel (xdge::constructor (car e1) (car e2)));_构造 Ge 曲线
  5.            (setq gel (mapcar 'xdge::entity:3d->2d gel));_用 2d 测试,3d 一样
  6.            (setq gp1 (xdge::constructor
  7.                        "kPointOnCurve2d"
  8.                        (car gel)
  9.                        (setq low1 (xdge::getpropertyvalue
  10.                                     (car gel)
  11.                                     "paramOf"
  12.                                     (xdge::getpropertyvalue
  13.                                       (car gel)
  14.                                       "closestPointTo"
  15.                                       (cadr e1)
  16.                                     );_构造 thisPointOnThisCurve
  17.                                   );_构造第一个测试区间 lowerBound
  18.                        )
  19.                      )

  20.                  gp2 (xdge::constructor
  21.                        "kPointOnCurve2d"
  22.                        (cadr gel)
  23.                        (setq low2 (xdge::getpropertyvalue
  24.                                     (cadr gel)
  25.                                     "paramOf"
  26.                                     (xdge::getpropertyvalue
  27.                                       (cadr gel)
  28.                                       "closestPointTo"
  29.                                       (cadr e2)
  30.                                     );_构造 ortherPointOnOrtherCurve
  31.                                   );_构造第二个测试区间 lowerBound
  32.                        )
  33.                      )
  34.            )
  35.            (xd::pnt:mark
  36.              (xd::pnt:setz (xdge::getpropertyvalue gp1 "Point") 0.)
  37.              1
  38.            )
  39.            (xd::pnt:mark
  40.              (xd::pnt:setz (xdge::getpropertyvalue gp2 "Point") 0.)
  41.              2
  42.            )
  43.       )
  44.     (progn
  45.       (setq in1        (car (xdge::getpropertyvalue (car gel) "getInterval"))
  46.             in2        (car (xdge::getpropertyvalue (cadr gel) "getInterval"))
  47.       )
  48.       (xdge::setpropertyvalue in1 "setLower" low1);_设置区间下限
  49.       (xdge::setpropertyvalue in2 "setLower" low2);_设置区间下限
  50.       (setq l (xdge::getpropertyvalue
  51.                 (car gel)
  52.                 "getLocalClosestPoints"
  53.                 (cadr gel)
  54.                 gp1
  55.                 gp2
  56.                 in1
  57.                 in2
  58.               )
  59.       );_以指定的两点为参考在指定区间内查找两曲线间最近距离对应点
  60.       (xdrx_line_make
  61.         (xdge::getpropertyvalue (car l) "Point")
  62.         (xdge::getpropertyvalue (cadr l) "Point")
  63.       )
  64.     )
  65.   )
  66.   (xdge::free)
  67.   (princ)
  68. )
更多图片 小图 大图
组图打开中,请稍候......
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 1268个

财富等级: 财源广进

 楼主| 发表于 2014-10-2 18:51:46 | 显示全部楼层
一个关于 reverseParam 的测试,对非闭合线好理解,闭合线是如何呢?
在 AcDb  中用 C 闭合的 Pline 反转时起点是在最后一段两端来回变化,在 Ge 中不是这样的,起点是不变的,反转后生成的 Pline,起点还是在原来位置,只是增加了一个终点,spline 使用 splinedit 反转后起点不变化
  1. (defun c:tt (/ _makepoints e ge pts)
  2.   (defun _makePoints (pts / i)
  3.     (setq i 0)
  4.     (mapcar '(lambda (x)
  5.                (xdrx_entity_setcolor (xdrx_point_make x) (setq i (1+ i)))
  6.              )
  7.             pts
  8.     )
  9.   )
  10.   (if (setq e (xdrx_entsel
  11.                 "\nPick closed pine: "
  12.                 '((0 . "lwpolyline") (-4 . "&=") (70 . 0))
  13.               )
  14.       )
  15.     (progn
  16.       (setq pts (xdrx_getpropertyvalue (car e) "vertices"))
  17.       (_makepoints pts)
  18.       (princ (strcat "\nnumVerts = " (itoa (length pts))))
  19.       (setq ge (xdge::constructor (car e)))
  20.       (xdge::getpropertyvalue ge "reverseParam")
  21.       (xdge::entity:make ge)
  22.       (xdge::free)
  23.       (vl-cmdf ".move" "L" "" (cadr e))
  24.       (while (/= (getvar "cmdactive") 0)
  25.         (command pause)
  26.       )
  27.       (setq pts (xdrx_getpropertyvalue (entlast) "vertices"))
  28.       (_makepoints (xdrx_getpropertyvalue (entlast) "vertices"))
  29.       (princ (strcat "\nnumVerts = " (itoa (length pts))))
  30.     )
  31.   )
  32.   (princ)
  33. )
  34. (defun c:tt1 (/ _makepoints e ge pts)
  35.   (defun _makePoints (pts / i)
  36.     (setq i 0)
  37.     (mapcar '(lambda (x)
  38.                (xdrx_entity_setcolor (xdrx_point_make x) (setq i (1+ i)))
  39.              )
  40.             pts
  41.     )
  42.   )
  43.   (if (setq e (xdrx_entsel
  44.                 "\nPick closed pine: "
  45.                 '((0 . "spline"))
  46.               )
  47.       )
  48.     (progn      
  49.       (xdrx_point_make (xdrx_curve_getstartpoint (car e)))
  50.       (setq ge (xdge::constructor (car e)))
  51.       (xdge::getpropertyvalue ge "reverseParam")
  52.       (xdge::entity:make ge)
  53.       (xdge::free)
  54.       (vl-cmdf ".move" "L" "" (cadr e))
  55.       (while (/= (getvar "cmdactive") 0)
  56.         (command pause)
  57.       )      
  58.       (xdrx_point_make (xdrx_curve_getstartpoint (entlast)))
  59.     )
  60.   )
  61.   (princ)
  62. )
20141002185127.jpg
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-4-19 09:36 , Processed in 0.210793 second(s), 41 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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