Skip to content

Commit 1c390f8

Browse files
authored
Merge pull request #1086 from compas-dev/brep_from_native
Brep from native
2 parents cb0b986 + 33da5d6 commit 1c390f8

File tree

7 files changed

+22
-18
lines changed

7 files changed

+22
-18
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3737
* Fixed the `test_tangent` to work with a properly defined circle
3838
* `RhinoBrep` serialization works now with surface types other than NURBS.
3939
* Fixed bug in finding halfedge before a given halfedge if that halfedge is on the boundary (`Mesh.halfedge_before`).
40+
* Renamed `Brep.from_brep` to `Brep.from_native`.
4041

4142
### Removed
4243

docs/tutorial/brep.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Every backend is expected to implement some alternative constructors
8282
>>> import Rhino
8383
>>> from compas.geometry import Brep
8484
>>> ...
85-
>>> Brep.from_brep(Rhino.Geometry.Brep())
85+
>>> Brep.from_native(Rhino.Geometry.Brep())
8686
8787
Brep operations
8888
===============

src/compas/geometry/brep/brep.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def new_brep(*args, **kwargs):
1212

1313

1414
@pluggable(category="factories")
15-
def from_brep(*args, **kwargs):
15+
def from_native(*args, **kwargs):
1616
raise PluginNotInstalledError()
1717

1818

@@ -355,8 +355,8 @@ def centroid(self):
355355
# ==============================================================================
356356

357357
@classmethod
358-
def from_brep(cls, brep):
359-
"""Create a Brep from an instance of a backend Brep.
358+
def from_native(cls, native_brep):
359+
"""Creates a Brep from an instance of a native backend Brep type.
360360
361361
Parameters
362362
----------
@@ -367,11 +367,11 @@ def from_brep(cls, brep):
367367
-------
368368
:class:`~compas.geometry.Brep`
369369
"""
370-
return from_brep(brep)
370+
return from_native(native_brep)
371371

372372
@classmethod
373373
def from_step_file(cls, filename):
374-
"""Conctruct a BRep from the data contained in a STEP file.
374+
"""Conctruct a Brep from the data contained in a STEP file.
375375
376376
Parameters
377377
----------

src/compas_rhino/geometry/brep/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"RhinoBrepLoop",
1717
"RhinoBrepFace",
1818
"new_brep",
19-
"from_brep",
19+
"from_native",
2020
"from_box",
2121
]
2222

@@ -29,8 +29,8 @@ def new_brep(*args, **kwargs):
2929

3030

3131
@plugin(category="factories", requires=["Rhino"])
32-
def from_brep(*args, **kwargs):
33-
return RhinoBrep.from_brep(*args, **kwargs)
32+
def from_native(*args, **kwargs):
33+
return RhinoBrep.from_native(*args, **kwargs)
3434

3535

3636
@plugin(category="factories", requires=["Rhino"])

src/compas_rhino/geometry/brep/brep.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ def volume(self):
134134
# ==============================================================================
135135

136136
@classmethod
137-
def from_brep(cls, rhino_brep):
138-
"""Constructs a RhinoBrep from an instance of a Rhino brep
137+
def from_native(cls, rhino_brep):
138+
"""Constructs a RhinoBrep from an instance of a Rhino.Geometry.Brep.
139139
140140
Parameters
141141
----------
@@ -165,7 +165,7 @@ def from_box(cls, box):
165165
166166
"""
167167
rhino_box = box_to_rhino(box)
168-
return cls.from_brep(rhino_box.ToBrep())
168+
return cls.from_native(rhino_box.ToBrep())
169169

170170
@classmethod
171171
def from_cylinder(cls, cylinder):
@@ -182,7 +182,7 @@ def from_cylinder(cls, cylinder):
182182
183183
"""
184184
rhino_cylinder = cylinder_to_rhino(cylinder)
185-
return cls.from_brep(rhino_cylinder.ToBrep(True, True))
185+
return cls.from_native(rhino_cylinder.ToBrep(True, True))
186186

187187
# ==============================================================================
188188
# Methods
@@ -255,7 +255,7 @@ def from_boolean_difference(cls, breps_a, breps_b):
255255
[b.native_brep for b in breps_b],
256256
TOLERANCE,
257257
)
258-
return [RhinoBrep.from_brep(brep) for brep in resulting_breps]
258+
return [RhinoBrep.from_native(brep) for brep in resulting_breps]
259259

260260
@classmethod
261261
def from_boolean_union(cls, breps_a, breps_b):
@@ -280,7 +280,7 @@ def from_boolean_union(cls, breps_a, breps_b):
280280
breps_b = [breps_b]
281281

282282
resulting_breps = Rhino.Geometry.Brep.CreateBooleanUnion([b.native_brep for b in breps_a + breps_b], TOLERANCE)
283-
return [RhinoBrep.from_brep(brep) for brep in resulting_breps]
283+
return [RhinoBrep.from_native(brep) for brep in resulting_breps]
284284

285285
@classmethod
286286
def from_boolean_intersection(cls, breps_a, breps_b):
@@ -308,7 +308,7 @@ def from_boolean_intersection(cls, breps_a, breps_b):
308308
[b.native_brep for b in breps_b],
309309
TOLERANCE,
310310
)
311-
return [RhinoBrep.from_brep(brep) for brep in resulting_breps]
311+
return [RhinoBrep.from_native(brep) for brep in resulting_breps]
312312

313313
def split(self, cutter):
314314
"""Splits a Brep into pieces using a Brep as a cutter.
@@ -325,7 +325,7 @@ def split(self, cutter):
325325
326326
"""
327327
resulting_breps = self._brep.Split(cutter.native_brep, TOLERANCE)
328-
return [RhinoBrep.from_brep(brep) for brep in resulting_breps]
328+
return [RhinoBrep.from_native(brep) for brep in resulting_breps]
329329

330330
# ==============================================================================
331331
# Other Methods

src/compas_rhino/geometry/brep/edge.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from compas.geometry import Line
33
from compas.geometry import Point
44
from compas.geometry import Circle
5+
from compas.geometry import Ellipse
56
from compas_rhino.geometry import RhinoNurbsCurve
67
from compas_rhino.conversions import curve_to_compas_line
78
from compas_rhino.conversions import curve_to_compas_circle
@@ -85,7 +86,7 @@ def data(self, value):
8586
elif curve_type == "circle":
8687
self._curve = circle_to_rhino_curve(Circle.from_data(value["value"])) # this returns a Nurbs Curve, why?
8788
elif curve_type == "ellipse":
88-
self._curve = ellipse_to_rhino_curve(value["value"])
89+
self._curve = ellipse_to_rhino_curve(Ellipse.from_data(value["value"]))
8990
else:
9091
self._curve = RhinoNurbsCurve.from_data(value["value"]).rhino_curve
9192

src/compas_rhino/geometry/brep/face.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
from compas.geometry import BrepFace
2+
from compas.geometry import Sphere
3+
from compas.geometry import Cylinder
24
from compas_rhino.geometry import RhinoNurbsSurface
35
from compas_rhino.conversions import plane_to_compas
46
from compas_rhino.conversions import sphere_to_compas

0 commit comments

Comments
 (0)