mirror of
https://github.com/jhasse/poly2tri.git
synced 2024-12-31 23:23:30 +01:00
bug hunting
This commit is contained in:
parent
072f43d502
commit
60b4f68d89
@ -126,7 +126,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 {
|
||||||
//var cTri: Triangle = null
|
//var cTri: Triangle = null
|
||||||
for(i <- 1 until 5 /*points.size*/) {
|
for(i <- 1 until 5 /*points.size*/ ) {
|
||||||
val point = points(i)
|
val point = points(i)
|
||||||
// Process Point event
|
// Process Point event
|
||||||
var triangle: Triangle = null
|
var triangle: Triangle = null
|
||||||
@ -136,7 +136,7 @@ class CDT(val points: List[Point], val segments: List[Segment], iTriangle: Trian
|
|||||||
case e: Exception => println("Offending triangle = " + i)
|
case e: Exception => println("Offending triangle = " + i)
|
||||||
}
|
}
|
||||||
// Process edge events
|
// Process edge events
|
||||||
point.edges.foreach(e => edgeEvent(e, triangle))
|
//point.edges.foreach(e => edgeEvent(e, triangle))
|
||||||
//if(i == 10) {cTri = triangle; mesh.debug += cTri}
|
//if(i == 10) {cTri = triangle; mesh.debug += cTri}
|
||||||
}
|
}
|
||||||
//mesh clean cTri
|
//mesh clean cTri
|
||||||
@ -191,14 +191,16 @@ class CDT(val points: List[Point], val segments: List[Segment], iTriangle: Trian
|
|||||||
mesh.map += triangle
|
mesh.map += triangle
|
||||||
|
|
||||||
// Legalize
|
// Legalize
|
||||||
val legal = legalization(triangle, nTri)
|
val legal = true //legalization(triangle, nTri)
|
||||||
var newNode: Node = null
|
var newNode: Node = null
|
||||||
|
|
||||||
// Update advancing front
|
// Update advancing front
|
||||||
if(legal) {
|
if(legal) {
|
||||||
newNode = aFront.insert(point, triangle, node)
|
newNode = aFront.insert(point, triangle, node)
|
||||||
// Update neighbors
|
// Update neighbors
|
||||||
|
println(1)
|
||||||
nTri.updateNeighbors(cwPoint, ccwPoint, triangle, mesh.debug)
|
nTri.updateNeighbors(cwPoint, ccwPoint, triangle, mesh.debug)
|
||||||
|
println(2)
|
||||||
} else {
|
} else {
|
||||||
newNode = new Node(triangle.points(1), triangle)
|
newNode = new Node(triangle.points(1), triangle)
|
||||||
val rNode = node.next
|
val rNode = node.next
|
||||||
@ -404,7 +406,7 @@ class CDT(val points: List[Point], val segments: List[Segment], iTriangle: Trian
|
|||||||
val sinB = v3 cross v4
|
val sinB = v3 cross v4
|
||||||
|
|
||||||
// Some small number
|
// Some small number
|
||||||
if(cosA*sinB + sinA*cosB < -0.0001f)
|
if((cosA*sinB + sinA*cosB) < -0.1)
|
||||||
true
|
true
|
||||||
else
|
else
|
||||||
false
|
false
|
||||||
@ -417,22 +419,23 @@ 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("legalize")
|
||||||
|
// Update neighbor pointers
|
||||||
|
val ccwNeighbor = t2.neighborCCW(oPoint)
|
||||||
|
|
||||||
|
if(ccwNeighbor != null) {
|
||||||
|
val point = if(t1.points(0).x > oPoint.x) t1.points(2) else t1.points(1)
|
||||||
|
ccwNeighbor.updateNeighbors(oPoint, point, t1, mesh.debug)
|
||||||
|
t1.neighbors(1) = ccwNeighbor
|
||||||
|
}
|
||||||
|
|
||||||
|
t2.rotateNeighborsCW(oPoint, t1)
|
||||||
|
|
||||||
// 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)
|
||||||
t2.legalize(oPoint, point)
|
t2.legalize(oPoint, point)
|
||||||
|
|
||||||
// Update neighbor pointers
|
|
||||||
|
|
||||||
val ccwNeighbor = t2.neighborCCW(oPoint)
|
|
||||||
|
|
||||||
if(ccwNeighbor != null) {
|
|
||||||
ccwNeighbor.updateNeighbors(t1.points(2), t1.points(0), t1, mesh.debug)
|
|
||||||
t1.neighbors(1) = ccwNeighbor
|
|
||||||
}
|
|
||||||
|
|
||||||
t2.rotateNeighborsCW(oPoint, t1)
|
|
||||||
t1.neighbors(0) = t2
|
t1.neighbors(0) = t2
|
||||||
t1.neighbors(2) = null
|
t1.neighbors(2) = null
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ class Triangle(val points: Array[Point], val neighbors: Array[Triangle]) {
|
|||||||
mesh += triangle
|
mesh += triangle
|
||||||
println(ccwPoint + "," + cwPoint)
|
println(ccwPoint + "," + cwPoint)
|
||||||
printDebug
|
printDebug
|
||||||
throw new Exception("Neighbor update error")
|
//throw new Exception("Neighbor update error")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user