Ab3d.PowerToys reference help

## Mesh |

MeshUtils class contains static methods that work with MeshGeometry3D.

Inheritance Hierarchy

Syntax

C#

public static class MeshUtils

The MeshUtils type exposes the following members.

Properties

Name | Description | |
---|---|---|

CreatePolygonIndicesByDefault | Gets or sets a static Boolean that specifies if Polygon indices are created for 3D models defined in Ab3d.PowerToys library (box, sphere, pyramid, etc.). Default value is false. This value is used when the CreatePolygonIndices property for the actual Mesh3D object does not have a value set - for example a CreatePolygonIndices in BoxMesh3D class. |

Methods

Name | Description | |
---|---|---|

AddPolygonPositions | Adds positions that define the edge lines for specified model3D (lines are not connected; each line is defined by two positions) to the specified Point3DCollection. Edge lines are specified with using PolygonIndicesProperty DependencyProperty on child MeshGeometry3D objects. See remarks in PolygonIndicesProperty for more info. | |

CalculateNormals(MeshGeometry3D) | Calculates normals for the meshGeometry. The normals are normalized. | |

CalculateNormals(MeshGeometry3D, Boolean) | Calculates normals for the meshGeometry. | |

CollectAllMeshes | CollectAllMeshes method returns a list of MeshUtilsMesh3DInfo structs that contains information about all 3D meshes in the specified Model3D hierarchy. | |

CombineAllMeshes(ListMeshUtilsMesh3DInfo) | CombineAllMeshes method combines all meshes from a list of Mesh3DInfo into a single MeshGeometry3D. It also applies all the transformations to the positions and normals (transformed by inversed transposed matrix). | |

CombineAllMeshes(Model3D, Transform3D) | CombineAllMeshes method combines all meshes from the specified Model3D hierarchy and converts them into a single MeshGeometry3D. It also applies all the transformations to the positions and normals (transformed by inversed transposed matrix). | |

CombineMeshes(IListMeshGeometry3D) | CombineMeshes return a MeshGeometry3D that is created with combining all Positions, Normals, TextureCoordinates and TriangleIndices for all the meshes that are set to the meshes parameter. | |

CombineMeshes(MeshGeometry3D) | CombineMeshes return a MeshGeometry3D that is created with combining all Positions, Normals, TextureCoordinates and TriangleIndices for all the meshes that are set to the meshes parameter. | |

ConvertConnectedPositionsToDisconnected | Converts collection of Point3D that represents a connected 3D line (3D line strip) into a collection of Point3D that represent disconnected 3D lines. In connected 3D lines the end position of one line is used as a start position of the next line. In disconnected 3D lines each lines is defined by 2 positions. | |

FlipNormals | Updates the normal vectors so that they point in the other direction. | |

FlipTriangles | Updates the TriangleIndices collection with swaping second and third index in each triangle. This changes the orientation in which the triangles are defined. | |

GenerateCubicTextureCoordinates | Returns a TextureCoordinates for the specified mesh. TextureCoordinates are calculated with using the cubic projection that projects the 3D positions to an axis aligned 3D cube. | |

GenerateCylindricalTextureCoordinates(MeshGeometry3D, Vector3D, Vector3D) | Returns a TextureCoordinates for the specified mesh. TextureCoordinates are calculated with using the Cylindrical projection. TextureCoordinates for position that are parallel to the cylinderDirectionVector use simple planar projection. TextureCoordinates for other positions are calculated based on the angle from the cylinder center axis to the position. The GenerateCylindricalTextureCoordinates does not set the TextureCoordinates on the mesh. | |

GenerateCylindricalTextureCoordinates(MeshGeometry3D, Rect, Vector3D, Vector3D, Boolean) | Returns a TextureCoordinates for the specified mesh. TextureCoordinates are calculated with using the Cylindrical projection. TextureCoordinates for position that are parallel to the cylinderDirectionVector use simple planar projection. TextureCoordinates for other positions are calculated based on the angle from the cylinder center axis to the position. The GenerateCylindricalTextureCoordinates does not set the TextureCoordinates on the mesh. | |

GeneratePlanarTextureCoordinates(MeshGeometry3D, Vector3D, Vector3D, Boolean, Boolean, Boolean) | Returns a TextureCoordinates for the specified mesh. TextureCoordinates are calculated with using the Planar projection. The plane is defined by the planeNormalVector (perpendicular to the plane) and planeHeightVector (defines the y up direction in the plane). | |

GeneratePlanarTextureCoordinates(MeshGeometry3D, Vector3D, Vector3D, Rect, Boolean, Boolean, Boolean) | Returns a TextureCoordinates for the specified mesh. TextureCoordinates are calculated with using the Planar projection. The plane is defined by the planeNormalVector (perpendicular to the plane) and planeHeightVector (defines the y up direction in the plane). | |

GetAverageNormalVector3D | Returns a Vector3D that represents an average normal vector of the MeshGeometry3D (calculated with summing normal vectors of all triangles and dividing it by the number of triangles). | |

GetIntersectingTriangles | GetIntersectingTriangles returns a list of indexes of triangles from the mesh that intersect the specified boundingBox. To actually split the mesh you can then call the SplitMeshByIndexesOfTriangles(MeshGeometry3D, ListInt32, Boolean, MeshGeometry3D, MeshGeometry3D) method. | |

GetPolygonPositions(MeshGeometry3D, Transform3D) | Returns Point3DCollection with positions that define the edge lines for the specified meshGeometry3D (lines are not connected; each line is defined by two positions). Edge lines are specified with using PolygonIndicesProperty DependencyProperty. If this DependencyProperty is not defined then null is returned. See remarks in PolygonIndicesProperty for more info. | |

GetPolygonPositions(Model3D, Transform3D) | Returns Point3DCollection with positions that define the edge lines for specified model3D (lines are not connected; each line is defined by two positions). Edge lines are specified with using PolygonIndicesProperty DependencyProperty on child MeshGeometry3D objects. See remarks in PolygonIndicesProperty for more info. | |

GetPolygonPositionsCount(MeshGeometry3D) | Returns the count of positions that can be created from polygon indices. | |

GetPolygonPositionsCount(Model3D) | Returns the count of positions that can be created from polygon indices that are defined in this Model3D. | |

GetPolygons | GetPolygons method returns a List of Lists of Point3D structs that represents polygons (each polygon is defined by a List of Point3D structs) that are created from the PolygonIndicesProperty DependencyProperty on the MeshGeometry3D object. When PolygonIndices are not defined, then null is returned. See remarks in PolygonIndicesProperty for more info. | |

PositionAndScaleMeshGeometry3D | PositionAndScaleModel3D method translates and scales the model3D so that it is positioned according to position and positionType parameters and that it will fit into the Size3D defined by finalSize parameter. | |

Project3DPointsTo2DPlane | Projects a list of 3D position into a 2D plane with specified planeNormalVector and planeHeightVector. | |

SplitMeshByIndexesOfTriangles | SplitMeshByIndexesOfTriangles splits the originalMeshGeometry3D into mesh1 and mesh2 based on the list of triangle indexes defined in indexesOfTriangles (can be get by GetIntersectingTriangles(Rect3D, MeshGeometry3D, Transform3D) method). When the triangle index is present in the indexesOfTriangles, then the triangle is added to mesh1, otherwise triangle is added to mesh2. Note that mesh1 can be null (when indexesOfTriangles is null or empty). mesh2 can be null when indexesOfTriangles contains the same number of triangles as the originalMeshGeometry3D. | |

TransformMeshGeometry3D | Transforms the specified MeshGeometry3D with the specified Transform3D and returns a new MeshGeometry3D (the same MeshGeometry3D is returned in case of null or identity transform). If transformNormals is set to true (by default) the normals are transformed with inverted and transposed transform matrix. |

Fields

Name | Description | |
---|---|---|

EdgeLineIndicesProperty | EdgeLineIndicesProperty is a DependencyProperty that can be set to the MeshGeometry3D object and specifies a List<int> with Position indexes that define edge lines for the MeshGeometry3D. Each line is defined by two consecutive indexes. | |

PolygonIndicesProperty | PolygonIndicesProperty is a DependencyProperty that can be set to the MeshGeometry3D object and specifies an Int32Collection with Position indexes that define polygons for the MeshGeometry3D. |

See Also