Draft: move more functions to draftgeoutils.faces

This commit is contained in:
vocx-fc
2020-05-31 03:17:50 -05:00
committed by Yorik van Havre
parent 5e25517c37
commit 3a572d50ca
2 changed files with 30 additions and 21 deletions

View File

@@ -380,27 +380,7 @@ from draftgeoutils.wires import tessellateProjection
from draftgeoutils.wires import rebaseWire
def removeSplitter(shape):
"""an alternative, shared edge-based version of Part.removeSplitter. Returns a
face or None if the operation failed"""
lut = {}
for f in shape.Faces:
for e in f.Edges:
h = e.hashCode()
if h in lut:
lut[h].append(e)
else:
lut[h] = [e]
edges = [e[0] for e in lut.values() if len(e) == 1]
try:
face = Part.Face(Part.Wire(edges))
except:
# operation failed
return None
else:
if face.isValid():
return face
return None
from draftgeoutils.faces import removeSplitter
# circle functions *********************************************************

View File

@@ -229,3 +229,32 @@ def cleanFaces(shape):
if shape.isClosed():
fshape = Part.makeSolid(fshape)
return fshape
def removeSplitter(shape):
"""Return a face from removing the splitter in a list of faces.
This is an alternative, shared edge-based version of Part.removeSplitter.
Returns a face, or `None` if the operation failed.
"""
lookup = dict()
for f in shape.Faces:
for e in f.Edges:
h = e.hashCode()
if h in lookup:
lookup[h].append(e)
else:
lookup[h] = [e]
edges = [e[0] for e in lookup.values() if len(e) == 1]
try:
face = Part.Face(Part.Wire(edges))
except:
# operation failed
return None
else:
if face.isValid():
return face
return None