Class ObjWriter.MeshBuffer
java.lang.Object
org.apache.commons.geometry.io.euclidean.threed.obj.ObjWriter.MeshBuffer
- Enclosing class:
ObjWriter
Class used to produce OBJ mesh content from sequences of facets. As facets are added to the buffer
their vertices and normals are converted to OBJ vertex and normal definition strings. Vertices and normals
that produce equal definition strings are shared among all of the facets in the buffer. This process
converts the facet sequence into a compact mesh suitable for writing as OBJ file content.
Ideally, no vertices or normals would be duplicated in an OBJ file. However, when working with very large
geometries it may not be desirable to store values in memory before writing to the output. This
is where the batchSize property comes into play. The batchSize represents the maximum
number of faces that the buffer will store before automatically flushing its contents to the output and
resetting its state. This reduces the amount of memory used by the buffer at the cost of increasing the
likelihood of duplicate vertices and/or normals in the output.
-
Method Summary
Modifier and TypeMethodDescriptionvoidadd(PlaneConvexSubset boundary) Add a boundary to this buffer.voidadd(FacetDefinition facet) Add a facet to this buffer.intAdd a normal to the buffer.intAdd a vertex to the buffer.voidflush()Flush the buffer content to the output and reset its state.
-
Method Details
-
add
Add a facet to this buffer. IfbatchSizeis greater than-1and the number of currently stored faces is greater than or equal tobatchSize, then the buffer content is written to the output and the buffer state is reset.- Parameters:
facet- facet to add- Throws:
UncheckedIOException- if an I/O error occurs
-
add
Add a boundary to this buffer. IfbatchSizeis greater than-1and the number of currently stored faces is greater than or equal tobatchSize, then the buffer content is written to the output and the buffer state is reset.- Parameters:
boundary- boundary to add- Throws:
IllegalArgumentException- if the boundary is infiniteUncheckedIOException- if an I/O error occurs
-
addVertex
-
addNormal
-
flush
Flush the buffer content to the output and reset its state.- Throws:
UncheckedIOException- if an I/O error occurs
-