SOOUTPUT(3iv)

πŸ’– SoOutput(3IV) β€” the write-y one πŸ’–

okay bestie, so this is SoOutput, and it's the class you use to write Inventor data files. that's the whole vibe. it's from the SoOutput(3IV) manual, and it inherits from... itself?? yeah, SoOutput is listed under INHERITS FROM. iconic of it honestly. no parents, no drama, just main character energy. πŸ’…


✨ INHERITS FROM ✨

SoOutput

🌸 SYNOPSIS 🌸

#include <Inventor/SoOutput.h>

typedef void *      SoOutputReallocCB(void *ptr, size_t newSize)

Methods from class SoOutput:

              SoOutput()
              ~SoOutput()
void          setFilePointer(FILE *newFP)
FILE *        getFilePointer() const
SbBool        openFile(const char *fileName)
              closeFile()
void          setBuffer(void *bufPointer, size_t initSize,
                 SoOutputReallocCB *reallocFunc, int32_t offset = 0)
SbBool        getBuffer(void *&bufPointer, size_t &nBytes) const
size_t        getBufferSize() const
void          resetBuffer()
void          setBinary(SbBool flag)
SbBool        isBinary() const
void          setHeaderString(const SbString &str)
void          resetHeaderString()
static SbString  getDefaultASCIIHeader()
static SbString  getDefaultBinaryHeader()
void          setFloatPrecision(int precision)

πŸ¦‹ DESCRIPTION πŸ¦‹

so basically, this class is used for writing Inventor data files. that's the job. that's the whole job. πŸ’–

it supports both ASCII (default) and binary formats β€” and by default it's giving ASCII, just so you know β€” and it comes with some convenience functions for handling files, because we love a helper. ✨

it can also write to a buffer in memory as well as to a file pointer. so flexible. so versatile. and you can specify a user-defined header for the output file if you're feeling custom. πŸŽ€

here's the tea: an instance of SoOutput is contained in an SoWriteAction, and ngl that's typically the only instance you need. so like... you probably don't even have to make one yourself?? but you can, and honestly good for you. πŸ‘‘


πŸ’… METHODS πŸ’…

  • SoOutput()
  • ~SoOutput()

Constructor and destructor, bestie. the default SoOutput writes to stdout β€” yes, straight to your terminal, no chill. and the destructor? it closes any files opened by the SoOutput, so it cleans up after itself. a class with manners. 🫢

  • void setFilePointer(FILE *newFP) β€” sets the file pointer to write to. that's it, that's the function.
  • FILE *getFilePointer() const β€” hands you back the file pointer currently in use, or NULL if it's using a buffer instead. buffer girlies, this one's not for you. πŸ’€
  • SbBool openFile(const char *fileName) β€” opens the named file and sets the file pointer to the result. returns FALSE on error. no cap, that's the whole thing.
  • closeFile() β€” closes the current file, but only if it was opened with openFile(). if you didn't open it, it's not gonna touch it. boundaries. periodt. βœ‹
  • void setBuffer(void *bufPointer, size_t initSize, SoOutputReallocCB *reallocFunc, int32_t offset = 0) β€” sets up a memory buffer to write to. you pass in the initial size, the reallocation function (which gets called if there's not enough room in the buffer), and the offset in the buffer where writing should begin. heads up though: if the reallocation function returns NULL, writing will be disabled. so like, don't do that unless you want the silence. 😭
  • SbBool getBuffer(void *&bufPointer, size_t &nBytes) const β€” gives you a pointer to the memory buffer being written to, plus the new size of the buffer. returns FALSE if it's not writing into a buffer at all. vibe check failed, basically. πŸ₯²
  • size_t getBufferSize() const β€” okay so the total number of bytes allocated to a memory buffer may be larger than the number of bytes actually written. this returns that total number. allocated β‰  used, bestie, keep them separate in your head. 🧠✨
  • void resetBuffer() β€” resets the buffer for output again. output starts over at the beginning of the buffer. fresh start, clean slate, we love a reset. πŸ¦‹
  • void setBinary(SbBool flag) β€” sets whether the output should be ASCII (the default) or binary. pick your fighter. πŸ’…
  • SbBool isBinary() const β€” returns the current state of that binary flag. simple. slay.
  • void setHeaderString(const SbString &str) β€” sets the header for output files. when's this useful? okay so like, if you've got a file format that's a superset of the Inventor file format and you want Inventor to be able to read those files, this is your moment. and it's highly recommend (their words, and honestly fair) that in your new header you just append to the header of the Inventor file format you're extending. for example β€” if a new file format is based on the Inventor 2.1 file format, you register a header similar to:
#Inventor V2.1 ascii MY FILE FORMAT EXTENSION

and then all Inventor 2.1 applications (and later) can read the file. that's the whole trick. backwards compatibility is the moment. πŸ‘‘

  • void resetHeaderString() β€” resets the header for output files back to the default header. we're going back to factory settings, no shame in it. πŸŽ€
  • static SbString getDefaultASCIIHeader() β€” returns the string representing the default ASCII header. ✨
  • static SbString getDefaultBinaryHeader() β€” returns the string representing the default binary header. ✨
  • void setFloatPrecision(int precision) β€” sets the precision for writing floating point numbers, i.e. the number of significant digits. the numbers get written using %.xg format, where 'x' is the value of the precision argument. so like, precision = how much of the float you actually get to see. no more, no less. πŸ’€

🌈 SEE ALSO 🌈

  • SoInput
  • SoWriteAction
  • SoTranSender

ok that's the whole page, bestie!! go forth and write some files πŸ’–βœ¨

and that's a wrap on SoOutput(3IV) πŸŽ€ β€” this lil group chat was brought to you by the SoOutput(3IV)() source and version, dated however the original dated it, so shoutout to whoever shipped it. mwah. πŸ’…πŸ¦‹πŸŒΈ