Skip to content

Commit

Permalink
Merge pull request #4443 from mlampert/bugfix/deburr-offset-part
Browse files Browse the repository at this point in the history
[Path]: Added support for Part.OffsetCurve to flipEdge.
  • Loading branch information
sliptonic committed Feb 14, 2021
2 parents e071d61 + 696e17c commit 62ed39e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Mod/Path/PathScripts/PathGeom.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,13 +534,18 @@ def flipEdge(edge):
flipped.buildFromPolesMultsKnots(poles, mults , knots, perio, degree, weights, ratio)

return Part.Edge(flipped)
elif type(edge.Curve) == Part.OffsetCurve:
return edge.reversed()

global OddsAndEnds # pylint: disable=global-statement
OddsAndEnds.append(edge)
PathLog.warning(translate('PathGeom', "%s not support for flipping") % type(edge.Curve))
PathLog.warning(translate('PathGeom', "%s not supported for flipping") % type(edge.Curve))

Wire = []

def flipWire(wire):
'''Flip the entire wire and all its edges so it is being processed the other way around.'''
Wire.append(wire)
edges = [flipEdge(e) for e in wire.Edges]
edges.reverse()
PathLog.debug(edges)
Expand Down
12 changes: 12 additions & 0 deletions src/Mod/Path/PathTests/TestPathGeom.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,4 +530,16 @@ def test75(self):
edge = Part.Edge(Part.BSplineCurve([Vector(-8,4,0), Vector(1,-5,0), Vector(5,11,0), Vector(12,-5,0)], weights=[2,3,5,7]))
self.assertEdgeShapesMatch(edge, PathGeom.flipEdge(edge))

def test76(self):
'''Flip an offset wire'''

e0 = Part.Edge(Part.BSplineCurve([Vector(-8,4,0), Vector(1,-5,0), Vector(5,11,0), Vector(12,-5,0)], weights=[2,3,5,7]))
e1 = Part.Edge(Part.LineSegment(Vector(12,-5,0), Vector(0,-7,0)))
e2 = Part.Edge(Part.LineSegment(Vector(0,-7,0), Vector(-8,4,0)))
w0 = Part.Wire([e0, e1, e2])
w1 = w0.makeOffset2D(1)
w2 = PathGeom.flipWire(w1)
# do some sanity checks
self.assertTrue(w2.isValid())
self.assertTrue(w2.isClosed())

0 comments on commit 62ed39e

Please sign in to comment.