From 3194d478f34a3fc49bd355800c347607d9e41c57 Mon Sep 17 00:00:00 2001 From: Jose Luis Cercos-Pita Date: Fri, 11 Jul 2014 17:01:04 +0200 Subject: [PATCH] Fixed box generation for small draft values --- src/Mod/Ship/shipHydrostatics/Tools.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/Mod/Ship/shipHydrostatics/Tools.py b/src/Mod/Ship/shipHydrostatics/Tools.py index b440f4fc4..88449d722 100644 --- a/src/Mod/Ship/shipHydrostatics/Tools.py +++ b/src/Mod/Ship/shipHydrostatics/Tools.py @@ -216,8 +216,11 @@ def wettedArea(shape, draft, trim): # Create the "sea" box L = xmax - xmin B = bbox.YMax - bbox.YMin - p = Vector(-1.5*L, -1.5*B, bbox.ZMin - 1.0) - box = Part.makeBox(3.0*L, 3.0*B, - bbox.ZMin + 1.0, p) + p = Vector(-1.5 * L, -1.5 * B, bbox.ZMin - 1.0) + try: + box = Part.makeBox(3.0 * L, 3.0 * B, - bbox.ZMin + 1.0, p) + except: + return 0.0 for f in shape.Faces: try: @@ -274,8 +277,11 @@ def FloatingArea(ship, draft, trim): # Create the "sea" box L = xmax - xmin B = bbox.YMax - bbox.YMin - p = Vector(-1.5*L, -1.5*B, bbox.ZMin - 1.0) - box = Part.makeBox(3.0*L, 3.0*B, - bbox.ZMin + 1.0, p) + p = Vector(-1.5 * L, -1.5 * B, bbox.ZMin - 1.0) + try: + box = Part.makeBox(3.0 * L, 3.0 * B, - bbox.ZMin + 1.0, p) + except: + return [area, cf] maxX = bbox.XMin / Units.Metre.Value minX = bbox.XMax / Units.Metre.Value @@ -368,8 +374,11 @@ def mainFrameCoeff(ship, draft): # Create the "sea" box L = xmax - xmin B = bbox.YMax - bbox.YMin - p = Vector(-1.5*L, -1.5*B, bbox.ZMin - 1.0) - box = Part.makeBox(1.5*L + x, 3.0*B, - bbox.ZMin + 1.0, p) + p = Vector(-1.5 * L, -1.5 * B, bbox.ZMin - 1.0) + try: + box = Part.makeBox(1.5 * L, 3.0 * B, - bbox.ZMin + 1.0, p) + except: + return cm maxY = bbox.YMin / Units.Metre.Value minY = bbox.YMax / Units.Metre.Value