mirror of
https://github.com/jhasse/poly2tri.git
synced 2025-01-31 12:43:31 +01:00
point event pointers
This commit is contained in:
parent
012dab34d3
commit
2cf811d635
@ -91,7 +91,7 @@ class Poly2TriDemo extends BasicGame("Poly2Tri") {
|
|||||||
|
|
||||||
def render(container: GameContainer, g: Graphics) {
|
def render(container: GameContainer, g: Graphics) {
|
||||||
|
|
||||||
g.drawString("'1-5' to cycle models", 10, 540)
|
g.drawString("'1-6' to cycle models", 10, 540)
|
||||||
g.drawString("'SPACE' to turn on debug info", 10, 552)
|
g.drawString("'SPACE' to turn on debug info", 10, 552)
|
||||||
g.drawString("'m' to show trapezoidal map (debug mode)", 10, 564)
|
g.drawString("'m' to show trapezoidal map (debug mode)", 10, 564)
|
||||||
g.drawString("'e' to switch Seidel / EarClip", 10, 576)
|
g.drawString("'e' to switch Seidel / EarClip", 10, 576)
|
||||||
|
@ -36,10 +36,10 @@ import shapes.{Point, Triangle}
|
|||||||
class AFront(iTriangle: Triangle) {
|
class AFront(iTriangle: Triangle) {
|
||||||
|
|
||||||
// Doubly linked list
|
// Doubly linked list
|
||||||
var head = new Node(iTriangle.points(0), iTriangle)
|
var head = new Node(iTriangle.points(1), iTriangle)
|
||||||
var tail = new Node(iTriangle.points(2), iTriangle)
|
var tail = new Node(iTriangle.points(2), iTriangle)
|
||||||
|
|
||||||
head.next = new Node(iTriangle.points(1), iTriangle)
|
head.next = new Node(iTriangle.points(0), iTriangle)
|
||||||
head.next.next = tail
|
head.next.next = tail
|
||||||
tail.prev = head.next
|
tail.prev = head.next
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ object CDT {
|
|||||||
|
|
||||||
val segments = initSegments(points)
|
val segments = initSegments(points)
|
||||||
val sortedPoints = pointSort(points)
|
val sortedPoints = pointSort(points)
|
||||||
val initialTriangle = new Triangle(Array(p1, sortedPoints(0), p2), null)
|
val initialTriangle = new Triangle(Array(sortedPoints(0), p1, p2), null)
|
||||||
new CDT(sortedPoints, segments, initialTriangle)
|
new CDT(sortedPoints, segments, initialTriangle)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,10 +120,42 @@ class CDT(val points: List[Point], val segments: List[Segment], initialTriangle:
|
|||||||
|
|
||||||
for(i <- 1 until points.size) {
|
for(i <- 1 until points.size) {
|
||||||
val point = points(i)
|
val point = points(i)
|
||||||
val triangle = aFront.locate(point)
|
pointEvent(point)
|
||||||
val (nPoints, nTriangle) = triangle
|
legalization
|
||||||
println(nPoints)
|
edgeEvent(point)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Point event
|
||||||
|
private def pointEvent(point: Point) {
|
||||||
|
|
||||||
|
// Neightbor points (ccw & cw) and triangle(i)
|
||||||
|
val (nPts, nTri) = aFront.locate(point)
|
||||||
|
val pts = Array(point, nPts(0), nPts(1))
|
||||||
|
val neighbors = Array(nTri, null, null)
|
||||||
|
val triangle = new Triangle(pts, neighbors)
|
||||||
|
mesh.map += triangle
|
||||||
|
|
||||||
|
// Update neighbor's pointers
|
||||||
|
if(nPts(0) == nTri.points(1) && nPts(1) == nTri.points(2))
|
||||||
|
nTri.neighbors(2) = triangle
|
||||||
|
else if(nPts(0) == nTri.points(2) && nPts(1) == nTri.points(1))
|
||||||
|
nTri.neighbors(1) = triangle
|
||||||
|
else
|
||||||
|
throw new Exception("CDT Error!")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private def legalization {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private def legalizeEdge {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// EdgeEvent
|
||||||
|
private def edgeEvent(point: Point) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ import shapes.{Point, Triangle}
|
|||||||
|
|
||||||
class Mesh(initialTriangle: Triangle) {
|
class Mesh(initialTriangle: Triangle) {
|
||||||
|
|
||||||
|
// Triangles that constitute the mesh
|
||||||
val map = HashSet(initialTriangle)
|
val map = HashSet(initialTriangle)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user