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 j in range(0,len(edges)):
for k in range(0,nP): for k in range(0,nP):
aux = self.lineFaceSection(edges[j], planes[k]) aux = self.lineFaceSection(edges[j], planes[k])
if not aux: if not aux: # No section
points.append(Vector(x,0,z0 + k*dz)) 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)): for l in range(0,len(aux)):
points.append(Vector(aux[l].X, aux[l].Y, aux[l].Z)) auxY.append(aux[l].Y)
# Sort section points at Y direction # Sort them
aux = [] auxY.sort()
for j in range(0,len(points)): # And store
aux.append(points[j].y) for l in range(0,len(aux)):
aux.sort() points.append(Vector(aux[l].X, auxY[l], aux[l].Z))
for j in range(0,len(points)):
section.append(Vector(points[j].x, aux[j], points[j].z))
# Store points # Store points
section = points[:]
nPoints.append(len(section)) nPoints.append(len(section))
for j in range(0,len(section)): for j in range(0,len(section)):
mSections.append(section[j]) mSections.append(section[j])