Permalink
Browse files

adding some tests with real-world data loaded from AI files.

  • Loading branch information...
1 parent 097f91f commit 8768cb993eb7e7603884cfe1c89fd7fc254afc10 @orthecreedence committed May 29, 2012
Showing with 55 additions and 1 deletion.
  1. +52 −0 test.lisp
  2. +3 −1 triangulation.lisp
View
@@ -0,0 +1,52 @@
+(in-package :cl-triangulation)
+
+(defparameter *verts* #((-3.0 179.0) (57.0 175.0) (144.5 153.5)
+ (230.5 139.5) (322.5 129.5) (411.0 110.5)
+ (536.0 104.5) (671.5 103.0) (768.0 106.5)
+ (837.5 110.0) (1043.5 136.0) (1200.0 143.5)
+ (1341.0 172.0) (1398.0 193.0) (1429.0 172.5)
+ (1449.0 163.5) (1478.0 123.5) (1497.0 83.0)
+ (1521.5 56.5) (1577.5 35.5) (1629.5 29.0)
+ (1674.5 52.5) (1740.0 48.5) (1777.5 41.0)
+ (1810.5 61.5) (1821.5 105.0) (1816.5 137.0)
+ (1782.5 182.5) (1766.5 227.5) (1760.0 259.5)
+ (1752.5 276.0) (1752.5 326.5) (1796.5 341.0)
+ (1832.5 343.0) (1865.0 344.0) (1905.0 333.0)
+ (1939.5 326.0) (1992.5 310.5) (2001.0 310.5)
+ (2001.0 -0.5) (-2.0 0.0)))
+
+(defparameter *verts* #((-1.0 115.5) (218.5 127.0) (307.5 145.0)
+ (348.5 148.5) (426.0 168.5) (498.5 195.5)
+ (587.5 219.0) (632.5 224.0) (747.0 204.5)
+ (807.5 164.5) (828.5 157.5) (847.0 159.5)
+ (934.0 153.0) (1015.5 153.0) (1075.0 134.5)
+ (1168.5 129.0) (1215.0 127.5) (1265.5 115.0)
+ (1363.5 131.5) (1439.0 127.0) (1486.5 117.0)
+ (1522.0 93.5) (1595.5 67.5) (1658.5 68.0)
+ (1724.0 80.0) (1750.5 94.0) (1816.5 190.5)
+ (1858.0 261.0) (1884.5 305.5) (1965.5 352.5)
+ (2000.0 360.0) (2000.5 0.0) (-1.0 -0.5)))
+
+(defparameter *verts* #((-2.9999 179.0) (56.9999 175.0) (144.4999 153.5)
+ (230.5 139.5) (322.5 129.5) (410.9999 110.5)
+ (535.9999 104.5) (671.5 103.0) (767.9999 106.5)
+ (837.5 110.0) (1043.4999 136.0) (1199.9999 143.5)
+ (1341.0 172.0) (1397.9999 193.0) (1428.9999 172.5)
+ (1448.9999 163.5) (1477.9999 123.5) (1497.0 83.0)
+ (1521.5 56.5) (1577.5 35.5) (1629.4999 29.0)
+ (1674.5 52.5) (1739.9999 48.5) (1777.4999 41.0)
+ (1810.4999 61.5) (1821.4999 105.0) (1816.4999 137.0)
+ (1782.4999 182.5) (1766.5 227.5) (1760.0 259.5)
+ (1752.4999 276.0) (1752.4999 326.5) (1796.5 341.0)
+ (1832.5 343.0) (1864.9999 344.0) (1905.0 333.0)
+ (1939.5 326.0) (1992.4999 310.5) (2000.9999 310.5)
+ (2002.9999 -469.5) (-2.0 -469.0)))
+
+(defparameter *bad* #((2002.9999 -469.5) (410.9999 110.5) (230.5 139.5)
+ (144.4999 153.5) (56.9999 175.0) (-2.9999 179.0)))
+
+(triangulate *bad*)
+(line-inside-polygon-p (list 2002.9999 -469.5 230.5 139.5) *bad*)
+(lines-intersect-p 2002.99 -469.5 230.5 139.5 410.99 110.5 230.5 139.5)
+
+(triangulate #((-3 179) (5699/100 175) (14449/100 307/2) (461/2 279/2) (645/2 259/2) (41099/100 221/2) (53599/100 209/2) (1343/2 103) (76799/100 213/2) (1675/2 110) (104349/100 136) (119999/100 287/2) (1341 172) (139799/100 193) (142899/100 345/2) (144899/100 327/2) (147799/100 247/2) (1497 83) (3043/2 113/2) (3155/2 71/2) (162949/100 29) (3349/2 105/2) (173999/100 97/2) (177749/100 41) (181049/100 123/2) (182149/100 105) (181649/100 137) (178249/100 365/2) (3533/2 455/2) (1760 519/2) (175249/100 276) (175249/100 653/2) (3593/2 341) (3665/2 343) (186499/100 344) (1905 333) (3879/2 326) (199249/100 621/2) (200099/100 621/2) (200299/100 -939/2) (0 -469) (-3 179)))
View
@@ -40,7 +40,8 @@
(pjx (car (aref polygon-points j)))
(pjy (cadr (aref polygon-points j))))
(when (and (not (eq (> py y) (> pjy y)))
- (< x (+ (/ (* (- pjx px) (- y py)) (- pjy py)) px)))
+ (< x (+ (/ (* (- pjx px) (- y py))
+ (- pjy py)) px)))
(setf c (not c))))
(setf j i))
c))
@@ -104,6 +105,7 @@
(progn (setf last-length-count 0)
(setf last-length (length points))))
(when (< (length points) last-length-count)
+ ;(format t "Endless loop with points: ~a~%" points)
(return-from triangulate nil)) ; (error 'triangulation-loop :points points)
(let ((cur-point (aref points i))
(next-point (aref points (mod (1+ i) (length points))))

0 comments on commit 8768cb9

Please sign in to comment.