Strange behavior with invalid mesh

Looking also at other methods, like here Fixing Invalid Mesh in Grasshopper - #2 by laurent_delrieu
… what is the smallest set of operations to simply “fix” a mesh? (without doing excessive and useless methods that burns CPU time…)

Also, it seems that Mesh.Append(Mesh) works while Mesh.CopyFrom(Mesh) fails (sometime)… i wonder why…


2023-06-30 13_06_12-Window
fixing mesh.gh (1.1 MB)

 private void RunScript(Mesh m, ref object A, ref object B)
  {
    A = FixMesh01(m);
    B = FixMesh02(m);
  }
  // <Custom additional code> 
  Mesh FixMesh01(Mesh M){
    Mesh m = new Mesh();
    m.Append(M);                                          //APPEND
    m.Vertices.CombineIdentical(true, true);
    m.Vertices.CullUnused();
    m.Weld(Math.PI);
    m.FaceNormals.ComputeFaceNormals();
    m.Normals.ComputeNormals();
    return m;
  }
  Mesh FixMesh02(Mesh M){
    Mesh m = new Mesh();
    m.CopyFrom(M);                                          //COPYFROM
    m.Vertices.CombineIdentical(true, true);
    m.Vertices.CullUnused();
    m.Weld(Math.PI);
    m.FaceNormals.ComputeFaceNormals();
    m.Normals.ComputeNormals();
    return m;
  }