public final class IO3D extends Object
BoundaryIOManager3D
instance. The default
configuration should be sufficient for most purposes. If customization is required, consider directly
creating and configuring and a BoundaryIOManager3D
instance.
Examples
The example below reads an OBJ file as a stream of triangles, transforms each triangle, and writes the result as a CSV file. The data formats are inferred from the input and output file extensions.
GeometryInput input = new FileGeometryInput(Paths.get("orig.obj")); GeometryOutput scaledOutput = new FileGeometryOutput(Paths.get("scaled.csv")); AffineTransformMatrix3D transform = AffineTransformMatrix3D.createScale(2); // Use the input triangle stream in a try-with-resources statement to ensure // all resources are properly released. try (Stream<Triangle3D> stream = IO3D.triangles(input, null, precision)) { IO3D.write(stream.map(t -> t.transform(transform)), scaledOutput, null); }
BoundaryIOManager3D
Modifier and Type | Method and Description |
---|---|
static Stream<PlaneConvexSubset> |
boundaries(GeometryInput in,
GeometryFormat fmt,
Precision.DoubleEquivalence precision)
Return a
Stream providing access to all boundaries from the given input. |
static Stream<PlaneConvexSubset> |
boundaries(Path path,
Precision.DoubleEquivalence precision)
Return a
Stream providing access to all boundaries from the given file path. |
static Stream<PlaneConvexSubset> |
boundaries(URL url,
Precision.DoubleEquivalence precision)
Return a
Stream providing access to all boundaries from the given URL. |
static FacetDefinitionReader |
facetDefinitionReader(GeometryInput in,
GeometryFormat fmt)
Get a
FacetDefinitionReader for reading facet information from the given input. |
static FacetDefinitionReader |
facetDefinitionReader(Path path)
Get a
FacetDefinitionReader for reading facet information from the given file path. |
static FacetDefinitionReader |
facetDefinitionReader(URL url)
Get a
FacetDefinitionReader for reading facet information from the given URL. |
static Stream<FacetDefinition> |
facets(GeometryInput in,
GeometryFormat fmt)
Return a
Stream providing access to all facets from the given input. |
static Stream<FacetDefinition> |
facets(Path path)
Return a
Stream providing access to all facets from the given file path. |
static Stream<FacetDefinition> |
facets(URL url)
Return a
Stream providing access to all facets from the given URL. |
static BoundaryIOManager3D |
getDefaultManager()
Get the default
BoundaryIOManager3D instance. |
static BoundarySource3D |
read(GeometryInput in,
GeometryFormat fmt,
Precision.DoubleEquivalence precision)
Return a
BoundarySource3D containing all boundaries from the given input. |
static BoundarySource3D |
read(Path path,
Precision.DoubleEquivalence precision)
Return a
BoundarySource3D containing all boundaries from the file at the
given path. |
static BoundarySource3D |
read(URL url,
Precision.DoubleEquivalence precision)
Return a
BoundarySource3D containing all boundaries from the given URL. |
static TriangleMesh |
readTriangleMesh(GeometryInput in,
GeometryFormat fmt,
Precision.DoubleEquivalence precision)
Return a
TriangleMesh containing all triangles from the given input. |
static TriangleMesh |
readTriangleMesh(Path path,
Precision.DoubleEquivalence precision)
Return a
TriangleMesh containing all triangles from the given file path. |
static TriangleMesh |
readTriangleMesh(URL url,
Precision.DoubleEquivalence precision)
Return a
TriangleMesh containing all triangles from the given URL. |
static Stream<Triangle3D> |
triangles(GeometryInput in,
GeometryFormat fmt,
Precision.DoubleEquivalence precision)
Return a
Stream providing access to all triangles from the given input. |
static Stream<Triangle3D> |
triangles(Path path,
Precision.DoubleEquivalence precision)
Return a
Stream providing access to all triangles from the given file path. |
static Stream<Triangle3D> |
triangles(URL url,
Precision.DoubleEquivalence precision)
Return a
Stream providing access to all triangles from the given URL. |
static void |
write(BoundarySource3D src,
GeometryOutput out,
GeometryFormat fmt)
Write all boundaries from
src to the given output. |
static void |
write(BoundarySource3D src,
Path path)
Write all boundaries from
src to the given file path. |
static void |
write(Stream<? extends PlaneConvexSubset> boundaries,
GeometryOutput out,
GeometryFormat fmt)
Write all boundaries in the stream to the output.
|
static void |
write(Stream<? extends PlaneConvexSubset> boundaries,
Path path)
Write all boundaries in the stream to given file path.
|
static void |
writeFacets(Collection<? extends FacetDefinition> facets,
GeometryOutput out,
GeometryFormat fmt)
Write the given collection of facets to the output.
|
static void |
writeFacets(Collection<? extends FacetDefinition> facets,
Path path)
Write the given facets to the file path.
|
static void |
writeFacets(Stream<? extends FacetDefinition> facets,
GeometryOutput out,
GeometryFormat fmt)
Write all facets in the stream to the output.
|
static void |
writeFacets(Stream<? extends FacetDefinition> facets,
Path path)
Write all facets in the stream to the file path.
|
public static FacetDefinitionReader facetDefinitionReader(Path path)
FacetDefinitionReader
for reading facet information from the given file path.
The data format is determined by the file extension of the argument.path
- path to obtain a reader forIllegalArgumentException
- if no handler has been registered with the
default manager
for the input formatIllegalStateException
- if a data format error occursUncheckedIOException
- if an I/O error occursBoundaryIOManager3D.facetDefinitionReader(GeometryInput, GeometryFormat)
public static FacetDefinitionReader facetDefinitionReader(URL url)
FacetDefinitionReader
for reading facet information from the given URL.
The data format is determined by the file extension of the argument.url
- URL to read fromIllegalArgumentException
- if no handler has been registered with the
default manager
for the input formatIllegalStateException
- if a data format error occursUncheckedIOException
- if an I/O error occursBoundaryIOManager3D.facetDefinitionReader(GeometryInput, GeometryFormat)
public static FacetDefinitionReader facetDefinitionReader(GeometryInput in, GeometryFormat fmt)
FacetDefinitionReader
for reading facet information from the given input.in
- input to read fromfmt
- format of the input; if null, the format is determined implicitly from the
file extension of the input file name
IllegalArgumentException
- if no handler has been registered with the
default manager
for the input formatIllegalStateException
- if a data format error occursUncheckedIOException
- if an I/O error occursBoundaryIOManager3D.facetDefinitionReader(GeometryInput, GeometryFormat)
public static Stream<FacetDefinition> facets(Path path)
Stream
providing access to all facets from the given file path. The data format
is determined by the file extension of the argument.
The underlying input stream is closed when the returned stream is closed. Callers should therefore use the returned stream in a try-with-resources statement to ensure that all resources are properly released. Ex:
try (Stream<FacetDefinition> stream = IO3D.facets(path)) { // access stream content }
The following exceptions may be thrown during stream iteration:
IllegalStateException
if a data format error occursUncheckedIOException
if an I/O error occurspath
- file path to read fromIllegalArgumentException
- if no handler has been registered with the
default manager
for the input formatIllegalStateException
- if a data format error occurs during stream creationUncheckedIOException
- if an I/O error occurs during stream creationBoundaryIOManager3D.facets(GeometryInput, GeometryFormat)
public static Stream<FacetDefinition> facets(URL url)
Stream
providing access to all facets from the given URL. he data format
is determined by the file extension of the argument.
The underlying input stream is closed when the returned stream is closed. Callers should therefore use the returned stream in a try-with-resources statement to ensure that all resources are properly released. Ex:
try (Stream<FacetDefinition> stream = IO3D.facets(url)) { // access stream content }
The following exceptions may be thrown during stream iteration:
IllegalStateException
if a data format error occursUncheckedIOException
if an I/O error occursurl
- URL to read fromIllegalArgumentException
- if no handler has been registered with the
default manager
for the input formatIllegalStateException
- if a data format error occurs during stream creationUncheckedIOException
- if an I/O error occurs during stream creationBoundaryIOManager3D.facets(GeometryInput, GeometryFormat)
public static Stream<FacetDefinition> facets(GeometryInput in, GeometryFormat fmt)
Stream
providing access to all facets from the given input. The underlying input
stream is closed when the returned stream is closed. Callers should therefore use the returned stream
in a try-with-resources statement to ensure that all resources are properly released.
try (Stream<FacetDefinition> stream = IO3D.facets(in, fmt)) { // access stream content }
The following exceptions may be thrown during stream iteration:
IllegalStateException
if a data format error occursUncheckedIOException
if an I/O error occursin
- input to read fromfmt
- format of the input; if null, the format is determined implicitly from the
file extension of the input file name
IllegalArgumentException
- if no read handler has been registered with the
default manager
for the input formatIllegalStateException
- if a data format error occurs during stream creationUncheckedIOException
- if an I/O error occurs during stream creationBoundaryIOManager3D.facets(GeometryInput, GeometryFormat)
public static Stream<PlaneConvexSubset> boundaries(Path path, Precision.DoubleEquivalence precision)
Stream
providing access to all boundaries from the given file path. The
data format is determined by the file extension of the argument.
The underlying input stream is closed when the returned stream is closed. Callers should therefore use the returned stream in a try-with-resources statement to ensure that all resources are properly released. Ex:
try (Stream<PlaneConvexSubset> stream = IO3D.boundaries(path, precision)) { // access stream content }
The following exceptions may be thrown during stream iteration:
IllegalArgumentException
if mathematically invalid data is encounteredIllegalStateException
if a data format error occursUncheckedIOException
if an I/O error occurspath
- file path to read fromprecision
- precision context used for floating point comparisonsIllegalArgumentException
- if no read handler has been registered with the
default manager
for the input formatIllegalStateException
- if a data format error occurs during stream creationUncheckedIOException
- if an I/O error occurs during stream creationBoundaryIOManager.boundaries(GeometryInput, GeometryFormat, Precision.DoubleEquivalence)
public static Stream<PlaneConvexSubset> boundaries(URL url, Precision.DoubleEquivalence precision)
Stream
providing access to all boundaries from the given URL. The data
format is determined by the file extension of the argument.
The underlying input stream is closed when the returned stream is closed. Callers should therefore use the returned stream in a try-with-resources statement to ensure that all resources are properly released. Ex:
try (Stream<PlaneConvexSubset> stream = IO3D.boundaries(url, precision)) { // access stream content }
The following exceptions may be thrown during stream iteration:
IllegalArgumentException
if mathematically invalid data is encounteredIllegalStateException
if a data format error occursUncheckedIOException
if an I/O error occursurl
- URL to read fromprecision
- precision context used for floating point comparisonsIllegalArgumentException
- if no read handler has been registered with the
default manager
for the input formatIllegalStateException
- if a data format error occurs during stream creationUncheckedIOException
- if an I/O error occurs during stream creationBoundaryIOManager.boundaries(GeometryInput, GeometryFormat, Precision.DoubleEquivalence)
public static Stream<PlaneConvexSubset> boundaries(GeometryInput in, GeometryFormat fmt, Precision.DoubleEquivalence precision)
Stream
providing access to all boundaries from the given input. The underlying input
stream is closed when the returned stream is closed. Callers should therefore use the returned stream
in a try-with-resources statement to ensure that all resources are properly released. Ex:
try (Stream<H> stream = IO3D.boundaries(in, fmt, precision)) { // access stream content }
The following exceptions may be thrown during stream iteration:
IllegalArgumentException
if mathematically invalid data is encounteredIllegalStateException
if a data format error occursUncheckedIOException
if an I/O error occursin
- input to read boundaries fromfmt
- format of the input; if null, the format is determined implicitly from the
file extension of the input file name
precision
- precision context used for floating point comparisonsIllegalArgumentException
- if no read handler is registered with the
default manager
for the input formatIllegalStateException
- if a data format error occurs during stream creationUncheckedIOException
- if an I/O error occurs during stream creationBoundaryIOManager.boundaries(GeometryInput, GeometryFormat, Precision.DoubleEquivalence)
public static Stream<Triangle3D> triangles(Path path, Precision.DoubleEquivalence precision)
Stream
providing access to all triangles from the given file path. The data
format is determined by the file extension of the argument.
The underlying input stream is closed when the returned stream is closed. Callers should therefore use the returned stream in a try-with-resources statement to ensure that all resources are properly released. Ex:
try (Stream<Triangle3D> stream = IO3D.triangles(path, precision)) { // access stream content }
The following exceptions may be thrown during stream iteration:
IllegalArgumentException
if mathematically invalid data is encounteredIllegalStateException
if a data format error occursUncheckedIOException
if an I/O error occurspath
- file path to read fromprecision
- precision context used for floating point comparisonsIllegalArgumentException
- if no read handler is registered with the
default manager
for the input formatIllegalStateException
- if a data format error occurs during stream creationUncheckedIOException
- if an I/O error occurs during stream creationBoundaryIOManager3D.triangles(GeometryInput, GeometryFormat, Precision.DoubleEquivalence)
public static Stream<Triangle3D> triangles(URL url, Precision.DoubleEquivalence precision)
Stream
providing access to all triangles from the given URL. The data format
is determined by the file extension of the argument.
The underlying input stream is closed when the returned stream is closed. Callers should therefore use the returned stream in a try-with-resources statement to ensure that all resources are properly released. Ex:
try (Stream<Triangle3D> stream = IO3D.triangles(url, precision)) { // access stream content }
The following exceptions may be thrown during stream iteration:
IllegalArgumentException
if mathematically invalid data is encounteredIllegalStateException
if a data format error occursUncheckedIOException
if an I/O error occursurl
- URL to read fromprecision
- precision context used for floating point comparisonsIllegalArgumentException
- if no read handler is registered with the
default manager
for the input formatIllegalStateException
- if a data format error occurs during stream creationUncheckedIOException
- if an I/O error occurs during stream creationBoundaryIOManager3D.triangles(GeometryInput, GeometryFormat, Precision.DoubleEquivalence)
public static Stream<Triangle3D> triangles(GeometryInput in, GeometryFormat fmt, Precision.DoubleEquivalence precision)
Stream
providing access to all triangles from the given input. The underlying input
stream is closed when the returned stream is closed. Callers should therefore use the returned stream
in a try-with-resources statement to ensure that all resources are properly released.
try (Stream<Triangle3D> stream = IO3D.triangles(in, fmt, precision)) { // access stream content }
The following exceptions may be thrown during stream iteration:
IllegalArgumentException
if mathematically invalid data is encounteredIllegalStateException
if a data format error occursUncheckedIOException
if an I/O error occursin
- input to read fromfmt
- format of the input; if null, the format is determined implicitly from the
file extension of the input file name
precision
- precision context used for floating point comparisonsIllegalArgumentException
- if no read handler is registered with the
default manager
for the input formatIllegalStateException
- if a data format error occurs during stream creationUncheckedIOException
- if an I/O error occurs during stream creationBoundaryIOManager3D.triangles(GeometryInput, GeometryFormat, Precision.DoubleEquivalence)
public static BoundarySource3D read(Path path, Precision.DoubleEquivalence precision)
BoundarySource3D
containing all boundaries from the file at the
given path. The data format is determined from the file extension. A runtime exception may be
thrown if mathematically invalid boundaries are encountered.path
- file path to read fromprecision
- precision context used for floating point comparisonsIllegalArgumentException
- if mathematically invalid data is encountered or no read handler
is registered with the default manager
for the input formatIllegalStateException
- if a data format error occursUncheckedIOException
- if an I/O error occursBoundaryIOManager.read(GeometryInput, GeometryFormat, Precision.DoubleEquivalence)
public static BoundarySource3D read(URL url, Precision.DoubleEquivalence precision)
BoundarySource3D
containing all boundaries from the given URL. The data
format is determined from the file extension of the URL path. A runtime exception may be
thrown if mathematically invalid boundaries are encountered.url
- URL to read fromprecision
- precision context used for floating point comparisonsIllegalArgumentException
- if mathematically invalid data is encountered or no read handler
is registered with the default manager
for the input formatIllegalStateException
- if a data format error occursUncheckedIOException
- if an I/O error occursBoundaryIOManager.read(GeometryInput, GeometryFormat, Precision.DoubleEquivalence)
public static BoundarySource3D read(GeometryInput in, GeometryFormat fmt, Precision.DoubleEquivalence precision)
BoundarySource3D
containing all boundaries from the given input. A runtime
exception may be thrown if mathematically invalid boundaries are encountered.in
- input to read boundaries fromfmt
- format of the input; if null, the format is determined implicitly from the
file extension of the input file name
precision
- precision context used for floating point comparisonsIllegalArgumentException
- if mathematically invalid data is encountered or no read handler
is registered with the default manager
for the input formatIllegalStateException
- if a data format error occursUncheckedIOException
- if an I/O error occursBoundaryIOManager.read(GeometryInput, GeometryFormat, Precision.DoubleEquivalence)
public static TriangleMesh readTriangleMesh(Path path, Precision.DoubleEquivalence precision)
TriangleMesh
containing all triangles from the given file path. The data
format is determined from the file extension of the path. A runtime exception may be
thrown if mathematically invalid boundaries are encountered.path
- file path to read fromprecision
- precision context used for floating point comparisonsIllegalArgumentException
- if mathematically invalid data is encountered or no read handler
is registered with the default manager
for the input formatIllegalStateException
- if a data format error occursUncheckedIOException
- if an I/O error occursBoundaryIOManager3D.readTriangleMesh(GeometryInput, GeometryFormat, Precision.DoubleEquivalence)
public static TriangleMesh readTriangleMesh(URL url, Precision.DoubleEquivalence precision)
TriangleMesh
containing all triangles from the given URL. The data
format is determined from the file extension of the URL path. A runtime exception may be
thrown if mathematically invalid boundaries are encountered.url
- URL to read fromprecision
- precision context used for floating point comparisonsIllegalArgumentException
- if mathematically invalid data is encountered or no read handler
is registered with the default manager
for the input formatIllegalStateException
- if a data format error occursUncheckedIOException
- if an I/O error occursBoundaryIOManager3D.readTriangleMesh(GeometryInput, GeometryFormat, Precision.DoubleEquivalence)
public static TriangleMesh readTriangleMesh(GeometryInput in, GeometryFormat fmt, Precision.DoubleEquivalence precision)
TriangleMesh
containing all triangles from the given input. A runtime exception
may be thrown if mathematically invalid boundaries are encountered.in
- input to read fromfmt
- format of the input; if null, the format is determined implicitly from the
file extension of the input file name
precision
- precision context used for floating point comparisonsIllegalArgumentException
- if mathematically invalid data is encountered or no read handler
is registered with the default manager
for the input formatIllegalStateException
- if a data format error occursUncheckedIOException
- if an I/O error occursBoundaryIOManager3D.readTriangleMesh(GeometryInput, GeometryFormat, Precision.DoubleEquivalence)
public static void write(Stream<? extends PlaneConvexSubset> boundaries, Path path)
This method does not explicitly close the boundaries
stream. Callers should use the stream
in a try-with-resources statement outside of this method if the stream is required to be closed.
boundaries
- stream containing boundaries to writepath
- file path to write toIllegalArgumentException
- if no write handler is registered with the
default manager
for the output formatUncheckedIOException
- if an I/O error occursBoundaryIOManager3D.write(Stream, GeometryOutput, GeometryFormat)
public static void write(Stream<? extends PlaneConvexSubset> boundaries, GeometryOutput out, GeometryFormat fmt)
This method does not explicitly close the boundaries
stream. Callers should use the stream
in a try-with-resources statement outside of this method if the stream is required to be closed.
boundaries
- stream containing boundaries to writeout
- output to write tofmt
- format of the output; if null, the format is determined implicitly from the
file extension of the output file name
IllegalArgumentException
- if no write handler is registered with the
default manager
for the output formatUncheckedIOException
- if an I/O error occursBoundaryIOManager3D.write(Stream, GeometryOutput, GeometryFormat)
public static void write(BoundarySource3D src, Path path)
src
to the given file path. The data format
is determined by the file extension of the target path. If the target path already exists,
it is overwritten.src
- boundary source containing the boundaries to writepath
- file path to write toIllegalArgumentException
- if no write handler is registered with the
default manager
for the output formatUncheckedIOException
- if an I/O error occursBoundaryIOManager.write(
org.apache.commons.geometry.core.partitioning.BoundarySource, GeometryOutput, GeometryFormat)
public static void write(BoundarySource3D src, GeometryOutput out, GeometryFormat fmt)
src
to the given output.src
- boundary source containing the boundaries to writeout
- output to write tofmt
- format of the output; if null, the format is determined implicitly from the
file extension of the output file name
IllegalArgumentException
- if no write handler is registered with the
default manager
for the output formatUncheckedIOException
- if an I/O error occursBoundaryIOManager.write(
org.apache.commons.geometry.core.partitioning.BoundarySource, GeometryOutput, GeometryFormat)
public static void writeFacets(Collection<? extends FacetDefinition> facets, Path path)
facets
- facets to writepath
- path to write toIllegalArgumentException
- if no write handler is registered with the
default manager
for the output formatUncheckedIOException
- if an I/O error occursBoundaryIOManager3D.writeFacets(Collection, GeometryOutput, GeometryFormat)
public static void writeFacets(Collection<? extends FacetDefinition> facets, GeometryOutput out, GeometryFormat fmt)
facets
- facets to writeout
- output to write tofmt
- format of the output; if null, the format is determined implicitly from the
file extension of the output file name
IllegalArgumentException
- if no write handler is registered with the
default manager
for the output formatUncheckedIOException
- if an I/O error occursBoundaryIOManager3D.writeFacets(Collection, GeometryOutput, GeometryFormat)
public static void writeFacets(Stream<? extends FacetDefinition> facets, Path path)
This method does not explicitly close the facets
stream. Callers should use the stream
in a try-with-resources statement outside of this method if the stream is required to be closed.
facets
- stream containing facets to writepath
- path to write toIllegalArgumentException
- if no write handler is registered with the
default manager
for the output formatUncheckedIOException
- if an I/O error occursBoundaryIOManager3D.writeFacets(Stream, GeometryOutput, GeometryFormat)
public static void writeFacets(Stream<? extends FacetDefinition> facets, GeometryOutput out, GeometryFormat fmt)
This method does not explicitly close the facets
stream. Callers should use the stream
in a try-with-resources statement outside of this method if the stream is required to be closed.
facets
- stream containing facets to writeout
- output to write tofmt
- format of the output; if null, the format is determined implicitly from the
file extension of the output file name
IllegalArgumentException
- if no write handler is registered with the
default manager
for the output formatUncheckedIOException
- if an I/O error occursBoundaryIOManager3D.writeFacets(Stream, GeometryOutput, GeometryFormat)
public static BoundaryIOManager3D getDefaultManager()
BoundaryIOManager3D
instance.BoundaryIOManager3D
instanceCopyright © 2016–2021 The Apache Software Foundation. All rights reserved.