mirror of
https://github.com/jhasse/poly2tri.git
synced 2024-11-30 01:03:30 +01:00
updates
This commit is contained in:
parent
daa7b135c8
commit
413275d415
@ -210,12 +210,10 @@ class Poly2TriDemo extends BasicGame("Poly2Tri") {
|
|||||||
g.draw(triangle)
|
g.draw(triangle)
|
||||||
})
|
})
|
||||||
|
|
||||||
//slCDT.cList.foreach(c => {
|
slCDT.cList.foreach(c => {
|
||||||
for(i <- 0 until 7) {
|
val circ = new Circle(c.x, c.y, 0.5f)
|
||||||
val circ = new Circle(slCDT.cList(i).x, slCDT.cList(i).y, 0.5f)
|
|
||||||
g.setColor(blue); g.draw(circ); g.fill(circ)
|
g.setColor(blue); g.draw(circ); g.fill(circ)
|
||||||
}
|
})
|
||||||
//})
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -439,10 +437,9 @@ class Poly2TriDemo extends BasicGame("Poly2Tri") {
|
|||||||
if(slCDT.cList.size > 1) {
|
if(slCDT.cList.size > 1) {
|
||||||
//slCDT.addPoint(slCDT.cList(0))
|
//slCDT.addPoint(slCDT.cList(0))
|
||||||
//slCDT.addPoint(slCDT.cList(1))
|
//slCDT.addPoint(slCDT.cList(1))
|
||||||
println(slCDT.cList.size)
|
for(i <- 0 until slCDT.cList.size)
|
||||||
for(i <- 0 until 7)
|
|
||||||
slCDT.addPoint(slCDT.cList(i))
|
slCDT.addPoint(slCDT.cList(i))
|
||||||
slCDT.triangulate
|
//slCDT.triangulate
|
||||||
}
|
}
|
||||||
|
|
||||||
println("CDT average (ms) = " + runTime*1e-6)
|
println("CDT average (ms) = " + runTime*1e-6)
|
||||||
|
@ -135,7 +135,7 @@ class CDT(polyLine: Array[Point], clearPoint: Point) {
|
|||||||
return List(p2, p1)
|
return List(p2, p1)
|
||||||
} else if(p1.y == p2.y) {
|
} else if(p1.y == p2.y) {
|
||||||
// If y values are equal, make sure point with smaller x value
|
// If y values are equal, make sure point with smaller x value
|
||||||
// is the the left
|
// is to the left
|
||||||
if(p1.x > p2.x) {
|
if(p1.x > p2.x) {
|
||||||
return List(p2, p1)
|
return List(p2, p1)
|
||||||
} else if(p1.x == p2.x) {
|
} else if(p1.x == p2.x) {
|
||||||
@ -153,7 +153,7 @@ class CDT(polyLine: Array[Point], clearPoint: Point) {
|
|||||||
// Implement sweep-line
|
// Implement sweep-line
|
||||||
private def sweep {
|
private def sweep {
|
||||||
// 48 67
|
// 48 67
|
||||||
val size = if(refine) 68 else points.size
|
val size = if(refine) 47 else points.size
|
||||||
|
|
||||||
for(i <- 1 until size) {
|
for(i <- 1 until size) {
|
||||||
|
|
||||||
@ -187,7 +187,7 @@ class CDT(polyLine: Array[Point], clearPoint: Point) {
|
|||||||
if(t.thin) {
|
if(t.thin) {
|
||||||
val center = Util.circumcenter(t.points(0), t.points(1), t.points(2))
|
val center = Util.circumcenter(t.points(0), t.points(1), t.points(2))
|
||||||
cList += center
|
cList += center
|
||||||
refine = true
|
//refine = true
|
||||||
//addPoint(center)
|
//addPoint(center)
|
||||||
//mesh.debug += t
|
//mesh.debug += t
|
||||||
}
|
}
|
||||||
@ -298,26 +298,32 @@ class CDT(polyLine: Array[Point], clearPoint: Point) {
|
|||||||
// 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
|
||||||
// Apply constraint; traverse the advancing front, and build triangles
|
// Apply constraint; traverse the advancing front, and build triangles
|
||||||
|
|
||||||
val ahead = (edge.p.x > edge.q.x)
|
var pNode, first = node
|
||||||
val point1 = if(ahead) edge.q else edge.p
|
|
||||||
val point2 = if(ahead) edge.p else edge.q
|
|
||||||
|
|
||||||
var pNode = if(ahead) node else aFront.locate(point1)
|
|
||||||
val first = pNode
|
|
||||||
|
|
||||||
val points = new ArrayBuffer[Point]
|
val points = new ArrayBuffer[Point]
|
||||||
|
|
||||||
// Neighbor triangles
|
// Neighbor triangles
|
||||||
val nTriangles = new ArrayBuffer[Triangle]
|
val nTriangles = new ArrayBuffer[Triangle]
|
||||||
nTriangles += pNode.triangle
|
nTriangles += pNode.triangle
|
||||||
pNode = pNode.next
|
|
||||||
|
|
||||||
while(pNode.point != point2) {
|
val ahead = (edge.p.x > edge.q.x)
|
||||||
points += pNode.point
|
|
||||||
nTriangles += pNode.triangle
|
|
||||||
pNode = pNode.next
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if(ahead) {
|
||||||
|
pNode = pNode.next
|
||||||
|
while(pNode.point != edge.p) {
|
||||||
|
points += pNode.point
|
||||||
|
nTriangles += pNode.triangle
|
||||||
|
pNode = pNode.next
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pNode = pNode.prev
|
||||||
|
while(pNode.point != edge.p) {
|
||||||
|
points += pNode.point
|
||||||
|
nTriangles += pNode.triangle
|
||||||
|
pNode = pNode.prev
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
val s = new Segment(first.point, first.next.point)
|
val s = new Segment(first.point, first.next.point)
|
||||||
if(s > point1) {
|
if(s > point1) {
|
||||||
mesh.map -= first.triangle
|
mesh.map -= first.triangle
|
||||||
@ -330,18 +336,23 @@ class CDT(polyLine: Array[Point], clearPoint: Point) {
|
|||||||
n.next.prev = n
|
n.next.prev = n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
// Triangulate empty areas.
|
// Triangulate empty areas.
|
||||||
val T = new ArrayBuffer[Triangle]
|
val T = new ArrayBuffer[Triangle]
|
||||||
triangulate(points.toArray, List(point1, point2), T)
|
triangulate(points.toArray, List(edge.q, edge.p), T)
|
||||||
|
|
||||||
// Update neighbors
|
// Update neighbors
|
||||||
edgeNeighbors(nTriangles, T)
|
edgeNeighbors(nTriangles, T)
|
||||||
|
|
||||||
// Update advancing front
|
// Update advancing front
|
||||||
aFront link (first, pNode, T.last)
|
if(ahead)
|
||||||
|
aFront link (first, pNode, T.last)
|
||||||
|
else
|
||||||
|
aFront link (pNode, first, T.last)
|
||||||
|
|
||||||
// Mark constrained edge
|
// Mark constrained edge
|
||||||
T.last markEdge(point1, point2)
|
T.last markEdge(edge.q, edge.p)
|
||||||
|
|
||||||
if(pNode.point != edge.p) {
|
if(pNode.point != edge.p) {
|
||||||
println("span")
|
println("span")
|
||||||
|
Loading…
Reference in New Issue
Block a user