Skip to content

Commit 80e58ff

Browse files
authored
Merge pull request #1304 from compas-dev/fix-bug-curve-degree
Fix bug related to value of degree in Nurbs Curves
2 parents 910965d + b9fc3e9 commit 80e58ff

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
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
* Changed `compas.scene.descriptors.ColorDictAttribute` to accept a `compas.colors.ColorDict` as value.
2223
* Changed `compas_rhino.scene.RhinoMeshObject.draw` to preprocess vertex and face color dicts into lists.
2324
* Changed `compas_rhino.conversions.vertices_and_faces_to_rhino` to handle vertex color information correctly.

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)