|
88 | 88 | from OCP.BRepOffsetAPI import BRepOffsetAPI_MakeOffset
|
89 | 89 | from OCP.BRepPrimAPI import BRepPrimAPI_MakeHalfSpace
|
90 | 90 | from OCP.BRepProj import BRepProj_Projection
|
91 |
| -from OCP.BRepTools import BRepTools |
| 91 | +from OCP.BRepTools import BRepTools, BRepTools_WireExplorer |
92 | 92 | from OCP.GC import GC_MakeArcOfCircle, GC_MakeArcOfEllipse
|
93 | 93 | from OCP.GCPnts import GCPnts_AbscissaPoint
|
94 | 94 | from OCP.GProp import GProp_GProps
|
@@ -480,10 +480,20 @@ def edge(self) -> Edge | None:
|
480 | 480 |
|
481 | 481 | def edges(self) -> ShapeList[Edge]:
|
482 | 482 | """edges - all the edges in this Shape"""
|
483 |
| - edge_list = Shape.get_shape_list(self, "Edge") |
484 |
| - return edge_list.filter_by( |
485 |
| - lambda e: BRep_Tool.Degenerated_s(e.wrapped), reverse=True |
486 |
| - ) |
| 483 | + if isinstance(self, Wire): |
| 484 | + # The WireExplorer is a tool to explore the edges of a wire in a connection order. |
| 485 | + explorer = BRepTools_WireExplorer(self.wrapped) |
| 486 | + |
| 487 | + edge_list: ShapeList[Edge] = ShapeList() |
| 488 | + while explorer.More(): |
| 489 | + edge_list.append(Edge(explorer.Current())) |
| 490 | + explorer.Next() |
| 491 | + return edge_list |
| 492 | + else: |
| 493 | + edge_list = Shape.get_shape_list(self, "Edge") |
| 494 | + return edge_list.filter_by( |
| 495 | + lambda e: BRep_Tool.Degenerated_s(e.wrapped), reverse=True |
| 496 | + ) |
487 | 497 |
|
488 | 498 | def end_point(self) -> Vector:
|
489 | 499 | """The end point of this edge.
|
|
0 commit comments