Skip to content

Commit d77f706

Browse files
authored
Merge pull request #1414 from papachap/feature-brep-fillet-edges
add implementation of fillet edges to brep
2 parents 5c334dd + 6fa8303 commit d77f706

File tree

4 files changed

+61
-2
lines changed

4 files changed

+61
-2
lines changed

AUTHORS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,5 @@
3939
- Katerina Toumpektsi <<[email protected]>> [@katarametin](https://github.com/katarametin)
4040
- Joelle Baehr-Bruyere <<[email protected]>> [@baehrjo](https://github.com/baehrjo)
4141
- Adam Anouar <<[email protected]>> [@AdamAnouar](https://github.com/AdamAnouar)
42-
- Joseph Kenny <<[email protected]>> [@jckenny59](https://github.com/jckenny59)
42+
- Joseph Kenny <<[email protected]>> [@jckenny59](https://github.com/jckenny59)
43+
- Panayiotis Papacharalambous <<[email protected]>> [@papachap](https://github.com/papachap)

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12+
* Added implementation of `RhinoBrep.fillet()` and `RhinoBrep.filleted()` to `compas_rhino`.
13+
1214
### Changed
1315

16+
* Fixed `native_edge` property of `RhinoBrepEdge`.
17+
1418
### Removed
1519

1620

src/compas_rhino/geometry/brep/brep.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from compas.geometry import Brep
88
from compas.geometry import BrepError
9+
from compas.geometry import BrepFilletError
910
from compas.geometry import BrepTrimmingError
1011
from compas.geometry import Frame
1112
from compas.geometry import Plane
@@ -583,3 +584,56 @@ def split(self, cutter):
583584
"""
584585
resulting_breps = self._brep.Split(cutter.native_brep, TOL.absolute)
585586
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])

src/compas_rhino/geometry/brep/edge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def curve(self):
115115

116116
@property
117117
def native_edge(self):
118-
return self._native_edge
118+
return self._edge
119119

120120
@native_edge.setter
121121
def native_edge(self, value):

0 commit comments

Comments
 (0)