[RhinoCommon] Mesh.ExplodeAtUnweldedEdges fails for 1-face mesh

When I use the code below in a command, the mesh with 1 face does not return anything when run through ExplodeAtUnweldedMeshEdges(). A mesh with 2 faces is returned as-is, which I expected to happen for a mesh with 1 face as well.

Mesh m = new Mesh();
m.Vertices.AddVertices(new []{
  new Point3d(0, 0, 0), 
  new Point3d(0, 1, 0), 
  new Point3d(1, 1, 0),
  new Point3d(1, 0, 0)
});

m.Faces.AddFace(0, 1, 2, 3);

var result = m.ExplodeAtUnweldedEdges();
if (null != result && result.Any())
{
  doc.Objects.AddMesh(result.First());
}
else
{
  RhinoApp.WriteLine("Exploded at unwelded edges failed for 1 quad face mesh.");
}

m.Vertices.AddVertices(new []
{
  new Point3d(1,2,0),
  new Point3d(0,2,0)
});
m.Faces.AddFace(1, 2, 4, 5);
result = m.ExplodeAtUnweldedEdges();
if (null != result && result.Any())
{
  doc.Objects.AddMesh(result.First());
}
else
{
  RhinoApp.WriteLine("Exploded at unwelded edges failed for 2 quad face mesh.");
}

return Result.Success;

Hi @menno,

I cannot modify the function, as there are other tools that expect Mesh.ExplodeAtUnweldedEdges to work the way it does. All I can suggest is filtering out meshes with a single face.

– Dale

Ok, I will do that. Thanks for the quick reply, as always :smile: