Class ObjBoundaryWriteHandler3D
- java.lang.Object
-
- org.apache.commons.geometry.io.euclidean.threed.AbstractBoundaryWriteHandler3D
-
- org.apache.commons.geometry.io.euclidean.threed.obj.ObjBoundaryWriteHandler3D
-
- All Implemented Interfaces:
BoundaryWriteHandler<PlaneConvexSubset,BoundarySource3D>,BoundaryWriteHandler3D
public class ObjBoundaryWriteHandler3D extends AbstractBoundaryWriteHandler3D
BoundaryWriteHandler3Dimplementation for writing OBJ content. Output is written using the UTF-8 charset by default.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringDEFAULT_LINE_SEPARATORThe default line separator value.private static intDEFAULT_MESH_BUFFER_BATCH_SIZEDefault mesh buffer batch size.private java.nio.charset.CharsetdefaultCharsetCharset used for text output.private java.util.function.DoubleFunction<java.lang.String>doubleFormatDouble format function.private java.lang.StringlineSeparatorLine separator string.private intmeshBufferBatchSizeBatch size used for mesh buffer creation.
-
Constructor Summary
Constructors Constructor Description ObjBoundaryWriteHandler3D()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private ObjWritercreateWriter(GeometryOutput out)Construct a new, configuredObjWriterinstance for writing content to the given output stream.java.nio.charset.CharsetgetDefaultCharset()Get the text output default charset, used if the output does not specify a charset.java.util.function.DoubleFunction<java.lang.String>getDoubleFormat()Get the function used to convert double values to strings.GeometryFormatgetFormat()Get thedata formatsupported by this handler.java.lang.StringgetLineSeparator()Get the line separator.intgetMeshBufferBatchSize()Get the batch size when generating OBJ mesh content from facet sequences.voidsetDefaultCharset(java.nio.charset.Charset charset)Set the text output default charset, used if the output does not specify a charset.voidsetDoubleFormat(java.util.function.DoubleFunction<java.lang.String> doubleFormat)Set the function used to convert double values to strings.voidsetLineSeparator(java.lang.String lineSeparator)Set the line separator.voidsetMeshBufferBatchSize(int batchSize)Set the batch size when generating OBJ mesh content from facet sequences.voidwrite(java.util.stream.Stream<? extends PlaneConvexSubset> boundaries, GeometryOutput out)Write all boundaries in the stream to the given output using the data format supported by this instance.voidwrite(BoundarySource3D src, GeometryOutput out)Write all boundaries fromsrcto the given output, using the data format for the instance.voidwriteFacets(java.util.stream.Stream<? extends FacetDefinition> facets, GeometryOutput out)Write allfacetsin the stream to the output using the data format supported by this instance.-
Methods inherited from class org.apache.commons.geometry.io.euclidean.threed.AbstractBoundaryWriteHandler3D
writeFacets
-
-
-
-
Field Detail
-
DEFAULT_LINE_SEPARATOR
private static final java.lang.String DEFAULT_LINE_SEPARATOR
The default line separator value.- See Also:
- Constant Field Values
-
DEFAULT_MESH_BUFFER_BATCH_SIZE
private static final int DEFAULT_MESH_BUFFER_BATCH_SIZE
Default mesh buffer batch size.- See Also:
- Constant Field Values
-
defaultCharset
private java.nio.charset.Charset defaultCharset
Charset used for text output.
-
lineSeparator
private java.lang.String lineSeparator
Line separator string.
-
doubleFormat
private java.util.function.DoubleFunction<java.lang.String> doubleFormat
Double format function.
-
meshBufferBatchSize
private int meshBufferBatchSize
Batch size used for mesh buffer creation.
-
-
Method Detail
-
getFormat
public GeometryFormat getFormat()
Get thedata formatsupported by this handler.- Returns:
- data format supported by this handler
-
getDefaultCharset
public java.nio.charset.Charset getDefaultCharset()
Get the text output default charset, used if the output does not specify a charset.- Returns:
- text output default charset
-
setDefaultCharset
public void setDefaultCharset(java.nio.charset.Charset charset)
Set the text output default charset, used if the output does not specify a charset.- Parameters:
charset- text output default charset
-
getLineSeparator
public java.lang.String getLineSeparator()
Get the line separator. This value defaults to "\n".- Returns:
- the current line separator
-
setLineSeparator
public void setLineSeparator(java.lang.String lineSeparator)
Set the line separator.- Parameters:
lineSeparator- the line separator to use
-
getDoubleFormat
public java.util.function.DoubleFunction<java.lang.String> getDoubleFormat()
Get the function used to convert double values to strings.- Returns:
- double format function
-
setDoubleFormat
public void setDoubleFormat(java.util.function.DoubleFunction<java.lang.String> doubleFormat)
Set the function used to convert double values to strings. The given function must be thread-safe if this handler is to be used in a multi-threaded context.- Parameters:
doubleFormat- double format function
-
getMeshBufferBatchSize
public int getMeshBufferBatchSize()
Get the batch size when generating OBJ mesh content from facet sequences. Larger batch sizes allow for reuse of vertex definitions but at the cost of more memory usage. The buffer size is unlimited if set to-1. Default value is -1.- Returns:
- mesh buffer batch size
- See Also:
ObjWriter.meshBuffer(int)
-
setMeshBufferBatchSize
public void setMeshBufferBatchSize(int batchSize)
Set the batch size when generating OBJ mesh content from facet sequences. Larger batch sizes allow for reuse of vertex definitions but at the cost of more memory usage. Set to-1to allow unlimited buffer size. Default value is -1.- Parameters:
batchSize- mesh buffer batch size; set to-1to allow unlimited buffer sizes- See Also:
ObjWriter.meshBuffer(int)
-
write
public void write(BoundarySource3D src, GeometryOutput out)
Write all boundaries fromsrcto the given output, using the data format for the instance.- Specified by:
writein interfaceBoundaryWriteHandler<PlaneConvexSubset,BoundarySource3D>- Overrides:
writein classAbstractBoundaryWriteHandler3D- Parameters:
src- boundary sourceout- output to write to
-
write
public void write(java.util.stream.Stream<? extends PlaneConvexSubset> boundaries, GeometryOutput out)
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
public void writeFacets(java.util.stream.Stream<? extends FacetDefinition> facets, GeometryOutput out)
Write allfacetsin 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
-
createWriter
private ObjWriter createWriter(GeometryOutput out)
Construct a new, configuredObjWriterinstance for writing content to the given output stream.- Parameters:
out- output stream to write to- Returns:
- new
OBJWriterfor writing content to the given output stream - Throws:
java.io.UncheckedIOException- if an I/O error occurs
-
-