public final class SimpleTriangleMesh extends Object implements TriangleMesh
TriangleMesh
interface. This class ensures that
faces always contain 3 valid references into the vertex list but does not enforce that
the referenced vertices are unique or that they define a triangle with non-zero size. For
example, a mesh could contain a face with 3 vertices that are considered equivalent by the
configured precision context. Attempting to call the TriangleMesh.Face.getPolygon()
method on such a face results in an exception. The
Mesh.Face.definesPolygon()
method can be used to determine if a face defines
a valid triangle.
Instances of this class are guaranteed to be immutable.
Modifier and Type | Class and Description |
---|---|
static class |
SimpleTriangleMesh.Builder
Builder class for creating mesh instances.
|
TriangleMesh.Face
Modifier and Type | Method and Description |
---|---|
Stream<PlaneConvexSubset> |
boundaryStream() |
static SimpleTriangleMesh.Builder |
builder(Precision.DoubleEquivalence precision)
Return a builder for creating new triangle mesh objects.
|
Iterable<TriangleMesh.Face> |
faces()
Get an iterable containing all faces in the mesh.
|
static SimpleTriangleMesh |
from(BoundarySource3D boundarySrc,
Precision.DoubleEquivalence precision)
Construct a new mesh instance containing all triangles from the given boundary
source.
|
static SimpleTriangleMesh |
from(Collection<Vector3D> vertices,
Collection<int[]> faces,
Precision.DoubleEquivalence precision)
Construct a new triangle mesh from the given vertices and face indices.
|
static SimpleTriangleMesh |
from(Vector3D[] vertices,
int[][] faces,
Precision.DoubleEquivalence precision)
Construct a new triangle mesh from the given vertices and face indices.
|
Bounds3D |
getBounds()
Get a
Bounds3D object defining the axis-aligned box containing all vertices
in the boundaries for this instance. |
TriangleMesh.Face |
getFace(int index)
Get a face from the mesh by its index.
|
int |
getFaceCount()
Get the number of faces in the mesh.
|
List<TriangleMesh.Face> |
getFaces()
Get a list containing all faces in the mesh.
|
Precision.DoubleEquivalence |
getPrecision()
Get the precision context for the mesh.
|
int |
getVertexCount()
Get the number of vertices in the mesh.
|
List<Vector3D> |
getVertices()
Get a list containing all vertices in the mesh.
|
String |
toString() |
SimpleTriangleMesh |
toTriangleMesh(Precision.DoubleEquivalence meshPrecision)
Return this instance if the given precision context is equal to the current precision context.
|
SimpleTriangleMesh |
transform(Transform<Vector3D> transform)
Return a new, transformed mesh by applying the given transform to
all vertices.
|
Stream<Triangle3D> |
triangleStream()
Return the boundaries of this instance as a stream of
Triangle3D
instances. |
Iterable<Vector3D> |
vertices()
Get an iterable containing the vertices in the mesh.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
linecast, linecastFirst, of, of, toList, toTree
linecast, linecastFirst
public Iterable<Vector3D> vertices()
vertices
in interface Mesh<TriangleMesh.Face>
public List<Vector3D> getVertices()
getVertices
in interface Mesh<TriangleMesh.Face>
public int getVertexCount()
getVertexCount
in interface Mesh<TriangleMesh.Face>
public Iterable<TriangleMesh.Face> faces()
faces
in interface Mesh<TriangleMesh.Face>
public List<TriangleMesh.Face> getFaces()
getFaces
in interface Mesh<TriangleMesh.Face>
public int getFaceCount()
getFaceCount
in interface Mesh<TriangleMesh.Face>
public TriangleMesh.Face getFace(int index)
getFace
in interface Mesh<TriangleMesh.Face>
index
- the index of the mesh to retrievepublic Bounds3D getBounds()
Bounds3D
object defining the axis-aligned box containing all vertices
in the boundaries for this instance. Null is returned if any boundary is infinite
or no vertices are found.getBounds
in interface BoundarySource3D
public Precision.DoubleEquivalence getPrecision()
Triangle3D
instances.public Stream<PlaneConvexSubset> boundaryStream()
boundaryStream
in interface BoundarySource<PlaneConvexSubset>
public Stream<Triangle3D> triangleStream()
Triangle3D
instances. An IllegalStateException
exception is thrown while reading
from the stream if any boundary cannot be converted to a triangle (i.e. if it
has infinite size).triangleStream
in interface BoundarySource3D
PlaneSubset.toTriangles()
public SimpleTriangleMesh transform(Transform<Vector3D> transform)
transform
in interface Mesh<TriangleMesh.Face>
transform
in interface TriangleMesh
transform
- transform to applypublic SimpleTriangleMesh toTriangleMesh(Precision.DoubleEquivalence meshPrecision)
toTriangleMesh
in interface BoundarySource3D
meshPrecision
- precision context to use when generating face polygonspublic static SimpleTriangleMesh.Builder builder(Precision.DoubleEquivalence precision)
precision
- precision object used for floating point comparisonspublic static SimpleTriangleMesh from(Vector3D[] vertices, int[][] faces, Precision.DoubleEquivalence precision)
vertices
- vertices for the meshfaces
- face indices for the meshprecision
- precision context used for floating point comparisonsIllegalArgumentException
- if any of the face index arrays does not have exactly 3 elements or
if any index is not a valid index into the vertex listpublic static SimpleTriangleMesh from(Collection<Vector3D> vertices, Collection<int[]> faces, Precision.DoubleEquivalence precision)
vertices
- vertices for the meshfaces
- face indices for the meshprecision
- precision context used for floating point comparisonsIllegalArgumentException
- if any of the face index arrays does not have exactly 3 elements or
if any index is not a valid index into the vertex listpublic static SimpleTriangleMesh from(BoundarySource3D boundarySrc, Precision.DoubleEquivalence precision)
boundarySrc
- boundary source to construct a mesh fromprecision
- precision context used for floating point comparisonsIllegalStateException
- if any boundary in the boundary source has infinite size and cannot
be converted to trianglesCopyright © 2016–2021 The Apache Software Foundation. All rights reserved.