Class SimpleTriangleMesh.Builder
java.lang.Object
org.apache.commons.geometry.euclidean.threed.mesh.SimpleTriangleMesh.Builder
- Enclosing class:
SimpleTriangleMesh
Builder class for creating mesh instances.
-
Method Summary
Modifier and TypeMethodDescriptionaddFace(int[] face) Append a face to this mesh.addFace(int index1, int index2, int index3) Append a face to this mesh.addFaceAndVertices(Vector3D p1, Vector3D p2, Vector3D p3) Add a face and its vertices to this mesh.addFaces(int[][] faceIndices) Append a group of faces to this mesh.addFaces(Collection<int[]> faceIndices) Append a group of faces to this mesh.addFaceUsingVertices(Vector3D p1, Vector3D p2, Vector3D p3) Add a face to this mesh, only adding vertices to the vertex list if equivalent vertices are not found.intAdd a vertex directly to the vertex list, returning the index of the added vertex.addVertices(Collection<? extends Vector3D> newVertices) Add a group of vertices directly to the vertex list.addVertices(Vector3D[] newVertices) Add a group of vertices directly to the vertex list.build()Build a triangle mesh containing the vertices and faces in this builder.ensureFaceCapacity(int numFaces) Ensure that this instance has enough capacity to store at leastnumFacesnumber of faces without reallocating space.ensureVertexCapacity(int numVertices) Ensure that this instance has enough capacity to store at leastnumVerticesnumber of vertices without reallocating space.intGet the current number of faces in this mesh.getVertex(int index) Get the vertex at the given index.intGet the current number of vertices in this mesh.intUse a vertex in the constructed mesh.
-
Method Details
-
useVertex
Use a vertex in the constructed mesh. If an equivalent vertex already exist, as determined by the configuredPrecision.DoubleEquivalence, then the index of the previously added vertex is returned. Otherwise, the given vertex is added to the vertex list and the index of the new entry is returned. This is in contrast with theaddVertex(Vector3D), which always adds a new entry to the vertex list.- Parameters:
vertex- vertex to use- Returns:
- the index of the added vertex or an equivalent vertex that was added previously
- See Also:
-
addVertex
Add a vertex directly to the vertex list, returning the index of the added vertex. The vertex is added regardless of whether or not an equivalent vertex already exists in the list. This is in contrast with theuseVertex(Vector3D)method, which only adds a new entry to the vertex list if an equivalent one does not already exist.- Parameters:
vertex- the vertex to append- Returns:
- the index of the appended vertex in the vertex list
-
addVertices
Add a group of vertices directly to the vertex list. No equivalent vertices are reused.- Parameters:
newVertices- vertices to append- Returns:
- this instance
- See Also:
-
addVertices
Add a group of vertices directly to the vertex list. No equivalent vertices are reused.- Parameters:
newVertices- vertices to append- Returns:
- this instance
- See Also:
-
ensureVertexCapacity
Ensure that this instance has enough capacity to store at leastnumVerticesnumber of vertices without reallocating space. This can be used to help improve performance and memory usage when creating meshes with large numbers of vertices.- Parameters:
numVertices- the number of vertices to ensure that this instance can contain- Returns:
- this instance
-
getVertexCount
Get the current number of vertices in this mesh.- Returns:
- the current number of vertices in this mesh
-
getVertex
Get the vertex at the given index.- Parameters:
index- index of the vertex to retrieve- Returns:
- vertex at the given index
- Throws:
IndexOutOfBoundsException- if the index is out of bounds of the mesh vertex list
-
addFace
Append a face to this mesh.- Parameters:
index1- index of the first vertex in the faceindex2- index of the second vertex in the faceindex3- index of the third vertex in the face- Returns:
- this instance
- Throws:
IllegalArgumentException- if any of the arguments is not a valid index into the current vertex list
-
addFace
Append a face to this mesh.- Parameters:
face- array containing the 3 vertex indices defining the face- Returns:
- this instance
- Throws:
IllegalArgumentException- iffacedoes not contain exactly 3 elements or if any of the vertex indices is not a valid index into the current vertex list
-
addFaces
Append a group of faces to this mesh.- Parameters:
faceIndices- faces to append- Returns:
- this instance
- Throws:
IllegalArgumentException- if any of the face index arrays does not have exactly 3 elements or if any index is not a valid index into the current vertex list
-
addFaces
Append a group of faces to this mesh.- Parameters:
faceIndices- faces to append- Returns:
- this instance
- Throws:
IllegalArgumentException- if any of the face index arrays does not have exactly 3 elements or if any index is not a valid index into the current vertex list
-
addFaceUsingVertices
Add a face to this mesh, only adding vertices to the vertex list if equivalent vertices are not found.- Parameters:
p1- first face vertexp2- second face vertexp3- third face vertex- Returns:
- this instance
- See Also:
-
addFaceAndVertices
Add a face and its vertices to this mesh. The vertices are always added to the vertex list, regardless of whether or not equivalent vertices exist in the vertex list.- Parameters:
p1- first face vertexp2- second face vertexp3- third face vertex- Returns:
- this instance
- See Also:
-
ensureFaceCapacity
Ensure that this instance has enough capacity to store at leastnumFacesnumber of faces without reallocating space. This can be used to help improve performance and memory usage when creating meshes with large numbers of faces.- Parameters:
numFaces- the number of faces to ensure that this instance can contain- Returns:
- this instance
-
getFaceCount
Get the current number of faces in this mesh.- Returns:
- the current number of faces in this meshr
-
build
Build a triangle mesh containing the vertices and faces in this builder.- Returns:
- a triangle mesh containing the vertices and faces in this builder
-