View Javadoc

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *      http://www.apache.org/licenses/LICENSE-2.0
    10   *
    11   * Unless required by applicable law or agreed to in writing, software
    12   * distributed under the License is distributed on an "AS IS" BASIS,
    13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14   * See the License for the specific language governing permissions and
    15   * limitations under the License.
    16   */
    17  package org.apache.commons.geometry.io.euclidean.threed;
    18
    19  import java.util.Collection;
    20  import java.util.stream.Stream;
    21
    22  import org.apache.commons.geometry.euclidean.threed.BoundarySource3D;
    23  import org.apache.commons.geometry.euclidean.threed.PlaneConvexSubset;
    24  import org.apache.commons.geometry.io.core.BoundaryWriteHandler;
    25  import org.apache.commons.geometry.io.core.output.GeometryOutput;
    26
    27  /** Basic interface for writing 3D geometric boundary representations
    28   * (<a href="https://en.wikipedia.org/wiki/Boundary_representation">B-reps</a>) in a specific data storage
    29   * format. This interface is primarily intended for use with {@link BoundaryIOManager3D}.
    30   *
    31   * <p><strong>Implementation note:</strong> implementations of this interface <em>must</em>
    32   * be thread-safe.</p>
    33   *
    34   * @see <a href="https://en.wikipedia.org/wiki/Boundary_representations">Boundary representations</a>
    35   * @see BoundaryReadHandler3D
    36   * @see BoundaryIOManager3D
    37   */
    38  public interface BoundaryWriteHandler3D extends BoundaryWriteHandler<PlaneConvexSubset, BoundarySource3D> {
    39
    40      /** Write all boundaries in the stream to the given output using the data format supported by this
    41       * instance. The stream passed as an argument is <em>not</em> closed, meaning that callers are responsible
    42       * for closing the stream if necessary (for example, if the stream fetches data from the file system).
    43       * @param boundaries stream containing boundaries to write
    44       * @param out output to write to
    45       * @throws java.io.UncheckedIOException if an I/O error occurs
    46       */
    47      void write(Stream<? extends PlaneConvexSubset> boundaries, GeometryOutput out);
    48
    49      /** Write all {@link FacetDefinition facets} in the collection to the output using the data format
    50       * supported by this instance.
    51       * @param facets facets to write
    52       * @param out output to write to
    53       * @throws java.io.UncheckedIOException if an I/O error occurs
    54       */
    55      void writeFacets(Collection<? extends FacetDefinition> facets, GeometryOutput out);
    56
    57      /** Write all {@link FacetDefinition facets} in the stream to the output using the data format
    58       * supported by this instance. The stream passed as an argument is <em>not</em> closed, meaning
    59       * that callers are responsible for closing the stream if necessary (for example, if the stream
    60       * fetches data from the file system).
    61       * @param facets stream containing facets to write
    62       * @param out output to write to
    63       * @throws java.io.UncheckedIOException if an I/O error occurs
    64       */
    65      void writeFacets(Stream<? extends FacetDefinition> facets, GeometryOutput out);
    66  }