Class TriangleMesh
Represents a triangle mesh defined by a collection of vertices and triangle indices.
public class TriangleMesh
- Inheritance
-
TriangleMesh
- Inherited Members
Constructors
TriangleMesh(IEnumerable<JTriangle>, bool)
Creates a mesh from a "soup" of triangles. Vertices are automatically identified and deduplicated.
public TriangleMesh(IEnumerable<JTriangle> soup, bool ignoreDegenerated = false)
Parameters
soupIEnumerable<JTriangle>The triangles used to build the mesh.
ignoreDegeneratedboolIf true, degenerate triangles are skipped.
Exceptions
- TriangleMesh.DegenerateTriangleException
Thrown when a degenerate triangle is found and
ignoreDegeneratedis false.
TriangleMesh(ReadOnlySpan<JTriangle>, bool)
Creates a mesh from a "soup" of triangles. Vertices are automatically identified and deduplicated.
public TriangleMesh(ReadOnlySpan<JTriangle> soup, bool ignoreDegenerated = false)
Parameters
soupReadOnlySpan<JTriangle>The triangles used to build the mesh.
ignoreDegeneratedboolIf true, degenerate triangles are skipped.
Exceptions
- TriangleMesh.DegenerateTriangleException
Thrown when a degenerate triangle is found and
ignoreDegeneratedis false.
TriangleMesh(ReadOnlySpan<JVector>, ReadOnlySpan<int>, bool)
Creates a mesh from existing vertices and indices.
public TriangleMesh(ReadOnlySpan<JVector> vertices, ReadOnlySpan<int> indices, bool ignoreDegenerated = false)
Parameters
verticesReadOnlySpan<JVector>The vertex buffer.
indicesReadOnlySpan<int>The index buffer (must be a multiple of 3).
ignoreDegeneratedboolIf true, degenerate triangles are skipped.
Remarks
Vertices with exactly identical positions are canonicalized so adjacency detection also works across duplicated seam vertices in indexed meshes.
Exceptions
- ArgumentException
Thrown when
indicesdoes not contain a multiple of three entries.- IndexOutOfRangeException
Thrown when an index references an element outside
vertices.- TriangleMesh.DegenerateTriangleException
Thrown when a degenerate triangle is found and
ignoreDegeneratedis false.
TriangleMesh(ReadOnlySpan<JVector>, ReadOnlySpan<ushort>, bool)
Creates a mesh from existing vertices and indices.
public TriangleMesh(ReadOnlySpan<JVector> vertices, ReadOnlySpan<ushort> indices, bool ignoreDegenerated = false)
Parameters
verticesReadOnlySpan<JVector>The vertex buffer.
indicesReadOnlySpan<ushort>The index buffer (must be a multiple of 3).
ignoreDegeneratedboolIf true, degenerate triangles are skipped.
Remarks
Vertices with exactly identical positions are canonicalized so adjacency detection also works across duplicated seam vertices in indexed meshes.
Exceptions
- ArgumentException
Thrown when
indicesdoes not contain a multiple of three entries.- IndexOutOfRangeException
Thrown when an index references an element outside
vertices.- TriangleMesh.DegenerateTriangleException
Thrown when a degenerate triangle is found and
ignoreDegeneratedis false.
TriangleMesh(ReadOnlySpan<JVector>, ReadOnlySpan<uint>, bool)
Creates a mesh from existing vertices and indices.
public TriangleMesh(ReadOnlySpan<JVector> vertices, ReadOnlySpan<uint> indices, bool ignoreDegenerated = false)
Parameters
verticesReadOnlySpan<JVector>The vertex buffer.
indicesReadOnlySpan<uint>The index buffer (must be a multiple of 3).
ignoreDegeneratedboolIf true, degenerate triangles are skipped.
Remarks
Vertices with exactly identical positions are canonicalized so adjacency detection also works across duplicated seam vertices in indexed meshes.
Exceptions
- ArgumentException
Thrown when
indicesdoes not contain a multiple of three entries.- IndexOutOfRangeException
Thrown when an index references an element outside
vertices.- TriangleMesh.DegenerateTriangleException
Thrown when a degenerate triangle is found and
ignoreDegeneratedis false.
Properties
Indices
Gets the triangle indices of the mesh.
public ReadOnlySpan<TriangleMesh.Triangle> Indices { get; }
Property Value
Vertices
Gets the vertices of the mesh.
public ReadOnlySpan<JVector> Vertices { get; }
Property Value
Methods
Create<TVertex>(ReadOnlySpan<TVertex>, ReadOnlySpan<int>, bool)
Creates a mesh from custom vertices (e.g. System.Numerics.Vector3) and indices.
public static TriangleMesh Create<TVertex>(ReadOnlySpan<TVertex> vertices, ReadOnlySpan<int> indices, bool ignoreDegenerated = false) where TVertex : unmanaged
Parameters
verticesReadOnlySpan<TVertex>The vertex buffer.
indicesReadOnlySpan<int>The index buffer (must be a multiple of 3).
ignoreDegeneratedboolIf true, degenerate triangles are skipped.
Returns
Type Parameters
TVertexThe unmanaged vertex type. It must have the same size as JVector.
Exceptions
- ArgumentException
Thrown when
TVertexdoes not have the same size as JVector.- ArgumentException
Thrown when
indicesdoes not contain a multiple of three entries.- IndexOutOfRangeException
Thrown when an index references an element outside
vertices.- TriangleMesh.DegenerateTriangleException
Thrown when a degenerate triangle is found and
ignoreDegeneratedis false.
Create<TVertex>(ReadOnlySpan<TVertex>, ReadOnlySpan<ushort>, bool)
Creates a mesh from custom vertices (e.g. System.Numerics.Vector3) and indices.
public static TriangleMesh Create<TVertex>(ReadOnlySpan<TVertex> vertices, ReadOnlySpan<ushort> indices, bool ignoreDegenerated = false) where TVertex : unmanaged
Parameters
verticesReadOnlySpan<TVertex>The vertex buffer.
indicesReadOnlySpan<ushort>The index buffer (must be a multiple of 3).
ignoreDegeneratedboolIf true, degenerate triangles are skipped.
Returns
Type Parameters
TVertexThe unmanaged vertex type. It must have the same size as JVector.
Exceptions
- ArgumentException
Thrown when
TVertexdoes not have the same size as JVector.- ArgumentException
Thrown when
indicesdoes not contain a multiple of three entries.- IndexOutOfRangeException
Thrown when an index references an element outside
vertices.- TriangleMesh.DegenerateTriangleException
Thrown when a degenerate triangle is found and
ignoreDegeneratedis false.
Create<TVertex>(ReadOnlySpan<TVertex>, ReadOnlySpan<uint>, bool)
Creates a mesh from custom vertices (e.g. System.Numerics.Vector3) and indices.
public static TriangleMesh Create<TVertex>(ReadOnlySpan<TVertex> vertices, ReadOnlySpan<uint> indices, bool ignoreDegenerated = false) where TVertex : unmanaged
Parameters
verticesReadOnlySpan<TVertex>The vertex buffer.
indicesReadOnlySpan<uint>The index buffer (must be a multiple of 3).
ignoreDegeneratedboolIf true, degenerate triangles are skipped.
Returns
Type Parameters
TVertexThe unmanaged vertex type. It must have the same size as JVector.
Exceptions
- ArgumentException
Thrown when
TVertexdoes not have the same size as JVector.- ArgumentException
Thrown when
indicesdoes not contain a multiple of three entries.- IndexOutOfRangeException
Thrown when an index references an element outside
vertices.- TriangleMesh.DegenerateTriangleException
Thrown when a degenerate triangle is found and
ignoreDegeneratedis false.