Class LoaderIteratorPLYTest

java.lang.Object
com.irurueta.geometry.io.LoaderIteratorPLYTest
All Implemented Interfaces:
LoaderListener

class LoaderIteratorPLYTest extends Object implements LoaderListener
  • Field Details

    • ERROR

      private static final double ERROR
      See Also:
    • MAX_VERTICES

      private static final int MAX_VERTICES
      See Also:
    • BYTES_TO_TRUNCATE

      private static final int BYTES_TO_TRUNCATE
      See Also:
    • DEFAULT_COORDS

      private static final float[] DEFAULT_COORDS
    • DEFAULT_INDICES

      private static final int[] DEFAULT_INDICES
    • N_DEFAULT_VERTICES

      private static final int N_DEFAULT_VERTICES
      See Also:
    • 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

    • LoaderIteratorPLYTest

      LoaderIteratorPLYTest()
  • Method Details

    • testConstructors

      @Test void testConstructors() throws IOException
      Throws:
      IOException
    • testHasSetFileAndIsReady

      @Test void testHasSetFileAndIsReady() throws LockedException, IOException
      Throws:
      LockedException
      IOException
    • testGetSetFileSizeLimitToKeepInMemory

      @Test void testGetSetFileSizeLimitToKeepInMemory() throws LockedException, IOException
      Throws:
      LockedException
      IOException
    • testGetSetListener

      @Test void testGetSetListener() throws LockedException, IOException
      Throws:
      LockedException
      IOException
    • testGetSetMaxVerticesInChunk

      @Test void testGetSetMaxVerticesInChunk() throws LockedException, IOException
      Throws:
      LockedException
      IOException
    • testGetSetAllowDuplicateVerticesInChunk

      @Test void testGetSetAllowDuplicateVerticesInChunk() throws LockedException, IOException
      Throws:
      LockedException
      IOException
    • testGetSetMaxStreamPositions

      @Test void testGetSetMaxStreamPositions() throws LockedException, IOException
      Throws:
      LockedException
      IOException
    • testIsValidFile

      @Test void testIsValidFile() throws LockedException, IOException
      Throws:
      LockedException
      IOException
    • testLoad

      Throws:
      LockedException
      NotReadyException
      IOException
      LoaderException
    • testLoadAndIterate

      Throws:
      IllegalArgumentException
      LockedException
      NotReadyException
      IOException
      LoaderException
      NotAvailableException
    • testLoadAndIterateRealFile

      @Test void testLoadAndIterateRealFile() throws LockedException, NotReadyException, IOException, LoaderException, NotAvailableException
      Throws:
      LockedException
      NotReadyException
      IOException
      LoaderException
      NotAvailableException
    • testLoadAndIterateRealFileWithNormals

      @Test void testLoadAndIterateRealFileWithNormals() throws LockedException, NotReadyException, IOException, LoaderException, NotAvailableException
      Throws:
      LockedException
      NotReadyException
      IOException
      LoaderException
      NotAvailableException
    • next_whenAllPropertiesUseSameType_returnsExpectedChunk

      @ParameterizedTest @MethodSource("formatsAndTypes") void next_whenAllPropertiesUseSameType_returnsExpectedChunk(String format, String type, @TempDir Path dir) throws Exception
      Checks that files using every data type for coordinates, colors, normals and faces can be loaded in every storage mode, so that all value readers are executed.
      Parameters:
      format - storage format name.
      type - data type name.
      dir - temporary directory.
      Throws:
      Exception - if any unexpected error occurs.
    • next_whenColorsNormalsAndTextureArePresent_returnsExpectedChunk

      @ParameterizedTest @MethodSource("formats") void next_whenColorsNormalsAndTextureArePresent_returnsExpectedChunk(String format, @TempDir Path dir) throws Exception
      Checks that mixed data types, three color components and unsupported texture properties are handled in every storage mode.
      Parameters:
      format - storage format name.
      dir - temporary directory.
      Throws:
      Exception - if any unexpected error occurs.
    • next_whenOnlyCoordinatesArePresent_returnsChunkWithoutColors

      @ParameterizedTest @MethodSource("formats") void next_whenOnlyCoordinatesArePresent_returnsChunkWithoutColors(String format, @TempDir Path dir) throws Exception
      Checks that files without optional properties can be loaded in every storage mode.
      Parameters:
      format - storage format name.
      dir - temporary directory.
      Throws:
      Exception - if any unexpected error occurs.
    • next_whenDuplicateVerticesAreAllowed_repeatsVertices

      @ParameterizedTest @MethodSource("formats") void next_whenDuplicateVerticesAreAllowed_repeatsVertices(String format, @TempDir Path dir) throws Exception
      Checks that duplicate vertices are kept when allowed.
      Parameters:
      format - storage format name.
      dir - temporary directory.
      Throws:
      Exception - if any unexpected error occurs.
    • next_whenChunkIsTooSmall_returnsSeveralChunks

      @ParameterizedTest @MethodSource("formats") void next_whenChunkIsTooSmall_returnsSeveralChunks(String format, @TempDir Path dir) throws Exception
      Checks that faces are split into several chunks when they do not fit in one chunk.
      Parameters:
      format - storage format name.
      dir - temporary directory.
      Throws:
      Exception - if any unexpected error occurs.
    • next_whenFaceIsQuad_triangulatesFace

      @ParameterizedTest @MethodSource("formats") void next_whenFaceIsQuad_triangulatesFace(String format, @TempDir Path dir) throws Exception
      Checks that polygons with more than three vertices are triangulated.
      Parameters:
      format - storage format name.
      dir - temporary directory.
      Throws:
      Exception - if any unexpected error occurs.
    • next_whenFaceIsPentagon_triangulatesFace

      @ParameterizedTest @MethodSource("formats") void next_whenFaceIsPentagon_triangulatesFace(String format, @TempDir Path dir) throws Exception
      Checks that polygons with five vertices are triangulated.
      Parameters:
      format - storage format name.
      dir - temporary directory.
      Throws:
      Exception - if any unexpected error occurs.
    • next_whenFaceHasTwoIndices_throwsLoaderException

      @ParameterizedTest @MethodSource("formats") void next_whenFaceHasTwoIndices_throwsLoaderException(String format, @TempDir Path dir) throws Exception
      Checks that a face with fewer than three indices is rejected.
      Parameters:
      format - storage format name.
      dir - temporary directory.
      Throws:
      Exception - if any unexpected error occurs.
    • next_whenFaceDoesNotFitInChunk_throwsLoaderException

      @ParameterizedTest @MethodSource("formats") void next_whenFaceDoesNotFitInChunk_throwsLoaderException(String format, @TempDir Path dir) throws Exception
      Checks that a face larger than the chunk is rejected.
      Parameters:
      format - storage format name.
      dir - temporary directory.
      Throws:
      Exception - if any unexpected error occurs.
    • next_whenFaceIndexIsOutOfRange_throwsLoaderException

      @ParameterizedTest @MethodSource("formats") void next_whenFaceIndexIsOutOfRange_throwsLoaderException(String format, @TempDir Path dir) throws Exception
      Checks that a face referencing a missing vertex is rejected.
      Parameters:
      format - storage format name.
      dir - temporary directory.
      Throws:
      Exception - if any unexpected error occurs.
    • next_whenFileIsTruncated_throwsException

      @ParameterizedTest @MethodSource("formats") void next_whenFileIsTruncated_throwsException(String format, @TempDir Path dir) throws Exception
      Checks that a file truncated in the middle of the faces is rejected.
      Parameters:
      format - storage format name.
      dir - temporary directory.
      Throws:
      Exception - if any unexpected error occurs.
    • load_whenFileEndsInsideVertices_throwsException

      @ParameterizedTest @MethodSource("formats") void load_whenFileEndsInsideVertices_throwsException(String format, @TempDir Path dir) throws Exception
      Checks that a file truncated in the middle of the vertices is rejected.
      Parameters:
      format - storage format name.
      dir - temporary directory.
      Throws:
      Exception - if any unexpected error occurs.
    • next_whenNoMoreChunks_throwsNotAvailableException

      @Test void next_whenNoMoreChunks_throwsNotAvailableException(@TempDir Path dir) throws Exception
      Checks that calling next when there are no more chunks fails.
      Parameters:
      dir - temporary directory.
      Throws:
      Exception - if any unexpected error occurs.
    • next_whenAsciiValueIsNotANumber_throwsException

      @Test void next_whenAsciiValueIsNotANumber_throwsException(@TempDir Path dir) throws Exception
      Checks that ASCII values that cannot be parsed are rejected as a corrupted file.
      Parameters:
      dir - temporary directory.
      Throws:
      Exception - if any unexpected error occurs.
    • next_whenAsciiCoordinateIsNotANumber_throwsLoaderException

      @ParameterizedTest @MethodSource("types") void next_whenAsciiCoordinateIsNotANumber_throwsLoaderException(String type, @TempDir Path dir) throws Exception
      Checks that ASCII coordinates that cannot be parsed are rejected for every data type.
      Parameters:
      type - data type name.
      dir - temporary directory.
      Throws:
      Exception - if any unexpected error occurs.
    • load_whenUnknownElementPrecedesVertices_throwsLoaderException

      @Test void load_whenUnknownElementPrecedesVertices_throwsLoaderException(@TempDir Path dir) throws Exception
      Checks that unknown elements declared before the vertices are rejected, because no reader is set for their properties.
      Parameters:
      dir - temporary directory.
      Throws:
      Exception - if any unexpected error occurs.
    • load_whenThereAreNoFaces_throwsLoaderException

      @Test void load_whenThereAreNoFaces_throwsLoaderException(@TempDir Path dir) throws Exception
      Checks that a file without face element cannot be iterated.
      Parameters:
      dir - temporary directory.
      Throws:
      Exception - if any unexpected error occurs.
    • formats

      private static Stream<String> formats()
      Provides the supported storage formats.
      Returns:
      storage formats.
    • types

      private static Stream<String> types()
      Provides all data types.
      Returns:
      data type names.
    • formatsAndTypes

      private static Stream<org.junit.jupiter.params.provider.Arguments> formatsAndTypes()
      Provides all combinations of storage format and data type.
      Returns:
      arguments.
    • loadAll

      private static List<DataChunk> loadAll(File file, int maxVerticesInChunk, boolean allowDuplicateVertices) throws Exception
      Loads all chunks of a file.
      Parameters:
      file - file to be loaded.
      maxVerticesInChunk - maximum number of vertices in a chunk.
      allowDuplicateVertices - true to allow duplicate vertices in a chunk.
      Returns:
      loaded chunks.
      Throws:
      Exception - if any error occurs.
    • checkDefaultChunk

      private static void checkDefaultChunk(DataChunk chunk, int components, boolean checkBlue)
      Checks that a chunk contains the data generated by default by PLYTestFileBuilder.
      Parameters:
      chunk - chunk to be checked.
      components - number of color components.
      checkBlue - true to check blue component (int typed blue components are not read by the loader).
    • onLoadStart

      public void onLoadStart(Loader loader)
      Specified by:
      onLoadStart in interface LoaderListener
    • onLoadEnd

      public void onLoadEnd(Loader loader)
      Specified by:
      onLoadEnd in interface LoaderListener
    • onLoadProgressChange

      public void onLoadProgressChange(Loader loader, float progress)
      Specified by:
      onLoadProgressChange in interface LoaderListener
    • checkLocked

      private void checkLocked(LoaderPLY loader)
    • resetListener

      private void resetListener()
    • isStartValid

      private boolean isStartValid()
    • isEndValid

      private boolean isEndValid()
    • isProgressValid

      private boolean isProgressValid()
    • isLockedValid

      private boolean isLockedValid()