Class ObjTriangleMeshReader
- java.lang.Object
-
- org.apache.commons.geometry.io.euclidean.threed.obj.AbstractObjPolygonReader
-
- org.apache.commons.geometry.io.euclidean.threed.obj.ObjTriangleMeshReader
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class ObjTriangleMeshReader extends AbstractObjPolygonReader
Class for reading OBJ content as atriangle mesh
.
-
-
Field Summary
Fields Modifier and Type Field Description private SimpleTriangleMesh.Builder
meshBuilder
Object used to construct the mesh.private java.util.List<Vector3D>
normals
List of normals discovered in the input.
-
Constructor Summary
Constructors Constructor Description ObjTriangleMeshReader(java.io.Reader reader, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision)
Construct a new instance that reads OBJ content from the given reader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
handleNormal(Vector3D normal)
Method called when a normal is found in the OBJ content.protected void
handleVertex(Vector3D vertex)
Method called when a vertex is found in the OBJ content.TriangleMesh
readTriangleMesh()
Return atriangle mesh
constructed from all of the OBJ content from the underlying reader.-
Methods inherited from class org.apache.commons.geometry.io.euclidean.threed.obj.AbstractObjPolygonReader
close, isFailOnNonPolygonKeywords, readFace, setFailOnNonPolygonKeywords
-
-
-
-
Field Detail
-
meshBuilder
private final SimpleTriangleMesh.Builder meshBuilder
Object used to construct the mesh.
-
normals
private final java.util.List<Vector3D> normals
List of normals discovered in the input.
-
-
Constructor Detail
-
ObjTriangleMeshReader
public ObjTriangleMeshReader(java.io.Reader reader, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision)
Construct a new instance that reads OBJ content from the given reader.- Parameters:
reader
- reader to read fromprecision
- precision context used to compare floating point numbers
-
-
Method Detail
-
readTriangleMesh
public TriangleMesh readTriangleMesh()
Return atriangle mesh
constructed from all of the OBJ content from the underlying reader. Non-triangle faces are converted to triangles using a simple triangle fan. All vertices present in the OBJ content are also present in the returned mesh, regardless of whether or not they are used in a face.- Returns:
- triangle mesh containing all data from the OBJ content
- Throws:
java.lang.IllegalStateException
- if data format error occursjava.io.UncheckedIOException
- if an I/O error occurs
-
handleVertex
protected void handleVertex(Vector3D vertex)
Method called when a vertex is found in the OBJ content.- Specified by:
handleVertex
in classAbstractObjPolygonReader
- Parameters:
vertex
- vertex value
-
handleNormal
protected void handleNormal(Vector3D normal)
Method called when a normal is found in the OBJ content.- Specified by:
handleNormal
in classAbstractObjPolygonReader
- Parameters:
normal
- normal value
-
-