diff --git a/src/Mod/CAM/Path/Op/Vcarve.py b/src/Mod/CAM/Path/Op/Vcarve.py index 179c6799a7..456409d4fa 100644 --- a/src/Mod/CAM/Path/Op/Vcarve.py +++ b/src/Mod/CAM/Path/Op/Vcarve.py @@ -284,29 +284,34 @@ class ObjectVcarve(PathEngraveBase.ObjectOp): ) obj.setEditorMode("BaseShapes", 2) # hide - obj.addProperty( - "App::PropertyBool", - "OptimizeMovements", - "Path", - QT_TRANSLATE_NOOP("App::Property", "Optimize movements"), - ) + if not hasattr(obj, "OptimizeMovements"): - obj.addProperty( - "App::PropertyBool", - "FinishingPass", - "Path", - QT_TRANSLATE_NOOP("App::Property", "Add finishing pass"), - ) + obj.addProperty( + "App::PropertyBool", + "OptimizeMovements", + "Path", + QT_TRANSLATE_NOOP("App::Property", "Optimize movements"), + ) + obj.OptimizeMovements = False - obj.addProperty( - "App::PropertyDistance", - "FinishingPassZOffset", - "Path", - QT_TRANSLATE_NOOP("App::Property", "Finishing pass Z offset"), - ) + if not hasattr(obj, "FinishingPass"): + obj.addProperty( + "App::PropertyBool", + "FinishingPass", + "Path", + QT_TRANSLATE_NOOP("App::Property", "Add finishing pass"), + ) + obj.FinishingPass = False - obj.FinishingPass = False - obj.FinishingPassZOffset = "0.00" + if not hasattr(obj, "FinishingPassZOffset"): + obj.addProperty( + "App::PropertyDistance", + "FinishingPassZOffset", + "Path", + QT_TRANSLATE_NOOP("App::Property", "Finishing pass Z offset"), + ) + + obj.FinishingPassZOffset = "0.00" def initOperation(self, obj): """initOperation(obj) ... create vcarve specific properties.""" @@ -334,7 +339,7 @@ class ObjectVcarve(PathEngraveBase.ObjectOp): ) obj.Colinear = 10.0 - obj.Discretize = 0.01 + obj.Discretize = 0.25 obj.Tolerance = Path.Preferences.defaultGeometryTolerance() self.setupAdditionalProperties(obj) @@ -350,6 +355,12 @@ class ObjectVcarve(PathEngraveBase.ObjectOp): wires_by_face = dict() self.voronoiDebugCache = dict() + def is_exterior(vertex, face): + vector = FreeCAD.Vector(vertex.toPoint(face.BoundBox.ZMin)) + (u, v) = face.Surface.parameter(vector) + # isPartOfDomain is faster than face.IsInside(...) + return not face.isPartOfDomain(u, v) + def insert_many_wires(vd, wires): for wire in wires: Path.Log.debug("discretize value: {}".format(obj.Discretize)) @@ -390,12 +401,17 @@ class ObjectVcarve(PathEngraveBase.ObjectOp): e.Color = PRIMARY else: e.Color = SECONDARY - vd.colorExterior(EXTERIOR1) - vd.colorExterior( - EXTERIOR2, - lambda v: not f.isInside(v.toPoint(f.BoundBox.ZMin), obj.Tolerance, True), - ) + + # filter our colinear edged so there are fewer ones + # to iterate over in colorExterior which is slow vd.colorColinear(COLINEAR, obj.Colinear) + + vd.colorExterior(EXTERIOR1) + vd.colorExterior(EXTERIOR2, lambda v: is_exterior(v, f)) + + # if colorTwin is done before colorExterior we seem to have + # much more weird exterior edges needed to be filtered out, + # keep it here to be safe vd.colorTwins(TWIN) wires = _collectVoronoiWires(vd)