From 0c32b1b0ecc3efbe924f75d3b784e9a049c06199 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Fri, 10 Apr 2015 12:10:28 -0300 Subject: [PATCH] Draft: make sure normal is consistent for whole path in PathArray --- src/Mod/Draft/Draft.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Mod/Draft/Draft.py b/src/Mod/Draft/Draft.py index 2a3c5b5c1c72..f0999b009bcf 100644 --- a/src/Mod/Draft/Draft.py +++ b/src/Mod/Draft/Draft.py @@ -4871,7 +4871,7 @@ def getParameterFromV0(self, edge, offset): length = offset return(edge.getParameterByLength(length)) - def orientShape(self,shape,edge,offset,RefPt,xlate,align): + def orientShape(self,shape,edge,offset,RefPt,xlate,align,normal=None): '''Orient shape to tangent at parm offset along edge.''' # http://en.wikipedia.org/wiki/Euler_angles import Part @@ -4893,8 +4893,11 @@ def orientShape(self,shape,edge,offset,RefPt,xlate,align): t = edge.tangentAt(self.getParameterFromV0(edge,offset)) t.normalize() try: - n = edge.normalAt(self.getParameterFromV0(edge,offset)) - n.normalize() + if normal: + n = normal + else: + n = edge.normalAt(self.getParameterFromV0(edge,offset)) + n.normalize() b = (t.cross(n)) b.normalize() except FreeCAD.Base.FreeCADError: # no normal defined here @@ -4932,7 +4935,8 @@ def pathArray(self,shape,pathwire,count,xlate,align): import Part import DraftGeomUtils closedpath = DraftGeomUtils.isReallyClosed(pathwire) - path = DraftGeomUtils.sortEdges(pathwire.Edges) + normal = DraftGeomUtils.getNormal(pathwire) + path = DraftGeomUtils.sortEdges(pathwire.Edges) ends = [] cdist = 0 for e in path: # find cumulative edge end distance @@ -4940,11 +4944,11 @@ def pathArray(self,shape,pathwire,count,xlate,align): ends.append(cdist) base = [] pt = path[0].Vertexes[0].Point # place the start shape - ns = self.orientShape(shape,path[0],0,pt,xlate,align) + ns = self.orientShape(shape,path[0],0,pt,xlate,align,normal) base.append(ns) if not(closedpath): # closed path doesn't need shape on last vertex pt = path[-1].Vertexes[-1].Point # place the end shape - ns = self.orientShape(shape,path[-1],path[-1].Length,pt,xlate,align) + ns = self.orientShape(shape,path[-1],path[-1].Length,pt,xlate,align,normal) base.append(ns) if count < 3: return(Part.makeCompound(base)) @@ -4968,7 +4972,7 @@ def pathArray(self,shape,pathwire,count,xlate,align): remains = ends[iend] - travel offset = path[iend].Length - remains pt = path[iend].valueAt(self.getParameterFromV0(path[iend],offset)) - ns = self.orientShape(shape,path[iend],offset,pt,xlate,align) + ns = self.orientShape(shape,path[iend],offset,pt,xlate,align,normal) base.append(ns) travel += step return(Part.makeCompound(base))