;; ! **************************************************************************** ;; ! GE_Dist&AngWeed_Front ;; ! **************************************************************************** ;; ! Function : Weed a list based on inter-vertex distance AND angular deflection ;; ! between the points. ;; ! The deflection angle is considered to be 'Front' i.e the angle ;; ! checked is between this - CurPt, NextPt and NextNextPt. ;; ! Arguments: ;; ! 'vlist' - List to be weeded ;; ! 'WeedDist' - Maximum Distance allowable between points. ;; ! 'WeedAng' - Deflection angle to check between points. ;; ! 'MeasD' - Measure Distance in 2D or 3D (accepts "Slope" or ;; ! "Horiz") ;; ! Return : Returns two lists, the first one is a list of retained points ;; ! and the second is a list of points which were weeded along with ;; ! their list array index (starting from 0). ;; ! Comments : The first and last points of the list will never be weeded ;; ! Author : Rakesh Rao, (C) 2004, Copyrights Four Dimension Technologies, ;; ! Bangalore ;; ! Updated : March 11, 2001 ;; ! (C) 1999-2004, Four Dimension Technologies, Bangalore ;; ! e-mail : rakesh.rao@4d-technologies.com ;; ! Web : www.4d-technologies.com ;; ! **************************************************************************** (defun GE_Dist&AngWeed_Front( vlist WeedDist WeedAng MeasD / nverts DelLst _vlist cnt CurPt More NextPt NextNextPt ang len1 len2 LastPt ) (setq nverts (length vlist) DelLst '() ) (if (<= nverts 2) (setq _vlist vlist) (progn (setq CurPt (car vlist) ; Make sure that the first [and last] points are not weeded LastPt (last vlist) More T _vlist (list CurPt) vlist (cdr vlist) cnt 0 ) (while More (setq cnt (1+ cnt) NextPt (nth 0 vlist) NextNextPt (nth 1 vlist) ) (if NextPt (progn (if (= MeasD "Slope") (setq len1 (distance CurPt NextPt)) (setq len1 (distance (list (car CurPt) (cadr CurPt) 0.0) (list (car NextPt) (cadr NextPt) 0.0) ) ) ) (if (< len1 WeedDist) (setq DelLst (cons NextPt DelLst) vlist (cdr vlist) ) (progn (if NextNextPt (progn (setq ang (GE_AngleBetn2L CurPt NextPt NextPt NextNextPt)) (if ang (setq ang (apply 'min ang)) ) (if (and ang (< ang WeedAng)) (progn (if (= MeasD "Slope") (setq len2 (distance CurPt NextNextPt)) (setq len2 (distance (list (car CurPt) (cadr CurPt) 0.0) (list (car NextNextPt) (cadr NextNextPt) 0.0) ) ) ) (if (< len2 WeedDist) (progn (setq DelLst (cons NextPt DelLst) vlist (cdr vlist) ) ) (setq _vlist (cons NextPt _vlist) CurPt NextPt )) ) (setq _vlist (cons NextPt _vlist) CurPt NextPt )) (setq vlist (cdr vlist)) ) (setq More nil) ) )) ) (setq More nil) ) (if (not vlist) (setq More nil) ) ) (if (not (equal (car _vlist) LastPt 0.001)) (setq _vlist (cons LastPt _vlist)) ) (setq _vlist (reverse _vlist)) )) (if (>= (length _vlist) 2) (list _vlist DelLst) nil ) )