fixed advancing front bug

This commit is contained in:
zzzzrrr 2009-08-25 10:25:19 -04:00
parent 8f8e8144bf
commit 8e788b2e15
3 changed files with 12 additions and 14 deletions

View File

@ -439,7 +439,7 @@ class Poly2TriDemo extends BasicGame("Poly2Tri") {
if(slCDT.cList.size > 1) {
//slCDT.addPoint(slCDT.cList(0))
//slCDT.addPoint(slCDT.cList(1))
for(i <- 0 until 9 /*slCDT.cList.size*/)
for(i <- 0 until slCDT.cList.size)
slCDT.addPoint(slCDT.cList(i))
slCDT.triangulate
}

View File

@ -155,7 +155,7 @@ class CDT(polyLine: Array[Point], clearPoint: Point) {
// 49 69
val size = if(refine) 50 else points.size
for(i <- 1 until size) {
for(i <- 1 until points.size) {
val point = points(i)
// Process Point event
@ -364,15 +364,13 @@ class CDT(polyLine: Array[Point], clearPoint: Point) {
pNode.prev = n
n
} else {
val n = new Node(point2, pNode.next.triangle)
val n = new Node(point2, T.last)
aFront link (n, first, T.last)
pNode.next = n
n.prev = pNode
n
pNode
}
val above = point2.y > edge.p.y
val e = if(above) new Segment(edge.p, point2) else { println("wtf"); new Segment(point2, edge.p)}
edgeEvent(e, iNode)
edgeEvent(new Segment(edge.p, point2), iNode)
}
} else if(firstTriangle.contains(edge.q, edge.p)) {

View File

@ -157,15 +157,15 @@ class Triangle(val points: Array[Point]) {
}
// Locate next triangle crossed by edge
def findNeighbor(e: Point): Triangle = {
def findNeighbor(p: Point): Triangle = {
if(contains(e)) return this
if(contains(p)) return this
if(Util.orient2d(points(1), points(0), e) > 0)
if(Util.orient2d(points(1), points(0), p) > 0)
return neighbors(2)
else if(Util.orient2d(points(2), points(1), e) > 0)
else if(Util.orient2d(points(2), points(1), p) > 0)
return neighbors(0)
else if(Util.orient2d(points(0), points(2), e) > 0)
else if(Util.orient2d(points(0), points(2), p) > 0)
return neighbors(1)
else
throw new Exception("Point not found")