Inconsistent mesh validity test between Rh6 and Rh7

Dear McNeel team,
It seems that the mesh validation method in Rh7 is more strict than in Rh5 and Rh6, thus leading to disappearing meshes.
Please see the attached GH file with an internalized mesh opening perfectly fine in previous versions, but marked as invalid in Rh7 (default settings everywhere, file in mm) with the following log:
“ON_Mesh.m_F[11914] has degenerate float precision vertex locations.”

Do you have a suggestion to avoid this issue? In our case it happens randomly when using Mesh.Transform, I suppose it’s related to precision / rounding in the test.

Best regards,
Thibault

Invalid Mesh.gh (268.6 KB)

I also had the same issue with Cockroach plugin in C++ when computing normally not the most clean meshes using Poisson Surface Reconstruction, in Rhino 6 it works most of the time, while in Rhino 7 most of the time fails.

The workaround I have, is to rebuild mesh faces. And skip ones that have coincident vertices because mesh faces are usually very small from Poisson, adding to tolerance issue you were referring to.

As a solution I use this code:

 if(!mesh.IsValid()){

               
                mesh.CombineIdenticalVertices(true,true);
                mesh.CullUnusedVertices();
                mesh.Cleanup(true);
                mesh.CullDegenerateFaces();
                mesh.CullUnusedVertices();

                ON_Mesh meshRebuilt(mesh.FaceCount(), mesh.VertexCount(), false,  false);

               for(int i = 0; i < mesh.VertexCount(); i++)
                    meshRebuilt.SetVertex(i,mesh.Vertex(i) );


   
               for(int i = 0; i < mesh.FaceCount(); i++){
                   auto f = mesh.m_F[i];
   
                   int a = f.vi[0];
                   int b = f.vi[1];
                   int c = f.vi[2];
                   
                   if (a != b && a != c && b != c)  
                         meshRebuilt.SetTriangle(i, a, b, c);
                }

               if(meshRebuilt.IsValid()){
                    if(meshObj==NULL){
                        meshObj= context.m_doc.AddMeshObject(meshRebuilt);
                        objRef = CRhinoObjRef(meshObj);
                        RhinoApp().Print(L"Mesh Added End \n");
                     } else{
                        context.m_doc.ReplaceObject( objRef, meshRebuilt );
                        RhinoApp().Print(L"Mesh Replaced End \n");
                    }
               context.m_doc.Redraw();
             }

Hey @t.schwartz,

Nice to hear from you.

Rhino 7 is a bit more strict on meshes. In this case, the fix should be pretty simple (attached).

test_thibault.gh (271.1 KB)

– Dale

Dear Petras & Dale, thanks a lot for your prompt replies. Culling degenerate faces seems to work!
Have both a nice evening, T.