.TH "SoWriteAction" 3 "Fri Sep 6 2024 15:32:06" "Version 4.0.3" "Coin" \" -*- nroff -*- .ad l .nh .SH NAME SoWriteAction \- The \fBSoWriteAction\fP class writes a scene graph to file\&. .SH SYNOPSIS .br .PP .PP \fR#include \fP .PP Inherits \fBSoAction\fP\&. .SS "Public Member Functions" .in +1c .ti -1c .RI "virtual \fBSoType\fP \fBgetTypeId\fP (void) const" .br .ti -1c .RI "\fBSoWriteAction\fP (void)" .br .ti -1c .RI "\fBSoWriteAction\fP (\fBSoOutput\fP *out)" .br .ti -1c .RI "virtual \fB~SoWriteAction\fP (void)" .br .ti -1c .RI "\fBSoOutput\fP * \fBgetOutput\fP (void) const" .br .ti -1c .RI "void \fBcontinueToApply\fP (\fBSoNode\fP *node)" .br .ti -1c .RI "void \fBcontinueToApply\fP (\fBSoPath\fP *path)" .br .in -1c Public Member Functions inherited from \fBSoAction\fP .in +1c .ti -1c .RI "virtual \fB~SoAction\fP (void)" .br .ti -1c .RI "virtual SbBool \fBisOfType\fP (\fBSoType\fP type) const" .br .ti -1c .RI "virtual void \fBapply\fP (\fBSoNode\fP *root)" .br .ti -1c .RI "virtual void \fBapply\fP (\fBSoPath\fP *path)" .br .ti -1c .RI "virtual void \fBapply\fP (const \fBSoPathList\fP &pathlist, SbBool obeysrules=FALSE)" .br .ti -1c .RI "void \fBapply\fP (\fBSoAction\fP *beingApplied)" .br .ti -1c .RI "virtual void \fBinvalidateState\fP (void)" .br .ti -1c .RI "\fBAppliedCode\fP \fBgetWhatAppliedTo\fP (void) const" .br .ti -1c .RI "\fBSoNode\fP * \fBgetNodeAppliedTo\fP (void) const" .br .ti -1c .RI "\fBSoPath\fP * \fBgetPathAppliedTo\fP (void) const" .br .ti -1c .RI "const \fBSoPathList\fP * \fBgetPathListAppliedTo\fP (void) const" .br .ti -1c .RI "const \fBSoPathList\fP * \fBgetOriginalPathListAppliedTo\fP (void) const" .br .ti -1c .RI "SbBool \fBisLastPathListAppliedTo\fP (void) const" .br .ti -1c .RI "\fBPathCode\fP \fBgetPathCode\fP (int &numindices, const int *&indices)" .br .ti -1c .RI "void \fBtraverse\fP (\fBSoNode\fP *const node)" .br .ti -1c .RI "SbBool \fBhasTerminated\fP (void) const" .br .ti -1c .RI "const \fBSoPath\fP * \fBgetCurPath\fP (void)" .br .ti -1c .RI "\fBSoState\fP * \fBgetState\fP (void) const" .br .ti -1c .RI "\fBPathCode\fP \fBgetCurPathCode\fP (void) const" .br .ti -1c .RI "virtual \fBSoNode\fP * \fBgetCurPathTail\fP (void)" .br .ti -1c .RI "void \fBusePathCode\fP (int &numindices, const int *&indices)" .br .ti -1c .RI "void \fBpushCurPath\fP (const int childindex, \fBSoNode\fP *node=NULL)" .br .ti -1c .RI "void \fBpopCurPath\fP (const \fBPathCode\fP prevpathcode)" .br .ti -1c .RI "void \fBpushCurPath\fP (void)" .br .ti -1c .RI "void \fBpopPushCurPath\fP (const int childindex, \fBSoNode\fP *node=NULL)" .br .ti -1c .RI "void \fBpopCurPath\fP (void)" .br .ti -1c .RI "void \fBswitchToPathTraversal\fP (\fBSoPath\fP *path)" .br .ti -1c .RI "void \fBswitchToNodeTraversal\fP (\fBSoNode\fP *node)" .br .in -1c .SS "Static Public Member Functions" .in +1c .ti -1c .RI "static \fBSoType\fP \fBgetClassTypeId\fP (void)" .br .ti -1c .RI "static void \fBaddMethod\fP (const \fBSoType\fP type, SoActionMethod method)" .br .ti -1c .RI "static void \fBenableElement\fP (const \fBSoType\fP type, const int stackindex)" .br .ti -1c .RI "static void \fBinitClass\fP (void)" .br .in -1c Static Public Member Functions inherited from \fBSoAction\fP .in +1c .ti -1c .RI "static void \fBinitClass\fP (void)" .br .ti -1c .RI "static void \fBinitClasses\fP (void)" .br .ti -1c .RI "static \fBSoType\fP \fBgetClassTypeId\fP (void)" .br .ti -1c .RI "static void \fBnullAction\fP (\fBSoAction\fP *action, \fBSoNode\fP *node)" .br .in -1c .SS "Protected Member Functions" .in +1c .ti -1c .RI "virtual const \fBSoEnabledElementsList\fP & \fBgetEnabledElements\fP (void) const" .br .ti -1c .RI "virtual void \fBbeginTraversal\fP (\fBSoNode\fP *node)" .br .ti -1c .RI "virtual SbBool \fBshouldCompactPathLists\fP (void) const" .br .in -1c Protected Member Functions inherited from \fBSoAction\fP .in +1c .ti -1c .RI "\fBSoAction\fP (void)" .br .ti -1c .RI "virtual void \fBendTraversal\fP (\fBSoNode\fP *node)" .br .ti -1c .RI "void \fBsetTerminated\fP (const SbBool flag)" .br .ti -1c .RI "virtual SbBool \fBshouldCompactPathList\fP (void) const" .br .in -1c .SS "Static Protected Member Functions" .in +1c .ti -1c .RI "static \fBSoEnabledElementsList\fP * \fBgetClassEnabledElements\fP (void)" .br .ti -1c .RI "static \fBSoActionMethodList\fP * \fBgetClassActionMethods\fP (void)" .br .in -1c Static Protected Member Functions inherited from \fBSoAction\fP .in +1c .ti -1c .RI "static \fBSoEnabledElementsList\fP * \fBgetClassEnabledElements\fP (void)" .br .ti -1c .RI "static \fBSoActionMethodList\fP * \fBgetClassActionMethods\fP (void)" .br .in -1c .SS "Additional Inherited Members" Public Types inherited from \fBSoAction\fP .in +1c .ti -1c .RI "enum \fBAppliedCode\fP { \fBNODE\fP = 0, \fBPATH\fP = 1, \fBPATH_LIST\fP = 2 }" .br .ti -1c .RI "enum \fBPathCode\fP { \fBNO_PATH\fP = 0, \fBIN_PATH\fP = 1, \fBBELOW_PATH\fP = 2, \fBOFF_PATH\fP = 3 }" .br .in -1c Protected Attributes inherited from \fBSoAction\fP .in +1c .ti -1c .RI "\fBSoState\fP * \fBstate\fP" .br .ti -1c .RI "\fBSoActionMethodList\fP * \fBtraversalMethods\fP" .br .in -1c .SH "Detailed Description" .PP The \fBSoWriteAction\fP class writes a scene graph to file\&. When applied to a scene, this action writes its contents to the stream contained within an \fBSoOutput\fP instance\&. This can be a file, a memory buffer or a system file handle like \fRstdout\fP, for instance\&. .PP \fIAll\fP information considered part of the scene graph should be written out, including not only nodes, but also the nodes' field values, global fields (at least those with connections inside the scene the action is applied to), engines in the scene, paths, etc\&. .PP The scene is written in the Open Inventor file format\&. Files in this format can be parsed into their scene graph structures by using the \fBSoDB::readAll()\fP method (\fBSoDB\fP also contains a few other import methods you can use)\&. .PP Here's a complete, standalone usage example which shows how to write a scene graph to a memory buffer: .PP .PP .nf #include #include #include #include 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; } .fi .PP .PP \fBSee also\fP .RS 4 \fBSoOutput\fP .RE .PP .SH "Constructor & Destructor Documentation" .PP .SS "SoWriteAction::SoWriteAction (void )" Default constructor\&. Output will be written to \fRstdout\fP in ASCII format\&. .SS "SoWriteAction::SoWriteAction (\fBSoOutput\fP * out)" Constructor\&. Output will be written via the \fIout\fP object\&. .SS "SoWriteAction::~SoWriteAction (void )\fR [virtual]\fP" Destructor\&. .SH "Member Function Documentation" .PP .SS "\fBSoType\fP SoWriteAction::getTypeId (void ) const\fR [virtual]\fP" Returns the type identification of an object derived from a class inheriting \fBSoAction\fP\&. This is used for runtime type checking and 'downward' casting\&. .br .PP Implements \fBSoAction\fP\&. .SS "\fBSoType\fP SoWriteAction::getClassTypeId (void )\fR [static]\fP" This static method returns the \fBSoType\fP object associated with objects of this class\&. .br .SS "void SoWriteAction::addMethod (const \fBSoType\fP type, SoActionMethod method)\fR [static]\fP" \fIThis API member is considered internal to the library, as it is not likely to be of interest to the application programmer\&.\fP .br .br .SS "void SoWriteAction::enableElement (const \fBSoType\fP type, const int stackindex)\fR [static]\fP" \fIThis API member is considered internal to the library, as it is not likely to be of interest to the application programmer\&.\fP .br .br .SS "const \fBSoEnabledElementsList\fP & SoWriteAction::getEnabledElements (void ) const\fR [protected]\fP, \fR [virtual]\fP" Returns list of enabled elements\&. .br .PP Reimplemented from \fBSoAction\fP\&. .SS "\fBSoEnabledElementsList\fP * SoWriteAction::getClassEnabledElements (void )\fR [static]\fP, \fR [protected]\fP" Returns list of enabled elements for this class\&. The enabledElements and methods variables are protected in the original OIV API\&. This is not such a good idea, since exposed static class member variables is a major grievance with regard to Win32 DLLs\&. This function is an extension for Coin, and it is not available in the original SGI Open Inventor v2\&.1 API\&. .br .br .SS "\fBSoActionMethodList\fP * SoWriteAction::getClassActionMethods (void )\fR [static]\fP, \fR [protected]\fP" Returns list of action methods for this class\&. The enabledElements and methods variables are protected in the original OIV API\&. This is not such a good idea, since exposed static class member variables is a major grievance with regard to Win32 DLLs\&. This function is an extension for Coin, and it is not available in the original SGI Open Inventor v2\&.1 API\&. .br .br .SS "void SoWriteAction::initClass (void )\fR [static]\fP" Initializes the runtime type system for this class, and sets up the enabled elements and action method list\&. .SS "\fBSoOutput\fP * SoWriteAction::getOutput (void ) const" Returns a pointer to the \fBSoOutput\fP object we're using when writing the scene graph\&. .SS "void SoWriteAction::continueToApply (\fBSoNode\fP * node)" Applies the write method to the subgraph starting at \fInode\fP with the current \fBSoOutput\fP instance, without resetting any of the internal state of the action instance\&. .PP This should normally be for internal use only\&. .SS "void SoWriteAction::continueToApply (\fBSoPath\fP * path)" Applies the write method to \fIpath\fP with the current \fBSoOutput\fP instance, without resetting any of the internal state of the action instance\&. .PP This should normally be for internal use only\&. .SS "void SoWriteAction::beginTraversal (\fBSoNode\fP * node)\fR [protected]\fP, \fR [virtual]\fP" This virtual method is called from \fBSoAction::apply()\fP, and is the entry point for the actual scene graph traversal\&. .PP It can be overridden to initialize the action at traversal start, for specific initializations in the action subclasses inheriting \fBSoAction\fP\&. .PP Default method just calls \fBtraverse()\fP, which any overridden implementation of the method must do too (or call \fBSoAction::beginTraversal()\fP) to trigger the scene graph traversal\&. .PP Reimplemented from \fBSoAction\fP\&. .SS "SbBool SoWriteAction::shouldCompactPathLists (void ) const\fR [protected]\fP, \fR [virtual]\fP" \fIThis API member is considered internal to the library, as it is not likely to be of interest to the application programmer\&.\fP .br .br Compact path lists are not implemented in Coin (yet), but if they are, \fBSoWriteAction\fP should return \fRFALSE\fP here -- it would only be extra overhead for the \fBSoWriteAction\fP to have path lists compacted before traversal\&. .PP Seems like a silly optimization to me, though\&.\&. :^/ 20000306 mortene\&. .SH "Author" .PP Generated automatically by Doxygen for Coin from the source code\&.