Work around for offsetting a circle with Placement.
This commit is contained in:
@@ -33,7 +33,7 @@ import math
|
||||
|
||||
from PySide import QtCore
|
||||
|
||||
if False:
|
||||
if True:
|
||||
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
|
||||
PathLog.trackModule(PathLog.thisModule())
|
||||
else:
|
||||
@@ -61,6 +61,12 @@ def offsetWire(wire, base, offset, forward):
|
||||
PathLog.track('offsetWire')
|
||||
|
||||
w = wire.makeOffset2D(offset)
|
||||
if 1 == len(w.Edges):
|
||||
e = w.Edges[0]
|
||||
e.Placement = FreeCAD.Placement()
|
||||
w = Part.Wire(e)
|
||||
|
||||
|
||||
if wire.isClosed():
|
||||
if not base.isInside(w.Edges[0].Vertexes[0].Point, offset/2, True):
|
||||
PathLog.track('closed - outside')
|
||||
@@ -164,6 +170,8 @@ class ObjectChamfer(PathEngraveBase.ObjectOp):
|
||||
extraOffset = self.tool.Diameter/2 - obj.Width.Value if 180 == angle else obj.ExtraDepth.Value / tan
|
||||
offset = toolOffset + extraOffset
|
||||
|
||||
self.basewires = []
|
||||
self.adjusted_basewires = []
|
||||
wires = []
|
||||
for base, subs in obj.Base:
|
||||
edges = []
|
||||
@@ -180,8 +188,12 @@ class ObjectChamfer(PathEngraveBase.ObjectOp):
|
||||
for edgelist in Part.sortEdges(edges):
|
||||
basewires.append(Part.Wire(edgelist))
|
||||
|
||||
self.basewires.extend(basewires)
|
||||
|
||||
for w in self.adjustWirePlacement(obj, base, basewires):
|
||||
wires.append(offsetWire(obj, w, base.Shape, offset))
|
||||
self.adjusted_basewires.append(w)
|
||||
wires.append(offsetWire(w, base.Shape, offset, True))
|
||||
|
||||
self.wires = wires
|
||||
self.buildpathocc(obj, wires, [depth], True)
|
||||
|
||||
|
||||
@@ -46,6 +46,33 @@ else:
|
||||
def translate(context, text, disambig=None):
|
||||
return QtCore.QCoreApplication.translate(context, text, disambig)
|
||||
|
||||
def adjustPlacement(obj, shape, wires):
|
||||
job = PathUtils.findParentJob(obj)
|
||||
if hasattr(shape, 'MapMode') and 'Deactivated' != shape.MapMode:
|
||||
if hasattr(shape, 'Support') and 1 == len(shape.Support) and 1 == len(shape.Support[0][1]):
|
||||
pmntShape = shape.Placement
|
||||
pmntSupport = shape.Support[0][0].getGlobalPlacement()
|
||||
#pmntSupport = shape.Support[0][0].Placement
|
||||
pmntBase = job.Base.Placement
|
||||
pmnt = pmntBase.multiply(pmntSupport.inverse().multiply(pmntShape))
|
||||
#PathLog.debug("pmnt = %s" % pmnt)
|
||||
newWires = []
|
||||
for w in wires:
|
||||
edges = []
|
||||
for e in w.Edges:
|
||||
e = e.copy()
|
||||
e.Placement = FreeCAD.Placement()
|
||||
edges.append(e)
|
||||
w = Part.Wire(edges)
|
||||
w.Placement = pmnt
|
||||
newWires.append(w)
|
||||
wires = newWires
|
||||
else:
|
||||
PathLog.warning(translate("PathEngrave", "Attachment not supported by engraver"))
|
||||
else:
|
||||
PathLog.debug("MapMode: %s" % (shape.MapMode if hasattr(shape, 'MapMode') else 'None'))
|
||||
return wires
|
||||
|
||||
class ObjectOp(PathOp.ObjectOp):
|
||||
'''Proxy base class for engrave operations.'''
|
||||
|
||||
@@ -135,29 +162,4 @@ class ObjectOp(PathOp.ObjectOp):
|
||||
obj.OpFinalDepth = -0.1
|
||||
|
||||
def adjustWirePlacement(self, obj, shape, wires):
|
||||
job = PathUtils.findParentJob(obj)
|
||||
if hasattr(shape, 'MapMode') and 'Deactivated' != shape.MapMode:
|
||||
if hasattr(shape, 'Support') and 1 == len(shape.Support) and 1 == len(shape.Support[0][1]):
|
||||
pmntShape = shape.Placement
|
||||
pmntSupport = shape.Support[0][0].getGlobalPlacement()
|
||||
#pmntSupport = shape.Support[0][0].Placement
|
||||
pmntBase = job.Base.Placement
|
||||
pmnt = pmntBase.multiply(pmntSupport.inverse().multiply(pmntShape))
|
||||
#PathLog.debug("pmnt = %s" % pmnt)
|
||||
newWires = []
|
||||
for w in wires:
|
||||
edges = []
|
||||
for e in w.Edges:
|
||||
e = e.copy()
|
||||
e.Placement = FreeCAD.Placement()
|
||||
edges.append(e)
|
||||
w = Part.Wire(edges)
|
||||
w.Placement = pmnt
|
||||
newWires.append(w)
|
||||
wires = newWires
|
||||
else:
|
||||
PathLog.warning(translate("PathEngrave", "Attachment not supported by engraver"))
|
||||
else:
|
||||
PathLog.debug("MapMode: %s" % (shape.MapMode if hasattr(shape, 'MapMode') else 'None'))
|
||||
return wires
|
||||
|
||||
return adjustPlacement(obj, shape, wires)
|
||||
|
||||
Reference in New Issue
Block a user