Skip to content

Commit

Permalink
Updated edges() to use WireExplorer when appropriate Issue #864
Browse files Browse the repository at this point in the history
  • Loading branch information
gumyr committed Feb 20, 2025
1 parent 2d84e6e commit 40cf143
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/build123d/topology/one_d.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
from OCP.BRepOffsetAPI import BRepOffsetAPI_MakeOffset
from OCP.BRepPrimAPI import BRepPrimAPI_MakeHalfSpace
from OCP.BRepProj import BRepProj_Projection
from OCP.BRepTools import BRepTools
from OCP.BRepTools import BRepTools, BRepTools_WireExplorer
from OCP.GC import GC_MakeArcOfCircle, GC_MakeArcOfEllipse
from OCP.GCPnts import GCPnts_AbscissaPoint
from OCP.GProp import GProp_GProps
Expand Down Expand Up @@ -480,10 +480,20 @@ def edge(self) -> Edge | None:

def edges(self) -> ShapeList[Edge]:
"""edges - all the edges in this Shape"""
edge_list = Shape.get_shape_list(self, "Edge")
return edge_list.filter_by(
lambda e: BRep_Tool.Degenerated_s(e.wrapped), reverse=True
)
if isinstance(self, Wire):
# The WireExplorer is a tool to explore the edges of a wire in a connection order.
explorer = BRepTools_WireExplorer(self.wrapped)

edge_list: ShapeList[Edge] = ShapeList()
while explorer.More():
edge_list.append(Edge(explorer.Current()))
explorer.Next()
return edge_list
else:
edge_list = Shape.get_shape_list(self, "Edge")
return edge_list.filter_by(
lambda e: BRep_Tool.Degenerated_s(e.wrapped), reverse=True
)

def end_point(self) -> Vector:
"""The end point of this edge.
Expand Down

0 comments on commit 40cf143

Please sign in to comment.