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

Surface from rhino #1350

wants to merge 30 commits into from

Conversation

chenkasirer
Copy link
Member

@chenkasirer chenkasirer commented May 2, 2024

  • Fixed Surface pluggable from_plane so that it's possible to create a planar surface in Rhino.
  • Added from_native in native_surface in Surface and RhinoSurface to align better with the Brep system.
  • Added deprecation warning on RhinoSurface.from_rhino.
  • Replaced Box argument with u_domain and v_domain in RhinoSurface.from_plane.
  • Changed new_surface pluggin to create a RhinoSurface object instead of Surface.
  • Default constructors in Surface and NurbsSurface are protected. Caller must use one of the alternative constructors.

https://miro.com/app/board/uXjVK2eWeOk=/

What type of change is this?

  • Bug fix in a backwards-compatible manner.
  • New feature in a backwards-compatible manner.
  • Breaking change: bug fix or new feature that involve incompatible API changes.
  • Other (e.g. doc update, configuration, etc)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I added a line to the CHANGELOG.md file in the Unreleased section under the most fitting heading (e.g. Added, Changed, Removed).
  • I ran all tests on my computer and it's all green (i.e. invoke test).
  • I ran lint on my computer and there are no errors (i.e. invoke lint).
  • I added new functions/classes and made them available on a second-level import, e.g. compas.datastructures.Mesh.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added necessary documentation (if appropriate)

src/compas/geometry/surfaces/nurbs.py Show resolved Hide resolved
src/compas_rhino/geometry/surfaces/nurbs.py Outdated Show resolved Hide resolved
src/compas_rhino/geometry/surfaces/surface.py Outdated Show resolved Hide resolved
Copy link

codecov bot commented Jul 3, 2024

Codecov Report

Attention: Patch coverage is 34.48276% with 38 lines in your changes missing coverage. Please review.

Please upload report for BASE (main@b7111f2). Learn more about missing BASE report.

Files Patch % Lines
src/compas/geometry/surfaces/nurbs.py 18.18% 27 Missing ⚠️
src/compas/geometry/surfaces/surface.py 56.00% 11 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1350   +/-   ##
=======================================
  Coverage        ?   59.90%           
=======================================
  Files           ?      206           
  Lines           ?    22162           
  Branches        ?        0           
=======================================
  Hits            ?    13277           
  Misses          ?     8885           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

data["degree_v"],
data["is_periodic_u"],
data["is_periodic_v"],
frame,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am not so sure that any of the methods of the surface class take this frame into account. currently, the frame is not settable and always defaults to world XY...

Comment on lines +57 to +70
@property
def __data__(self):
return {
"frame": self._frame.__data__,
"domain_u": list(self.domain_u),
"domain_v": list(self.domain_v),
}

@classmethod
def __from_data__(cls, data):
frame = Frame.__from_data__(data["frame"])
domain_u = tuple(data["domain_u"])
domain_v = tuple(data["domain_v"])
return cls.from_plane(frame, domain_u, domain_v)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since the base surface is abstract and since it should not be possible to create instances of it directly, i don't think it should provide the possibility to create one from data...

Copy link
Member Author

@chenkasirer chenkasirer Jul 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from_plane will invoke the plugin, if available. it just seems to be the canonical surface representation (maybe with exception of frame which it seems I didn't quite get)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but why should we provide functionality for making a "canonical" surface from data, when the surface can't actually by instantiated in the normal way. i though we agreed that only the spacial constructors can be used to create an actual surface and that the base class only provides the shared interface...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for CAD agnostic (de)serialization? maybe what's confusing me is that lack of other kinds of surface types
maybe this should be in a PlanarSurface like in Rhino..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are plenty of other surface types (including planar surface). they just don't require a Rhino or OCC plugin...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compas.geometry.surfaces has CylindricalSurface, ConicalSurface, PlanarSurface, SphericalSurface, ToroidalSurface

Comment on lines +56 to +62
def _get_frame_from_planesurface(self):
u_start = self.domain_u[0]
v_start = self.domain_v[0]
success, frame = self.native_surface.FrameAt(u_start, v_start)
if not success:
raise ValueError("Failed to get frame at u={} v={}".format(u_start, v_start))
return plane_to_compas_frame(frame)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think this is correct. control points are usually in world coordinates, not in local coordinates wrt to a frame positioned at the beginning of the domain.

Comment on lines +210 to +212
instance.frame = instance._get_frame_from_planesurface()
instance._domain_u = native_surface.Domain(0)[0], native_surface.Domain(0)[1]
instance._domain_v = native_surface.Domain(1)[0], native_surface.Domain(1)[1]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't make sense to me

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the domain part also?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

afaik the u and v domain are read from the native surface by the corresponding properties. they are never set...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but my comment was mostly about the frame thing indeed

@tomvanmele tomvanmele mentioned this pull request Jul 3, 2024
10 tasks
@chenkasirer
Copy link
Member Author

replaced by #1375

@chenkasirer chenkasirer closed this Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants