[Draft - DraftGeoUtils] Refine isReallyClosed() : Part of ArchWall / DraftGeomUtils Multi-Width Support Improvement Proposal

This commit is contained in:
paullee0
2019-10-01 09:03:24 +08:00
committed by Yorik van Havre
parent c331ce29f1
commit bbff21935a

View File

@@ -1116,9 +1116,18 @@ def offset(edge,vector,trim=False):
def isReallyClosed(wire):
"checks if a wire is really closed"
if len(wire.Edges) == len(wire.Vertexes): return True
v1 = wire.Vertexes[0].Point
v2 = wire.Vertexes[-1].Point
## 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)
v1 = wire.Edges[0].Vertexes[0].Point #v1 = wire.Vertexes[0].Point
v2 = wire.Edges[length-1].Vertexes[1].Point #v2 = wire.Vertexes[-1].Point
if DraftVecUtils.equals(v1,v2): return True
return False