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:
Closeable
,AutoCloseable
Class for reading OBJ content as a
triangle mesh
.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final SimpleTriangleMesh.Builder
Object used to construct the mesh.List of normals discovered in the input. -
Constructor Summary
ConstructorsConstructorDescriptionObjTriangleMeshReader
(Reader reader, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision) Construct a new instance that reads OBJ content from the given reader. -
Method Summary
Modifier and TypeMethodDescriptionprotected 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.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 Details
-
meshBuilder
Object used to construct the mesh. -
normals
List of normals discovered in the input.
-
-
Constructor Details
-
ObjTriangleMeshReader
public ObjTriangleMeshReader(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 Details
-
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:
IllegalStateException
- if data format error occursUncheckedIOException
- if an I/O error occurs
-
handleVertex
Method called when a vertex is found in the OBJ content.- Specified by:
handleVertex
in classAbstractObjPolygonReader
- Parameters:
vertex
- vertex value
-
handleNormal
Method called when a normal is found in the OBJ content.- Specified by:
handleNormal
in classAbstractObjPolygonReader
- Parameters:
normal
- normal value
-