谢谢,当我看到你的代码时,我已经开始实现我的解决方案,基本思想是一样的,只是我的代码效率和流线型要低得多,但它似乎在工作。
这就是我想到的:
- (defun connect (paired plista plista2 / i j pa pb done ul s p1 p2)
- (setq done nil)
- (setq pa (cdar plista))
- (setq i 0)
- (if (= 0 (length plista2)) (setq done paired))
- (while (and (not done) (< i (length plista2)))
-
- (setq pb (nth i plista2))
- (setq ul (vl-remove (nth i plista2) plista2))
-
- (setq j 0)
- (setq s T)
- (repeat (length paired)
- (setq p1 (cadr (nth j paired)))
- (setq p2 (last (nth j paired)))
- (if (inters p1 p2 pa pb) (setq s nil))
- (setq j (1+ j))
-
- )
-
- (if s
- (setq done (connect (append paired (list (list (caar plista) (cdar plista) pb))) (cdr plista) ul ))
-
- )
- (setq i (1+ i))
-
-
-
- )
- (setq ret done)
- )
列表处理中的复杂性是因为我实际上在“plista”中的点上附加了一个数字,我需要保留这些关联。
普利斯塔看起来是这样的:(((“12881”658886.0 231817.0 0.0)(“10388”658885.0 231819.0 0 0.0)(“10387”658885.0 231819.0 0 0.0))
函数的结果是plista2的点
(("12881" (658886.0 231817.0 0.0) (658889.0 231819.0 0.0)) ("10388" (658885.0 231819.0 0.0) (658889.0 231820.0 0.0)) ("10387" (658885.0 231819.0 0.0) (658889.0 231821.0 0.0))) |