Outline drawing tool updated to new paradigm

This commit is contained in:
Jose Luis Cercós pita 2012-06-09 18:26:22 +02:00
parent 8e70fda227
commit 706e9ead7e

View File

@ -63,48 +63,67 @@ class Preview(object):
sections = [] sections = []
for i in range(0,nL): for i in range(0,nL):
pos = sectionsL[i] pos = sectionsL[i]
# Cut ship
section = shape.slice(Vector(1.0,0.0,0.0), pos) section = shape.slice(Vector(1.0,0.0,0.0), pos)
for j in range(0,len(section)): for j in range(0,len(section)):
edges = section[j].Edges edges = section[j].Edges
if pos == 0.0: # We have 3 cases,
section[j] = section[j].mirror(Vector(0.0, 0.0, 0.0),Vector(0.0, 1.0, 0.0)) # * when section is before midship, then only starboard section will be considered
edges2 = section[j].Edges # * When section is midship, then all section must be preserved
for k in range(0,len(edges2)): # * When section is after midship, then only board will be considered
edges.append(edges2[k]) if pos > 0.01:
elif pos < 0: # Look for edges at the wrong side and delete it
section[j] = section[j].mirror(Vector(0.0, 0.0, 0.0),Vector(0.0, 1.0, 0.0)) for k in range(len(edges)-1,-1,-1):
edges = section[j].Edges edge = edges[k]
for k in range(0,len(edges)): bbox = edge.BoundBox
sections.append(edges[k]) if bbox.YMin < -0.001:
del edges[k]
elif pos < -0.01:
# Look for edges at the wrong side and delete it
for k in range(len(edges)-1,-1,-1):
edge = edges[k]
bbox = edge.BoundBox
if bbox.YMax > 0.001:
del edges[k]
sections.extend(edges)
for i in range(0,nB): for i in range(0,nB):
pos = sectionsB[i] pos = sectionsB[i]
section = shape.slice(Vector(0.0,1.0,0.0), pos) section = shape.slice(Vector(0.0,1.0,0.0), pos)
for j in range(0,len(section)): for j in range(0,len(section)):
edges = section[j].Edges edges = section[j].Edges
# Longitudinal sections will preserve board and starboard ever. Since we take from one side,
# we nned to mirror it.
section[j] = section[j].mirror(Vector(0.0, 0.0, 0.0),Vector(0.0, 1.0, 0.0)) section[j] = section[j].mirror(Vector(0.0, 0.0, 0.0),Vector(0.0, 1.0, 0.0))
edges2 = section[j].Edges edges2 = section[j].Edges
for k in range(0,len(edges2)): sections.extend(edges)
edges.append(edges2[k]) sections.extend(edges2)
for k in range(0,len(edges)):
sections.append(edges[k])
for i in range(0,nT): for i in range(0,nT):
pos = sectionsT[i] pos = sectionsT[i]
section = shape.slice(Vector(0.0,0.0,1.0), pos) section = shape.slice(Vector(0.0,0.0,1.0), pos)
for j in range(0,len(section)): for j in range(0,len(section)):
edges = section[j].Edges edges = section[j].Edges
if pos == T: # We have 3 cases,
section[j] = section[j].mirror(Vector(0.0, 0.0, 0.0),Vector(0.0, 1.0, 0.0)) # * when section is below draft, then only board section will be considered
edges2 = section[j].Edges # * When section is draft, then all section must be preserved
for k in range(0,len(edges2)): # * When section is above draft, then only starboard will be considered
edges.append(edges2[k]) if pos > T + 0.01:
elif pos > T: # Look for edges at the wrong side and delete it
section[j] = section[j].mirror(Vector(0.0, 0.0, 0.0),Vector(0.0, 1.0, 0.0)) for k in range(len(edges)-1,-1,-1):
edges = section[j].Edges edge = edges[k]
for k in range(0,len(edges)): bbox = edge.BoundBox
sections.append(edges[k]) if bbox.YMax > 0.001:
del edges[k]
elif pos < T - 0.01:
# Look for edges at the wrong side and delete it
for k in range(len(edges)-1,-1,-1):
edge = edges[k]
bbox = edge.BoundBox
if bbox.YMin < -0.001:
del edges[k]
sections.extend(edges)
# Convert all BSplines into a shape # Convert all BSplines into a shape
if not sections: if not sections:
msg = Translator.translate('Any valid ship section found\n') msg = Translator.translate('Any valid ship section found')
FreeCAD.Console.PrintWarning(msg) FreeCAD.Console.PrintWarning(msg)
return return
obj = sections[0] obj = sections[0]