Class PLYTestFileBuilder

java.lang.Object
com.irurueta.geometry.io.PLYTestFileBuilder

final class PLYTestFileBuilder extends Object
Test helper that programmatically generates small PLY files (ASCII, binary little endian or binary big endian) so that every data type, storage mode and face layout can be exercised without committing binaries.
  • Field Details

    • ASCII

      static final String ASCII
      ASCII storage format name.
      See Also:
    • LITTLE

      static final String LITTLE
      Binary little endian storage format name.
      See Also:
    • BIG

      static final String BIG
      Binary big endian storage format name.
      See Also:
    • TYPES

      static final List<String> TYPES
      All data type names supported by PLY files, including aliases.
    • RED

      static final int RED
      Value of the red color component of every generated vertex.
      See Also:
    • GREEN

      static final int GREEN
      Value of the green color component of every generated vertex.
      See Also:
    • BLUE

      static final int BLUE
      Value of the blue color component of every generated vertex.
      See Also:
    • ALPHA

      static final int ALPHA
      Value of the alpha color component of every generated vertex.
      See Also:
    • DEFAULT_VERTICES

      private static final double[][] DEFAULT_VERTICES
      Default vertices (x, y, z): a planar square plus an apex.
    • DEFAULT_FACES

      private static final int[][] DEFAULT_FACES
      Default faces: three triangles.
    • format

      private final String format
      Storage format name.
    • comments

      private final List<String> comments
      Header comments.
    • coordType

      private String coordType
      Data type of coordinates.
    • colorType

      private String colorType
      Data type of colors or null if there are no colors.
    • colorComponents

      private int colorComponents
      Number of color components.
    • normalType

      private String normalType
      Data type of normals or null if there are no normals.
    • textureType

      private String textureType
      Data type of texture coordinates or null if there are none.
    • faceLengthType

      private String faceLengthType
      Data type of the number of indices of each face.
    • faceIndexType

      private String faceIndexType
      Data type of face indices.
    • vertices

      private final double[][] vertices
      Vertices to be written.
    • faces

      private int[][] faces
      Faces to be written.
  • Constructor Details

    • PLYTestFileBuilder

      PLYTestFileBuilder(String format)
      Constructor.
      Parameters:
      format - storage format name.
  • Method Details

    • coordType

      PLYTestFileBuilder coordType(String type)
      Sets data type of coordinates.
      Parameters:
      type - data type name.
      Returns:
      this instance.
    • colors

      PLYTestFileBuilder colors(String type, int components)
      Enables colors.
      Parameters:
      type - data type name.
      components - number of components (3 or 4).
      Returns:
      this instance.
    • normals

      PLYTestFileBuilder normals(String type)
      Enables normals (0, 0, 1).
      Parameters:
      type - data type name.
      Returns:
      this instance.
    • texture

      PLYTestFileBuilder texture(String type)
      Enables texture coordinates (s, t), which the loader does not interpret.
      Parameters:
      type - data type name.
      Returns:
      this instance.
    • faceTypes

      PLYTestFileBuilder faceTypes(String lengthType, String indexType)
      Sets data types of the face list.
      Parameters:
      lengthType - data type of list length.
      indexType - data type of list values.
      Returns:
      this instance.
    • faces

      PLYTestFileBuilder faces(int[][] faces)
      Sets faces to be written.
      Parameters:
      faces - faces.
      Returns:
      this instance.
    • comment

      PLYTestFileBuilder comment(String comment)
      Adds a header comment.
      Parameters:
      comment - comment.
      Returns:
      this instance.
    • build

      byte[] build() throws IOException
      Builds the file content.
      Returns:
      file bytes.
      Throws:
      IOException - if an I/O error occurs.
    • write

      File write(Path dir, String name) throws IOException
      Writes the generated file.
      Parameters:
      dir - directory where file is written.
      name - file name.
      Returns:
      written file.
      Throws:
      IOException - if an I/O error occurs.
    • writeBytes

      static File writeBytes(Path dir, String name, byte[] bytes) throws IOException
      Writes bytes into a file.
      Parameters:
      dir - directory where file is written.
      name - file name.
      bytes - content.
      Returns:
      written file.
      Throws:
      IOException - if an I/O error occurs.
    • writeText

      static File writeText(Path dir, String name, String text) throws IOException
      Writes a text file using ASCII encoding.
      Parameters:
      dir - directory where file is written.
      name - file name.
      text - content.
      Returns:
      written file.
      Throws:
      IOException - if an I/O error occurs.
    • header

      private String header()
      Builds the textual header.
      Returns:
      header text.
    • put

      private static void put(boolean ascii, List<String> values, ByteBuffer buffer, String type, double value)
      Appends a value either as text or as binary.
      Parameters:
      ascii - true to write text.
      values - text values.
      buffer - binary buffer.
      type - data type name.
      value - value to write.