mirror of
https://github.com/jhasse/poly2tri.git
synced 2024-11-30 01:03:30 +01:00
fixed legalization bug
This commit is contained in:
parent
60b4f68d89
commit
ea65046b07
@ -126,7 +126,7 @@ class CDT(val points: List[Point], val segments: List[Segment], iTriangle: Trian
|
||||
// Implement sweep-line
|
||||
private def sweep {
|
||||
//var cTri: Triangle = null
|
||||
for(i <- 1 until 5 /*points.size*/ ) {
|
||||
for(i <- 1 until points.size) {
|
||||
val point = points(i)
|
||||
// Process Point event
|
||||
var triangle: Triangle = null
|
||||
@ -191,7 +191,7 @@ class CDT(val points: List[Point], val segments: List[Segment], iTriangle: Trian
|
||||
mesh.map += triangle
|
||||
|
||||
// Legalize
|
||||
val legal = true //legalization(triangle, nTri)
|
||||
val legal = legalization(triangle, nTri)
|
||||
var newNode: Node = null
|
||||
|
||||
// Update advancing front
|
||||
@ -424,21 +424,21 @@ class CDT(val points: List[Point], val segments: List[Segment], iTriangle: Trian
|
||||
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)
|
||||
//val point = if(t1.points(0).x > oPoint.x) t1.points(1) else t1.points(2)
|
||||
ccwNeighbor.updateNeighbors(oPoint, t1.points(2), t1, mesh.debug)
|
||||
t1.neighbors(1) = ccwNeighbor
|
||||
}
|
||||
|
||||
t2.rotateNeighborsCW(oPoint, t1)
|
||||
|
||||
t1.neighbors(0) = t2
|
||||
t1.neighbors(2) = null
|
||||
|
||||
// Flip edges and rotate everything clockwise
|
||||
val point = t1.points(0)
|
||||
t1.legalize(oPoint)
|
||||
t2.legalize(oPoint, point)
|
||||
|
||||
t1.neighbors(0) = t2
|
||||
t1.neighbors(2) = null
|
||||
|
||||
false
|
||||
} else {
|
||||
true
|
||||
|
@ -139,21 +139,21 @@ class Triangle(val points: Array[Point], val neighbors: Array[Triangle]) {
|
||||
// The neighbor clockwise to given point
|
||||
def neighborCW(point: Point): Triangle = {
|
||||
if(point == points(0)) {
|
||||
neighbors(2)
|
||||
}else if(point == points(1)) {
|
||||
neighbors(0)
|
||||
} else
|
||||
neighbors(1)
|
||||
}else if(point == points(1)) {
|
||||
neighbors(2)
|
||||
} else
|
||||
neighbors(0)
|
||||
}
|
||||
|
||||
// The neighbor counter-clockwise to given point
|
||||
def neighborCCW(point: Point): Triangle = {
|
||||
if(point == points(0)) {
|
||||
neighbors(1)
|
||||
}else if(point == points(1)) {
|
||||
neighbors(2)
|
||||
} else
|
||||
}else if(point == points(1)) {
|
||||
neighbors(0)
|
||||
} else
|
||||
neighbors(1)
|
||||
}
|
||||
|
||||
// The neighbor clockwise to given point
|
||||
|
Loading…
Reference in New Issue
Block a user