Trimming a NURBS surface in C++

Dale,

We have a boundary loop in parameter space. How to trim a NURBS surface using these UV curves in parameter space? Do you have a C++ example (we have no need to make a brep)? Many thanks.

Hi @XNurbs,

See opennurbs_surface.h for the ON_Surface::Trim method.

Does this help?

– Dale

Dale,

ON_Surface::Trim is not what we are looking for.

We have a boundary loop in parameter space, and the loop has a set of curves (e.g., 2D/UV BSpline curves) in parameter space. We would like to trim the surface with those curves.

Hi @XNurbs,

Rhino doesn’t have trimmed surface, it has Breps with faces. So you’ll need to construct one.

This should do the trick.

– Dale

Dale,

That is a good example. Do you have other examples for trimming a surface? We are trying to understand how Rhino trims a surface (it is a bit different from other kernels). Many thanks.

In general, we encourage the use of high-level functions, such as RhinoBrepTrim and RhinoBrepSplit, declared in rhinoSdkUtilities.h, as there can be quite a bit of work involved on creating your own trimmed Brep.

Here is a another more complicated example that creates a simple trimmed plane.

https://github.com/mcneel/rhino-developer-samples/blob/6/cpp/SampleCommands/cmdSampleTrimmedPlane.cpp

The ON_Brep class is heavily commented. If you plan on using this class to a great extent, it is worth your time to review the class and the comments.

– Dale

Dale,

Do you have an example to trim a surface (not a plane) with a single outer loop? (We only need to use ON_Brep to trim common surfaces, which have a single outer loop. A simple example for this would be very helpful.)

“However, if the boundary has some tiny gap of 1.0e-5, then the code may not work.”
boundary.IsClosed() and ON_BrepTrimmedPlane in “ON_BrepFromSurfaceAndBoundary” may not work if the boundary has some tiny gap.

Many thanks.

Dale,

Your Patch tool has the code for trimming a surface with a single outer loop. Could you provide that piece of code as an example? We only need the code related to “trimming a surface with a single outer loop”. Many thanks.

I’m confused, did you try the sample function? Did it not work for you?

Also, the functionality benind Rhino’s Patch command can be found in CRhinoFitPatch.

– Dale