On Render Mesh
Last changed: dale@mcneel.com-204.177.179.143

.
DeveloperopenNURBS

Question

We’ve developed software to read 3DM files, but we found the software can only read NURBS data; render mesh are ignored. Our software takes a very long time to generate these meshes. Do we provide methods that allow third-party developer to read render mesh from 3DM files?

Answer

An object's render meshes are stored on that object. For example, the render meshes for an ON_Brep object are stored on that brep. The developer can obtain an object's render meshes from a brep by calling ON_Brep:GetMesh.

It should be noted that if the call to ON_Brep:GetMesh does not return any meshes, then the object did not have any render meshes.

If you are referencing the "Example_read" sample included with the openNURBS toolkit, then after the 3DM file has been read, you can obtain the render meshes from the ONX_Model object as follows:

  ONX_Model model = .....


  int i;
  for( i = 0; i < m_object_table.Count(); i++ )
  {
    ONX_Model_Object model_object = m_object_table[i];
    ON_Brep* brep = ON_Brep::Cast( model_object->m_object );
    if( brep )
    {
      ON_SimpleArray<const ON_Mesh*> meshes;
      int mesh_count = brep->GetMesh( ON::render_mesh, meshes );
      if( mesh_count )
      {
        // TODO: do something with the array of meshes..
      }
    }
  }