RhinoCommon Mesh Face/NGon enumeration and count

It seems that in some cases Rhino.Geometry.Mesh.GetNgonAndFacesEnumerable() also unexpectedly enumerates the internal triangles of every ngon.
Interestingly, Rhino.Geometry.Mesh.GetNgonAndFacesCount() does not, as expected.

At least according to my (possibly wrong) expectations?

C# Example script, run via ScriptEditor, I used Rhino 8 SR32
// #! csharp
using System;
using System.Linq;
using Rhino;
using Rhino.Geometry;

// some points
var points = new Point3d[] {
    new(729, 1108, -62), new(3006, 1078, -76), new(4100, 1072, -62),
    new(7432, 1075, 75), new(11077, 1089, 264), new(0, 0, 0),
    new(3688, 470, -53), new(2116, -1861, 46), new(5797, -1334, 140),
    new(9588, -913, 518), new(7921, -3225, 600)
};

// connect points with lines to define faces
var lines = new LineCurve[] {
    // face 1: start with 5-sided ngon
    new(points[0], points[1]), new(points[1], points[6]),
    new(points[6], points[7]), new(points[5], points[7]), 
    new(points[0], points[5]),
    // face 2: add triangle
    new(points[1], points[2]), new(points[2], points[6]),
    // face 3: add quad
    new(points[2], points[3]), new(points[3], points[8]),
    new(points[6], points[8]),
    // face 4: add another quad
    new(points[3], points[9]), new(points[9], points[10]),
    new(points[8], points[10]),
    // face 5: add another triangle
    new(points[3], points[4]), new(points[4], points[9]),
};

// create a mesh from the lines
var mesh = Mesh.CreateFromLines(lines, 6, __rhino_doc__.ModelAbsoluteTolerance);

// count the faces/ngons by specific method (should correctly count 5)
RhinoApp.WriteLine($"Mesh counts {mesh.GetNgonAndFacesCount()} ngons/faces");

// count the faces/ngons by enumeration (should incorrectly count 8)
// somehow the 3 internal triangles of the 5-sided ngon are also enumerated
RhinoApp.WriteLine($"Mesh enumerates {mesh.GetNgonAndFacesEnumerable().Count()} ngons/faces");

// draw mesh and lines for visual inspection
__rhino_doc__.Objects.AddMesh(mesh);
foreach (var line in lines)
    __rhino_doc__.Objects.AddCurve(line);

Hi @mikeJM,

Thanks for reporting - I’ve logged the issue so a developer can review.

– Dale