Skip to content

Commit ab5a1e6

Browse files
committed
fix bug related to value of degree in Nurbs Curves
1 parent d70fb45 commit ab5a1e6

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818

1919
* Changed `compas.datastructures.TreeNode` to skip serialising `attributes`, `name` and `children` if being empty.
2020
* Changed `compas.datastructures.TreeNode.__repr__` to omit `name` if `None`.
21+
* Fix bug in `compas_rhino.geometry.NurbsCurve.from_parameters` and `compas_rhino.geometry.NurbsCurve.from_points` related to the value of the parameter `degree`.
2122

2223
### Removed
2324

src/compas_rhino/geometry/curves/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
from .curve import RhinoCurve
1+
from .curve import RhinoCurve # noqa: F401
22
from .nurbs import RhinoNurbsCurve
33

4+
from compas.geometry import Curve
5+
from compas.geometry import NurbsCurve
46
from compas.plugins import plugin
57

68

79
@plugin(category="factories", requires=["Rhino"])
810
def new_curve(cls, *args, **kwargs):
9-
curve = object.__new__(RhinoCurve)
11+
curve = super(Curve, cls).__new__(cls)
1012
curve.__init__(*args, **kwargs)
1113
return curve
1214

1315

1416
@plugin(category="factories", requires=["Rhino"])
1517
def new_nurbscurve(cls, *args, **kwargs):
16-
curve = object.__new__(RhinoNurbsCurve)
18+
curve = super(NurbsCurve, cls).__new__(cls)
1719
curve.__init__(*args, **kwargs)
1820
return curve
1921

src/compas_rhino/geometry/curves/nurbs.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ def from_parameters(cls, points, weights, knots, multiplicities, degree, is_peri
187187
188188
"""
189189
curve = cls()
190+
degree = min(degree, len(points) - 1)
190191
curve.rhino_curve = rhino_curve_from_parameters(points, weights, knots, multiplicities, degree)
191192
return curve
192193

@@ -208,9 +209,10 @@ def from_points(cls, points, degree=3, is_periodic=False):
208209
:class:`compas_rhino.geometry.RhinoNurbsCurve`
209210
210211
"""
211-
points[:] = [point_to_rhino(point) for point in points]
212212
curve = cls()
213-
curve.rhino_curve = Rhino.Geometry.NurbsCurve.Create(is_periodic, degree, points)
213+
degree = min(degree, len(points) - 1)
214+
rhino_curve = Rhino.Geometry.NurbsCurve.Create(is_periodic, degree, [point_to_rhino(point) for point in points])
215+
curve.rhino_curve = rhino_curve
214216
return curve
215217

216218
@classmethod

0 commit comments

Comments
 (0)