(setq a (vl-position (car e) pl)
b (vl-position (cadr e) pl)
flg (or (not a) (not b))
lst (cons (list a b) lst)
)
in get_constraints yes, i think comparing vertices with point needs a tolerance, the vl-position will possible not found the according point in the list
I did some testing with steiner, it doesn't work in all cases, because when you add points it might be in a circumcle of a segment that already is processed.
This (terrible) code add's steiner points (only line segments)
(defun c:add_steiner (/ ss i e np newlist)
(setq ss
(ssget '((0 . "LINE"))
)
)
(if ss
(progn
(repeat (setq i (sslength ss))
(setq e (ssname ss (setq i (1- i))))
(gabriel e)
;;; (setq newlist (append (gabriel e) newlist))
;;; (setq newlist (cons (cdr (assoc 10 (entget e))) newlist))
;;; (setq newlist (cons (cdr (assoc 11 (entget e))) newlist))
)
)
)
;;; (foreach np newlist
;;; (entmake (list (cons 0 "POINT") (cons 10 np)))
;;; )
)
(defun gabriel (e / entl bp ep mp r elist edge found i ss)
(setq nplist nil)
(setq entl (entget e))
(setq bp (cdr (assoc 10 entl)))
(setq ep (cdr (assoc 11 entl)))
(setq mp (list (/ (+ (car bp) (car ep)) 2.0)
(/ (+ (cadr bp) (cadr ep)) 2.0)
(/ (+ (caddr bp) (caddr ep)) 2.0)
)
)
;; middle point
(setq r (/ (distance bp (list (car ep) (cadr ep))) 2.0))
;; 2D radius
(setq elist (list (list bp ep mp r)))
(setq ss
(ssget "_w"
(list (- (car mp) r) (- (cadr mp) r))
(list (+ (car mp) r) (+ (cadr mp) r))
'((0 . "POINT"))
)
)
;; selectionset of points around edge
(while elist
(setq edge (car elist))
(setq bp (car edge))
(setq ep (cadr edge))
(setq mp (caddr edge))
(setq r (cadddr edge))
;; (command "line" (list (- (car mp) r) (- (cadr mp) r)) (list (+ (car mp) r) (+ (cadr mp) r)) "")
(if ss
(progn
(setq found nil)
(repeat (setq i (sslength ss))
(setq e (ssname ss (setq i (1- i))))
(setq pt (cdr (assoc 10 (entget e))))
(if (and (not found)
(< (distance (list (car pt) (cadr pt)) mp) (- r 0.001)) ;;; 0.001 fuzz to avoid edge points bp ep
)
;; point in circle, we have to split segment
(progn
(setq newmp_bp (list (/ (+ (car bp)
(car mp)
)
2.0
)
(/ (+ (cadr bp)
(cadr mp)
)
2.0
)
(/ (+ (caddr bp)
(caddr mp)
)
2.0
)
)
)
(setq newmp_ep (list (/ (+ (car ep)
(car mp)
)
2.0
)
(/ (+ (cadr ep)
(cadr mp)
)
2.0
)
(/ (+ (caddr ep)
(caddr mp)
)
2.0
)
)
)
(setq elist (cdr elist));;; remove current edge and add 2 new edge segments
(setq elist (cons (list bp mp newmp_bp (/ r 2.0)) elist))
(setq elist (cons (list ep mp newmp_ep (/ r 2.0)) elist))
(entmake (list (cons 0 "POINT") (cons 10 mp)))
; (setq nplist (cons mp nplist))
(setq found t)
)
)
)
(if (not found)
(setq elist (cdr elist))
)
;;; points do not meet criteria, remove the edge
)
(progn
(setq elist (cdr elist))
;;; no points, remove the edge
)
)
)
; nplist
)