mirror of
https://github.com/jhasse/poly2tri.git
synced 2024-12-31 23:23:30 +01:00
edge mark
This commit is contained in:
parent
96713f6595
commit
552cc3f564
@ -136,13 +136,13 @@ class CDT(val points: List[Point], val segments: List[Segment], iTriangle: Trian
|
|||||||
} catch {
|
} catch {
|
||||||
case e: Exception =>
|
case e: Exception =>
|
||||||
println("Offending triangle = " + i)
|
println("Offending triangle = " + i)
|
||||||
//System exit 0
|
|
||||||
}
|
}
|
||||||
// Process edge events
|
// Process edge events
|
||||||
point.edges.foreach(e => edgeEvent(e, triangle))
|
point.edges.foreach(e => edgeEvent(e, triangle))
|
||||||
//if(i == 5) {cTri = triangle; mesh.debug += cTri}
|
//if(i == 7) {cTri = triangle; mesh.debug += cTri}
|
||||||
}
|
}
|
||||||
//mesh clean cTri
|
//mesh clean cTri
|
||||||
|
//mesh.map.foreach(m => m.edges.foreach(e => if(e) mesh.debug += m))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Point event
|
// Point event
|
||||||
@ -165,7 +165,7 @@ class CDT(val points: List[Point], val segments: List[Segment], iTriangle: Trian
|
|||||||
mesh.map += lTriangle
|
mesh.map += lTriangle
|
||||||
mesh.map += rTriangle
|
mesh.map += rTriangle
|
||||||
|
|
||||||
// Skip legalization
|
// TODO: check to see of legalization is necessary here
|
||||||
|
|
||||||
// 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)
|
||||||
@ -223,8 +223,10 @@ class CDT(val points: List[Point], val segments: List[Segment], iTriangle: Trian
|
|||||||
// STEP 1: Locate the first intersected triangle
|
// STEP 1: Locate the first intersected triangle
|
||||||
val firstTriangle = triangle.locateFirst(edge)
|
val firstTriangle = triangle.locateFirst(edge)
|
||||||
|
|
||||||
|
val contains = if(firstTriangle != null) firstTriangle.contains(edge) else false
|
||||||
|
|
||||||
// STEP 2: Remove intersected triangles
|
// STEP 2: Remove intersected triangles
|
||||||
if(firstTriangle != null && !firstTriangle.contains(edge)) {
|
if(firstTriangle != null && !contains) {
|
||||||
|
|
||||||
// Collect intersected triangles
|
// Collect intersected triangles
|
||||||
val tList = new ArrayBuffer[Triangle]
|
val tList = new ArrayBuffer[Triangle]
|
||||||
@ -274,9 +276,9 @@ class CDT(val points: List[Point], val segments: List[Segment], iTriangle: Trian
|
|||||||
|
|
||||||
// Mark constrained edges
|
// Mark constrained edges
|
||||||
val dEdge = new Segment(point1, point2)
|
val dEdge = new Segment(point1, point2)
|
||||||
T1.first markEdge dEdge
|
T1.first mark dEdge
|
||||||
T2.first markEdge dEdge
|
T2.first mark dEdge
|
||||||
println("cut")
|
|
||||||
} else if(firstTriangle == null) {
|
} else if(firstTriangle == null) {
|
||||||
|
|
||||||
// No triangles are intersected by the edge; edge must lie outside the mesh
|
// No triangles are intersected by the edge; edge must lie outside the mesh
|
||||||
@ -306,14 +308,13 @@ class CDT(val points: List[Point], val segments: List[Segment], iTriangle: Trian
|
|||||||
|
|
||||||
// Mark constrained edge
|
// Mark constrained edge
|
||||||
val dEdge = new Segment(point1, point2)
|
val dEdge = new Segment(point1, point2)
|
||||||
T.first markEdge dEdge
|
T.first mark dEdge
|
||||||
|
|
||||||
} else {
|
|
||||||
// Triangle must contain the edge
|
|
||||||
// Mark constrained edge
|
|
||||||
firstTriangle markEdge edge
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mark constrained edge
|
||||||
|
if(contains)
|
||||||
|
firstTriangle mark edge
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Marc Vigo Anglada's triangulate pseudo-polygon algo
|
// Marc Vigo Anglada's triangulate pseudo-polygon algo
|
||||||
@ -433,7 +434,6 @@ class CDT(val points: List[Point], val segments: List[Segment], iTriangle: Trian
|
|||||||
val ccwNeighbor = t2.neighborCCW(oPoint)
|
val ccwNeighbor = t2.neighborCCW(oPoint)
|
||||||
|
|
||||||
if(ccwNeighbor != null) {
|
if(ccwNeighbor != null) {
|
||||||
//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)
|
ccwNeighbor.updateNeighbors(oPoint, t1.points(2), t1, mesh.debug)
|
||||||
t1.neighbors(1) = ccwNeighbor
|
t1.neighbors(1) = ccwNeighbor
|
||||||
}
|
}
|
||||||
|
@ -47,11 +47,11 @@ class Mesh(initialTriangle: Triangle) {
|
|||||||
if(triangle != null && triangle.clean == false) {
|
if(triangle != null && triangle.clean == false) {
|
||||||
triangle.clean = true
|
triangle.clean = true
|
||||||
triangles += triangle
|
triangles += triangle
|
||||||
if(triangle.edges(0) == false)
|
if(!triangle.edges(0))
|
||||||
clean(triangle.neighbors(0))
|
clean(triangle.neighbors(0))
|
||||||
if(triangle.edges(1) == false)
|
if(!triangle.edges(1))
|
||||||
clean(triangle.neighbors(1))
|
clean(triangle.neighbors(1))
|
||||||
if(triangle.edges(2) == false)
|
if(!triangle.edges(2))
|
||||||
clean(triangle.neighbors(2))
|
clean(triangle.neighbors(2))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ class Triangle(val points: Array[Point], val neighbors: Array[Triangle]) {
|
|||||||
neighbors(2) = triangle
|
neighbors(2) = triangle
|
||||||
else {
|
else {
|
||||||
debug += triangle
|
debug += triangle
|
||||||
//throw new Exception("Neighbor pointer error, please report!")
|
throw new Exception("Neighbor pointer error, please report!")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,8 +267,15 @@ class Triangle(val points: Array[Point], val neighbors: Array[Triangle]) {
|
|||||||
ki = points(0) - points(2)
|
ki = points(0) - points(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def mark(e: Segment) {
|
||||||
|
markEdge(e)
|
||||||
|
markNeighbors(e)
|
||||||
|
}
|
||||||
|
|
||||||
|
private def markNeighbors(e: Segment) = neighbors.foreach(n => if(n != null) n.markEdge(e))
|
||||||
|
|
||||||
// Mark edge as constrained
|
// Mark edge as constrained
|
||||||
def markEdge(e: Segment) {
|
private def markEdge(e: Segment) {
|
||||||
if((e.q == points(0) && e.p == points(1)) || (e.q == points(1) && e.p == points(0))) {
|
if((e.q == points(0) && e.p == points(1)) || (e.q == points(1) && e.p == points(0))) {
|
||||||
edges(2) = true
|
edges(2) = true
|
||||||
} else if ((e.q == points(0) && e.p == points(2)) || (e.q == points(2) && e.p == points(0))) {
|
} else if ((e.q == points(0) && e.p == points(2)) || (e.q == points(2) && e.p == points(0))) {
|
||||||
|
Loading…
Reference in New Issue
Block a user