 # Mesh Simplification Problem

#1

Hello!
I have some problem with Reducer.
I have STL model, which loaded in my App by Helix-Toolkit.
And I want to reduce number of verticies of the model. I wrote this method:

``````    private int OptimazeModel(Geometry3D geometry)
{
var meshModel = geometry as MeshGeometry3D;

DMesh3 dmesh = new DMesh3(MeshComponents.VertexNormals);

Debug.Print(\$"Raw: numbers of vertecies: {meshModel.Positions.Count}, " +
\$"numbers of nomals {meshModel.Normals.Count}, " +
\$"numbers of triangles {meshModel.TriangleIndices.Count}");

for (int i = 0; i < meshModel.Positions.Count; i++)
{
var idx = meshModel.TriangleIndices[i];
dmesh.AppendVertex(
new NewVertexInfo(
new Vector3d(
meshModel.Positions[idx].X,
meshModel.Positions[idx].Y,
meshModel.Positions[idx].Z),
new Vector3f(
meshModel.Normals[idx].X,
meshModel.Normals[idx].Y,
meshModel.Normals[idx].Z)
));

dmesh.AppendTriangle(new Index3i(idx));
}

if (dmesh.CheckValidity(eFailMode: FailMode.DebugAssert))
Debug.Print("Check - Ok");
else
Debug.Print("Check - Error");

Reducer reducer = new Reducer(dmesh);

reducer.ReduceToTriangleCount(1000);

Debug.Print(\$"Reduced: number of vertecies: {reducer.Mesh.VertexCount}");

return reducer.Mesh.VertexCount;
}
``````

So, I have an output:
Raw: numbers of vertecies: 25368, numbers of nomals 25368, numbers of triangles 25368
Check - Ok
ReducedL number of vertecies: 25368

And haven’t any exceptions. But model is not reduced, What I do wrong?
Thanks a lot!