The selected object is 90mm in total. Now if I enter 50 in the textbox, 1mm to 50mm objects are shown and 51mm to 90mm objects are removed.
if (meshGeometry != null)
{
var newMeshGeometry = new MeshGeometry3D();
for (int i = 0; i < meshGeometry.TriangleIndices.Count; i += 3)
{
Point3D p1 = meshGeometry.Positions[meshGeometry.TriangleIndices[i]];
Point3D p2 = meshGeometry.Positions[meshGeometry.TriangleIndices[i + 1]];
Point3D p3 = meshGeometry.Positions[meshGeometry.TriangleIndices[i + 2]];
double minZ = Math.Min(Math.Min(p1.Z, p2.Z), p3.Z);
double maxZ = Math.Max(Math.Max(p1.Z, p2.Z), p3.Z);
if (maxZ < bounds.SizeZ * hidePercent)
{
newMeshGeometry.Positions.Add(p1);
newMeshGeometry.Positions.Add(p2);
newMeshGeometry.Positions.Add(p3);
newMeshGeometry.TriangleIndices.Add(newMeshGeometry.Positions.Count - 3);
newMeshGeometry.TriangleIndices.Add(newMeshGeometry.Positions.Count - 2);
newMeshGeometry.TriangleIndices.Add(newMeshGeometry.Positions.Count - 1);
}
}
model.Geometry = newMeshGeometry;
viewPort3d.InvalidateVisual();
}