From d22bfecdadbf8634e01d64df4aa6281a5d4664b1 Mon Sep 17 00:00:00 2001 From: sliptonic Date: Tue, 22 Sep 2020 16:54:36 -0500 Subject: [PATCH] improve selection and avoid border case with ultra short segments --- src/Mod/Path/PathScripts/PathSelection.py | 12 ++++++++++-- src/Mod/Path/PathScripts/PathVcarve.py | 12 ++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathSelection.py b/src/Mod/Path/PathScripts/PathSelection.py index 657f4519ce..f6483f8505 100644 --- a/src/Mod/Path/PathScripts/PathSelection.py +++ b/src/Mod/Path/PathScripts/PathSelection.py @@ -57,13 +57,21 @@ class VCARVEGate: if math.fabs(shape.Volume) < 1e-9 and len(shape.Wires) > 0: return True - if shape.ShapeType == 'Edge': + if shape.ShapeType == 'Face': return True + elif shape.ShapeType == 'Solid': + if sub and sub[0:4] == 'Face': + return True + + elif shape.ShapeType == 'Compound': + if sub and sub[0:4] == 'Face': + return True + if sub: subShape = shape.getElement(sub) if subShape.ShapeType == 'Edge': - return True + return False return False diff --git a/src/Mod/Path/PathScripts/PathVcarve.py b/src/Mod/Path/PathScripts/PathVcarve.py index 0273c8e190..fb4b04969c 100644 --- a/src/Mod/Path/PathScripts/PathVcarve.py +++ b/src/Mod/Path/PathScripts/PathVcarve.py @@ -47,7 +47,7 @@ TWIN = 2 COLINEAR = 3 OTHER = 5 -if False: +if True: PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule()) PathLog.trackModule(PathLog.thisModule()) else: @@ -146,13 +146,15 @@ class ObjectVcarve(PathEngraveBase.ObjectOp): mywire.Edges[-1].valueAt(mywire.Edges[-1].LastParameter)] for i, candidate in enumerate(unmatched): - if candidate.Length < obj.Tolerance: - continue # end points of candidate edge cverts = [candidate.Edges[0].valueAt(candidate.Edges[0].FirstParameter), candidate.Edges[-1].valueAt(candidate.Edges[-1].LastParameter)] + # ignore short segments below tolerance level + if PathGeom.pointsCoincide(cverts[0], cverts[1], obj.Tolerance): + continue + # iterate the combination of endpoints. If a match is found, # make an edge from the common endpoint to the other end of # the candidate wire. Add the edge to the wire and return it. @@ -165,8 +167,10 @@ class ObjectVcarve(PathEngraveBase.ObjectOp): wireGrowing = True elist = mywire.Edges otherIndex = int(not(idx)) + newedge = Part.Edge(Part.Vertex(wvert), - Part.Vertex(cverts[otherIndex])) + Part.Vertex(cverts[otherIndex])) + elist.append(newedge) mywire = Part.Wire(Part.__sortEdges__(elist)) remaining.extend(unmatched[i+1:])