mirror of
https://github.com/jhasse/poly2tri.git
synced 2024-11-26 15:26:12 +01:00
python work
This commit is contained in:
parent
dede764bb7
commit
8635340839
@ -99,18 +99,15 @@ class Triangulator(object) {
|
|||||||
trapezoidalMap.clear
|
trapezoidalMap.clear
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
// Mark outside trapezoids
|
|
||||||
for t in trapezoidalMap.map
|
for t in trapezoidalMap.map
|
||||||
markOutside(t)
|
markOutside(t)
|
||||||
|
|
||||||
// Collect interior trapezoids
|
|
||||||
for t in trapezoidalMap.map
|
for t in trapezoidalMap.map
|
||||||
if t.inside:
|
if t.inside:
|
||||||
trapezoids.append(t)
|
trapezoids.append(t)
|
||||||
t.addPoints()
|
t.addPoints()
|
||||||
|
|
||||||
// Generate the triangles
|
createMountains()
|
||||||
createMountains
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,29 +129,20 @@ class Triangulator(object) {
|
|||||||
|
|
||||||
if(s.mPoints.size > 0) {
|
if(s.mPoints.size > 0) {
|
||||||
|
|
||||||
val mountain = new MonotoneMountain
|
mountain = MonotoneMountain()
|
||||||
var k: List[Point] = None
|
|
||||||
|
|
||||||
// Sorting is a perfromance hit. Literature says this can be accomplised in
|
|
||||||
// linear time, although I don't see a way around using traditional methods
|
if len(s.mPoints) < 10:
|
||||||
// when using a randomized incremental algorithm
|
k = insertSort((p1: Point, p2: Point) => p1 < p2)(s.mPoints).toList
|
||||||
if(s.mPoints.size < 10)
|
|
||||||
// Insertion sort is one of the fastest algorithms for sorting arrays containing
|
|
||||||
// fewer than ten elements, or for lists that are already mostly sorted.
|
|
||||||
k = Util.insertSort((p1: Point, p2: Point) => p1 < p2)(s.mPoints).toList
|
|
||||||
else
|
else
|
||||||
k = Util.msort((p1: Point, p2: Point) => p1 < p2)(s.mPoints.toList)
|
k = msort((p1: Point, p2: Point) => p1 < p2)(s.mPoints.toList)
|
||||||
|
|
||||||
val points = s.p :: k ::: List(s.q)
|
points = s.p :: k ::: List(s.q)
|
||||||
|
|
||||||
var j = 0
|
for p in points:
|
||||||
while(j < points.size) {
|
mountain.add(p)
|
||||||
mountain += points(j)
|
|
||||||
j += 1
|
|
||||||
}
|
|
||||||
|
|
||||||
// Triangulate monotone mountain
|
mountain.process()
|
||||||
mountain process
|
|
||||||
|
|
||||||
// Extract the triangles into a single list
|
// Extract the triangles into a single list
|
||||||
j = 0
|
j = 0
|
||||||
|
Loading…
Reference in New Issue
Block a user