Skip to content

Commit

Permalink
Merge pull request #1414 from papachap/feature-brep-fillet-edges
Browse files Browse the repository at this point in the history
add implementation of fillet edges to brep
  • Loading branch information
chenkasirer authored Dec 12, 2024
2 parents 5c334dd + 6fa8303 commit d77f706
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 2 deletions.
3 changes: 2 additions & 1 deletion AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@
- Katerina Toumpektsi <<[email protected]>> [@katarametin](https://github.com/katarametin)
- Joelle Baehr-Bruyere <<[email protected]>> [@baehrjo](https://github.com/baehrjo)
- Adam Anouar <<[email protected]>> [@AdamAnouar](https://github.com/AdamAnouar)
- Joseph Kenny <<[email protected]>> [@jckenny59](https://github.com/jckenny59)
- Joseph Kenny <<[email protected]>> [@jckenny59](https://github.com/jckenny59)
- Panayiotis Papacharalambous <<[email protected]>> [@papachap](https://github.com/papachap)
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

* Added implementation of `RhinoBrep.fillet()` and `RhinoBrep.filleted()` to `compas_rhino`.

### Changed

* Fixed `native_edge` property of `RhinoBrepEdge`.

### Removed


Expand Down
54 changes: 54 additions & 0 deletions src/compas_rhino/geometry/brep/brep.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from compas.geometry import Brep
from compas.geometry import BrepError
from compas.geometry import BrepFilletError
from compas.geometry import BrepTrimmingError
from compas.geometry import Frame
from compas.geometry import Plane
Expand Down Expand Up @@ -583,3 +584,56 @@ def split(self, cutter):
"""
resulting_breps = self._brep.Split(cutter.native_brep, TOL.absolute)
return [RhinoBrep.from_native(brep) for brep in resulting_breps]

def fillet(self, radius, edges=None):
"""Fillet edges of the Brep.
Parameters
----------
radius : float
The radius of the fillet.
edges : list(:class:`compas_rhino.geometry.RhinoBrepEdge`)
The edges to fillet.
Raises
-------
BrepFilletingError
If the fillet operation fails.
"""
resulting_breps = self.filleted(radius, edges)
self._brep = resulting_breps.native_brep

def filleted(self, radius, edges=None):
"""Returns a filleted copy of the Brep.
Parameters
----------
radius : float
The radius of the fillet.
edges : list(:class:`compas_rhino.geometry.RhinoBrepEdge`)
List of edges to exclude from the operation. When None all edges are included.
Returns
-------
:class:`compas_rhino.geometry.RhinoBrep`
The resulting Brep.
Raises
-------
BrepFilletingError
If the fillet operation fails.
"""
all_edge_indices = set(edge.native_edge.EdgeIndex for edge in self.edges)
excluded_indices = set(edge.native_edge.EdgeIndex for edge in edges or [])

edge_indices = all_edge_indices - excluded_indices
radii = [radius] * len(edge_indices)
blend = Rhino.Geometry.BlendType.Fillet
rail = Rhino.Geometry.RailType.DistanceFromEdge

resulting_breps = Rhino.Geometry.Brep.CreateFilletEdges(self._brep, edge_indices, radii, radii, blend, rail, TOL.absolute)
if not resulting_breps:
raise BrepFilletError("Fillet operation ended with no result")
return RhinoBrep.from_native(resulting_breps[0])
2 changes: 1 addition & 1 deletion src/compas_rhino/geometry/brep/edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def curve(self):

@property
def native_edge(self):
return self._native_edge
return self._edge

@native_edge.setter
def native_edge(self, value):
Expand Down

0 comments on commit d77f706

Please sign in to comment.