A trimmed curve that represents the border of a face
| 2553 | |
| 2554 | |
| 2555 | class Edge(Shape, Mixin1D): |
| 2556 | """ |
| 2557 | A trimmed curve that represents the border of a face |
| 2558 | """ |
| 2559 | |
| 2560 | wrapped: TopoDS_Edge |
| 2561 | |
| 2562 | def _geomAdaptor(self) -> BRepAdaptor_Curve: |
| 2563 | """ |
| 2564 | Return the underlying geometry |
| 2565 | """ |
| 2566 | |
| 2567 | return BRepAdaptor_Curve(self.wrapped) |
| 2568 | |
| 2569 | def close(self) -> Edge | Wire: |
| 2570 | """ |
| 2571 | Close an Edge |
| 2572 | """ |
| 2573 | rv: Wire | Edge |
| 2574 | |
| 2575 | if not self.IsClosed(): |
| 2576 | rv = Wire.assembleEdges((self,)).close() |
| 2577 | else: |
| 2578 | rv = self |
| 2579 | |
| 2580 | return rv |
| 2581 | |
| 2582 | def arcCenter(self) -> Vector: |
| 2583 | """ |
| 2584 | Center of an underlying circle or ellipse geometry. |
| 2585 | """ |
| 2586 | |
| 2587 | g = self.geomType() |
| 2588 | a = self._geomAdaptor() |
| 2589 | |
| 2590 | if g == "CIRCLE": |
| 2591 | rv = Vector(a.Circle().Position().Location()) |
| 2592 | elif g == "ELLIPSE": |
| 2593 | rv = Vector(a.Ellipse().Position().Location()) |
| 2594 | else: |
| 2595 | raise ValueError(f"{g} has no arc center") |
| 2596 | |
| 2597 | return rv |
| 2598 | |
| 2599 | def trim(self, u0: Real, u1: Real) -> Edge: |
| 2600 | """ |
| 2601 | Trim the edge in the parametric space to (u0, u1). |
| 2602 | |
| 2603 | NB: this operation is done on the base geometry. |
| 2604 | """ |
| 2605 | |
| 2606 | bldr = BRepBuilderAPI_MakeEdge(self._geomAdaptor().Curve().Curve(), u0, u1) |
| 2607 | |
| 2608 | return self.__class__(bldr.Shape()) |
| 2609 | |
| 2610 | def hasPCurve(self, f: Face) -> bool: |
| 2611 | """ |
| 2612 | Check if self has a pcurve defined on f. |
no outgoing calls