Table of Contents

Class MeshGeometryHelper

Namespace
HelixToolkit.Geometry
Assembly
HelixToolkit.Geometry.dll

Provides helper methods for mesh geometries.

public static class MeshGeometryHelper
Inheritance
MeshGeometryHelper
Inherited Members

Methods

CalculateNormals(MeshGeometry3D)

Calculates the normal vectors.

public static IList<Vector3> CalculateNormals(this MeshGeometry3D mesh)

Parameters

mesh MeshGeometry3D

The mesh.

Returns

IList<Vector3>

Collection of normal vectors.

CalculateNormals(IList<Vector3>, IList<int>)

Calculates the normal vectors.

public static IList<Vector3> CalculateNormals(IList<Vector3> positions, IList<int> triangleIndices)

Parameters

positions IList<Vector3>

The positions.

triangleIndices IList<int>

The triangle indices.

Returns

IList<Vector3>

Collection of normal vectors.

CombineSegments(IList<Vector3>, float)

Combines the segments.

public static IEnumerable<IList<Vector3>> CombineSegments(IList<Vector3> segments, float eps)

Parameters

segments IList<Vector3>

The segments.

eps float

The tolerance.

Returns

IEnumerable<IList<Vector3>>

Enumerated connected contour curves.

Cut(MeshGeometry3D, Plane)

Cuts the mesh with the specified plane.

public static MeshGeometry3D Cut(this MeshGeometry3D mesh, Plane plane)

Parameters

mesh MeshGeometry3D

The mesh.

plane Plane

The plane

Returns

MeshGeometry3D

The new cutted MeshGeometry3D by the plane.

Cut(MeshGeometry3D, Vector3, Vector3)

Cuts the mesh with the specified plane.

public static MeshGeometry3D Cut(this MeshGeometry3D mesh, Vector3 planeOrigin, Vector3 planeNormal)

Parameters

mesh MeshGeometry3D

The mesh.

planeOrigin Vector3

The plane origin.

planeNormal Vector3

The plane normal.

Returns

MeshGeometry3D

The new cutted MeshGeometry3D by the plane.

FindBorderEdges(MeshGeometry3D)

Finds edges that are only connected to one triangle.

public static IList<int> FindBorderEdges(this MeshGeometry3D mesh)

Parameters

mesh MeshGeometry3D

A mesh geometry.

Returns

IList<int>

The edge indices for the edges that are only used by one triangle.

FindEdges(MeshGeometry3D)

Finds all edges in the mesh (each edge is only included once).

public static IList<int> FindEdges(this MeshGeometry3D mesh)

Parameters

mesh MeshGeometry3D

A mesh geometry.

Returns

IList<int>

The edge indices (minimum index first).

FindSharpEdges(MeshGeometry3D, float)

Finds all edges where the angle between adjacent triangle normal vectors. is larger than minimumAngle

public static IList<int> FindSharpEdges(this MeshGeometry3D mesh, float minimumAngle)

Parameters

mesh MeshGeometry3D

A mesh geometry.

minimumAngle float

The minimum angle between the normal vectors of two adjacent triangles (degrees).

Returns

IList<int>

The edge indices.

GetContourSegments(MeshGeometry3D, Plane)

Gets the contour segments.

public static IList<Vector3> GetContourSegments(this MeshGeometry3D mesh, Plane plane)

Parameters

mesh MeshGeometry3D

The mesh.

plane Plane

The plane.

Returns

IList<Vector3>

GetContourSegments(MeshGeometry3D, Vector3, Vector3)

Gets the contour segments.

public static IList<Vector3> GetContourSegments(this MeshGeometry3D mesh, Vector3 planeOrigin, Vector3 planeNormal)

Parameters

mesh MeshGeometry3D

The mesh.

planeOrigin Vector3

The plane origin.

planeNormal Vector3

The plane normal.

Returns

IList<Vector3>

The segments of the contour.

NoSharedVertices(MeshGeometry3D)

Creates a new mesh where no vertices are shared.

public static MeshGeometry3D NoSharedVertices(this MeshGeometry3D input)

Parameters

input MeshGeometry3D

The input mesh.

Returns

MeshGeometry3D

A new mesh.

NormalizeInPlace(Vector3Collection)

public static void NormalizeInPlace(Vector3Collection data)

Parameters

data Vector3Collection

RemoveIsolatedVertices(MeshGeometry3D)

Remove isolated(not connected to any triangles) vertices

public static MeshGeometry3D RemoveIsolatedVertices(this MeshGeometry3D mesh)

Parameters

mesh MeshGeometry3D

Returns

MeshGeometry3D

RemoveIsolatedVertices(IList<Vector3>, IList<int>, IList<Vector2>?, IList<Vector3>?, out IList<Vector3>, out IList<int>, out IList<Vector2>?, out IList<Vector3>?)

Remove isolated(not connected to any triangles) vertices

public static void RemoveIsolatedVertices(IList<Vector3> vertices, IList<int> triangles, IList<Vector2>? texture, IList<Vector3>? normals, out IList<Vector3> verticesOut, out IList<int> trianglesOut, out IList<Vector2>? textureOut, out IList<Vector3>? normalOut)

Parameters

vertices IList<Vector3>
triangles IList<int>
texture IList<Vector2>
normals IList<Vector3>
verticesOut IList<Vector3>
trianglesOut IList<int>
textureOut IList<Vector2>
normalOut IList<Vector3>

RemoveOutOfRangeTriangles(IList<int>, int)

public static void RemoveOutOfRangeTriangles(this IList<int> triangles, int numVerts)

Parameters

triangles IList<int>
numVerts int

Simplify(MeshGeometry3D, float)

Simplifies the specified mesh.

public static MeshGeometry3D Simplify(this MeshGeometry3D mesh, float eps)

Parameters

mesh MeshGeometry3D

The mesh.

eps float

The tolerance.

Returns

MeshGeometry3D

A simplified mesh.

Validate(MeshGeometry3D)

Validates the specified mesh.

public static string? Validate(this MeshGeometry3D mesh)

Parameters

mesh MeshGeometry3D

The mesh.

Returns

string

Validation report or null if no issues were found.