Grasshopper

algorithmic modeling for Rhino

How to apply ShortPath to a Brep (BrepFace / Surface problem) c#

Hello,

I've been struggling to find an example for the use of DuplicateSurface in c#. I have a list of Brep Faces that I'd like to convert into Surfaces but am having difficulty.

I'm having the problem because I'd like to apply "ShortPath" to a Brep.

Above the hood (in the Canvas environment) this is is possible to do, but it doesn't seem so easy when working directly in c#. I understand, as outlined by David in another thread, that surfaces are an abstract class that don't contain trimming information so I'm worried that duplicating a surface (which I've not had luck with yet) will produce incorrect geometry relative to what I'm really after.

Help is welcome. A sample of c# code would be terrific.

Note: Related topic here: http://www.grasshopper3d.com/forum/topics/isplanar-in-c

Views: 740

Replies to This Discussion

Correct, Surfaces in RhinoCommon do not support trimming information. The Surface class itself is abstract, and Rhino provides several implementations of it, most notably:

  • NurbsSurface
  • PlaneSurface
  • RevSurface
  • Extrusion

Extrusion is a bit weird as it topologically looks more like a Brep, but it does derive from Surface.

A BrepFace also derives from Surface (via SurfaceProxy) and it adds all the trimming and brep topology methods and bookkeeping needed. However you cannot have just a BrepFace, it is always part of an entire Brep.

When you call DuplicateSurface() on a BrepFace you get a duplicate of the underlying surface data minus all the trimming.

When you call DuplicateFace() on a BrepFace you get a new Brep which contains only one face, namely a duplicate of the original one.

It's probably not smart to call Duplicate() on a BrepFace, I'm not entirely sure what happens then.

BrepFace inherits the ShortPath() method from Surface, but I don't think it has been re-implemented to take trims into account.

--

David Rutten

david@mcneel.com

David,

Once again thank you for all of your fantastic help.  I have resolved all of my shortpath questions and produced 2d points from UV coordinates derived from the "ClosestPoint" method.

I have one remaining question: 

Can you provide a small piece of sample code to help with the conversion of a brep to a surface that I can use with shortpath in c#?  It would be very helpful if you could because I've had absolutely no luck with surface duplications from Breps other than for edges and faces and I need new geometry that can be used with shortpath so faces just won't do.

Many thanks.

Assuming the brep only has a single face... then:

Surface srf = brp.Faces[0];

If you intent to modify the surface or if you want the surface to 'live longer' than the brep it came from, then it's wise to duplicate and disassociate the geometry from the original brep:

Surface srf = brp.Faces[0].DuplicateSurface();

--

David Rutten

david@mcneel.com

David -- Thanks!.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service