马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
使用AcGeEntity3d::boundBlock和AcGeEntity3d::orthoBoundBlock
1、求正交的盒子用 orthoBoundBlock,求随轴的盒子,用boundBlock
2、对于正交的盒子,调用isBox返回kTrue
3、getMinMaxPoints是求正交盒子的最大最小点
4、求随轴盒子的最大最小点,不要用getMinMaxPoints,要考虑转轴的向量和基点,这个通过Get方法得到
5、当然,都通过GET,都能得到盒子的正确的四个角点,下面为了说明区别,求正交的盒子,用的是GetMinMaxPoints
AcGeBoundBlock3d::get Function
void get( AcGePoint3d& base, AcGeVector3d& dir1, AcGeVector3d& dir2, AcGeVector3d& dir3) const; base | Output origin vertex a corner of the bounding box | dir1 | Output direction and size for first side of the bounding box | dir2 | Output direction and size for second side of the bounding box | dir3 | Output direction and size for third side of the bounding box | Computes a vertex and sides of the bounding block.
上面的DIR不是单位向量,他们的长度是边的长度。
下面代码演示了,看就理解了。
- (defun c:tt ()
- (if (and (setq e (car (xdrx_entsel
- "\n拾取一个曲线<退出>:"
- '((0 . "*LINE,ARC,ELLIPSE,CIRCLE"))
- )
- )
- )
- (setq g (xdge::constructor e))
- )
- (progn
- (xdrx_begin)
- (xdrx_initget "1 2")
- (if (setq sel (getint "\n正交(1)/随轴(2)<退出>:"))
- (progn (cond ((= sel 2)
- (setq box (xdge::getpropertyvalue g "boundblock"))
- (setq pts1 (xdge::getpropertyvalue box "get")
- origin (car pts1)
- xdir (cadr pts1)
- ydir (caddr pts1)
- zdir (cadddr pts1)
- )
- (setq p1 origin
- p2 (mapcar '+ p1 xdir)
- p3 (mapcar '+ p2 ydir)
- p4 (mapcar '+ p1 ydir)
- )
- )
- (t
- (setq box (xdge::getpropertyvalue g "orthoboundblock"))
- (setq pts1 (xdge::getpropertyvalue box "getMinMaxPoints")
- dir (mapcar '- (cadr pts1) (car pts1))
- p1 (car pts1)
- p2 (mapcar '+ p1 (list (car dir) 0.0 0.0))
- p3 (cadr pts1)
- p4 (mapcar '+ p1 (list 0.0 (cadr dir) 0.0))
- )
- )
- )
- (xdrx_polyline_make p1 p2 p3 p4 t)
- (xdrx_setpropertyvalue
- (entlast)
- "color"
- sel
- "constantwidth"
- 10.0
- )
- )
- )
- (xdrx_end)
- )
- )
- (princ)
- )
上面的随轴的盒子,也可以说是这个曲线凸包的最小面积盒,下面图,黄色线是凸包边界,红线是最小面积包围盒
下面代码求:
- (defun c:tt ()
- (if (setq e (car (xdrx_entsel
- "\n拾取一个曲线<退出>:"
- '((0 . "*LINE,ARC,ELLIPSE,CIRCLE"))
- )
- )
- )
- (progn (setq pts (xdrx_getsamplept e)
- hull (xdrx_points_ghull pts)
- pts1 (xdrx_points_minareabox pts)
- )
- (xdrx_polyline_make pts1 t)
- (xdrx_setpropertyvalue
- (entlast)
- "color"
- 1
- "constantwidth"
- 15.0
- )
- (xdrx_polyline_make hull t)
- (xdrx_setpropertyvalue
- (entlast)
- "color"
- 2
- "constantwidth"
- 30.0
- )
- )
- )
- (princ)
- )
|