Class TextStlWriter
- All Implemented Interfaces:
Closeable, AutoCloseable
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionTextStlWriter(Writer writer) Construct a new instance for writing STL content to the given writer. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidendSolid()Write the end of the current STL solid definition.voidWrite the start of an unnamed STL solid definition.voidstartSolid(String solidName) Write the start of an STL solid definition with the given name.voidwriteTriangle(Vector3D p1, Vector3D p2, Vector3D p3, Vector3D normal) Write a triangle to the output.voidwriteTriangles(List<Vector3D> vertices, Vector3D normal) Write the facet defined by the given vertices and normal to the output as triangles.voidwriteTriangles(PlaneConvexSubset boundary) Write the given boundary to the output as triangles.voidwriteTriangles(FacetDefinition facet) Write the given facet definition to the output as triangles.Methods inherited from class AbstractTextFormatWriter
getDoubleFormat, getLineSeparator, getWriter, setDoubleFormat, setLineSeparator, write, write, write, write, writeNewLine
-
Constructor Details
-
TextStlWriter
Construct a new instance for writing STL content to the given writer.- Parameters:
writer- writer to write to
-
-
Method Details
-
startSolid
Write the start of an unnamed STL solid definition. This method is equivalent to callingstlWriter.startSolid(null);- Throws:
UncheckedIOException- if an I/O error occurs
-
startSolid
Write the start of an STL solid definition with the given name.- Parameters:
solidName- the name of the solid; may be null- Throws:
IllegalArgumentException- ifsolidNamecontains new line charactersIllegalStateException- if a solid definition has already been startedUncheckedIOException- if an I/O error occurs
-
endSolid
Write the end of the current STL solid definition. This method is called automatically onclose()if needed.- Throws:
IllegalStateException- if no solid definition has been startedUncheckedIOException- if an I/O error occurs
-
writeTriangles
Write the given boundary to the output as triangles.- Parameters:
boundary- boundary to write- Throws:
IllegalStateException- if no solid has been started yetUncheckedIOException- if an I/O error occurs- See Also:
-
writeTriangles
Write the given facet definition to the output as triangles.- Parameters:
facet- facet definition to write- Throws:
IllegalStateException- if no solid has been started yetUncheckedIOException- if an I/O error occurs- See Also:
-
writeTriangles
Write the facet defined by the given vertices and normal to the output as triangles. If the the given list of vertices contains more than 3 vertices, it is converted to triangles using a triangle fan. Callers are responsible for ensuring that the given vertices represent a valid convex polygon.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.
- Parameters:
vertices- vertices defining the facetnormal- facet normal; may be null- Throws:
IllegalStateException- if no solid has been started yet or fewer than 3 vertices are givenUncheckedIOException- if an I/O error occurs
-
writeTriangle
Write a triangle to the output.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.
- Parameters:
p1- first pointp2- second pointp3- third pointnormal- facet normal; may be null- Throws:
IllegalStateException- if no solid has been started yetUncheckedIOException- if an I/O error occurs
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classAbstractTextFormatWriter
-