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.euclidean.threed; 018 019import java.util.Collection; 020import java.util.stream.Stream; 021 022import org.apache.commons.geometry.euclidean.threed.BoundarySource3D; 023import org.apache.commons.geometry.euclidean.threed.PlaneConvexSubset; 024import org.apache.commons.geometry.io.core.BoundaryWriteHandler; 025import org.apache.commons.geometry.io.core.output.GeometryOutput; 026 027/** Basic interface for writing 3D geometric boundary representations 028 * (<a href="https://en.wikipedia.org/wiki/Boundary_representation">B-reps</a>) in a specific data storage 029 * format. This interface is primarily intended for use with {@link BoundaryIOManager3D}. 030 * 031 * <p><strong>Implementation note:</strong> implementations of this interface <em>must</em> 032 * be thread-safe.</p> 033 * 034 * @see <a href="https://en.wikipedia.org/wiki/Boundary_representations">Boundary representations</a> 035 * @see BoundaryReadHandler3D 036 * @see BoundaryIOManager3D 037 */ 038public interface BoundaryWriteHandler3D extends BoundaryWriteHandler<PlaneConvexSubset, BoundarySource3D> { 039 040 /** Write all boundaries in the stream to the given output using the data format supported by this 041 * instance. The stream passed as an argument is <em>not</em> closed, meaning that callers are responsible 042 * for closing the stream if necessary (for example, if the stream fetches data from the file system). 043 * @param boundaries stream containing boundaries to write 044 * @param out output to write to 045 * @throws java.io.UncheckedIOException if an I/O error occurs 046 */ 047 void write(Stream<? extends PlaneConvexSubset> boundaries, GeometryOutput out); 048 049 /** Write all {@link FacetDefinition facets} in the collection to the output using the data format 050 * supported by this instance. 051 * @param facets facets to write 052 * @param out output to write to 053 * @throws java.io.UncheckedIOException if an I/O error occurs 054 */ 055 void writeFacets(Collection<? extends FacetDefinition> facets, GeometryOutput out); 056 057 /** Write all {@link FacetDefinition facets} in the stream to the output using the data format 058 * supported by this instance. The stream passed as an argument is <em>not</em> closed, meaning 059 * that callers are responsible for closing the stream if necessary (for example, if the stream 060 * fetches data from the file system). 061 * @param facets stream containing facets to write 062 * @param out output to write to 063 * @throws java.io.UncheckedIOException if an I/O error occurs 064 */ 065 void writeFacets(Stream<? extends FacetDefinition> facets, GeometryOutput out); 066}