SoOutput(3)
π NAME π
SoOutput β bestie, this is the class that's basically an abstraction of an output stream. It writes stuff out. That's the whole vibe. β¨
π SYNOPSIS π
#include <Inventor/SoOutput.h>
π Public Types
enum Stage { COUNT_REFS, WRITE }
enum Annotations { ADDRESSES = 0x01, REF_COUNTS = 0x02 }
π«Ά Public Member Functions
SoOutput (void)
SoOutput (SoOutput *dictOut)
virtual ~SoOutput ()
virtual void setFilePointer (FILE *newFP)
virtual FILE * getFilePointer (void) const
virtual SbBool openFile (const char *const fileName)
virtual void closeFile (void)
SbBool setCompression (const SbName &compmethod, const float level=0.5f)
virtual void setBuffer (void *bufPointer, size_t initSize,
SoOutputReallocCB *reallocFunc, int32_t offset=0)
virtual SbBool getBuffer (void *&bufPointer, size_t &nBytes) const
virtual size_t getBufferSize (void) const
virtual void resetBuffer (void)
virtual void setBinary (const SbBool flag)
virtual SbBool isBinary (void) const
virtual void setHeaderString (const SbString &str)
virtual void resetHeaderString (void)
virtual void setFloatPrecision (const int precision)
void setStage (Stage stage)
Stage getStage (void) const
void incrementIndent (const int levels=1)
void decrementIndent (const int levels=1)
virtual void write (const char c)
virtual void write (const char *s)
virtual void write (const SbString &s)
virtual void write (const SbName &n)
virtual void write (const int i)
virtual void write (const unsigned int i)
virtual void write (const short s)
virtual void write (const unsigned short s)
virtual void write (const float f)
virtual void write (const double d)
virtual void writeBinaryArray (const unsigned char *c, const int length)
virtual void writeBinaryArray (const int32_t *const l, const int length)
virtual void writeBinaryArray (const float *const f, const int length)
virtual void writeBinaryArray (const double *const d, const int length)
virtual void indent (void)
virtual void reset (void)
void setCompact (SbBool flag)
SbBool isCompact (void) const
void setAnnotation (uint32_t bits)
uint32_t getAnnotation (void)
int addReference (const SoBase *base)
int findReference (const SoBase *base) const
void setReference (const SoBase *base, int refid)
void addDEFNode (SbName name)
SbBool lookupDEFNode (SbName name)
void removeDEFNode (SbName name)
void pushProto (SoProto *proto)
SoProto * getCurrentProto (void) const
void popProto (void)
void addRoute (SoFieldContainer *from, const SbName &fromfield,
SoFieldContainer *to, const SbName &tofield)
void resolveRoutes (void)
β Static Public Member Functions
static const SbName * getAvailableCompressionMethods (unsigned int &num)
static SbString getDefaultASCIIHeader (void)
static SbString getDefaultBinaryHeader (void)
π§ Protected Member Functions
SbBool isToBuffer (void) const
size_t bytesInBuf (void) const
SbBool makeRoomInBuf (size_t nBytes)
void convertShort (short s, char *to)
void convertInt32 (int32_t l, char *to)
void convertFloat (float f, char *to)
void convertDouble (double d, char *to)
void convertShortArray (short *from, char *to, int len)
void convertInt32Array (int32_t *from, char *to, int len)
void convertFloatArray (float *from, char *to, int len)
void convertDoubleArray (double *from, char *to, int len)
πΈ Static Protected Member Functions
static SbString padHeader (const SbString &inString)
π Protected Attributes
SbBool wroteHeader
π DETAILED DESCRIPTION π
SoOutput is, like, the class that is an abstraction of an output stream. No cap.
It gives you the power to write basic types to a file or to a memory buffer, in ASCII or in binary format. Both. Your choice. Main character energy. π
See also: SoInput, SoWriteAction
π MEMBER ENUMERATION DOCUMENTATION π
enum SoOutput::Stage
This one lists out all the possible stages of a write operation β because writing needs to happen in multiple passes, okay? It's a whole process, not a one-and-done. π
See also: setStage(), getStage()
Enumerator
COUNT_REFSβ bestie, we are not writing right now. We're just counting the internal references inside the scene graph. That's it. That's the task.WRITEβ ok so THIS is the one where the actual data export should take place during this pass. Periodt.
enum SoOutput::Annotations
The values in this enum get used for debugging purposes, to annotate the output from a write operation. iykyk. π
Enumerator
ADDRESSESβ annotates the output with pointer address information.REF_COUNTSβ annotates the output with reference counts of the objects that got written.
π¦ CONSTRUCTOR & DESTRUCTOR DOCUMENTATION π¦
SoOutput::SoOutput (void )
The default constructor, slay. It makes an SoOutput instance that will write to the standard output.
See also: setFilePointer(), openFile(), setBuffer()
SoOutput::SoOutput (SoOutput * dictOut)
Constructs an SoOutput that has a copy of the set of named references from dictOut. It's giving "borrowed your notes but made my own copy". π
SoOutput::~SoOutput (void ) [virtual]
Destructor. Say bye bestie. π
π MEMBER FUNCTION DOCUMENTATION π
void SoOutput::setFilePointer (FILE * newFP) [virtual]
Sets up a new file pointer that we're gonna write to.
Important note: do not use this method when the Coin library has been compiled as a Microsoft Windows DLL. Passing FILE* instances back or forth to DLLs is dangerous and will most likely cause a crash. This is an intrinsic limitation for Microsoft Windows DLLs. π Not a vibe. Not fixable by us.
See also: openFile(), setBuffer(), getFilePointer()
FILE * SoOutput::getFilePointer (void ) const [virtual]
Returns the current file pointer. If we're writing to a memory buffer, NULL gets returned instead.
Important note: same deal β do not use this method when the Coin library has been compiled as a Microsoft Windows DLL, because passing FILE* instances back or forth to DLLs is dangerous and will most likely cause a crash. Intrinsic Microsoft Windows DLL limitation, bestie. π«
See also: setFilePointer()
SbBool SoOutput::openFile (const char *const fileName) [virtual]
Opens a file for writing. If the file can't be opened or isn't writable, FALSE comes back at you.
Files opened by this method will automatically be closed if the user supplies another file pointer, another filename for writing, or if the SoOutput instance gets deleted. She cleans up after herself. π
See also: setFilePointer(), setBuffer(), closeFile()
void SoOutput::closeFile (void ) [virtual]
Closes the currently opened file β but only if that file was passed to SoOutput through the openFile() method. If you handed it over some other way, it's not hers to close. Respect the boundaries. π«
See also: openFile()
SbBool SoOutput::setCompression (const SbName & compmethod, const float level = 0.5f)
Sets the compression method and level used when writing the file.
- compmethod is the compression library/method to use when compressing.
- level is the compression level, where
0.0means no compression and1.0means maximum compression.
Currently BZIP2 and GZIP are the only compression methods supported, and you have to compile Coin with zlib and bzip2 support to enable them. No support, no squish. ποΈ
Supply compmethod = NONE or level = 0.0 if you want to disable compression. Compression is disabled by default.
Please note: it's not possible to compress when writing to a memory buffer. That's just not a thing.
This method returns TRUE if the compression method you picked is available. If it's not available, FALSE gets returned and compression is disabled.
See also: getAvailableCompressionMethods()
Since: Coin 2.1
const SbName * SoOutput::getAvailableCompressionMethods (unsigned int & num) [static]
Returns the array of available compression methods. The number of elements in the array gets stored in num. So you know exactly how many you're working with. π’
See also: setCompression()
Since: Coin 2.1
void SoOutput::setBuffer (void * bufPointer, size_t initSize, SoOutputReallocCB * reallocFunc, int32_t offset = 0) [virtual]
Sets up a memory buffer of size initSize for writing. Writing will start at bufPointer + offset.
If the buffer fills up, reallocFunc gets called to grab more memory. If reallocFunc returns NULL, further writing is disabled. That's the hard stop. π
Important note: remember that the resultant memory buffer after write operations have completed may reside somewhere else in memory than on bufPointer if reallocFunc is set. It's a good idea to make it a habit to always use getBuffer() to retrieve the memory buffer pointer after write operations. Don't be out here trusting the original pointer, bestie. π
Here's a complete, standalone usage example showing how to write a scene graph to a memory buffer:
#include <Inventor/SoDB.h>
#include <Inventor/actions/SoWriteAction.h>
#include <Inventor/nodes/SoCone.h>
#include <Inventor/nodes/SoSeparator.h>
static char * buffer;
static size_t buffer_size = 0;
static void *
buffer_realloc(void * bufptr, size_t size)
{
buffer = (char *)realloc(bufptr, size);
buffer_size = size;
return buffer;
}
static SbString
buffer_writeaction(SoNode * root)
{
SoOutput out;
buffer = (char *)malloc(1024);
buffer_size = 1024;
out.setBuffer(buffer, buffer_size, buffer_realloc);
SoWriteAction wa(&out);
wa.apply(root);
SbString s(buffer);
free(buffer);
return s;
}
int
main(int argc, char ** argv)
{
SoDB::init();
SoSeparator * root = new SoSeparator;
root->ref();
root->addChild(new SoCone);
SbString s = buffer_writeaction(root);
(void)fprintf(stdout, "%s\n", s.getString());
root->unref();
return 0;
}
See also: getBuffer(), getBufferSize(), resetBuffer()
SbBool SoOutput::getBuffer (void *& bufPointer, size_t & nBytes) const [virtual]
Returns the current buffer in bufPointer and the current write position of the buffer in nBytes.
If we're writing into a file and not a memory buffer, FALSE gets returned and the other return values will be undefined. So like, don't count on them. π
See also: getBufferSize()
size_t SoOutput::getBufferSize (void ) const [virtual]
Returns the total size of the memory buffer. The whole thing. Every byte. π
See also: getBuffer()
void SoOutput::resetBuffer (void ) [virtual]
Resets the memory buffer write pointer back to the beginning of the buffer. Rewind, bestie. βͺ
void SoOutput::setBinary (const SbBool flag) [virtual]
Sets whether or not to write the output as a binary stream. You decide. π
See also: isBinary()
SbBool SoOutput::isBinary (void ) const [virtual]
Returns a flag that tells you whether or not we're writing the output as a binary stream.
See also: setBinary()
void SoOutput::setHeaderString (const SbString & str) [virtual]
Sets the output file header string. That first line of the file? Yours now. βοΈ
See also: resetHeaderString(), getDefaultASCIIHeader(), getDefaultBinaryHeader()
void SoOutput::resetHeaderString (void ) [virtual]
Resets the header string back to the default one. Undo button, but for headers. π
See also: setHeaderString(), getDefaultASCIIHeader(), getDefaultBinaryHeader()
void SoOutput::setFloatPrecision (const int precision) [virtual]
Bestie, this is the glow-up knob for your floaty little numbers. It sets the precision used when writing floating point numbers out to ASCII files. <yellow>precision</yellow> should sit between 0 and 8 β no wildin' outside that range, okay? And heads up: the double precision gets set to precision * 2. β¨
void SoOutput::setStage (Stage stage)
Sets an indicator on the current stage. Why do we even need stages? Because the writing has to happen in multiple passes to account for the export of references/connections within the scene graphs. It's giving multi-step skincare routine, not one-and-done. π§
This method is basically just used from within SoWriteAction, and it should usually not be of interest to the application programmer.
β οΈ Do not use it unless you really know what you are doing. Like, really really. π
See also: getStage()
SoOutput::Stage SoOutput::getStage (void ) const
Returns an indicator on the current write stage. Writing is done in two passes β one to count and check connections, one to do the actual ASCII or binary export of data. Two passes, one iconique output. π
You should not need to use this method, as it is meant for internal purposes in Coin.
See also: setStage()
void SoOutput::incrementIndent (const int levels = 1)
Increase indentation level in the file. Cute lil staircase moment. πͺ
See also: decrementIndent(), indent()
void SoOutput::decrementIndent (const int levels = 1)
Decrease indentation level in the file. Going back down the stairs, no drama. πΈ
See also: incrementIndent(), indent()
void SoOutput::write (const char c) [virtual]
Write the character in c.
For binary write, the character plus 3 padding zero characters will be written.
void SoOutput::write (const char * s) [virtual]
Write the character string pointed to by s.
For binary write, a 4-byte MSB-ordered integer with the string length, plus the string plus padding zero characters to get on a 4-byte boundary (if necessary) will be written. Alignment queen behavior, no cap. π
void SoOutput::write (const SbString & s) [virtual]
Write the character string in s. The string will be written with apostrophes. Cast SbString to char * to write without apostrophes. β¨
If we are supposed to write in binary format, no apostrophes will be added, and writing will be done in the exact same manner as with SoOutput::write(const char * s).
void SoOutput::write (const SbName & n) [virtual]
Write the character string in n. The name will be enclosed by apostrophes. If you want to write an SbName instance without the apostrophes, cast the argument to a char *. π
If we are supposed to write in binary format, no apostrophes will be added, and writing will be done in the exact same manner as with SoOutput::write(const char * s).
void SoOutput::write (const int i) [virtual]
Write i as a character string, or as an architecture independent binary pattern if the setBinary() flag is activated. Two vibes, one function. π¦
void SoOutput::write (const unsigned int i) [virtual]
Write i as a character string, or as an architecture independent binary pattern if the setBinary() flag is activated. Same energy, unsigned edition. π
void SoOutput::write (const short s) [virtual]
Write s as a character string, or as an architecture independent binary pattern if the setBinary() flag is activated. πΈ
void SoOutput::write (const unsigned short s) [virtual]
Write s as a character string, or as an architecture independent binary pattern if the setBinary() flag is activated. And here's the plot twist: if we're writing in ASCII format, the value will be written in base 16 (hexadecimal). Slay. π₯
void SoOutput::write (const float f) [virtual]
Write f as a character string.
void SoOutput::write (const double d) [virtual]
Write d as a character string.
void SoOutput::writeBinaryArray (const unsigned char * constc, const int length) [virtual]
Write the given number of bytes to either a file or a memory buffer in binary format. Raw bytes, going straight to their destination, main character energy. β¨
void SoOutput::writeBinaryArray (const int32_t *const l, const int length) [virtual]
Write an length array of int32_t values in binary format.
void SoOutput::writeBinaryArray (const float *const f, const int length) [virtual]
Write an array of float values in binary format.
void SoOutput::writeBinaryArray (const double *const d, const int length) [virtual]
Write an array of double values in binary format.
void SoOutput::indent (void ) [virtual]
Call this method after writing a newline to a file to indent the next line to the correct position. Pretty-printing is self-care, fr fr. π
See also: incrementIndent(), decrementIndent()
void SoOutput::reset (void ) [virtual]
Reset all value and make ready for using another file pointer or buffer. Wipe the slate, fresh start, new era. π§
void SoOutput::setCompact (SbBool flag)
Set up the output to be more compact than with the default write routines. Less whitespace, more efficiency, it's giving minimalism. π
SbBool SoOutput::isCompact (void ) const
Returns whether or not the write routines try to compact the data when writing it (i.e. using less whitespace, etc).
π Note that "compact" in this sense does not mean "bitwise compression", as it could easily be mistaken for. Bestie, do not get it twisted.
void SoOutput::setAnnotation (uint32_t bits)
Set up annotation of different aspects of the output data. This is not useful for much else than debugging purposes, I suppose. Lowkey a debug-only situation. π¦
uint32_t SoOutput::getAnnotation (void )
Returns the current annotation debug bitflag settings. π
SbString SoOutput::getDefaultASCIIHeader (void ) [static]
Return the default header string written to ASCII files. β¨
See also: setHeaderString(), resetHeaderString(), getDefaultBinaryHeader()
SbString SoOutput::getDefaultBinaryHeader (void ) [static]
Return the default header string written to binary files. π
See also: setHeaderString(), resetHeaderString(), getDefaultASCIIHeader()
int SoOutput::addReference (const SoBase * base)
Makes a unique id for base and adds a mapping into our dictionary. Every base gets its own little ID card. πͺͺ
int SoOutput::findReference (const SoBase * base) const
Returns the unique identifier for base or -1 if not found. If they're not in the book, they get a -1, periodt. π
void SoOutput::setReference (const SoBase * base, int refid)
Sets the reference for base manually. Manual override moment. π₯
void SoOutput::addDEFNode (SbName name)
Adds name to the set of currently DEF'ed node names so far in the output process. π
SbBool SoOutput::lookupDEFNode (SbName name)
Checks whether name is already DEF'ed at this point in the output process. Returns TRUE if name is DEF'ed. Vibe check: already in the club? β¨
void SoOutput::removeDEFNode (SbName name)
Removes name from the set of DEF'ed node names. Used after the last reference to a DEF'ed node if we want to reuse the DEF at a later point in the file. Recycling the name tag, sustainability queen. πΈ
void SoOutput::pushProto (SoProto * proto)
This API member is considered internal to the library, as it is not likely to be of interest to the application programmer.
π This function is an extension for Coin, and it is not available in the original SGI Open Inventor v2.1 API.
Since: Coin 2.0
SoProto * SoOutput::getCurrentProto (void ) const
This API member is considered internal to the library, as it is not likely to be of interest to the application programmer.
π This function is an extension for Coin, and it is not available in the original SGI Open Inventor v2.1 API.
Since: Coin 2.0
void SoOutput::popProto (void )
This API member is considered internal to the library, as it is not likely to be of interest to the application programmer.
π This function is an extension for Coin, and it is not available in the original SGI Open Inventor v2.1 API.
Since: Coin 2.0
void SoOutput::addRoute (SoFieldContainer * from, const SbName & fromfield, SoFieldContainer * to, const SbName & tofield)
This API member is considered internal to the library, as it is not likely to be of interest to the application programmer.
π This function is an extension for Coin, and it is not available in the original SGI Open Inventor v2.1 API.
Since: Coin 2.0
void SoOutput::resolveRoutes (void )
This API member is considered internal to the library, as it is not likely to be of interest to the application programmer.
π This function is an extension for Coin, and it is not available in the original SGI Open Inventor v2.1 API.
Since: Coin 2.0
SbBool SoOutput::isToBuffer (void ) const [protected]
Returns TRUE if we're set up to write to a memory buffer. Are we buffering or are we filing? This tells you. π¦
size_t SoOutput::bytesInBuf (void ) const [protected]
Returns current write position. π
Note that for memory buffer writing, this includes the offset from SoOutput::setBuffer(), if any.
SbBool SoOutput::makeRoomInBuf (size_t bytes) [protected]
Check that the current memory buffer has enough space to contain the given number of bytes needed for the next write operation. Scoot over, we need room. π
Returns FALSE if there's not enough space left, otherwise TRUE.
Note that there will automatically be made an attempt at allocating more memory if the reallocation callback function argument of setBuffer() was not NULL. Automatic glow-up of your buffer, no cap. β¨
void SoOutput::convertShort (short s, char * to) [protected]
Convert the short integer in s to most-significant-byte first format and put the resulting bytes sequentially at to. π
See also: SoInput::convertShort()
void SoOutput::convertInt32 (int32_t l, char * to) [protected]
Convert the 32-bit integer in l to most-significant-byte first format and put the resulting bytes sequentially at to. π₯
See also: SoInput::convertInt32()
void SoOutput::convertFloat (float f, char * to) [protected]
Convert the single-precision floating point number in f to most-significant-byte first format and put the resulting bytes sequentially at to. πΈ
See also: SoInput::convertFloat()
void SoOutput::convertDouble (double d, char * to) [protected]
Convert the double-precision floating point number in d to most-significant-byte first format and put the resulting bytes sequentially at to. π
See also: SoInput::convertDouble()
void SoOutput::convertShortArray (short * from, char * to, int len) [protected]
Convert len short integer values from the array at from into the array at to from native host format to network independent format (i.e. most significant byte first). Same bytes, new accent. β¨
void SoOutput::convertInt32Array (int32_t * from, char * to, int len) [protected]
Convert len 32-bit integer values from the array at from into the array at to from native host format to network independent format (i.e. most significant byte first). π
void SoOutput::convertFloatArray (float * from, char * to, int len) [protected]
Convert len single-precision floating point values from the array at from into the array at to from native host format to network independent format (i.e. most significant byte first). π¦
void SoOutput::convertDoubleArray (double * from, char * to, int len) [protected]
Convert len double-precision floating point values from the array at from into the array at to from native host format to network independent format (i.e. most significant byte first). π
SbString SoOutput::padHeader (const SbString & inString) [static], [protected]
Pads the header we're writing so it contains the correct amount of bytes for the alignment of the following binary writes. Giving the header exactly the cushion it needs before the main event. π
πΎ MEMBER DATA DOCUMENTATION πΎ
π SbBool SoOutput::wroteHeader [protected] π
okay bestie, this is the flag that keeps track of the header situation β¨
It indicates whether or not the file format header has been written out. As long as this is FALSE, the header will be written once upon the first invocation of any write method in the class. Thatβs it. Thatβs the whole personality. π
βοΈ Author βοΈ
Generated automatically by Doxygen for Coin from the source code. So yeah, Doxygen did that, not a human typing dramatically at 3am. π€π
This was SoOutput(3) from Coin version 4.0.10, dated Thu Jun 25 2026 00:00:00 β mwah, bye bestie! ππ
π¦ where this page comes from
- fedora 43: Coin4-devel 4.0.10-1.fc43 Β· BSD-3-Clause AND GPL-3.0-or-later
- fedora 43: Coin4-devel 4.0.10-1.fc43 Β· BSD-3-Clause AND GPL-3.0-or-later
- fedora 44: Coin4-devel 4.0.10-1.fc44 Β· BSD-3-Clause AND GPL-3.0-or-later
- fedora 44: Coin4-devel 4.0.10-1.fc44 Β· BSD-3-Clause AND GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms