Class StlBoundaryWriteHandler3D
java.lang.Object
org.apache.commons.geometry.io.euclidean.threed.AbstractBoundaryWriteHandler3D
org.apache.commons.geometry.io.euclidean.threed.stl.StlBoundaryWriteHandler3D
- All Implemented Interfaces:
BoundaryWriteHandler<PlaneConvexSubset,
,BoundarySource3D> BoundaryWriteHandler3D
BoundaryWriteHandler3D
implementation for writing STL content. Because of its compact nature, all STL content is written in
binary format, as opposed the text (i.e. "ASCII") format. Callers should use the TextStlWriter
class directly in order to create text STL content.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
Initial size of the data buffer.private int
Initial size of data buffers used during write operations. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate int
Get the attribute value that should be used for the given facet.Get thedata format
supported by this handler.int
Get the initial size of the data buffers used by this instance.void
setInitialBufferSize
(int initialBufferSize) Set the initial size of the data buffers used by this instance.void
write
(Stream<? extends PlaneConvexSubset> boundaries, GeometryOutput out) Write all boundaries in the stream to the given output using the data format supported by this instance.void
write
(BoundarySource3D src, GeometryOutput out) Write all boundaries fromsrc
to the given output, using the data format for the instance.void
writeFacets
(Stream<? extends FacetDefinition> facets, GeometryOutput out) Write allfacets
in the stream to the output using the data format supported by this instance.private void
writeTriangleMesh
(TriangleMesh mesh, GeometryOutput output) Write all triangles in the given mesh to the output using the binary STL format.private void
writeWithHeader
(ByteArrayOutputStream triangleBuffer, int count, GeometryOutput out) Write the given triangle data prefixed with an STL header to the output stream fromout
.Methods inherited from class org.apache.commons.geometry.io.euclidean.threed.AbstractBoundaryWriteHandler3D
writeFacets
-
Field Details
-
DEFAULT_BUFFER_SIZE
private static final int DEFAULT_BUFFER_SIZEInitial size of the data buffer.- See Also:
-
initialBufferSize
private int initialBufferSizeInitial size of data buffers used during write operations.
-
-
Constructor Details
-
StlBoundaryWriteHandler3D
public StlBoundaryWriteHandler3D()
-
-
Method Details
-
getFormat
Get thedata 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
Write all boundaries fromsrc
to the given output, using the data format for the instance.- Specified by:
write
in interfaceBoundaryWriteHandler<PlaneConvexSubset,
BoundarySource3D> - Overrides:
write
in classAbstractBoundaryWriteHandler3D
- Parameters:
src
- boundary sourceout
- output to write to
-
write
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 writeout
- output to write to
-
writeFacets
Write allfacets
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 writeout
- output to write to
-
writeWithHeader
Write the given triangle data prefixed with an STL header to the output stream fromout
.- Parameters:
triangleBuffer
- buffer containing STL triangle datacount
- number of triangles intriangleBuffer
out
- output to write to- Throws:
UncheckedIOException
- if an I/O error occurs
-
writeTriangleMesh
Write all triangles in the given mesh to the output using the binary STL format.- Parameters:
mesh
- mesh to writeoutput
- output to write to- Throws:
UncheckedIOException
- if an I/O error occurs
-
getFacetAttributeValue
Get the attribute value that should be used for the given facet.- Parameters:
facet
- facet to get the attribute value for- Returns:
- attribute value
-