public class TextStlWriter extends AbstractTextFormatWriter
Constructor and Description |
---|
TextStlWriter(Writer writer)
Construct a new instance for writing STL content to the given writer.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
endSolid()
Write the end of the current STL solid definition.
|
void |
startSolid()
Write the start of an unnamed STL solid definition.
|
void |
startSolid(String solidName)
Write the start of an STL solid definition with the given name.
|
void |
writeTriangle(Vector3D p1,
Vector3D p2,
Vector3D p3,
Vector3D normal)
Write a triangle to the output.
|
void |
writeTriangles(FacetDefinition facet)
Write the given facet definition to the output as triangles.
|
void |
writeTriangles(List<Vector3D> vertices,
Vector3D normal)
Write the facet defined by the given vertices and normal to the output as triangles.
|
void |
writeTriangles(PlaneConvexSubset boundary)
Write the given boundary to the output as triangles.
|
getDoubleFormat, getLineSeparator, getWriter, setDoubleFormat, setLineSeparator, write, write, write, write, writeNewLine
public TextStlWriter(Writer writer)
writer
- writer to write topublic void startSolid()
stlWriter.startSolid(null);
UncheckedIOException
- if an I/O error occurspublic void startSolid(String solidName)
solidName
- the name of the solid; may be nullIllegalArgumentException
- if solidName
contains new line charactersIllegalStateException
- if a solid definition has already been startedUncheckedIOException
- if an I/O error occurspublic void endSolid()
close()
if needed.IllegalStateException
- if no solid definition has been startedUncheckedIOException
- if an I/O error occurspublic void writeTriangles(PlaneConvexSubset boundary)
boundary
- boundary to writeIllegalStateException
- if no solid has been started yetUncheckedIOException
- if an I/O error occursPlaneSubset.toTriangles()
public void writeTriangles(FacetDefinition facet)
facet
- facet definition to writeIllegalStateException
- if no solid has been started yetUncheckedIOException
- if an I/O error occurswriteTriangle(Vector3D, Vector3D, Vector3D, Vector3D)
public void writeTriangles(List<Vector3D> vertices, Vector3D normal)
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.
vertices
- vertices defining the facetnormal
- facet normal; may be nullIllegalStateException
- if no solid has been started yet or fewer than 3 vertices
are givenUncheckedIOException
- if an I/O error occurspublic void writeTriangle(Vector3D p1, Vector3D p2, Vector3D p3, Vector3D normal)
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
- facet normal; may be nullIllegalStateException
- if no solid has been started yetUncheckedIOException
- if an I/O error occurspublic void close()
close
in interface Closeable
close
in interface AutoCloseable
close
in class AbstractTextFormatWriter
Copyright © 2016–2021 The Apache Software Foundation. All rights reserved.