Commit 021f5f37 authored by ronan's avatar ronan
Browse files

Premiers tests

parent 89528d13
......@@ -13,6 +13,11 @@ class BeachLine:
else:
return self.root.insert(p0)
def update(self, ly):
if self.root is None or self.root.isLeaf():
return
self.root.update(ly)
def remove(self, p0):
assert(self.root is not None)
self.root.remove(p0)
......@@ -29,12 +29,13 @@ class Fortune:
def create(self):
while len(self.events) != 0:
self.beachLine.update(self.events[len(self.events)-1].point.getY())
if type(self.events[len(self.events)-1]) == VSite:
self.handleVertex()
else:
self.handleSite()
def handleSite(self):
site = self.events.pop(len(self.events)-1) #SweapLine
[p1, p, p3] = self.beachLine.insert(site)
......@@ -52,6 +53,7 @@ class Fortune:
if min.point.y > site.point.y:
self.addEvent(min)
def handleVertex(self):
vSite = self.events.pop(len(self.events)-1)
[p1, pi, pk, p2] = self.beachLine.remove(vSite)
......@@ -90,6 +92,7 @@ class Fortune:
else:
print("normal?")
#removeEvent
def addEvent(self, site):
......
......@@ -49,8 +49,9 @@ def computeBreakPoint(p1, p2, ly):
f = (((h*b)/e) + c)
delta = (d*d - 4*b*f/e)
assert(delta >= 0), "Ca a crashé " + str(delta)
if delta < 0.00001:
if delta < 0.0:
return []
elif delta < 0.00001:
x = -d/(2*b/e)
y = (x*x - 2*x1*x + h)/e
return [Vector3D(x, y)]
......
from Geom import *
class Node:
def __init__(self, site = None):
......@@ -68,6 +68,25 @@ class Node:
else:
return l
def update(self, ly):
iNode1 = self.left.max()
iNode2 = self.right.low()
c = None
breakpoints = computeBreakPoint(iNode1.site, iNode2.site, ly)
if len(breakpoints) == 2:
if iNode1.site.point.getY() < iNode2.site.point.getY():
c = breakpoints[0]
else:
c = breakpoints[1]
else:
assert(len(breakpoints) != 0)
c = breakpoints[0]
self.value = c.getX()
if not self.left.isLeaf():
self.left.update(ly)
if not self.right.isLeaf():
self.right.update(ly)
def isLeaf(self):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment