Class PolygonObjParser
java.lang.Object
org.apache.commons.geometry.io.euclidean.threed.obj.AbstractObjParser
org.apache.commons.geometry.io.euclidean.threed.obj.PolygonObjParser
Low-level parser class for reading 3D polygon (face) data in the OBJ file format.
This class provides access to OBJ data structures but does not retain any of the
parsed data. For example, it is up to callers to store vertices as they are parsed
for later reference. This allows callers to determine what values are stored and in
what format.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classClass representing an OBJ face definition.static final classClass representing a set of attributes for a face vertex. -
Constructor Summary
ConstructorsConstructorDescriptionPolygonObjParser(Reader reader) Construct a new instance for parsing OBJ content from the given reader.PolygonObjParser(SimpleTextParser parser) Construct a new instance for parsing OBJ content from the given text parser. -
Method Summary
Modifier and TypeMethodDescriptionintGet the number oftexture coordinate keywordsparsed so far.intGet the number ofvertex keywordsparsed so far.intGet the number ofvertex normal keywordsparsed so far.protected voidhandleKeyword(String keywordValue) Method called when a keyword is encountered in the parsed OBJ content.booleanReturn true if the instance is configured to throw anIllegalStateExceptionwhen OBJ keywords not commonly used with files containing only polygon data are encountered.readFace()Read an OBJ face definition from the current line.voidsetFailOnNonPolygonKeywords(boolean failOnNonPolygonKeywords) Set the flag determining if the instance should throw anIllegalStateExceptionwhen encountering keywords not commonly used with OBJ files containing only polygon data.Methods inherited from class AbstractObjParser
discardDataLine, discardDataLineWhitespace, getCurrentKeyword, getTextParser, nextDataLineContent, nextDouble, nextKeyword, readDataLine, readDoubles, readVector
-
Constructor Details
-
PolygonObjParser
Construct a new instance for parsing OBJ content from the given reader.- Parameters:
reader- reader to parser content from
-
PolygonObjParser
Construct a new instance for parsing OBJ content from the given text parser.- Parameters:
parser- text parser to read content from
-
-
Method Details
-
getVertexCount
Get the number ofvertex keywordsparsed so far.- Returns:
- the number of vertex keywords parsed so far
-
getVertexNormalCount
Get the number ofvertex normal keywordsparsed so far.- Returns:
- the number of vertex normal keywords parsed so far
-
getTextureCoordinateCount
Get the number oftexture coordinate keywordsparsed so far.- Returns:
- the number of texture coordinate keywords parsed so far
-
isFailOnNonPolygonKeywords
Return true if the instance is configured to throw anIllegalStateExceptionwhen OBJ keywords not commonly used with files containing only polygon data are encountered. The default value isfalse, meaning that no keyword validation is performed. When set to true, only the following keywords are accepted:vvnvtfogsmtllibusemtl
- Returns:
- true if the instance is configured to fail when a non-polygon keyword is encountered
-
setFailOnNonPolygonKeywords
Set the flag determining if the instance should throw anIllegalStateExceptionwhen encountering keywords not commonly used with OBJ files containing only polygon data. If true, only the following keywords are accepted:vvnvtfogsmtllibusemtl
- Parameters:
failOnNonPolygonKeywords- new flag value
-
handleKeyword
Method called when a keyword is encountered in the parsed OBJ content. Subclasses should use this method to validate the keyword and/or update any internal state.- Specified by:
handleKeywordin classAbstractObjParser- Parameters:
keywordValue- keyword encountered in the OBJ content
-
readFace
Read an OBJ face definition from the current line.- Returns:
- OBJ face definition read from the current line
- Throws:
IllegalStateException- if a face definition is not able to be parsedUncheckedIOException- if an I/O error occurs
-