Class BoundaryIOManager3D
java.lang.Object
org.apache.commons.geometry.io.core.BoundaryIOManager<PlaneConvexSubset,BoundarySource3D,BoundaryReadHandler3D,BoundaryWriteHandler3D>
org.apache.commons.geometry.io.euclidean.threed.BoundaryIOManager3D
public class BoundaryIOManager3D
extends BoundaryIOManager<PlaneConvexSubset,BoundarySource3D,BoundaryReadHandler3D,BoundaryWriteHandler3D>
Class managing IO operations for geometric data formats containing 3D region boundaries.
IO operation are performed by read and write handlers registered for specific data formats.
Implementation note:Instances of this class are thread-safe as long as the registered handler instances are thread-safe.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet aFacetDefinitionReaderfor reading facet information from the given input.facets(GeometryInput in, GeometryFormat fmt) Return aStreamproviding access to all facets from the given input.readTriangleMesh(GeometryInput in, GeometryFormat fmt, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision) Return aTriangleMeshcontaining all triangles from the given input.voidRegister default read/write handlers.triangles(GeometryInput in, GeometryFormat fmt, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision) Return aStreamproviding access to all triangles from the given input.voidwrite(Stream<? extends PlaneConvexSubset> boundaries, GeometryOutput out, GeometryFormat fmt) Write all boundaries in the stream to the output.voidwriteFacets(Collection<? extends FacetDefinition> facets, GeometryOutput out, GeometryFormat fmt) Write the given facets to the output.voidwriteFacets(Stream<? extends FacetDefinition> facets, GeometryOutput out, GeometryFormat fmt) Write all facet in the stream to the output.Methods inherited from class org.apache.commons.geometry.io.core.BoundaryIOManager
boundaries, getReadFormats, getReadHandlerForFileExtension, getReadHandlerForFormat, getReadHandlers, getWriteFormats, getWriteHandlerForFileExtension, getWriteHandlerForFormat, getWriteHandlers, read, registerReadHandler, registerWriteHandler, requireReadHandler, requireWriteHandler, unregisterReadHandler, unregisterWriteHandler, write
-
Constructor Details
-
BoundaryIOManager3D
public BoundaryIOManager3D()
-
-
Method Details
-
facetDefinitionReader
Get aFacetDefinitionReaderfor reading facet information from the given input.- Parameters:
in- input to read facets fromfmt- format of the input; if null, the format is determined implicitly from the file extension of the inputfile name- Returns:
- facet definition reader
- Throws:
IllegalArgumentException- if no read handler can be found for the input formatIllegalStateException- if a data format error occursUncheckedIOException- if an I/O error occurs
-
facets
Return aStreamproviding 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 = manager.facets(in, fmt)) { // access stream content }The following exceptions may be thrown during stream iteration:
IllegalStateExceptionif a data format error occursUncheckedIOExceptionif an I/O error occurs
- Parameters:
in- input to read fromfmt- format of the input; if null, the format is determined implicitly from the file extension of the inputfile name- Returns:
- stream providing access to the facets in the input
- Throws:
IllegalArgumentException- if no read handler can be found for the input formatIllegalStateException- if a data format error occurs during stream creationUncheckedIOException- if an I/O error occurs during stream creation
-
triangles
public Stream<Triangle3D> triangles(GeometryInput in, GeometryFormat fmt, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision) Return aStreamproviding 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 = manager.triangles(in, fmt, precision)) { // access stream content }The following exceptions may be thrown during stream iteration:
IllegalArgumentExceptionif mathematically invalid data is encounteredIllegalStateExceptionif a data format error occursUncheckedIOExceptionif an I/O error occurs
- Parameters:
in- input to read fromfmt- format of the input; if null, the format is determined implicitly from the file extension of the inputfile nameprecision- precision context used for floating point comparisons- Returns:
- stream providing access to the triangles in the input
- Throws:
IllegalArgumentException- if no read handler can be found for the input formatIllegalStateException- if a data format error occurs during stream creationUncheckedIOException- if an I/O error occurs during stream creation
-
readTriangleMesh
public TriangleMesh readTriangleMesh(GeometryInput in, GeometryFormat fmt, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision) Return aTriangleMeshcontaining all triangles from the given input.- Parameters:
in- input to read fromfmt- format of the input; if null, the format is determined implicitly from the file extension of the inputfile nameprecision- precision context used for floating point comparisons- Returns:
- mesh containing all triangles from the input
- Throws:
IllegalArgumentException- if mathematically invalid data is encountered or no read handler can be found for the input formatIllegalStateException- if a data format error occursUncheckedIOException- if an I/O error occurs
-
write
public void write(Stream<? extends PlaneConvexSubset> boundaries, GeometryOutput out, GeometryFormat fmt) Write all boundaries in the stream to the output.This method does not explicitly close the
boundariesstream. If callers need to ensure that the stream is closed (for example, if the stream is reading from a file), they should use it in a try-with-resources statement outside of this method.- Parameters:
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 outputfile name- Throws:
IllegalArgumentException- if no write handler can be found for the output formatUncheckedIOException- if an I/O error occurs
-
writeFacets
public void writeFacets(Stream<? extends FacetDefinition> facets, GeometryOutput out, GeometryFormat fmt) Write all facet in the stream to the output.This method does not explicitly close the
boundariesstream. If callers need to ensure that the stream is closed (for example, if the stream is reading from a file), they should use it in a try-with-resources statement outside of this method.- Parameters:
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 outputfile name- Throws:
IllegalArgumentException- if no write handler can be found for the output formatUncheckedIOException- if an I/O error occurs
-
writeFacets
public void writeFacets(Collection<? extends FacetDefinition> facets, GeometryOutput out, GeometryFormat fmt) Write the given facets to the output.- Parameters:
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 outputfile name- Throws:
IllegalArgumentException- if no write handler can be found for the output formatUncheckedIOException- if an I/O error occurs
-
registerDefaultHandlers
public void registerDefaultHandlers()Register default read/write handlers. This method registers a read and write handler for each value inGeometryFormat3D.
-