From 122b2d6f40d244a51b372cc3c0b6d8a3cb5b189c Mon Sep 17 00:00:00 2001 From: Mason Date: Wed, 19 Aug 2009 19:58:51 -0400 Subject: [PATCH] updated comments --- src/org/poly2tri/cdt/CDT.scala | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/org/poly2tri/cdt/CDT.scala b/src/org/poly2tri/cdt/CDT.scala index 695e7ed..de3c42a 100644 --- a/src/org/poly2tri/cdt/CDT.scala +++ b/src/org/poly2tri/cdt/CDT.scala @@ -189,14 +189,15 @@ class CDT(polyLine: Array[Point], clearPoint: Point) { // Locate the first intersected triangle val firstTriangle = node.triangle.locateFirst(edge) - // Remove intersected triangles if(firstTriangle != null && !firstTriangle.contains(edge)) { - + + // Constrained edge lies below the advancing front. Traverse through intersected triangles, + // form empty pseudo-polygons, and re-triangulate + // Collect intersected triangles val tList = new ArrayBuffer[Triangle] tList += firstTriangle - // Not sure why tList.last is null sometimes.... while(!tList.last.contains(edge.p)) tList += tList.last.findNeighbor(edge.p) @@ -210,6 +211,7 @@ class CDT(polyLine: Array[Point], clearPoint: Point) { mesh.map -= t }) + // Using a hashMap or set may improve performance val lPoints = new ArrayBuffer[Point] val rPoints = new ArrayBuffer[Point] @@ -263,7 +265,7 @@ class CDT(polyLine: Array[Point], clearPoint: Point) { } else if(firstTriangle == null) { // No triangles are intersected by the edge; edge must lie outside the mesh - // Apply constraint; traverse the AFront, and build triangles + // Apply constraint; traverse the advancing front, and build triangles val ahead = (edge.p.x > edge.q.x) val point1 = if(ahead) edge.q else edge.p @@ -299,11 +301,12 @@ class CDT(polyLine: Array[Point], clearPoint: Point) { T.last markEdge(point1, point2) } else if(firstTriangle.contains(edge.q, edge.p)) { + // Constrained edge lies on the side of a triangle // Mark constrained edge firstTriangle markEdge(edge.q, edge.p) firstTriangle.finalized = true } else { - throw new Exception("Triangulation error") + throw new Exception("Triangulation error - unexpected case") } }