public class BinaryStlWriter extends Object implements Closeable
Constructor and Description |
---|
BinaryStlWriter(OutputStream out)
Construct a new instance for writing to the given output.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
writeHeader(byte[] headerContent,
int triangleCount)
Write binary STL header content.
|
void |
writeTriangle(Vector3D p1,
Vector3D p2,
Vector3D p3,
Vector3D normal)
Write a triangle to the output using a default attribute value of 0.
|
void |
writeTriangle(Vector3D p1,
Vector3D p2,
Vector3D p3,
Vector3D normal,
int attributeValue)
Write a triangle to the output.
|
public BinaryStlWriter(OutputStream out)
out
- output stream to write topublic void writeHeader(byte[] headerContent, int triangleCount)
headerContent
is null, the written header
will consist entirely of zeros. Otherwise, up to 80 bytes from headerContent
are written to the header, with any remaining bytes of the header filled with zeros.headerContent
- bytes to include in the header; may be nulltriangleCount
- number of triangles to be included in the contentUncheckedIOException
- if an I/O error occurspublic void writeTriangle(Vector3D p1, Vector3D p2, Vector3D p3, Vector3D normal)
If a normal is given, the vertices are ordered using the right-hand rule, meaning that they will be in a counter-clockwise orientation when looking down the normal. Thus, the given point ordering may not be the ordering used in the written content.
p1
- first pointp2
- second pointp3
- third pointnormal
- triangle normal; may be nullUncheckedIOException
- if an I/O error occurspublic void writeTriangle(Vector3D p1, Vector3D p2, Vector3D p3, Vector3D normal, int attributeValue)
If a non-zero normal is given, the vertices are ordered using the right-hand rule, meaning that they will be in a counter-clockwise orientation when looking down the normal. If no normal is given, or the given value cannot be normalized, a normal is computed from the triangle vertices, also using the right-hand rule. If this also fails (for example, if the triangle vertices do not define a plane), then the zero vector is used.
p1
- first pointp2
- second pointp3
- third pointnormal
- triangle normal; may be nullattributeValue
- 2-byte STL triangle attribute valueUncheckedIOException
- if an I/O error occurspublic void close()
close
in interface Closeable
close
in interface AutoCloseable
Copyright © 2016–2021 The Apache Software Foundation. All rights reserved.