1SoOutput(3IV)() SoOutput(3IV)()
2
3
4
6 SoOutput — used to write Inventor data files
7
9 SoOutput
10
12 #include <Inventor/SoOutput.h>
13
14 typedef void * SoOutputReallocCB(void *ptr, size_t newSize)
15
16 Methods from class SoOutput:
17
18 SoOutput()
19 ~SoOutput()
20 void setFilePointer(FILE *newFP)
21 FILE * getFilePointer() const
22 SbBool openFile(const char *fileName)
23 closeFile()
24 void setBuffer(void *bufPointer, size_t initSize, SoOutpu‐
25 tReallocCB *reallocFunc, int32_t offset = 0)
26 SbBool getBuffer(void *&bufPointer, size_t &nBytes) const
27 size_t getBufferSize() const
28 void resetBuffer()
29 void setBinary(SbBool flag)
30 SbBool isBinary() const
31 void setHeaderString(const SbString &str)
32 void resetHeaderString()
33 static SbString getDefaultASCIIHeader()
34 static SbString getDefaultBinaryHeader()
35 void setFloatPrecision(int precision)
36
37
39 This class is used for writing Inventor data files. It supports both
40 ASCII (default) and binary formats and provides some convenience func‐
41 tions for handling files. It can also write to a buffer in memory as
42 well as to a file pointer. A user-defined header can be specified for
43 the output file. An instance of SoOutput is contained in an SoWriteAc‐
44 tion; this is typically the only instance needed.
45
47 SoOutput()
48 ~SoOutput()
49 Constructor and destructor. The default SoOutput writes to stdout.
50 The destructor closes any files opened by the SoOutput.
51
52 void setFilePointer(FILE *newFP)
53 Sets file pointer to write to.
54
55 FILE * getFilePointer() const
56 Returns the file pointer in use, or NULL if using a buffer.
57
58 SbBool openFile(const char *fileName)
59 Opens named file, sets file pointer to result. This returns FALSE on
60 error.
61
62 closeFile()
63 Closes current file if opened with openFile().
64
65 void setBuffer(void *bufPointer, size_t initSize, SoOutpu‐
66 tReallocCB *reallocFunc, int32_t offset = 0)
67 Sets up memory buffer to write to, initial size, reallocation func‐
68 tion (which is called if there is not enough room in the buffer),
69 and offset in the buffer at which to begin writing. If the realloca‐
70 tion function returns NULL, writing will be disabled.
71
72 SbBool getBuffer(void *&bufPointer, size_t &nBytes) const
73 Returns pointer to memory buffer being written to and the new size
74 of the buffer. Returns FALSE if not writing into a buffer.
75
76 size_t getBufferSize() const
77 The total number of bytes allocated to a memory buffer may be larger
78 than the number of bytes written. This returns that total number.
79
80 void resetBuffer()
81 Resets buffer for output again. Output starts over at beginning of
82 buffer.
83
84 void setBinary(SbBool flag)
85 Sets whether output should be ASCII (default) or binary.
86
87 SbBool isBinary() const
88 Returns current state of binary flag.
89
90 void setHeaderString(const SbString &str)
91 Sets the header for output files. This is useful, for example, if
92 you have a file format that is a superset of the Inventor file for‐
93 mat and you want Inventor to read the files. It is highly recommend
94 that in your new header you simply append to the header of the
95 Inventor file format you are extending. For example, if a new file
96 format is based on the Inventor 2.1 file format, register a header
97 similar to: "#Inventor V2.1 ascii MY FILE FORMAT EXTENSION" Then all
98 Inventor 2.1 applications (and later) can read the file.
99
100 void resetHeaderString()
101 Resets the header for output files to be the default header.
102
103 static SbString getDefaultASCIIHeader()
104 Returns the string representing the default ASCII header.
105
106 static SbString getDefaultBinaryHeader()
107 Returns the string representing the default binary header.
108
109 void setFloatPrecision(int precision)
110 Sets the precision for writing floating point numbers, i.e. the num‐
111 ber of significant digits. Floating point numbers are written using
112 %.xg format, where 'x' is the value of the precision argument.
113
114
116 SoInput, SoWriteAction, SoTranSender
117
118
119
120
121 SoOutput(3IV)()