improve selection and avoid border case with ultra short segments

This commit is contained in:
sliptonic
2020-09-22 16:54:36 -05:00
parent 8758cfce9f
commit d22bfecdad
2 changed files with 18 additions and 6 deletions

View File

@@ -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

View File

@@ -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:])