code cleanup

This commit is contained in:
zzzzrrr 2009-07-23 15:43:11 -04:00
parent cb57653cbd
commit 3efb9622ee

View File

@ -86,6 +86,7 @@ class TrapezoidalMap {
bCross = t.bottom bCross = t.bottom
tCross = t.top tCross = t.top
s.above = trapezoids(1) s.above = trapezoids(1)
s.below = trapezoids(2) s.below = trapezoids(2)
@ -98,31 +99,29 @@ class TrapezoidalMap {
val lp = if(s.p.x == t.leftPoint.x) s.p else t.leftPoint val lp = if(s.p.x == t.leftPoint.x) s.p else t.leftPoint
val rp = if(s.q.x == t.rightPoint.x) s.q else t.rightPoint val rp = if(s.q.x == t.rightPoint.x) s.q else t.rightPoint
val topCross = (tCross == t.top)
val bottomCross = (bCross == t.bottom)
val trapezoids = new Array[Trapezoid](2) val trapezoids = new Array[Trapezoid](2)
trapezoids(0) = if(topCross) t.upperLeft else new Trapezoid(lp, rp, t.top, s)
trapezoids(1) = if(bottomCross) t.lowerLeft else new Trapezoid(lp, rp, s, t.bottom)
if(topCross) { if(tCross == t.top) {
trapezoids(0).upperRight = t.upperRight trapezoids(0) = t.upperLeft
if(t.upperRight != null) t.upperRight.upperLeft = trapezoids(0) trapezoids(0).updateRight(t.upperRight, null)
trapezoids(0).rightPoint = rp trapezoids(0).rightPoint = rp
} else { } else {
trapezoids(0) = new Trapezoid(lp, rp, t.top, s)
trapezoids(0).updateLeftRight(t.upperLeft, s.above, t.upperRight, null) trapezoids(0).updateLeftRight(t.upperLeft, s.above, t.upperRight, null)
} }
if(bottomCross) { if(bCross == t.bottom) {
trapezoids(1).lowerRight = t.lowerRight trapezoids(1) = t.lowerLeft
if(t.lowerRight != null) t.lowerRight.lowerLeft = trapezoids(1) trapezoids(1).updateRight(null, t.lowerRight)
trapezoids(1).rightPoint = rp trapezoids(1).rightPoint = rp
} else { } else {
trapezoids(1) = new Trapezoid(lp, rp, s, t.bottom)
trapezoids(1).updateLeftRight(s.below, t.lowerLeft, null, t.lowerRight) trapezoids(1).updateLeftRight(s.below, t.lowerLeft, null, t.lowerRight)
} }
bCross = t.bottom bCross = t.bottom
tCross = t.top tCross = t.top
s.above = trapezoids(0) s.above = trapezoids(0)
s.below = trapezoids(1) s.below = trapezoids(1)
@ -135,26 +134,25 @@ class TrapezoidalMap {
val lp = if(s.p.x == t.leftPoint.x) s.p else t.leftPoint val lp = if(s.p.x == t.leftPoint.x) s.p else t.leftPoint
val topCross = (tCross == t.top)
val bottomCross = (bCross == t.bottom)
val trapezoids = new Array[Trapezoid](3) val trapezoids = new Array[Trapezoid](3)
trapezoids(0) = if(topCross) t.upperLeft else new Trapezoid(lp, s.q, t.top, s)
trapezoids(1) = if(bottomCross) t.lowerLeft else new Trapezoid(lp, s.q, s, t.bottom)
trapezoids(2) = new Trapezoid(s.q, t.rightPoint, t.top, t.bottom)
if(topCross) { if(tCross == t.top) {
trapezoids(0) = t.upperLeft
trapezoids(0).rightPoint = s.q trapezoids(0).rightPoint = s.q
} else { } else {
trapezoids(0) = new Trapezoid(lp, s.q, t.top, s)
trapezoids(0).updateLeft(t.upperLeft, s.above) trapezoids(0).updateLeft(t.upperLeft, s.above)
} }
if(bottomCross) { if(bCross == t.bottom) {
trapezoids(1) = t.lowerLeft
trapezoids(1).rightPoint = s.q trapezoids(1).rightPoint = s.q
} else { } else {
trapezoids(1) = new Trapezoid(lp, s.q, s, t.bottom)
trapezoids(1).updateLeft(s.below, t.lowerLeft) trapezoids(1).updateLeft(s.below, t.lowerLeft)
} }
trapezoids(2) = new Trapezoid(s.q, t.rightPoint, t.top, t.bottom)
trapezoids(2).updateLeftRight(trapezoids(0), trapezoids(1), t.upperRight, t.lowerRight) trapezoids(2).updateLeftRight(trapezoids(0), trapezoids(1), t.upperRight, t.lowerRight)
trapezoids trapezoids