How to triangulate mesh in Open NURBS

Hello @dale,
I am converting a Rhino mesh object into Parasolid.
From Rhino I am getting a quadrangular mesh face. Now I want to Split each quadrangular mesh face into two triangles. I know that in Rhino thre is a command ‘TriangulateMesh’ whch can do this. But I am using Open NURBS SDK (C++) for converting Rhino model to Parasolid, so it will be helpful if you suggest us any API which can do the same.

Hi @psomesh94,

You might do something like the following:

CRhinoCommand::result CCommandTest::RunCommand(const CRhinoCommandContext& context)
  CRhinoGetObject go;
  go.SetCommandPrompt(L"Select mesh to triangulate");
  go.EnableSubObjectSelect(false, false);
  go.GetObjects(1, 1);
  if (go.CommandResult() != CRhinoCommand::success)
    return go.CommandResult();

  const CRhinoObjRef& obj_ref = go.Object(0);
  const ON_Mesh* mesh = obj_ref.Mesh();
  if (nullptr == mesh)
    return CRhinoCommand::failure;

  ON_Mesh new_mesh(*mesh);
  if (new_mesh.IsValid())
    context.m_doc.ReplaceObject(obj_ref, new_mesh);

  return CRhinoCommand::success;

– Dale

Thank you very much ! @dale.