| 
使用ARX的几何库 AcGeCurveCurveInt3d 类 判断曲线位置关系,两曲线的交点关系有如下可能:
×
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册 
    1、相交 2、相离 3、内部 4、外部、5、相贴
 
 AcGe::AcGeXConfig Enum
 AcGeXConfig
 | Name | Declared Value | Description |  | kNotDefined | 1 << 0 |  |  | kUnknown | 1 << 1 |  |  | kLeftRight | 1 << 2 |  |  | kRightLeft | 1 << 3 |  |  | kLeftLeft | 1 << 4 |  |  | kRightRight | 1 << 5 |  |  | kPointLeft | 1 << 6 |  |  | kPointRight | 1 << 7 |  |  | kLeftOverlap | 1 << 8 |  |  | kOverlapLeft | 1 << 9 |  |  | kRightOverlap | 1 << 10 |  |  | kOverlapRight | 1 << 11 |  |  | kOverlapStart | 1 << 12 |  |  | kOverlapEnd | 1 << 13 |  |  | kOverlapOverlap | 1 << 14 |  | 
 
 通过图示说明下
 
 
   
 通过使用AcGeCurveCurveInt3d类下的getIntConfigs方法,下面写个判断两曲线关系的函数。
 
 
 (defun XD::Curve:Relation (e1 e2 / config config1 g1 g2 gint i numints pos1
                              pos2 ret tf
                          )
  (if (and
        (setq g1 (xdge::Constructor e1))
        (setq g2 (xdge::Constructor e2))
        (setq gint (xdge::Constructor "kCurveCurveInt3d" g1 g2))
      )
    (progn
      (setq numints (xdge::getpropertyvalue gint "numintpoints"))
      (cond
        ((= numints 0)
          (cond
            ((xdrx_curve_isclosed e1)
              (if (xdrx_curve_isinside e1 e2)
                (setq ret "Outside")
                (progn
                  (if (xdrx_curve_isclosed e2)
                    (if (xdrx_curve_isinside e2 e1)
                      (setq ret "Inside")
                      (setq ret "Disjoint")
                    )
                    (setq ret "Disjoint")
                  )
                )
              )
            )
            (t
              (setq ret "Disjoint")
            )
          )
        )
        ((> numints 0)
          (setq tf t
                i 0
          )
          (setq config1 (xdge::getpropertyvalue gint "getintconfigs" 0 t)
                pos1 (car (xdrx_string_regexps "(?<=k)[a-zA-Z]+(?=overlap)"
                                               (car config1)
                          )
                     )
          )
          (while (and
                   tf
                   (< i numints)
                 )
            (setq config (xdge::getpropertyvalue gint "getintconfigs" i t))
            (setq i (1+ i))
            (setq pos2 (car (xdrx_string_regexps "(?<=koverlap)[a-zA-Z]+"
                                                 (car config)
                            )
                       )
            )
            (if (or
                  (and
                    (xdrx_string_regexps "right" (car config))
                    (xdrx_string_regexps "left" (car config))
                  )
                  (and
                    pos2
                    (/= pos2 "Overlap")
                    (/= pos1 pos2)
                  )
                )
              (progn
                (setq tf nil
                      ret "Intersect"
                )
              )
            )
          )
          (if (not ret)
            (setq ret "Overlap")
          )
        )
      )
    )
  )
  ret
)
 
   
 
 测试命令TT
 
 
 (defun c:tt ()
  (if (and (setq e1 (car (entsel)))
           (setq e2 (car (entsel)))
      )
    (progn
      (setq pos (XD::Curve:Relation e1 e2))
      (cond
        ((= pos "Inside")
         (xdrx_prompt "\n曲线1在曲线2内部!")
        )
        ((= pos "Outside")
         (xdrx_prompt "\n曲线1在曲线2外部!")
        )
        ((= pos "Intersect")
         (xdrx_prompt "\n曲线1和曲线2相交!")
        )
        ((= pos "Disjoint")
         (xdrx_prompt "\n曲线1和曲线2相离!")
        )
        ((= pos "Overlap")
         (xdrx_prompt "\n曲线1和曲线2相贴!")
        )
      )
    )
  )
  (princ)
)
 
 
 |