;; | ---------------------------------------------------------------------------- ;; | GE_DistDefDistWeed ;; | ---------------------------------------------------------------------------- ;; | Function : Weed a list based on inter-vertex distance AND deflection distance ;; | between the points. ;; | Arguments: ;; | 'vlist' - List to be weeded ;; | 'WeedDist' - Maximum Distance allowable between points. ;; | 'DefDist' - Deflection distance 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) 2008, Copyrights Four Dimension Technologies, ;; | Bangalore ;; | Updated : July 2, 2008 ;; | e-mail : rakesh.rao@4d-technologies.com ;; | Web : www.4d-technologies.com ;; | ---------------------------------------------------------------------------- (defun GE_DistDefDistWeed ( vlist WeedDist DefDist MeasD / nverts DelLst _vlist cnt CurPt More NextPt NextNextPt len1 len2 LastPt _DefDist ) (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 _DefDist (GE_GetDefDist CurPt NextPt NextNextPt)) (if _DefDist (progn (if (> _DefDist DefDist) (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 DelLst (cons NextPt DelLst) vlist (cdr vlist) )) ) (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 ) )