public class SoOutput extends Inventor
SbFileHelper
for more convenience functions. It can write to a buffer in memory as well as to a file. Since Open Inventor 8.1, SoOutput
can write compressed data in the lossless Zlib (aka gzip) format. Both ASCII and binary format files may be compressed.
An instance of SoOutput
is automatically created by SoWriteAction
and can be queried using the getOutput() method in that class. This is typically the only instance needed. For example:
SoWriteAction writeAction = new SoWriteAction() ; writeAction.getOutput().openFile( "output.iv" ); writeAction.apply( root ); writeAction.getOutput().closeFile();
Note that file properties (binary, compression, header string, etc) should be set before calling openFile()
or setFilePointer().
File extensions
The recommended file extension for Open Inventor format files, both ASCII and binary is ".iv". Open Inventor will automatically detect if the file is ASCII or binary based on the file header string. Compressed Open Inventor files may be given the extension ".ivz" for convenience, but it is not required. Open Inventor automatically detects compressed files.
File Header
Open Inventor writes a human readable file header as the first line of both ASCII and binary format files. Since Open Inventor 8.0, the default file header looks like this:
ASCII : "#Inventor V8.0 ascii"
Binary: "#Inventor V8.0 binary LE"
The two character code at the end of the binary header indicates if the file was written on a little-endian (LE) or big-endian (BE) machine. The version number string may change again in the future if incompatible changes are made to the file format. You can always query the current default headers using static methods getDefaultASCIIHeader()
and getDefaultBinaryHeader()
.
All versions of Open Inventor from version 2.1 through version 7.x, wrote the version number string "V2.1" by default and did not append "LE" (or "BE") to the binary header. Open Inventor cannot, in general, load files containing a file header from a newer version. However all versions of Open Inventor can load files written by older versions and can load files containing the V2.1 file header. We recommend always using the default file header because newer versions enable performance enhancing features in the file format. If you need to write a file compatible with older versions, call setHeaderString()
with "#Inventor V2.1 ascii" or "#Inventor V2.1 binary".
See also:
Modifier and Type | Class and Description |
---|---|
static class |
SoOutput.FileProperties
This enum defines the properties used when data are written to a file.
|
static class |
SoOutput.Stages |
Inventor.ConstructorCommand
VERBOSE_LEVEL, ZeroHandle
Constructor and Description |
---|
SoOutput()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
closeFile()
Closes current file if opened with
openFile() . |
void |
decrementIndent()
Calls decrementIndent((int)1).
|
void |
decrementIndent(int amount) |
int |
filePutc(int name_18391)
Write a byte to the currently open file.
|
int |
filePuts(java.lang.String name_18390)
Write a string to the currently open file.
|
void |
flushFile() |
long |
getBufferSize()
The total number of bytes allocated to a memory buffer may be larger than the number of bytes written.
|
static java.lang.String |
getDefaultASCIIHeader()
Returns the string representing the default ASCII header.
|
static java.lang.String |
getDefaultBinaryHeader()
Returns the string representing the default binary header.
|
SoOutput.FileProperties |
getFileProperty()
Returns the current properties used by
SoOutput . |
int |
getIndentLevel() |
SoOutput.Stages |
getStage() |
void |
incrementIndent()
Calls incrementIndent((int)1).
|
void |
incrementIndent(int amount) |
void |
indent() |
boolean |
isBinary()
Returns current state of binary flag.
|
boolean |
isWritingForScaleViz()
Returns true if ScaleViz is currently writing data for synchronization.
|
boolean |
openFile(java.lang.String fileName)
Opens named file, sets current file to result.
|
void |
resetBuffer()
Resets buffer for output again.
|
void |
resetHeaderString()
Resets the header for output files to be the default header.
|
void |
setBinary(boolean flag)
Sets whether output should be ASCII (default) or binary.
|
void |
setDoublePrecision(int precision)
Sets the precision for writing floating point numbers (type double), i.e.
|
void |
setFileProperty(SoOutput.FileProperties properties)
Sets a combination of properties for the current file.
|
void |
setFloatPrecision(int precision)
Sets the precision for writing floating point numbers (type float), i.e.
|
void |
setHeaderString(java.lang.String str)
Sets the header for output files.
|
void |
setStage(SoOutput.Stages stage) |
void |
write(boolean b) |
void |
write(byte c) |
void |
write(double d) |
void |
write(float f) |
void |
write(int i) |
void |
write(long i) |
void |
write(short s) |
void |
write(java.lang.String n) |
dispose, getNativeResourceHandle
public SoOutput()
SoOutput
writes to stdout.public void incrementIndent()
public void decrementIndent()
public void setFileProperty(SoOutput.FileProperties properties)
The default property is DefaultProperty when the SoOutput
object is created.
public void resetHeaderString()
public SoOutput.FileProperties getFileProperty()
SoOutput
.
public int filePuts(java.lang.String name_18390)
public boolean isBinary()
public boolean isWritingForScaleViz()
public long getBufferSize()
public void setBinary(boolean flag)
public void resetBuffer()
public boolean openFile(java.lang.String fileName)
public int filePutc(int name_18391)
public void closeFile()
openFile()
.public void setHeaderString(java.lang.String str)
public void write(java.lang.String n)
public void incrementIndent(int amount)
public SoOutput.Stages getStage()
public void setStage(SoOutput.Stages stage)
public void write(int i)
public void write(byte c)
public void write(boolean b)
public int getIndentLevel()
public void decrementIndent(int amount)
public void indent()
public static java.lang.String getDefaultASCIIHeader()
public void setDoublePrecision(int precision)
public void setFloatPrecision(int precision)
public void write(double d)
public void flushFile()
public void write(long i)
public void write(short s)
public static java.lang.String getDefaultBinaryHeader()
public void write(float f)
Generated on July 31, 2019, Copyright © Thermo Fisher Scientific. All rights reserved. http://www.openinventor.com