;; | ---------------------------------------------------------------------------------- ;; | GE_DistWeed ;; | ---------------------------------------------------------------------------------- ;; | Function : Weed a list purely based on inter point distance ;; | Arguments: ;; | 'vlist' - List to be weeded ;; | 'WeedDist' - Weed Distance ;; | '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 ;; | Updated : October 30, 1998 ;; | e-mail : rakesh.rao@4d-technologies.com ;; | Web : www.4d-technologies.com ;; | --------------------------------------------------------------------------------- (defun GE_DistWeed( vlist WeedDist MeasD / _vlist nverts cnt pt2 len CurPt tmp DelLst ) (setq nverts (length vlist) tmp (- nverts 2) cnt 0 CurPt (nth 0 vlist) ; Make sure that the last point is not weeded DelLst '() _vlist (list CurPt) ) (repeat nverts (if (< cnt (1- nverts)) (progn (setq pt2 (nth (1+ cnt) vlist)) (if (= MeasD "Slope") (setq len (distance CurPt pt2)) (setq len (distance (list (car CurPt) (cadr CurPt) 0.0) (list (car pt2) (cadr pt2) 0.0) ) ) ) (if (> len WeedDist) (setq _vlist (cons pt2 _vlist) CurPt pt2 ) (setq DelLst (cons (list (1+ cnt) pt2) DelLst)) ) )) (setq cnt (1+ cnt)) ) ;; Make sure that the last point is not weeded (if (not (equal (car _vlist) (last vlist))) (setq _vlist (cons (last vlist) (cdr _vlist))) ) (setq _vlist (reverse _vlist) DelLst (reverse DelLst) ) (if (>= (length _vlist) 1) (list _vlist DelLst) nil ) )