001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.commons.geometry.io.core;
018
019import org.apache.commons.geometry.core.partitioning.BoundarySource;
020import org.apache.commons.geometry.core.partitioning.HyperplaneConvexSubset;
021import org.apache.commons.geometry.io.core.output.GeometryOutput;
022
023/** Basic interface for writing geometric boundary representations
024 * (<a href="https://en.wikipedia.org/wiki/Boundary_representation">B-reps</a>) in a specific data storage
025 * format. This interface is intended primarily for use with {@link BoundaryIOManager}.
026 *
027 * <p><strong>Implementation note:</strong> implementations of this interface <em>must</em>
028 * be thread-safe.</p>
029 * @param <H> Geometric boundary type
030 * @param <B> Boundary source type
031 * @see BoundaryReadHandler
032 * @see BoundaryIOManager
033 * @see <a href="https://en.wikipedia.org/wiki/Boundary_representations">Boundary representations</a>
034 */
035public interface BoundaryWriteHandler<H extends HyperplaneConvexSubset<?>, B extends BoundarySource<H>> {
036
037    /** Get the {@link GeometryFormat data format} supported by this handler.
038     * @return data format supported by this handler
039     */
040    GeometryFormat getFormat();
041
042    /** Write all boundaries from {@code src} to the given output, using the data format for
043     * the instance.
044     * @param src boundary source
045     * @param out output to write to
046     * @throws java.io.UncheckedIOException if an I/O error occurs
047     */
048    void write(B src, GeometryOutput out);
049}