Package com.irurueta.geometry.io
Class PLYTestFileBuilder
java.lang.Object
com.irurueta.geometry.io.PLYTestFileBuilder
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 Summary
FieldsModifier and TypeFieldDescription(package private) static final intValue of the alpha color component of every generated vertex.(package private) static final StringASCII storage format name.(package private) static final StringBinary big endian storage format name.(package private) static final intValue of the blue color component of every generated vertex.private intNumber of color components.private StringData type of colors or null if there are no colors.Header comments.private StringData type of coordinates.private static final int[][]Default faces: three triangles.private static final double[][]Default vertices (x, y, z): a planar square plus an apex.private StringData type of face indices.private StringData type of the number of indices of each face.private int[][]Faces to be written.private final StringStorage format name.(package private) static final intValue of the green color component of every generated vertex.(package private) static final StringBinary little endian storage format name.private StringData type of normals or null if there are no normals.(package private) static final intValue of the red color component of every generated vertex.private StringData type of texture coordinates or null if there are none.All data type names supported by PLY files, including aliases.private final double[][]Vertices to be written. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) byte[]build()Builds the file content.(package private) PLYTestFileBuilderEnables colors.(package private) PLYTestFileBuilderAdds a header comment.(package private) PLYTestFileBuilderSets data type of coordinates.(package private) PLYTestFileBuilderfaces(int[][] faces) Sets faces to be written.(package private) PLYTestFileBuilderSets data types of the face list.private Stringheader()Builds the textual header.(package private) PLYTestFileBuilderEnables normals (0, 0, 1).private static voidput(boolean ascii, List<String> values, ByteBuffer buffer, String type, double value) Appends a value either as text or as binary.(package private) PLYTestFileBuilderEnables texture coordinates (s, t), which the loader does not interpret.(package private) FileWrites the generated file.(package private) static FilewriteBytes(Path dir, String name, byte[] bytes) Writes bytes into a file.(package private) static FileWrites a text file using ASCII encoding.
-
Field Details
-
ASCII
ASCII storage format name.- See Also:
-
LITTLE
Binary little endian storage format name.- See Also:
-
BIG
Binary big endian storage format name.- See Also:
-
TYPES
All data type names supported by PLY files, including aliases. -
RED
static final int REDValue of the red color component of every generated vertex.- See Also:
-
GREEN
static final int GREENValue of the green color component of every generated vertex.- See Also:
-
BLUE
static final int BLUEValue of the blue color component of every generated vertex.- See Also:
-
ALPHA
static final int ALPHAValue of the alpha color component of every generated vertex.- See Also:
-
DEFAULT_VERTICES
private static final double[][] DEFAULT_VERTICESDefault vertices (x, y, z): a planar square plus an apex. -
DEFAULT_FACES
private static final int[][] DEFAULT_FACESDefault faces: three triangles. -
format
Storage format name. -
comments
Header comments. -
coordType
Data type of coordinates. -
colorType
Data type of colors or null if there are no colors. -
colorComponents
private int colorComponentsNumber of color components. -
normalType
Data type of normals or null if there are no normals. -
textureType
Data type of texture coordinates or null if there are none. -
faceLengthType
Data type of the number of indices of each face. -
faceIndexType
Data type of face indices. -
vertices
private final double[][] verticesVertices to be written. -
faces
private int[][] facesFaces to be written.
-
-
Constructor Details
-
PLYTestFileBuilder
PLYTestFileBuilder(String format) Constructor.- Parameters:
format- storage format name.
-
-
Method Details
-
coordType
Sets data type of coordinates.- Parameters:
type- data type name.- Returns:
- this instance.
-
colors
Enables colors.- Parameters:
type- data type name.components- number of components (3 or 4).- Returns:
- this instance.
-
normals
Enables normals (0, 0, 1).- Parameters:
type- data type name.- Returns:
- this instance.
-
texture
Enables texture coordinates (s, t), which the loader does not interpret.- Parameters:
type- data type name.- Returns:
- this instance.
-
faceTypes
Sets data types of the face list.- Parameters:
lengthType- data type of list length.indexType- data type of list values.- Returns:
- this instance.
-
faces
Sets faces to be written.- Parameters:
faces- faces.- Returns:
- this instance.
-
comment
Adds a header comment.- Parameters:
comment- comment.- Returns:
- this instance.
-
build
Builds the file content.- Returns:
- file bytes.
- Throws:
IOException- if an I/O error occurs.
-
write
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
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
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
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.
-