Class TextStlFacetDefinitionReader
java.lang.Object
org.apache.commons.geometry.io.euclidean.threed.stl.TextStlFacetDefinitionReader
- All Implemented Interfaces:
AutoCloseable, FacetDefinitionReader
FacetDefinitionReader for reading the text (i.e., "ASCII") version of the STL file format.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanFlag indicating if the end of a solid definition was detected.private booleanFlag indicating if the start of a solid definition was detected.private SimpleTextParserText parser.private ReaderUnderlying reader instance.private StringThe name of the solid being read. -
Constructor Summary
ConstructorsConstructorDescriptionTextStlFacetDefinitionReader(Reader reader) Construct a new instance for reading text STL content from the given reader. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidBegin reading an STL solid definition.voidclose()Close this instance and release all associated resources.private voidEnsure that an STL solid definition is in the process of being read.Get the name of the STL solid being read or null if no name was specified.private voidmatchKeyword(String keyword) Read the next word from the content and match it against the given keyword.private voidnextWord()Read the next word from the content, discarding preceding whitespace.private doubleRead a double value from the input.Return the next facet definition from the input source or null if no more facets are available.private FacetDefinitionInternal method to read a single facet from the STL content.private Vector3DRead a vector from the input.private static StringtrimmedOrNull(String str) Return a trimmed version of the given string or null if the string contains only whitespace.
-
Field Details
-
reader
Underlying reader instance. -
parser
Text parser. -
foundSolidStart
private boolean foundSolidStartFlag indicating if the start of a solid definition was detected. -
foundSolidEnd
private boolean foundSolidEndFlag indicating if the end of a solid definition was detected. -
solidName
The name of the solid being read.
-
-
Constructor Details
-
TextStlFacetDefinitionReader
Construct a new instance for reading text STL content from the given reader.- Parameters:
reader- reader to read characters from
-
-
Method Details
-
getSolidName
Get the name of the STL solid being read or null if no name was specified.- Returns:
- the name of the STL solid being read or null if no name was specified
- Throws:
IllegalStateException- if a data format error occursUncheckedIOException- if an I/O error occurs
-
readFacet
Return the next facet definition from the input source or null if no more facets are available.- Specified by:
readFacetin interfaceFacetDefinitionReader- Returns:
- the next facet definition or null if no more facets are available
-
close
public void close()Close this instance and release all associated resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceFacetDefinitionReader
-
readFacetInternal
Internal method to read a single facet from the STL content.- Returns:
- next facet definition
- Throws:
IllegalStateException- if a data format error occursUncheckedIOException- if an I/O error occurs
-
ensureSolidStarted
private void ensureSolidStarted()Ensure that an STL solid definition is in the process of being read. If not, the beginning of a the definition is attempted to be read from the input.- Throws:
IllegalStateException- if a data format error occursUncheckedIOException- if an I/O error occurs
-
beginSolid
private void beginSolid()Begin reading an STL solid definition. The "solid" keyword is read along with the name of the solid.- Throws:
IllegalStateException- if a data format error occursUncheckedIOException- if an I/O error occurs
-
nextWord
private void nextWord()Read the next word from the content, discarding preceding whitespace.- Throws:
IllegalStateException- if a data format error occursUncheckedIOException- if an I/O error occurs
-
matchKeyword
Read the next word from the content and match it against the given keyword.- Parameters:
keyword- keyword to match against- Throws:
IllegalStateException- if the read content does not match the given keywordUncheckedIOException- if an I/O error occurs or
-
readVector
Read a vector from the input.- Returns:
- the vector read from the input
- Throws:
IllegalStateException- if a data format error occursUncheckedIOException- if an I/O error occurs
-
readDouble
private double readDouble()Read a double value from the input.- Returns:
- double value read from the input
- Throws:
IllegalStateException- if a data format error occursUncheckedIOException- if an I/O error occurs
-
trimmedOrNull
-