Commit 0a814d66 authored by ronan's avatar ronan
Browse files

A verifier:

Après un événement vertex de type 0, un autre événement vertex, comment faire?
parent f6a11b6a
......@@ -70,25 +70,30 @@ class Fortune:
if p1 is not None:
min = findMinCircle(p1, p, site)
min.on = p
if min.point.getY() > site.point.getY():
if self.isValidVertex(min) and min.point.getY() > site.point.getY():
vertexVerif(min)
self.addEvent(min)
if p3 is not None:
min = findMinCircle(p3, p, site)
min.on = p
if min.point.getY() > site.point.getY():
if self.isValidVertex(min) and min.point.getY() > site.point.getY():
vertexVerif(min)
self.addEvent(min)
def handleVertex(self):
vSite = self.events.pop(len(self.events)-1)
on = None
if vSite.type == 1:
on = vSite.sites[0] if vSite.sites[0] is not vSite.on else vSite.sites[2]
print("=== Vertex Ev ===")
print("Sites = " + str(vSite.sites[0]) + ", " + str(vSite.sites[1]) + ", " + str(vSite.sites[2]))
self.rEvents.append(vSite)
[p1, pi, pk, p2, on] = self.beachLine.removeFromVSite(vSite)
[p1, pi, pk, p2, on2] = self.beachLine.removeFromVSite(vSite)
for i in range(len(vSite.sites)):
vSite.sites[i].sites.remove(vSite)
print("remove-> " + str(p1) + ", " + str(pi) + ", " + str(pk) + ", " + str(p2))
......@@ -109,11 +114,13 @@ class Fortune:
print("Normal?")
# AJout des breakpoints
if p1 is not None and (vSite.type == 0 or p1 is not vSite.on):
if p1 is not None and (p1 is not vSite.on):
# On supprime les evenements liés aux anciens points
self.removeEvent(p1, pi, vSite)
min = findMinCircle(p1, pi, pk)
if min.point.getY() > vSite.point.getY():
if self.isValidVertex(min) and min.point.getY() > vSite.point.getY():
if vSite.type == 0:
pass
min.on = on
vertexVerif(min)
......@@ -122,12 +129,15 @@ class Fortune:
self.addEvent(min)
if p2 is not None and (vSite.type == 0 or p2 is not vSite.on):
if p2 is not None and (p2 is not vSite.on):
# On supprime les evenements liés aux anciens points
self.removeEvent(vSite, pk, p2)
min = findMinCircle(pi, pk, p2)
if min.point.getY() > vSite.point.getY():
if self.isValidVertex(min) and min.point.getY() > vSite.point.getY():
min.on = on
if vSite.type == 0:
pass
vertexVerif(min)
assert(min.type != 1 or vSite.type != 0), "Que faire?"
......@@ -147,6 +157,9 @@ class Fortune:
break
i -= 1
if len(site.sites) == 1:
pass
# test
for x in range(len(self.events)-1):
if self.events[x].point.getY() < self.events[x+1].point.getY():
......@@ -168,3 +181,14 @@ class Fortune:
i -= 1
i += 1
def isValidVertex(self, vSite):
radius = (vSite.center - vSite.point).getMagnitude()
i = len(self.sites) - 1
while i > -1 and vSite.point.getY() >= self.sites[i].point.getY():
if self.sites[i] not in vSite.sites:
vec = vSite.center - self.sites[i].point
if vec.getMagnitude() < radius:
return False
i -= 1
return True
......@@ -123,7 +123,8 @@ def vertexVerif(min):
min.sites[i], min.sites[j] = min.sites[j], min.sites[i]
# Ajout des edges et set le type
if min.sites[1].point.getY() <= min.sites[0].point.getY() and min.sites[1].point.getY() <= min.sites[2].point.getY():
if min.sites[1] is min.on: #min.sites[1].point.getY() <= min.sites[0].point.getY() and min.sites[1].point.getY() <= min.sites[2].point.getY():
min.type = 0
edge = None
i = 0
......@@ -141,8 +142,7 @@ def vertexVerif(min):
i += 1
min.edges.append(edge)
elif min.sites[1].point.getY() > min.sites[0].point.getY() and min.sites[1].point.getY() > min.sites[2].point.getY():
else: #if min.sites[1].point.getY() > min.sites[0].point.getY() and min.sites[1].point.getY() > min.sites[2].point.getY():
min.type = 1
edge = None
......@@ -162,7 +162,7 @@ def vertexVerif(min):
i += 1
min.edges.append(edge)
"""
else:
min.type = 0
edge = None
......@@ -180,7 +180,7 @@ def vertexVerif(min):
edge = min.sites[2].edges[i]
i += 1
min.edges.append(edge)
"""
......@@ -194,4 +194,3 @@ def getPosCurve(p, x, y):
return Vector3D(x1, y1)
else:
return Vector3D(0, 0)
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