From f06306794c8edbae210d7fb7e2227b4d17887bd8 Mon Sep 17 00:00:00 2001 From: Markus Lampert Date: Tue, 21 Aug 2018 20:37:09 -0700 Subject: [PATCH] If an edge cannot be flipped, issue a warning and approximate it through straight line segments. --- src/Mod/Path/PathScripts/PathDressupHoldingTags.py | 13 ++++++++++++- src/Mod/Path/PathScripts/PathGeom.py | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Mod/Path/PathScripts/PathDressupHoldingTags.py b/src/Mod/Path/PathScripts/PathDressupHoldingTags.py index bcd89fbd73..8732910501 100644 --- a/src/Mod/Path/PathScripts/PathDressupHoldingTags.py +++ b/src/Mod/Path/PathScripts/PathDressupHoldingTags.py @@ -380,7 +380,18 @@ class MapWireToTag: debugEdge(e, ">>>>> no flip") break elif PathGeom.pointsCoincide(p2, p0): - outputEdges.append((PathGeom.flipEdge(e), True)) + flipped = PathGeom.flipEdge(e) + if not flipped is None: + outputEdges.append((flipped, True)) + else: + p0 = None + cnt = 0 + for p in reversed(e.discretize(Deflection=0.01)): + if not p0 is None: + outputEdges.append((Part.Edge(Part.LineSegment(p0, p)), True)) + cnt = cnt + 1 + p0 = p + PathLog.info("replaced edge with %d straight segments" % cnt) edges.remove(e) lastP = None p0 = p1 diff --git a/src/Mod/Path/PathScripts/PathGeom.py b/src/Mod/Path/PathScripts/PathGeom.py index 8433f1b437..f79a50adbe 100644 --- a/src/Mod/Path/PathScripts/PathGeom.py +++ b/src/Mod/Path/PathScripts/PathGeom.py @@ -507,6 +507,8 @@ def flipEdge(edge): return Part.Edge(flipped) + PathLog.warning(translate('PathGeom', "%s not support for flipping") % type(edge.Curve)) + def flipWire(wire): '''Flip the entire wire and all its edges so it is being processed the other way around.''' edges = [flipEdge(e) for e in wire.Edges]