Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Surface from rhino #1350

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c41b638
added plugin for Surface.from_plane
chenkasirer May 2, 2024
1d0b2c6
made argument `box` optional in `RhinoSurface.from_plane`
chenkasirer May 2, 2024
27a20d9
Merge branch 'main' of https://github.com/compas-dev/compas into surf…
chenkasirer May 2, 2024
b2a18e3
added `NurbsSurface.from_plane`
chenkasirer May 2, 2024
fdd97a9
Merge branch 'main' into surface_from_rhino
chenkasirer Jun 21, 2024
4dd4294
surface domain instead of box
chenkasirer Jun 21, 2024
4354d35
user specifies domain in RhinoNurbsSurface.from_plane
chenkasirer Jun 21, 2024
605a95e
default domains
chenkasirer Jun 21, 2024
7249f1e
noqa on typing imports
chenkasirer Jun 21, 2024
4242ee3
added from_native and native_surface to Surface
chenkasirer Jun 21, 2024
b78432a
Surface() create a RhinoSurface object in Rhino
chenkasirer Jun 21, 2024
5ed8791
added RhinoSurface.from_native plugin with intention to replace from_…
chenkasirer Jun 21, 2024
3e5017c
updated changelog
chenkasirer Jun 21, 2024
5566f95
unused import
chenkasirer Jun 21, 2024
de97233
WIP
chenkasirer Jun 24, 2024
0d72fe5
protect Surface(). Surface object can only be created via alternative…
chenkasirer Jul 2, 2024
0ea3ede
unused import
chenkasirer Jul 2, 2024
6a9c286
merge from_frame/plane. only implement abstract properties
chenkasirer Jul 3, 2024
d4f3ee0
fix search and replace accident
chenkasirer Jul 3, 2024
a3d6ecc
removed Surface.__from_data__
chenkasirer Jul 3, 2024
186ba78
instantiating nurbs surface via from_native
chenkasirer Jul 3, 2024
dafabfa
same from_native in nurbs and normal surface
chenkasirer Jul 3, 2024
5d86721
added domain and frame to nurbs params. __from_data__ is generic but …
chenkasirer Jul 3, 2024
33c388f
removed dead code and unused imports
chenkasirer Jul 3, 2024
9f6631d
added nurbssurface_to_compas
chenkasirer Jul 3, 2024
de25d04
native_surface is readonly
chenkasirer Jul 3, 2024
370ec8f
is_closed_u/v instead of is_closed
chenkasirer Jul 3, 2024
af70a6d
removed debug print
chenkasirer Jul 3, 2024
f8db6c9
updated changelog
chenkasirer Jul 3, 2024
5b5e1ac
linting
chenkasirer Jul 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/compas/geometry/surfaces/nurbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ def new_nurbssurface_from_parameters(cls, *args, **kwargs):
raise PluginNotInstalledError


@pluggable(category="factories")
def new_nurbssurface_from_plane(cls, *args, **kwargs):
raise PluginNotInstalledError


@pluggable(category="factories")
def new_nurbssurface_from_points(cls, *args, **kwargs):
raise PluginNotInstalledError
Expand Down Expand Up @@ -350,6 +355,10 @@ def from_fill(cls, curve1, curve2, curve3=None, curve4=None, style="stretch"):
"""
return new_nurbssurface_from_fill(cls, curve1, curve2, curve3, curve4, style)

@classmethod
def from_plane(cls, plane, u_degree=1, v_degree=1):
chenkasirer marked this conversation as resolved.
Show resolved Hide resolved
return new_nurbssurface_from_plane(cls, plane, u_degree, v_degree)

# ==============================================================================
# Conversions
# ==============================================================================
Expand Down
5 changes: 5 additions & 0 deletions src/compas_rhino/geometry/surfaces/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ def new_surface(cls, *args, **kwargs):
return surface


@plugin(category="factories", requires=["Rhino"])
def new_surface_from_plane(cls, *args, **kwargs):
return RhinoSurface.from_plane(*args, **kwargs)


@plugin(category="factories", requires=["Rhino"])
def new_nurbssurface(cls, *args, **kwargs):
surface = super(NurbsSurface, cls).__new__(cls)
Expand Down
27 changes: 27 additions & 0 deletions src/compas_rhino/geometry/surfaces/nurbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from compas.geometry import Point
from compas.geometry import knots_and_mults_to_knotvector
from compas.itertools import flatten
from compas_rhino.conversions import plane_to_rhino
from compas_rhino.conversions import point_to_compas
from compas_rhino.conversions import point_to_rhino

Expand Down Expand Up @@ -361,6 +362,32 @@ def from_fill(cls, curve1, curve2):
surface.rhino_surface = Rhino.Geometry.NurbsSurface.CreateRuledSurface(curve1, curve2)
return surface

@classmethod
def from_plane(cls, plane, u_degree=1, v_degree=1):
"""Construct a NURBS surface from a plane.

Parameters
----------
plane : :class:`compas.geometry.Plane`

Returns
-------
:class:`compas_rhino.geometry.RhinoNurbsSurface`

"""
plane = plane_to_rhino(plane)
surface = cls()
surface.rhino_surface = Rhino.Geometry.NurbsSurface.CreateFromPlane(
plane,
Rhino.Geometry.Interval(0, 1),
Rhino.Geometry.Interval(0, 1),
chenkasirer marked this conversation as resolved.
Show resolved Hide resolved
u_degree,
v_degree,
u_degree + 1,
v_degree + 1,
)
return surface

# ==============================================================================
# Conversions
# ==============================================================================
Expand Down
11 changes: 8 additions & 3 deletions src/compas_rhino/geometry/surfaces/surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,22 +168,27 @@ def from_rhino(cls, rhino_surface):
return curve

@classmethod
def from_plane(cls, plane, box):
def from_plane(cls, plane, box=None):
"""Construct a surface from a plane.

Parameters
----------
plane : :class:`compas.geometry.Plane`
The plane.
box : :class:`compas.geometry.Box`, optional
A box that bounds the surface.

Returns
-------
:class:`compas_rhino.geometry.RhinoSurface`

"""
plane = plane_to_rhino(plane)
box = Rhino.Geometry.BoundingBox(box.xmin, box.ymin, box.zmin, box.xmax, box.ymax, box.zmax)
rhino_surface = Rhino.Geometry.PlaneSurface.CreateThroughBox(plane, box)
if box:
box = Rhino.Geometry.BoundingBox(box.xmin, box.ymin, box.zmin, box.xmax, box.ymax, box.zmax)
rhino_surface = Rhino.Geometry.PlaneSurface.CreateThroughBox(plane, box)
else:
rhino_surface = Rhino.Geometry.PlaneSurface(plane, Rhino.Geometry.Interval(0, 1), Rhino.Geometry.Interval(0, 1))
chenkasirer marked this conversation as resolved.
Show resolved Hide resolved
return cls.from_rhino(rhino_surface)

@classmethod
Expand Down
Loading