GetPolygonPositions of an object created using MeshBooleanOperations.Union
#2
Using MeshUtils.GetPolygonPositions works only on models that have PolygonIndices property set. This is a custom property that is defined by the Ab3d.PowerToys library and defines the polygons that can also define the 3D model (all 3D models in WPF are defined by triangles that are needed for the graphics card - triangles are set by TriangleIndices; but some objects can be also created from polygons - for example box - and polygons better show the object when itis shown by the lines). Most of the 3D objects that are created by Ab3d.PowerToys library define the PolygonIndices. Also ReaderObj and Assimp importer set the PolygonIndices.

See more in the online help (or in the Ab3d.PowerToys help file):
https://www.ab4d.com/help/PowerToys/html...itions.htm
https://www.ab4d.com/help/PowerToys/html...operty.htm

But boolean objects do not have that, so you will need to get the triangles.

To get triangles use the following code:
Code:
// Get local accessors to prevent calling DependecyProperty getters in a loop
var triangleIndices = mesh.TriangleIndices;
var positions = mesh.Positions;

var triangleIndicesCount = triangleIndices.Count;

var polyPositions = new Point3DCollection();
for (var i = 0; i < triangleIndicesCount; i += 3)
{
    // Add 3 lines from one triangle
    polyPositions.Add(positions[triangleIndices[i]]);
    polyPositions.Add(positions[triangleIndices[i + 1]]);

    polyPositions.Add(positions[triangleIndices[i + 1]]);
    polyPositions.Add(positions[triangleIndices[i + 2]]);

    polyPositions.Add(positions[triangleIndices[i + 2]]);
    polyPositions.Add(positions[triangleIndices[i]]);
}
Andrej Benedik
  


Messages In This Thread
RE: GetPolygonPositions of an object created using MeshBooleanOperations.Union - by abenedik - 04-10-2019, 05:49 PM

Forum Jump:


Users browsing this thread:
1 Guest(s)