Package com.irurueta.geometry.io
Class MeshWriterBinaryTest
java.lang.Object
com.irurueta.geometry.io.MeshWriterBinaryTest
- All Implemented Interfaces:
MeshWriterListener
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classConfigurable listener recording received notifications. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intprivate booleanprivate static final Stringprivate booleanprivate static final String[]Lines of a mesh containing malformed vertices.private static final String[]Lines of a material library having all kinds of texture maps.private static final String[]Lines of a small mesh with a triangle using a material.private floatprivate booleanprivate intprivate boolean(package private) PathTemporary folder where generated files are stored.private static final StringName of the texture image used by generated materials.private static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcheckLocked(MeshWriterBinary writer) private FileCreates a binary mesh file with every texture map embedded, using a mesh with textures.private FilecreateObjWithAllTextureMaps(String[] lines) Creates a mesh file, its material library and the texture image in the temporary folder.private booleanprivate booleanprivate booleanprivate booleanvoidonChunkAvailable(MeshWriter writer, DataChunk chunk) voidonDidValidateTexture(MeshWriter writer, File f) onMaterialFileRequested(MeshWriter writer, String path) onTextureDataAvailable(MeshWriter writer, File textureFile, int textureWidth, int textureHeight) voidonTextureDataProcessed(MeshWriter writer, File textureFile, int textureWidth, int textureHeight) onTextureReceived(MeshWriter writer, int textureWidth, int textureHeight) onValidateTexture(MeshWriter writer, Texture texture) voidonWriteEnd(MeshWriter writer) voidonWriteProgressChange(MeshWriter writer, float progress) voidonWriteStart(MeshWriter writer) private void(package private) static void(package private) static void(package private) void(package private) void(package private) void(package private) void(package private) voidtestWriteAndIsReadyObj(String inputFile, String outputFile) (package private) voidtestWriteAndIsReadyPly(String inputFile, String outputFile) (package private) voidChecks that a material using every kind of texture map is written when a listener provides the files.(package private) voidChecks that a listener returning no material file or a missing one results in the material being ignored.(package private) voidChecks that malformed mesh content makes the writer fail.(package private) voidChecks that materials and textures are ignored when no listener is set.(package private) voidChecks that texture data coming from a binary file is dispatched to the listener, and that a listener returning a converted file, no file at all, or no listener, are all handled.(package private) voidChecks that I/O errors of the output stream are propagated by the writer.(package private) voidChecks that an invalid texture makes the writer fail, and that a listener providing no texture file is accepted.
-
Field Details
-
INPUT_FOLDER
- See Also:
-
TMP_FOLDER
- See Also:
-
TEXTURE_NAME
Name of the texture image used by generated materials.- See Also:
-
OBJ_LINES
Lines of a small mesh with a triangle using a material. -
MALFORMED_OBJ_LINES
Lines of a mesh containing malformed vertices. -
MTL_LINES
Lines of a material library having all kinds of texture maps. -
tempDir
Temporary folder where generated files are stored. -
startValid
private boolean startValid -
endValid
private boolean endValid -
progressValid
private boolean progressValid -
lockedValid
private boolean lockedValid -
startCounter
private int startCounter -
endCounter
private int endCounter -
previousProgress
private float previousProgress
-
-
Constructor Details
-
MeshWriterBinaryTest
MeshWriterBinaryTest()
-
-
Method Details
-
setUpClass
@BeforeAll static void setUpClass() -
tearDownClass
@AfterAll static void tearDownClass() -
testConstructors
- Throws:
IOException
-
testGetSetListener
- Throws:
IOExceptionLockedException
-
testWriteAndIsReadyPly
@ParameterizedTest(name="{index} - inputFile = {0}, outputFile = {1}") @CsvSource({"randomAscii.ply,randomAscii.bin","randomLittle.ply,randomLittle.bin","randomBig.ply,randomBig.bin","booksBinary.ply,booksBinary.bin","booksAscii.ply,booksAscii.bin","pilarAscii.ply,pilarAscii.bin","pilarLittleEndian.ply,pilarLittleEndian.bin","pilarBigEndian.ply,pilarBigEndian.bin"}) void testWriteAndIsReadyPly(String inputFile, String outputFile) throws IOException, LockedException, LoaderException, NotReadyException -
testWriteAndIsReadyObj
@ParameterizedTest(name="{index} - inputFile = {0}, outputFile = {1}") @CsvSource({"books.obj,booksObj.bin","pitcher.obj,pitcherObj.bin","potro.obj,potroObj.bin"}) void testWriteAndIsReadyObj(String inputFile, String outputFile) throws IOException, LockedException, LoaderException, NotReadyException -
testWriteAndIsReadyBooksBinaryStlFile
@Test void testWriteAndIsReadyBooksBinaryStlFile() throws IOException, LockedException, LoaderException, NotReadyException -
testWriteAndIsReadyBooksAsciiStlFile
@Test void testWriteAndIsReadyBooksAsciiStlFile() throws IOException, LockedException, LoaderException, NotReadyException -
write_whenAllTextureMapsAvailable_validatesEveryTexture
@Test void write_whenAllTextureMapsAvailable_validatesEveryTexture() throws IOException, LoaderException, NotReadyException, LockedExceptionChecks that a material using every kind of texture map is written when a listener provides the files.- Throws:
IOException- if an I/O error occurs.LoaderException- if the mesh cannot be loaded.NotReadyException- if the writer is not ready.LockedException- if the writer is locked.
-
write_whenNoListener_ignoresMaterials
@Test void write_whenNoListener_ignoresMaterials() throws IOException, LoaderException, NotReadyException, LockedExceptionChecks that materials and textures are ignored when no listener is set.- Throws:
IOException- if an I/O error occurs.LoaderException- if the mesh cannot be loaded.NotReadyException- if the writer is not ready.LockedException- if the writer is locked.
-
write_whenMaterialFileMissing_ignoresMaterials
@Test void write_whenMaterialFileMissing_ignoresMaterials() throws IOException, LoaderException, NotReadyException, LockedExceptionChecks that a listener returning no material file or a missing one results in the material being ignored.- Throws:
IOException- if an I/O error occurs.LoaderException- if the mesh cannot be loaded.NotReadyException- if the writer is not ready.LockedException- if the writer is locked.
-
write_whenTextureInvalidOrWithoutFile_failsOrSkipsTexture
@Test void write_whenTextureInvalidOrWithoutFile_failsOrSkipsTexture() throws IOException, LoaderException, NotReadyException, LockedExceptionChecks that an invalid texture makes the writer fail, and that a listener providing no texture file is accepted.- Throws:
IOException- if an I/O error occurs.LoaderException- if the mesh cannot be loaded.NotReadyException- if the writer is not ready.LockedException- if the writer is locked.
-
write_whenSourceIsBinaryWithTextures_notifiesTextureCallbacks
@Test void write_whenSourceIsBinaryWithTextures_notifiesTextureCallbacks() throws IOException, LoaderException, NotReadyException, LockedExceptionChecks that texture data coming from a binary file is dispatched to the listener, and that a listener returning a converted file, no file at all, or no listener, are all handled.- Throws:
IOException- if an I/O error occurs.LoaderException- if the mesh cannot be loaded.NotReadyException- if the writer is not ready.LockedException- if the writer is locked.
-
write_whenStreamFails_throwsIOException
Checks that I/O errors of the output stream are propagated by the writer.- Throws:
IOException- if an I/O error occurs.
-
write_whenMeshContentIsMalformed_throwsException
Checks that malformed mesh content makes the writer fail.- Throws:
IOException- if an I/O error occurs.
-
onWriteStart
- Specified by:
onWriteStartin interfaceMeshWriterListener
-
onWriteEnd
- Specified by:
onWriteEndin interfaceMeshWriterListener
-
onWriteProgressChange
- Specified by:
onWriteProgressChangein interfaceMeshWriterListener
-
onChunkAvailable
- Specified by:
onChunkAvailablein interfaceMeshWriterListener
-
onMaterialFileRequested
- Specified by:
onMaterialFileRequestedin interfaceMeshWriterListener
-
onValidateTexture
- Specified by:
onValidateTexturein interfaceMeshWriterListener
-
onDidValidateTexture
- Specified by:
onDidValidateTexturein interfaceMeshWriterListener
-
onTextureReceived
- Specified by:
onTextureReceivedin interfaceMeshWriterListener
-
onTextureDataAvailable
public File onTextureDataAvailable(MeshWriter writer, File textureFile, int textureWidth, int textureHeight) - Specified by:
onTextureDataAvailablein interfaceMeshWriterListener
-
onTextureDataProcessed
public void onTextureDataProcessed(MeshWriter writer, File textureFile, int textureWidth, int textureHeight) - Specified by:
onTextureDataProcessedin interfaceMeshWriterListener
-
checkLocked
-
resetListener
private void resetListener() -
isStartValid
private boolean isStartValid() -
isEndValid
private boolean isEndValid() -
isProgressValid
private boolean isProgressValid() -
isLockedValid
private boolean isLockedValid() -
createBinaryWithTextures
private File createBinaryWithTextures() throws IOException, LoaderException, NotReadyException, LockedExceptionCreates a binary mesh file with every texture map embedded, using a mesh with textures.- Returns:
- created binary file.
- Throws:
IOException- if an I/O error occurs.LoaderException- if the mesh cannot be loaded.NotReadyException- if the writer is not ready.LockedException- if the writer is locked.
-
createObjWithAllTextureMaps
Creates a mesh file, its material library and the texture image in the temporary folder.- Parameters:
lines- lines of the mesh file.- Returns:
- created mesh file.
- Throws:
IOException- if an I/O error occurs.
-