|
6 | 6 |
|
7 | 7 | from compas.geometry import Brep |
8 | 8 | from compas.geometry import BrepError |
| 9 | +from compas.geometry import BrepFilletError |
9 | 10 | from compas.geometry import BrepTrimmingError |
10 | 11 | from compas.geometry import Frame |
11 | 12 | from compas.geometry import Plane |
@@ -583,3 +584,56 @@ def split(self, cutter): |
583 | 584 | """ |
584 | 585 | resulting_breps = self._brep.Split(cutter.native_brep, TOL.absolute) |
585 | 586 | return [RhinoBrep.from_native(brep) for brep in resulting_breps] |
| 587 | + |
| 588 | + def fillet(self, radius, edges=None): |
| 589 | + """Fillet edges of the Brep. |
| 590 | +
|
| 591 | + Parameters |
| 592 | + ---------- |
| 593 | + radius : float |
| 594 | + The radius of the fillet. |
| 595 | + edges : list(:class:`compas_rhino.geometry.RhinoBrepEdge`) |
| 596 | + The edges to fillet. |
| 597 | +
|
| 598 | + Raises |
| 599 | + ------- |
| 600 | + BrepFilletingError |
| 601 | + If the fillet operation fails. |
| 602 | +
|
| 603 | + """ |
| 604 | + resulting_breps = self.filleted(radius, edges) |
| 605 | + self._brep = resulting_breps.native_brep |
| 606 | + |
| 607 | + def filleted(self, radius, edges=None): |
| 608 | + """Returns a filleted copy of the Brep. |
| 609 | +
|
| 610 | + Parameters |
| 611 | + ---------- |
| 612 | + radius : float |
| 613 | + The radius of the fillet. |
| 614 | + edges : list(:class:`compas_rhino.geometry.RhinoBrepEdge`) |
| 615 | + List of edges to exclude from the operation. When None all edges are included. |
| 616 | +
|
| 617 | + Returns |
| 618 | + ------- |
| 619 | + :class:`compas_rhino.geometry.RhinoBrep` |
| 620 | + The resulting Brep. |
| 621 | +
|
| 622 | + Raises |
| 623 | + ------- |
| 624 | + BrepFilletingError |
| 625 | + If the fillet operation fails. |
| 626 | +
|
| 627 | + """ |
| 628 | + all_edge_indices = set(edge.native_edge.EdgeIndex for edge in self.edges) |
| 629 | + excluded_indices = set(edge.native_edge.EdgeIndex for edge in edges or []) |
| 630 | + |
| 631 | + edge_indices = all_edge_indices - excluded_indices |
| 632 | + radii = [radius] * len(edge_indices) |
| 633 | + blend = Rhino.Geometry.BlendType.Fillet |
| 634 | + rail = Rhino.Geometry.RailType.DistanceFromEdge |
| 635 | + |
| 636 | + resulting_breps = Rhino.Geometry.Brep.CreateFilletEdges(self._brep, edge_indices, radii, radii, blend, rail, TOL.absolute) |
| 637 | + if not resulting_breps: |
| 638 | + raise BrepFilletError("Fillet operation ended with no result") |
| 639 | + return RhinoBrep.from_native(resulting_breps[0]) |
0 commit comments