[C++] ON_PlanarSections - how does this work!?


I was trying to get ON_PlanarSections::AttachToObject running, but so far I have not been able to see a result. Also, I don’t know exactly what to expect as a result so that doesn’t really help.

So far, this is what I have. After AttachToObject, which is successful, what is supposed to happen? Should I be able to see something in the document? Can I query the planarsections object somehow? When the object updates, are the planar sections automatically updated too?

Any hints on how to proceed are much appreciated!

CRhinoObjRef objRef; // obtained by selecting one surface_object
const CRhinoObject* obj = objRef.Object();
if (!obj) 
    // when nothing was selected there isn't anything left to do.
    return nothing;

const ON_Surface* srf = objRef.Surface();
if (!srf)
    return nothing;

ON_SimpleArray<const ON_Mesh*> arr;
obj->GetMeshes(ON::mesh_type::any_mesh, arr);
if (arr.Count() == 0)
    ON_MeshParameters mp;
    ON_Mesh* m = srf->CreateMesh(mp);
ON_Plane xp(ON_3dPoint(0,0,0), ON_3dVector(1,0,0));
ON_MeshXPlane mxp( *(arr[0]), 0);
ON_SectionAnalysisPlane p;
p.m_plane_equation = xp.plane_equation;
if (!ON_PlanarSections::AttachToObject(obj, mxp, srf, ON_SectionAnalysisAppearance::Default, p))
    RhinoApp().Print("Failed to attach planar sections to object\n");
return success;

The openNURBS definitions is available. But thats it. You’ll need some Rhino stuff exposed to use this.

Just curious, what are you looking to do?

I’m trying to show planar sections in all world-axis directions on ship hull shapes that update their shape while the user is dragging control points.

Since my original post, I have since explored further and now have a working solution based on ON_PlanarSections that still needs some further optimization. I will try to post an example on its use later.