Draft: improve wires.isReallyClosed (#8167)

This commit is contained in:
Roy-043
2023-01-12 10:25:48 +01:00
committed by GitHub
parent 0e517b0e19
commit 8a3b45ca73

View File

@@ -246,58 +246,9 @@ def superWire(edgeslist, closed=False):
def isReallyClosed(wire):
"""Check if a wire is really closed."""
# TODO yet to find out why not use wire.isClosed() direct,
# in isReallyClosed(wire)
# Remark out below - Found not true if a vertex is used again
# in a wire in sketch (e.g. wire with shape like 'd', 'b', 'g', ...)
# if len(wire.Edges) == len(wire.Vertexes): return True
# Found cases where Wire[-1] are not 'last' vertexes
# e.g. Part.Wire( Part.__sortEdges__(<Rectangle Geometries>.toShape()))
# aboveWire.isClosed() == True, but Wire[-1] are the 3rd vertex
# for the rectangle - use Edges[i].Vertexes[0/1] instead
length = len(wire.Edges)
# Test if it is full circle / ellipse first
if length == 1:
if len(wire.Edges[0].Vertexes) == 1:
return True # This is a closed wire - full circle/ellipse
else:
# TODO Should be False if 1 edge but not single vertex, correct?
# No need to test further below.
return False
# If more than 1 edge, further test below
e1 = wire.Edges[0]
e2 = wire.Edges[length-1]
if DraftVecUtils.equals(e1.Vertexes[0].Point, e2.Vertexes[1].Point):
if length == 2:
return DraftVecUtils.equals(e1.Vertexes[1].Point, e2.Vertexes[0].Point)
else:
return True
if DraftVecUtils.equals(e1.Vertexes[1].Point, e2.Vertexes[0].Point):
if length == 2:
return DraftVecUtils.equals(e1.Vertexes[0].Point, e2.Vertexes[1].Point)
else:
return True
if DraftVecUtils.equals(e1.Vertexes[0].Point, e2.Vertexes[0].Point):
if length == 2:
return DraftVecUtils.equals(e1.Vertexes[1].Point, e2.Vertexes[1].Point)
else:
return True
if DraftVecUtils.equals(e1.Vertexes[1].Point, e2.Vertexes[1].Point):
if length == 2:
return DraftVecUtils.equals(e1.Vertexes[0].Point, e2.Vertexes[0].Point)
else:
return True
return False
if isinstance(wire, (Part.Wire, Part.Edge)):
return wire.isClosed()
return isinstance(wire, Part.Face)
def curvetowire(obj, steps):