I have the following code attempting to extract the NURBS surfaces I see in the Rhino viewport. I used the sample file example_3dm_files_20130711/V5/v5_rhino_logo.3dm as a reference. The NURBs surfaces I got is different from what I see in Rhino. Some of them matches but there are (1) extra surfaces (2) missing extruded-like surface
If I am purely interested in extract all the NURBS surfaces as one would see in Rhino3D viewport, what is the correct way to go about doing that ? Is there an example showing the best practice ?
I am interested in surfaces that I can write out for rendering by various renderer so I guess that would be trimmed surfaces, am I correct ? I am targeting RenderMan for now so with support of RiNuPatch includes trim and holes.
With regards to the extrusion, I will dig further and add additional processing steps.
You find ON_NurbsSurface, ON_PlaneSurface, ON_RevSurface, and ON_SumSurface in an ON_Brep(ON_Brep::m_S).
All surface types can be represented as NURBS surfaces. To do so, use ON_Surface::GetNurbForm.
ON_Extrusion objects are more like ON_Brep objects then they are surfaces. You can the Brep form of an ON_Extrusion object using `ON_Extrusion::BrepForm```.
What you see in viewports are Breps, not surfaces. The term Brep, or boundary representation, indicates that there are portions of underlying surfaces that you may not see due to trimming. So what you are really seeing in a viewport is a Brep’s Faces (ON_BrepFace), not the underlying surface.
If you are not familiar with Breps, then you might spend some time reviewing the Brep Data Structure that @menno referenced. The openNURBS headers are also a wealth of information. For Breps, see opennurbs_brep.h.