Bugfixes in Arch Section plane

This commit is contained in:
Yorik van Havre 2012-04-20 13:07:42 -03:00
parent bf2225c4a2
commit 173af46744
3 changed files with 49 additions and 6 deletions

View File

@ -195,9 +195,10 @@ class _ArchDrawingView:
colors.append(color)
sec = o.Shape.section(cp[0])
if sec.Edges:
sec = Part.Wire(fcgeo.sortEdges(sec.Edges))
sec = Part.Face(sec)
sections.append(sec)
wires = fcgeo.findWires(sec.Edges)
for w in wires:
sec = Part.Face(fcgeo.sortEdges(w))
sections.append(sec)
else:
shapes.append(o.Shape)
colors.append(color)
@ -237,7 +238,7 @@ class _ArchDrawingView:
def renderVRM(self,shapes,placement,colors,linewidth):
"renders an SVG fragment with the ArchVRM method"
import ArchVRM
render = ArchVRM.Renderer(debug=False)
render = ArchVRM.Renderer()
render.setWorkingPlane(FreeCAD.Placement(placement))
for i in range(len(shapes)):
if colors:

View File

@ -31,7 +31,7 @@ MAXLOOP = 10 # the max number of loop before abort
class Renderer:
"A renderer object"
def __init__(self,wp=None,debug=None):
def __init__(self,wp=None):
"""
Creates a renderer with a default Draft WorkingPlane
@ -44,7 +44,6 @@ class Renderer:
p.buildDummy()
"""
if debug != None: DEBUG = debug
self.defaultFill = (0.9,0.9,0.9,1.0) # the default fill color
self.wp = wp
self.faces = []

View File

@ -513,6 +513,49 @@ def sortEdges(lEdges, aVertex=None):
else :
return []
def findWires(edgeslist):
'''finds connected wires in the given list of edges'''
def touches(e1,e2):
if len(e1.Vertexes) < 2:
return False
if len(e2.Vertexes) < 2:
return False
if fcvec.equals(e1.Vertexes[0].Point,e2.Vertexes[0].Point):
return True
if fcvec.equals(e1.Vertexes[0].Point,e2.Vertexes[-1].Point):
return True
if fcvec.equals(e1.Vertexes[-1].Point,e2.Vertexes[0].Point):
return True
if fcvec.equals(e1.Vertexes[-1].Point,e2.Vertexes[-1].Point):
return True
return False
edges = edgeslist[:]
wires = []
while edges:
e = edges[0]
if not wires:
# create first group
edges.remove(e)
wires.append([e])
else:
found = False
for w in wires:
if found:
break
for we in w:
if touches(e,we):
edges.remove(e)
w.append(e)
found = True
break
else:
# edge doesn't connect with any existing group
edges.remove(e)
wires.append([e])
return wires
def superWire(edgeslist,closed=False):
'''superWire(edges,[closed]): forces a wire between edges that don't necessarily