Class StlBoundaryWriteHandler3D

    • Field Detail

      • DEFAULT_BUFFER_SIZE

        private static final int DEFAULT_BUFFER_SIZE
        Initial size of the data buffer.
        See Also:
        Constant Field Values
      • initialBufferSize

        private int initialBufferSize
        Initial size of data buffers used during write operations.
    • Constructor Detail

      • StlBoundaryWriteHandler3D

        public StlBoundaryWriteHandler3D()
    • Method Detail

      • getFormat

        public GeometryFormat getFormat()
        Get the data format supported by this handler.
        Returns:
        data format supported by this handler
      • getinitialBufferSize

        public int getinitialBufferSize()
        Get the initial size of the data buffers used by this instance.

        The buffer is used in situations where it is not clear how many triangles will ultimately be written to the output. In these cases, the triangle data is first written to an internal buffer. Once all triangles are written, the STL header containing the total triangle count is written to the output, followed by the buffered triangle data.

        Returns:
        initial buffer size
      • setInitialBufferSize

        public void setInitialBufferSize​(int initialBufferSize)
        Set the initial size of the data buffers used by this instance.

        The buffer is used in situations where it is not clear how many triangles will ultimately be written to the output. In these cases, the triangle data is first written to an internal buffer. Once all triangles are written, the STL header containing the total triangle count is written to the output, followed by the buffered triangle data.

        Parameters:
        initialBufferSize - initial buffer size
      • write

        public void write​(java.util.stream.Stream<? extends PlaneConvexSubset> boundaries,
                          GeometryOutput out)
        Write all boundaries in the stream to the given output using the data format supported by this instance. The stream passed as an argument is not closed, meaning that callers are responsible for closing the stream if necessary (for example, if the stream fetches data from the file system).
        Parameters:
        boundaries - stream containing boundaries to write
        out - output to write to
      • writeFacets

        public void writeFacets​(java.util.stream.Stream<? extends FacetDefinition> facets,
                                GeometryOutput out)
        Write all facets in the stream to the output using the data format supported by this instance. The stream passed as an argument is not closed, meaning that callers are responsible for closing the stream if necessary (for example, if the stream fetches data from the file system).
        Parameters:
        facets - stream containing facets to write
        out - output to write to
      • writeWithHeader

        private void writeWithHeader​(java.io.ByteArrayOutputStream triangleBuffer,
                                     int count,
                                     GeometryOutput out)
        Write the given triangle data prefixed with an STL header to the output stream from out.
        Parameters:
        triangleBuffer - buffer containing STL triangle data
        count - number of triangles in triangleBuffer
        out - output to write to
        Throws:
        java.io.UncheckedIOException - if an I/O error occurs
      • writeTriangleMesh

        private void writeTriangleMesh​(TriangleMesh mesh,
                                       GeometryOutput output)
        Write all triangles in the given mesh to the output using the binary STL format.
        Parameters:
        mesh - mesh to write
        output - output to write to
        Throws:
        java.io.UncheckedIOException - if an I/O error occurs
      • getFacetAttributeValue

        private int getFacetAttributeValue​(FacetDefinition facet)
        Get the attribute value that should be used for the given facet.
        Parameters:
        facet - facet to get the attribute value for
        Returns:
        attribute value