Package com.irurueta.geometry.io
Class LoaderSTL
java.lang.Object
com.irurueta.geometry.io.Loader
com.irurueta.geometry.io.LoaderSTL
- All Implemented Interfaces:
Closeable,AutoCloseable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classInternal listener to be notified when loading process finishes.private classLoader iterator in charge of loading file data in small chunks. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intConstant defining the default value of maximum number of vertices to keep in a chunk.private LoaderSTL.LoaderIteratorSTLprivate intstatic final intMinimum allowed value for maximum number of vertices in chunk, which is one.static final floatAmount of progress variation (1%) used to notify progress. -
Constructor Summary
ConstructorsConstructorDescriptionConstructor.LoaderSTL(int maxVerticesInChunk) Constructor.LoaderSTL(LoaderListener listener) Constructor.LoaderSTL(LoaderListener listener, int maxVerticesInChunk) Constructor.Constructor.Constructor.LoaderSTL(File f, LoaderListener listener) Constructor.LoaderSTL(File f, LoaderListener listener, int maxVerticesInChunk) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionintReturns maximum number of vertices allowed in a chunk.Returns mesh format supported by this class, which is MESH_FORMAT_STL.protected LongGets number of vertices contained in the file.protected StringReturns name for the 3D object.private voidinternalSetMaxVerticesInChunk(int maxVerticesInChunk) Internal method to set maximum number of vertices allowed in a chunk.booleanisReady()If loader is ready to start loading a file.booleanDetermines if provided file is a valid file that can be read by this loader.load()Starts the loading process of provided file.voidsetMaxVerticesInChunk(int maxVerticesInChunk) Sets maximum number of vertices allowed in a chunk.Methods inherited from class com.irurueta.geometry.io.Loader
close, getFileSizeLimitToKeepInMemory, getListener, hasFile, isLocked, setFile, setFileSizeLimitToKeepInMemory, setListener, setLocked
-
Field Details
-
DEFAULT_MAX_VERTICES_IN_CHUNK
public static final int DEFAULT_MAX_VERTICES_IN_CHUNKConstant defining the default value of maximum number of vertices to keep in a chunk. This is 65535, which corresponds to the maximum value allowed by graphical layer such as OpenGL when working with Vertex Buffer Objects.- See Also:
-
MIN_MAX_VERTICES_IN_CHUNK
public static final int MIN_MAX_VERTICES_IN_CHUNKMinimum allowed value for maximum number of vertices in chunk, which is one.- See Also:
-
PROGRESS_DELTA
public static final float PROGRESS_DELTAAmount of progress variation (1%) used to notify progress.- See Also:
-
loaderIterator
-
maxVerticesInChunk
private int maxVerticesInChunk
-
-
Constructor Details
-
LoaderSTL
public LoaderSTL()Constructor. -
LoaderSTL
public LoaderSTL(int maxVerticesInChunk) Constructor.- Parameters:
maxVerticesInChunk- Maximum number of vertices allowed in a chunk. Once this value is exceeded when loading a file, a new chunk of data is created.- Throws:
IllegalArgumentException- if maximum number of vertices allowed in a chunk is lower than 1.
-
LoaderSTL
Constructor.- Parameters:
f- file to be loaded.- Throws:
IOException- if an I/O error occurs.
-
LoaderSTL
Constructor.- Parameters:
f- file to be loaded.maxVerticesInChunk- Maximum number of vertices allowed in a chunk. Once this value is exceeded when loading a file, a new chunk of data is created.- Throws:
IllegalArgumentException- if maximum number of vertices allowed in a chunk is lower than 1.IOException- if an I/O error occurs.
-
LoaderSTL
Constructor.- Parameters:
listener- listener to be notified of loading progress and when loading process starts or finishes.
-
LoaderSTL
Constructor.- Parameters:
listener- listener to be notified of loading progress and when loading process starts or finishes.maxVerticesInChunk- Maximum number of vertices allowed in a chunk. Once this value is exceeded when loading a file, a new chunk of data is created.- Throws:
IllegalArgumentException- if maximum number of vertices allowed in a chunk is lower than 1.
-
LoaderSTL
Constructor.- Parameters:
f- file to be loaded.listener- listener to be notified of loading progress and when loading process starts or finishes.- Throws:
IOException- if an I/O error occurs.
-
LoaderSTL
Constructor.- Parameters:
f- file to be loaded.listener- listener to be notified of loading progress and when loading process starts or finishes.maxVerticesInChunk- Maximum number of vertices allowed in a chunk. Once this value is exceeded when loading a file, a new chunk of data is created.- Throws:
IllegalArgumentException- if maximum number of vertices allowed in a chunk is lower than 1.IOException- if an I/O error occurs.
-
-
Method Details
-
setMaxVerticesInChunk
Sets maximum number of vertices allowed in a chunk. Once this value is exceeded when loading a file, a new chunk of data is created.- Parameters:
maxVerticesInChunk- maximum allowed number of vertices to be set.- Throws:
IllegalArgumentException- if provided value is lower than 1.LockedException- if this loader is currently loading a file.
-
getMaxVerticesInChunk
public int getMaxVerticesInChunk()Returns maximum number of vertices allowed in a chunk. Once this value is exceeded when loading a file, a new chunk of data is created.- Returns:
- maximum number of vertices allowed in a chunk.
-
isReady
public boolean isReady()If loader is ready to start loading a file. This is true once a file has been provided. -
getMeshFormat
Returns mesh format supported by this class, which is MESH_FORMAT_STL.- Specified by:
getMeshFormatin classLoader- Returns:
- mesh format supported by this class.
-
isValidFile
Determines if provided file is a valid file that can be read by this loader.- Specified by:
isValidFilein classLoader- Returns:
- true if file is valid, false otherwise.
- Throws:
LockedException- raised if this instance is already locked.IOException- if an I/O error occurs.
-
load
public LoaderIterator load() throws LockedException, NotReadyException, IOException, LoaderExceptionStarts the loading process of provided file. This method returns a LoaderIterator to start the iterative process to load a file in small chunks of data.- Specified by:
loadin classLoader- Returns:
- a loader iterator to read the file in a step-by-step process.
- Throws:
LockedException- raised if this instance is already locked.NotReadyException- raised if this instance is not yet ready.IOException- if an I/O error occurs.LoaderException- if file is corrupted or cannot be interpreted.
-
getSolidName
Returns name for the 3D object.- Returns:
- name for the 3D object.
-
getNumberOfVertices
Gets number of vertices contained in the file.- Returns:
- number of vertices contained in the file.
-
internalSetMaxVerticesInChunk
private void internalSetMaxVerticesInChunk(int maxVerticesInChunk) Internal method to set maximum number of vertices allowed in a chunk. This method is reused both in the constructor and in the setter of maximum number of vertices allowed in a chunk.- Parameters:
maxVerticesInChunk- maximum allowed number of vertices to be set.- Throws:
IllegalArgumentException- if provided value is lower than 1.
-