Inconsistency in MeshFace between rhino3dm and rhinocommon

Hi all, I´m wondering why when running the following code in rhino3dm (python) and rhinocommon I get two different results:

import rhino3dm as r

m = r.Mesh()



print (m.Faces[0])
print (m.Faces.TriangleCount)

As you can see the topology produced by rhino3dm is (0,1,2,2) in spite of the face being a triangle.
Is this intentional?

Dear @dadandroid
check out rhinocommons MeshFace-Structure

Gets or sets the fourth corner index of the mesh face. If D equals C, the mesh face is considered to be a triangle rather than a quad.

The structure has 4 int fields, and ints are 0 by default. … but 0 is a valid value for vertex-index.
… so what to do for triangles ? I assume it is wise a design decision from the developer, to repeat the value - this will avoid to handle separate cases for triangles and quads in many situations… as a very simple example if you want to calculate the circumference of the face - you will just get a forth edge with length 0…
There is MeshFace.IsQuad() and MeshFace.IsTriangle() to get a more readable differentiation.

for more general stuff - to store the information “index not found” / “index does not exist” -1 is a nice value to use.

hope that helps - kind regards -tom


That sounds reasonable. Thanks @Tom_