public class TextFacetDefinitionReader extends Object implements FacetDefinitionReader
x
, y
, and z
components in that order. The format can be described as follows:
p1x p1y p1z p2x p2y p2z p3x p3y p3z ...
where the p1 elements contain the coordinates of the first facet vertex,
p2 those of the second, and so on. At least 3 vertices are required for each
facet but more can be specified as long as all x, y, z
components are provided
for each vertex. The facet normal is defined implicitly from the facet vertices using
the right-hand rule (i.e. vertices are arranged counter-clockwise).
Delimiters
Vertex coordinate values may be separated by any character that is not a digit, alphabetic, '-' (minus), or '+' (plus). The character does not need to be consistent between (or even within) lines and does not need to be configured in the reader. This design provides configuration-free support for common formats such as CSV as well as other formats designed for human readability.
Comments
Comments are supported through use of the comment token
property. Characters from the comment token through the end of the current line are
discarded. Setting the comment token to null or the empty string disables comment parsing.
The default comment token is "#"
Examples
The following examples demonstrate the definition of two facets, one with 3 vertices and one with 4 vertices, in different formats.
CSV
0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0
Whitespace and semicolons
# line comment 0 0 0; 1 0 0; 1 1 0 # 3 vertices 1 0 0; 1 1 0; 1 1 1; 1 0 1 # 4 vertices
TextFacetDefinitionWriter
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_COMMENT_TOKEN
Default comment token string.
|
Constructor and Description |
---|
TextFacetDefinitionReader(Reader reader)
Construct a new instance that reads characters from the argument and uses
the default comment token value of .
|
TextFacetDefinitionReader(Reader reader,
String commentToken)
Construct a new instance with the given reader and comment token.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close this instance and release all associated resources.
|
String |
getCommentToken()
Get the comment token string.
|
FacetDefinition |
readFacet()
Return the next facet definition from the input source or null if no more
facets are available.
|
void |
setCommentToken(String commentToken)
Set the comment token string.
|
public static final String DEFAULT_COMMENT_TOKEN
public TextFacetDefinitionReader(Reader reader)
reader
- reader to read characters frompublic TextFacetDefinitionReader(Reader reader, String commentToken)
reader
- reader to read characters fromcommentToken
- comment token string; set to null to disable comment parsingIllegalArgumentException
- if commentToken
is non-null and contains whitespacepublic String getCommentToken()
public void setCommentToken(String commentToken)
commentToken
- token to setIllegalArgumentException
- if the argument is non-null and contains whitespacepublic FacetDefinition readFacet()
readFacet
in interface FacetDefinitionReader
public void close()
close
in interface AutoCloseable
close
in interface FacetDefinitionReader
Copyright © 2016–2021 The Apache Software Foundation. All rights reserved.