added way of breaking BSplines into line segments in Shape2DView

This commit is contained in:
Daniel Falck 2014-02-08 15:16:36 -08:00 committed by Yorik van Havre
parent 4fb000f0c8
commit 9ede51b2f6
2 changed files with 22 additions and 7 deletions

View File

@ -4023,9 +4023,11 @@ class _Shape2DView(_DraftObject):
"The indices of the faces to be projected in Individual Faces mode")
obj.addProperty("App::PropertyBool","HiddenLines","Draft",
"Show hidden lines")
obj.addProperty("App::PropertyBool","Tessellation","Draft", "Tessellate BSplines into line segments using number of spline poles")
obj.Projection = Vector(0,0,1)
obj.ProjectionMode = ["Solid","Individual Faces","Cutlines"]
obj.HiddenLines = False
obj.Tessellation = True
_DraftObject.__init__(self,obj,"Shape2DView")
def execute(self,obj):
@ -4048,7 +4050,7 @@ class _Shape2DView(_DraftObject):
for g in groups[5:]:
edges.append(g)
#return Part.makeCompound(edges)
return DraftGeomUtils.cleanProjection(Part.makeCompound(edges))
return DraftGeomUtils.cleanProjection(Part.makeCompound(edges),obj.Tessellation)
def createGeometry(self,obj):
import DraftGeomUtils

View File

@ -1783,8 +1783,18 @@ def getCircleFromSpline(edge):
circle = Part.makeCircle(r,c,n)
#print circle.Curve
return circle
def cleanProjection(shape):
def curvetowire(obj,steps):
points = obj.copy().discretize(steps)
p0 = points[0]
edgelist = []
for p in points[1:]:
edge = Part.makeLine((p0.x,p0.y,p0.z),(p.x,p.y,p.z))
edgelist.append(edge)
p0 = p
return edgelist
def cleanProjection(shape,tessellate):
"returns a valid compound of edges, by recreating them"
# this is because the projection algorithm somehow creates wrong shapes.
# they dispay fine, but on loading the file the shape is invalid
@ -1808,11 +1818,14 @@ def cleanProjection(shape):
else:
newedges.append(e.Curve.toShape())
elif geomType(e) == "BSplineCurve":
if isLine(e.Curve):
l = Part.Line(e.Vertexes[0].Point,e.Vertexes[-1].Point).toShape()
newedges.append(l)
if tessellate:
newedges.append(Part.Wire(curvetowire(e,e.Curve.NbPoles)))
else:
newedges.append(e.Curve.toShape())
if isLine(e.Curve):
l = Part.Line(e.Vertexes[0].Point,e.Vertexes[-1].Point).toShape()
newedges.append(l)
else:
newedges.append(e.Curve.toShape())
else:
newedges.append(e)
except: