Mesh in Rhino4 vs Mesh in Rhino5

Using C++ Rhino SDK I create Mesh from Brep using DefaultFastMeshParameters.
But Mesh created in Rhino5 is different from mesh created in Rhino4. In the attached picture is part of the mesh created in Rhino5 (left picture) and the same part of the mesh created in Rhino4(right picture). I notice that in Rhino5 corner angles of the Mesh are too small so some of my algorithms does not work. How can I fix that ??

Hi Biljana,

Can you post your geometry?

I create new polysurface that I send in attach.

This is the code for the command that I use to create mesh from polysurface:

CRhinoCommand::result CCommandCreateMesh::RunCommand( const CRhinoCommandContext& context )
{

CRhinoGetObject go;
go.SetCommandPrompt(L"Select PolySrf");
go.SetGeometryFilter( CRhinoGetObject::surface_object);
go.GetObjects( 1, 1 );

if( go.Result() == CRhinoGet::cancel )
    return CRhinoCommand::failure;

if( go.CommandResult() != CRhinoCommand::success )
    return CRhinoCommand::failure;

// Validate selection 
const CRhinoObject* obj = go.Object(0).Object();
const CRhinoObjRef& ref(obj);
const ON_Brep* brep = ref.Brep();

const CRhinoAppRenderMeshSettings& rms = RhinoApp().AppSettings().RenderMeshSettings();
ON_MeshParameters mp = rms.DefaultFastMeshParameters();

// Create Mesh
ON_Mesh* mesh = NULL;

ON_SimpleArray<ON_Mesh*> meshList;
brep->CreateMesh(mp, meshList);

for(int i = 0; i < meshList.Count(); i++)
{
    meshList[i]->ConvertQuadsToTriangles();

    if(mesh == NULL)
        mesh = meshList[0];      
    else 
        mesh->Append(*meshList[i]);
} 

RhinoApp().ActiveDoc()->AddMeshObject(*mesh);

return CRhinoCommand::success;

}

When I use this CCommandCreateMesh in Rhino4 I got mesh as on picture 1. When I use this command in Rhino5 I got mesh as on picture 2. As you can see on Mesh on picture 2 I have a lot of triangles with very small corner angles. Is it possible to create mesh in Rhino5 similar to the one created in Rhino4.

polysrf.3dm (17.8 MB)

Thanks

I agree that something seems to be astray with the meshing.
Take a look at these settings, should not the “Minimum edge length” apply here?

The red circles has diameter of 2 units.

1 Like

Hi Bijana,

Your polysurface does have some issues:

brep.m_T[29] trim is not valid.
	trim.m_type = seam, the edge is manifold, but brep.m_L[trim.m_li=2].m_type is not outer.
brep.m_L[2] loop is not valid.
	brep.m_T[loop.m_ti[5]=29] is not valid.
brep.m_F[0] face is not valid.
	brep.m_L[face.m_li[2]=2] is not valid.
ON_Brep.m_F[0] is invalid.
brep.m_T[29] trim is not valid.
	trim.m_type = seam, the edge is manifold, but brep.m_L[trim.m_li=2].m_type is not outer.
brep.m_L[2] loop is not valid.
	brep.m_T[loop.m_ti[5]=29] is not valid.
brep.m_F[0] face is not valid.
	brep.m_L[face.m_li[2]=2] is not valid.
ON_Brep.m_F[0] is invalid.

You might also want to compare your source code with this:

CRhinoCommand::result CCommandTestBiljana::RunCommand( const CRhinoCommandContext& context )
{
  CRhinoGetObject go;
  go.SetCommandPrompt( L"Select surface or polysurface to mesh with fast parameters" );
  go.SetGeometryFilter( CRhinoGetObject::surface_object | CRhinoGetObject::polysrf_object );
  go.EnableSubObjectSelect( FALSE );
  go.GetObjects( 1, 1 );
  if( go.CommandResult() != CRhinoCommand::success )
    return go.CommandResult();

  const CRhinoObjRef& obj_ref = go.Object(0);
  const ON_Brep* brep = obj_ref.Brep();
  if( 0 == brep )
    return CRhinoCommand::failure;

  const CRhinoAppRenderMeshSettings& rms = RhinoApp().AppSettings().RenderMeshSettings();
  const ON_MeshParameters& mp = rms.DefaultQualityMeshParameters();

  ON_SimpleArray<ON_Mesh*> mesh_list;
  int mesh_count = brep->CreateMesh( mp, mesh_list );
  if( 0 == mesh_count )
    return CRhinoCommand::failure;

  ON_Mesh mesh;
  for( int i = 0; i < mesh_count; i++)
  {
    if( mesh_list[i] )
    {
      mesh_list[i]->ConvertQuadsToTriangles();
      mesh.Append( *mesh_list[i] ); // Copy mesh
      delete mesh_list[i]; // Don't leak...
    }
  } 

  if( mesh.IsValid() )
  {
    context.m_doc.AddMeshObject( mesh );
    context.m_doc.Redraw();
  }

  return CRhinoCommand::success;
}

With all this said, meshing has changed somewhat between V4 and V5. Does Holo’s suggestions help you?

I was doing some tests to create mesh from brep with different types of parameters ( for example to set minimum and maximum edge length) and for some polysurfaces I’ve got satisfied results. But for some polysurfaces (also imported from my costumers) when I create mesh, some triangles have strange behavior. Two of the corner angles of the triangle are close to zero and one corner angle is close to 180 deg. This happened only in Rhino5 and also happened when I create mesh with default parameters.

You should get different results, in some cases, with Rhino mesher because there are differences between the meshers in Rhino 4 and in Rhino 5. For the most part, Rhino 5’s mesher works “better.” But again, you will see differences at times.

If you want revert using the old mesher, then run the TestNewMesher test command. Note, this command may not persist in Rhino 6, so it would be wise to understand how to use the Rhino 5 mesher going forward.

If you have examples were Rhino 5 is not producing the mesh you expect, please send me the geometry along with the meshing parameters and I will evaluate for you.

Thanks Dale

I will try to manage working with Mesh in Rhino5

Best regards