mirror of
https://github.com/jhasse/poly2tri.git
synced 2024-11-26 15:26:12 +01:00
bug fixes
This commit is contained in:
parent
0db13d6586
commit
a04b382f7d
@ -124,7 +124,7 @@ class CDT(val points: List[Point], val segments: List[Segment], iTriangle: Trian
|
|||||||
|
|
||||||
// Implement sweep-line
|
// Implement sweep-line
|
||||||
private def sweep {
|
private def sweep {
|
||||||
for(i <- 1 until 7 /*points.size*/) {
|
for(i <- 1 until points.size) {
|
||||||
val point = points(i)
|
val point = points(i)
|
||||||
// Process Point event
|
// Process Point event
|
||||||
val triangle = pointEvent(point)
|
val triangle = pointEvent(point)
|
||||||
@ -145,8 +145,8 @@ class CDT(val points: List[Point], val segments: List[Segment], iTriangle: Trian
|
|||||||
val rNeighbors = Array(node.triangle, null, null)
|
val rNeighbors = Array(node.triangle, null, null)
|
||||||
val rTriangle = new Triangle(rPts, rNeighbors)
|
val rTriangle = new Triangle(rPts, rNeighbors)
|
||||||
|
|
||||||
val lPts = Array(node.prev.point, node.point, point)
|
val lPts = Array(point, node.prev.point, node.point)
|
||||||
val lNeighbors = Array(rTriangle, null, node.prev.triangle)
|
val lNeighbors = Array(node.prev.triangle, rTriangle, null)
|
||||||
val lTriangle = new Triangle(lPts, lNeighbors)
|
val lTriangle = new Triangle(lPts, lNeighbors)
|
||||||
|
|
||||||
rTriangle.neighbors(2) = lTriangle
|
rTriangle.neighbors(2) = lTriangle
|
||||||
@ -155,17 +155,15 @@ class CDT(val points: List[Point], val segments: List[Segment], iTriangle: Trian
|
|||||||
|
|
||||||
// Legalize new triangles
|
// Legalize new triangles
|
||||||
val rLegal = legalization(rTriangle, rTriangle.neighbors(0))
|
val rLegal = legalization(rTriangle, rTriangle.neighbors(0))
|
||||||
val lLegal = legalization(lTriangle, lTriangle.neighbors(2))
|
val lLegal = legalization(lTriangle, lTriangle.neighbors(0))
|
||||||
var scanNode: Node = null
|
var scanNode: Node = null
|
||||||
|
|
||||||
// Update advancing front
|
// Update advancing front
|
||||||
if(rLegal) {
|
if(rLegal) {
|
||||||
println("rLegal")
|
|
||||||
// Update neighbors
|
// Update neighbors
|
||||||
node.triangle.updateNeighbors(rTriangle.points(1), rTriangle.points(2), rTriangle, mesh.debug)
|
node.triangle.updateNeighbors(rTriangle.points(1), rTriangle.points(2), rTriangle, mesh.debug)
|
||||||
scanNode = aFront.insert(point, rTriangle, node)
|
scanNode = aFront.insert(point, rTriangle, node)
|
||||||
} else {
|
} else {
|
||||||
println("rIllegal")
|
|
||||||
scanNode = new Node(rTriangle.points(1), rTriangle)
|
scanNode = new Node(rTriangle.points(1), rTriangle)
|
||||||
scanNode.next = node.next
|
scanNode.next = node.next
|
||||||
node.next = scanNode
|
node.next = scanNode
|
||||||
@ -174,15 +172,15 @@ class CDT(val points: List[Point], val segments: List[Segment], iTriangle: Trian
|
|||||||
|
|
||||||
// Update neighbor pointers
|
// Update neighbor pointers
|
||||||
if(lLegal) {
|
if(lLegal) {
|
||||||
println("lLegal")
|
lTriangle.neighbors(0).updateNeighbors(lTriangle.points(1), lTriangle.points(2), lTriangle, mesh.debug)
|
||||||
node.prev.triangle.updateNeighbors(lTriangle.points(0), lTriangle.points(1), lTriangle, mesh.debug)
|
node.prev.next = scanNode
|
||||||
aFront -= (scanNode, node, lTriangle)
|
scanNode.prev = node.prev
|
||||||
|
node.prev.triangle = lTriangle
|
||||||
} else {
|
} else {
|
||||||
println("lIllegal")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill in adjacent triangles if required
|
// Fill in adjacent triangles if required
|
||||||
//scanAFront(scanNode)
|
scanAFront(scanNode)
|
||||||
scanNode.triangle
|
scanNode.triangle
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -208,13 +206,15 @@ class CDT(val points: List[Point], val segments: List[Segment], iTriangle: Trian
|
|||||||
scanNode = aFront.insert(point, triangle, node)
|
scanNode = aFront.insert(point, triangle, node)
|
||||||
} else {
|
} else {
|
||||||
scanNode = new Node(triangle.points(1), triangle)
|
scanNode = new Node(triangle.points(1), triangle)
|
||||||
scanNode.next = node.next
|
val rNode = node.next
|
||||||
|
rNode.prev = scanNode
|
||||||
|
scanNode.next = rNode
|
||||||
node.next = scanNode
|
node.next = scanNode
|
||||||
scanNode.prev = node
|
scanNode.prev = node
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill in adjacent triangles if required
|
// Fill in adjacent triangles if required
|
||||||
//scanAFront(scanNode)
|
scanAFront(scanNode)
|
||||||
scanNode.triangle
|
scanNode.triangle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -419,7 +419,6 @@ class CDT(val points: List[Point], val segments: List[Segment], iTriangle: Trian
|
|||||||
val oPoint = t2 oppositePoint t1
|
val oPoint = t2 oppositePoint t1
|
||||||
|
|
||||||
if(illegal(t1.points(1), oPoint, t1.points(2), t1.points(0))) {
|
if(illegal(t1.points(1), oPoint, t1.points(2), t1.points(0))) {
|
||||||
println("illegal")
|
|
||||||
// Flip edges and rotate everything clockwise
|
// Flip edges and rotate everything clockwise
|
||||||
val point = t1.points(0)
|
val point = t1.points(0)
|
||||||
t1.legalize(oPoint)
|
t1.legalize(oPoint)
|
||||||
|
@ -51,6 +51,9 @@ class Triangle(val points: Array[Point], val neighbors: Array[Triangle]) {
|
|||||||
neighbors(2) = triangle
|
neighbors(2) = triangle
|
||||||
else {
|
else {
|
||||||
mesh += this
|
mesh += this
|
||||||
|
println("**********")
|
||||||
|
println(cwPoint + "," + ccwPoint)
|
||||||
|
printDebug
|
||||||
throw new Exception("neighbor error")
|
throw new Exception("neighbor error")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -204,10 +207,7 @@ class Triangle(val points: Array[Point], val neighbors: Array[Triangle]) {
|
|||||||
updateEdges
|
updateEdges
|
||||||
}
|
}
|
||||||
|
|
||||||
def printDebug {
|
def printDebug = println(points(0) + "," + points(1) + "," + points(2))
|
||||||
println("**************")
|
|
||||||
println(points(0) + "," + points(1) + "," + points(2))
|
|
||||||
}
|
|
||||||
|
|
||||||
private var ik, ij , jk, ji, kj, ki: Point = null
|
private var ik, ij , jk, ji, kj, ki: Point = null
|
||||||
updateEdges
|
updateEdges
|
||||||
|
Loading…
Reference in New Issue
Block a user