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.core;
18  
19  import org.apache.commons.geometry.core.partitioning.BoundarySource;
20  import org.apache.commons.geometry.core.partitioning.HyperplaneConvexSubset;
21  import org.apache.commons.geometry.io.core.output.GeometryOutput;
22  
23  /** Basic interface for writing geometric boundary representations
24   * (<a href="https://en.wikipedia.org/wiki/Boundary_representation">B-reps</a>) in a specific data storage
25   * format. This interface is intended primarily for use with {@link BoundaryIOManager}.
26   *
27   * <p><strong>Implementation note:</strong> implementations of this interface <em>must</em>
28   * be thread-safe.</p>
29   * @param <H> Geometric boundary type
30   * @param <B> Boundary source type
31   * @see BoundaryReadHandler
32   * @see BoundaryIOManager
33   * @see <a href="https://en.wikipedia.org/wiki/Boundary_representations">Boundary representations</a>
34   */
35  public interface BoundaryWriteHandler<H extends HyperplaneConvexSubset<?>, B extends BoundarySource<H>> {
36  
37      /** Get the {@link GeometryFormat data format} supported by this handler.
38       * @return data format supported by this handler
39       */
40      GeometryFormat getFormat();
41  
42      /** Write all boundaries from {@code src} to the given output, using the data format for
43       * the instance.
44       * @param src boundary source
45       * @param out output to write to
46       * @throws java.io.UncheckedIOException if an I/O error occurs
47       */
48      void write(B src, GeometryOutput out);
49  }