From 0e090ee032dd696d7cf1d948eb477b34582d362c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Luis=20Cerc=C3=B3s=20Pita?= Date: Tue, 31 Jan 2012 10:30:24 +0100 Subject: [PATCH] Fixed bad points sort algorithm --- src/Mod/Ship/Instance.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/Mod/Ship/Instance.py b/src/Mod/Ship/Instance.py index 26f28aabe..49cb37a51 100644 --- a/src/Mod/Ship/Instance.py +++ b/src/Mod/Ship/Instance.py @@ -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)) - 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)) + 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)): + 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])