Skip to content

Commit 9594b4d

Browse files
committed
small fixes and updates
1 parent e4c8066 commit 9594b4d

File tree

4 files changed

+24
-14
lines changed

4 files changed

+24
-14
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2626
* Changed `compas_plotters.artists.MeshArtist.draw_vertexlabels` to use `compas_plotters.Plotter.fontsize`.
2727
* Changed `compas_plotters.artists.MeshArtist.draw_edgelabels` to use `compas_plotters.Plotter.fontsize`.
2828
* Changed `compas_plotters.artists.MeshArtist.draw_facelabels` to use `compas_plotters.Plotter.fontsize`.
29+
* Fixed bug in `compas_rhino.conversions.plane_to_compas_frame`.
30+
* Changed implementation of `compas.geometry.NurbsSurface.xyz`.
31+
* Fixed bug in `compas.geometry.NurbsSurface.to_mesh`.
32+
* Changed `compas_rhino.geometry.RhinoNurbsSurface.from_points` to use transposed points.
2933

3034
### Removed
3135

src/compas/geometry/surfaces/nurbs.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ def to_mesh(self, nu=100, nv=None):
333333
from compas.datastructures import Mesh
334334

335335
nv = nv or nu
336-
vertices = [self.point_at(i, j) for i, j in product(self.u_space(nv + 1), self.v_space(nv + 1))]
336+
vertices = [self.point_at(i, j) for i, j in product(self.u_space(nu + 1), self.v_space(nv + 1))]
337337
faces = [[
338338
i * (nv + 1) + j,
339339
(i + 1) * (nv + 1) + j,
@@ -556,9 +556,7 @@ def xyz(self, nu=10, nv=10):
556556
nv : int, optional
557557
The size of the grid in the V direction.
558558
"""
559-
import numpy as np
560-
U, V = np.meshgrid(self.u_space(nu), self.v_space(nv), indexing='ij')
561-
return [self.point_at(U[i, j], V[i, j]) for i, j in product(np.arange(nu), np.arange(nv))]
559+
return [self.point_at(i, j) for i, j in product(self.u_space(nu), self.v_space(nv))]
562560

563561
def point_at(self, u, v):
564562
"""Compute a point on the surface.

src/compas_rhino/geometry/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
:nosignatures:
1414
1515
RhinoNurbsCurve
16+
RhinoNurbsSurface
1617
1718
1819
Plugins
@@ -75,6 +76,7 @@
7576
from compas_rhino.conversions import RhinoVector
7677

7778
from .curves import RhinoNurbsCurve
79+
from .surfaces import RhinoNurbsSurface
7880

7981

8082
__all__ = [
@@ -94,5 +96,6 @@
9496
'RhinoSurface',
9597
'RhinoVector',
9698

97-
'RhinoNurbsCurve'
99+
'RhinoNurbsCurve',
100+
'RhinoNurbsSurface',
98101
]

src/compas_rhino/geometry/surfaces/nurbs.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from compas_rhino.conversions import vector_to_compas
1313
from compas_rhino.conversions import plane_to_compas_frame
1414
from compas_rhino.conversions import box_to_compas
15+
from compas_rhino.conversions import RhinoCurve
1516

1617
import Rhino.Geometry
1718

@@ -226,11 +227,12 @@ def from_points(cls, points, u_degree=3, v_degree=3):
226227
-------
227228
:class:`compas.geometry.NurbsSurface`
228229
"""
230+
points = list(zip(*points))
229231
u_count = len(points[0])
230232
v_count = len(points)
231233
points[:] = [point_to_rhino(point) for row in points for point in row]
232234
surface = cls()
233-
surface.rhino_surface = Rhino.Geometry.NurbsSurface.CreateFromPoints(points, u_count, v_count, u_degree, v_degree)
235+
surface.rhino_surface = Rhino.Geometry.NurbsSurface.CreateFromPoints(points, v_count, u_count, u_degree, v_degree)
234236
return surface
235237

236238
@classmethod
@@ -281,9 +283,9 @@ def to_step(self, filepath, schema="AP203"):
281283
def points(self):
282284
if self.rhino_surface:
283285
points = []
284-
for i in range(self.rhino_surface.Points.CountV):
286+
for i in range(self.rhino_surface.Points.CountU):
285287
row = []
286-
for j in range(self.rhino_surface.Points.CountU):
288+
for j in range(self.rhino_surface.Points.CountV):
287289
row.append(point_to_compas(self.rhino_surface.Points.GetControlPoint(i, j).Location))
288290
points.append(row)
289291
return points
@@ -292,9 +294,9 @@ def points(self):
292294
def weights(self):
293295
if self.rhino_surface:
294296
weights = []
295-
for i in range(self.rhino_surface.Points.CountV):
297+
for i in range(self.rhino_surface.Points.CountU):
296298
row = []
297-
for j in range(self.rhino_surface.Points.CountU):
299+
for j in range(self.rhino_surface.Points.CountV):
298300
row.append(self.rhino_surface.Points.GetWeight(i, j))
299301
weights.append(row)
300302
return weights
@@ -374,7 +376,8 @@ def u_isocurve(self, u):
374376
-------
375377
:class:`compas.geometry.NurbsCurve`
376378
"""
377-
raise NotImplementedError
379+
curve = self.rhino_surface.IsoCurve(1, u)
380+
return RhinoCurve.from_geometry(curve).to_compas()
378381

379382
def v_isocurve(self, v):
380383
"""Compute the isoparametric curve at parameter v.
@@ -387,7 +390,8 @@ def v_isocurve(self, v):
387390
-------
388391
:class:`compas.geometry.NurbsCurve`
389392
"""
390-
raise NotImplementedError
393+
curve = self.rhino_surface.IsoCurve(0, v)
394+
return RhinoCurve.from_geometry(curve).to_compas()
391395

392396
def boundary(self):
393397
"""Compute the boundary curves of the surface.
@@ -440,8 +444,9 @@ def frame_at(self, u, v):
440444
-------
441445
:class:`compas.geometry.Frame`
442446
"""
443-
plane = self.rhino_surface.FrameAt(u, v)
444-
return plane_to_compas_frame(plane)
447+
result, plane = self.rhino_surface.FrameAt(u, v)
448+
if result:
449+
return plane_to_compas_frame(plane)
445450

446451
def closest_point(self, point, return_parameters=False):
447452
"""Compute the closest point on the curve to a given point.

0 commit comments

Comments
 (0)