Class BoundaryIOManager3D


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 Details

    • BoundaryIOManager3D

      public BoundaryIOManager3D()
  • Method Details

    • facetDefinitionReader

      public FacetDefinitionReader facetDefinitionReader(GeometryInput in, GeometryFormat fmt)
      Get a FacetDefinitionReader for reading facet information from the given input.
      Parameters:
      in - input to read facets from
      fmt - format of the input; if null, the format is determined implicitly from the file extension of the input file name
      Returns:
      facet definition reader
      Throws:
      IllegalArgumentException - if no read handler can be found for the input format
      IllegalStateException - if a data format error occurs
      UncheckedIOException - if an I/O error occurs
    • facets

      Return a 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 = manager.facets(in, fmt)) {
            // access stream content
        }
       

      The following exceptions may be thrown during stream iteration:

      Parameters:
      in - input to read from
      fmt - format of the input; if null, the format is determined implicitly from the file extension of the input file name
      Returns:
      stream providing access to the facets in the input
      Throws:
      IllegalArgumentException - if no read handler can be found for the input format
      IllegalStateException - if a data format error occurs during stream creation
      UncheckedIOException - 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 a 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 = manager.triangles(in, fmt, precision)) {
            // access stream content
        }
       

      The following exceptions may be thrown during stream iteration:

      Parameters:
      in - input to read from
      fmt - 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 comparisons
      Returns:
      stream providing access to the triangles in the input
      Throws:
      IllegalArgumentException - if no read handler can be found for the input format
      IllegalStateException - if a data format error occurs during stream creation
      UncheckedIOException - 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 a TriangleMesh containing all triangles from the given input.
      Parameters:
      in - input to read from
      fmt - 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 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 format
      IllegalStateException - if a data format error occurs
      UncheckedIOException - 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 boundaries stream. 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 write
      out - output to write to
      fmt - format of the output; if null, the format is determined implicitly from the file extension of the output file name
      Throws:
      IllegalArgumentException - if no write handler can be found for the output format
      UncheckedIOException - 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 boundaries stream. 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 write
      out - output to write to
      fmt - format of the output; if null, the format is determined implicitly from the file extension of the output file name
      Throws:
      IllegalArgumentException - if no write handler can be found for the output format
      UncheckedIOException - 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 write
      out - output to write to
      fmt - format of the output; if null, the format is determined implicitly from the file extension of the output file name
      Throws:
      IllegalArgumentException - if no write handler can be found for the output format
      UncheckedIOException - 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 in GeometryFormat3D.