import rhino3dm as r
m = r.Mesh()
m.Vertices.Add(1,1,1)
m.Vertices.Add(2,2,2)
m.Vertices.Add(3,3,3)
m.Faces.AddFace(0,1,2)
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?
MeshFace.D
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.