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

Avancé dans la gestion des vertex

parent e3b81339
......@@ -57,8 +57,13 @@ class Fortune:
if p is not None:
if p1 is not None and p3 is not None:
# On supprime les evenements liés aux anciens points
self.removeEvent(p1, p, p3)
# Création du segment
createEdge(p, site)
# AJout des breakpoints
if p1 is not None:
min = findMinCircle(p1, p, site)
min.on = p
......@@ -80,43 +85,42 @@ class Fortune:
print("Sites = " + str(vSite.sites[0]) + ", " + str(vSite.sites[1]) + ", " + str(vSite.sites[2]))
self.rEvents.append(vSite)
[p1, pi, pk, p2] = self.beachLine.removeFromVSite(vSite)
[p1, pi, pk, p2, on] = self.beachLine.removeFromVSite(vSite)
print("remove-> " + str(p1) + ", " + str(pi) + ", " + str(pk) + ", " + str(p2))
print("=================")
if pi is not None and pk is not None:
edge1 = None
edge2 = None
i = 0
while edge1 is None:
if vSite.edges[i] in pi.edges:
edge1 = vSite.edges[i]
i += 1
i = 0
while edge2 is None:
if vSite.edges[i] in pk.edges:
edge2 = vSite.edges[i]
i += 1
edge1.addPoint(vSite.center)
edge2.addPoint(vSite.center)
vSite.edges[0].addPoint(vSite.center)
vSite.edges[1].addPoint(vSite.center)
self.vertex.append(vSite.center)
# AJout des breakpoints
if p1 is not None:
# 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():
vertexVerif(min)
assert(min.type != 1 or vSite.type != 0), "Que faire?"
assert(min.on != None or min.type != 1)
min.on = on
self.addEvent(min)
if p2 is not None:
# 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():
vertexVerif(min)
assert(min.type != 1 or vSite.type != 0), "Que faire?"
assert(min.on != None or min.type != 1)
min.on = on
self.addEvent(min)
else:
print("normal?")
......
......@@ -28,12 +28,15 @@ def findMinCircle(p1, p2, p3):
minY = Vector3D(x, y + magn)
vSite = VSite(minY, center)
vSite.sites.append(p1)
vSite.sites.append(p2)
vSite.sites.append(p3)
p1.sites.append(vSite)
p2.sites.append(vSite)
p3.sites.append(vSite)
return vSite
......@@ -79,14 +82,92 @@ def createEdge(p0, p1):
def vertexVerif(min):
# type 0
# -------------------------------------
# ------------------*------------------
# ------------------p2-----------------
# -----*-------------------------------
# -----p1-----------------------*------
# -----------------------------p3------
# type 1
# On regarde sue quelle courbe on est actuellement
# Pour ca on calcule la collision entre les deux courbes de p1 et p3
# ------------------------------*------
# -----*------------------------p3-----
# -----p1------------------------------
# -------------------------------------
# -----------------*-------------------
# ----------------p2-------------------
for i in range(len(min.sites)):
for j in range(i+1, len(min.sites)):
if min.sites[i].point.getX() > min.sites[j].point.getX():
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():
min.type = 0
edge = None
i = 0
while edge == None:
if min.sites[0].edges[i] in min.sites[1].edges:
edge = min.sites[0].edges[i]
min.edges.append(edge)
edge = None
i = 0
while edge == None:
if min.sites[2].edges[i] in min.sites[1].edges:
edge = min.sites[2].edges[i]
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():
min.type = 1
edge = None
i = 0
while edge == None:
if min.sites[0].edges[i] in min.sites[2].edges:
edge = min.sites[0].edges[i]
min.edges.append(edge)
# L'autre on cherche
edge = None
i = 0 # A régler
while edge == None:
if min.sites[1].edges[i] in min.on.edges:
edge = min.sites[1].edges[i]
min.edges.append(edge)
else:
min.type = 0
print("How to handle this thing?")
\ No newline at end of file
edge = None
i = 0
while edge == None:
if min.sites[0].edges[i] in min.sites[1].edges:
edge = min.sites[0].edges[i]
min.edges.append(edge)
edge = None
i = 0
while edge == None:
if min.sites[2].edges[i] in min.sites[1].edges:
edge = min.sites[2].edges[i]
min.edges.append(edge)
def getPosCurve(p, x, y):
a = p.getY()*p.getY() - y*y
b = (2*(y - p.getY()))
if b != 0.0:
x1 = x + p.getX() - 250
h = (p.getX() - x1)*(p.getX() - x1) + a
y1 = -h/b
return Vector3D(x1, y1)
else:
return Vector3D(0, 0)
......@@ -35,6 +35,15 @@ class Node:
if piN.site in p0.sites:
pkN = self.next()
if pkN.site in p0.sites:
sites = p0.copySites()
sites.remove(piN.site)
sites.remove(p0.sites[1])
sites.remove(pkN.site)
notUsed = None
if len(sites) != 0:
assert(len(sites) == 1)
notUsed = sites[0]
p1 = piN.lastSite()
p2 = pkN.nextSite()
pi = piN.site
......@@ -51,7 +60,7 @@ class Node:
else:
self.root.root.right = self.root.left
self.root.left = self.root.root
return [p1, pi, pk, p2]
return [p1, pi, pk, p2, notUsed]
if self.isLeaf():
#assert(False), "No site found"
......
......@@ -10,3 +10,11 @@ class Site:
def __str__(self):
return self.name
#return "[ " + str(self.point.getX()) + ", " + str(self.point.getY()) + " ]"
def copySites(self):
sites = []
for i in range(len(self.sites)):
sites.append(self.sites[i])
return sites
......@@ -13,3 +13,4 @@ class VSite (Site):
return str(self.sites[0]) + ", " + str(self.sites[1]) + ", " + str(self.sites[2])
else:
return "vSite ??"
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