From d6c588e57b08a15e93fee2ecf906f0cd77e4f423 Mon Sep 17 00:00:00 2001 From: Markus Lampert Date: Mon, 12 Dec 2016 22:41:18 -0800 Subject: [PATCH] Added resiliancy against vertical path elements. --- .../PathScripts/PathDressupHoldingTags.py | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathDressupHoldingTags.py b/src/Mod/Path/PathScripts/PathDressupHoldingTags.py index 2617134b7..1d43a6039 100644 --- a/src/Mod/Path/PathScripts/PathDressupHoldingTags.py +++ b/src/Mod/Path/PathScripts/PathDressupHoldingTags.py @@ -279,17 +279,20 @@ class MapWireToTag: else: plinths.append(p1) # remove all edges that are connected to the plinths of the (former) internal struts - # including the edge that connects the entry and exit point directly for e in copy.copy(inputEdges): - if PathGeom.edgeConnectsTo(e, self.entry) and PathGeom.edgeConnectsTo(e, self.exit): - debugEdge(e, '......... X1') - inputEdges.remove(e) - continue for p in plinths: if PathGeom.edgeConnectsTo(e, p): - debugEdge(e, '......... X2') + debugEdge(e, '......... X1') inputEdges.remove(e) break + # if there are any edges beside a direct edge remaining, the direct edge between + # entry and exit is redundant + if len(inputEdges) > 1: + for e in copy.copy(inputEdges): + if PathGeom.edgeConnectsTo(e, self.entry) and PathGeom.edgeConnectsTo(e, self.exit): + debugEdge(e, '......... X2') + inputEdges.remove(e) + # the remaining edges form a walk around the tag # they need to be ordered and potentially flipped though outputEdges = [] @@ -321,6 +324,13 @@ class MapWireToTag: # print("xxxxxx (%.2f, %.2f, %.2f)" % (p.x, p.y, p.z)) return outputEdges + def shell(self): + shell = self.wire.extrude(FreeCAD.Vector(0, 0, 10)) + redundant = filter(lambda f: f.Area == 0, shell.childShapes()) + if redundant: + return shell.removeShape(redundant) + return shell + def add(self, edge): self.tail = None if self.tag.solid.isInside(edge.valueAt(edge.LastParameter), 0.000001, True): @@ -335,8 +345,7 @@ class MapWireToTag: self.tail = tail self.exit = i if self.wire: - shell = self.wire.extrude(FreeCAD.Vector(0, 0, 10)) - face = shell.common(self.tag.solid) + face = self.shell().common(self.tag.solid) for e,flip in self.cleanupEdges(face.Edges): debugEdge(e, '++++++++ %s' % ('.' if not flip else '@'))