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

public class ObjTriangleMeshReader extends AbstractObjPolygonReader
Class for reading OBJ content as a triangle mesh.
  • Field Details

    • meshBuilder

      private final SimpleTriangleMesh.Builder meshBuilder
      Object used to construct the mesh.
    • normals

      private final List<Vector3D> 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 from
      precision - precision context used to compare floating point numbers
  • Method Details

    • readTriangleMesh

      public TriangleMesh readTriangleMesh()
      Return a triangle 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 occurs
      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 class AbstractObjPolygonReader
      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 class AbstractObjPolygonReader
      Parameters:
      normal - normal value