Fixed bad points sort algorithm

This commit is contained in:
Jose Luis Cercós Pita 2012-01-31 10:30:24 +01:00
parent c59ae2a843
commit 0e090ee032

View File

@ -152,18 +152,22 @@ class Ship:
for j in range(0,len(edges)):
for k in range(0,nP):
aux = self.lineFaceSection(edges[j], planes[k])
if not aux:
if not aux: # No section
points.append(Vector(x,0,z0 + k*dz))
if len(aux) == 1: # Single point section
points.append(Vector(aux[0].X, aux[0].Y, aux[0].Z))
else: # Several points, so ship has more than one body
# Get Y coordinates
auxY = []
for l in range(0,len(aux)):
points.append(Vector(aux[l].X, aux[l].Y, aux[l].Z))
# Sort section points at Y direction
aux = []
for j in range(0,len(points)):
aux.append(points[j].y)
aux.sort()
for j in range(0,len(points)):
section.append(Vector(points[j].x, aux[j], points[j].z))
auxY.append(aux[l].Y)
# Sort them
auxY.sort()
# And store
for l in range(0,len(aux)):
points.append(Vector(aux[l].X, auxY[l], aux[l].Z))
# Store points
section = points[:]
nPoints.append(len(section))
for j in range(0,len(section)):
mSections.append(section[j])