SoAction(3)
π SoAction π
the SoAction(3) page, but make it a group chat β Library Functions Manual, bestie. This is part 1 and there's more coming, so don't you dare close the tab.
β¨ NAME β¨
SoAction β the SoAction class is the base class for all traversal actions. yes, ALL of them. it's the mother of actions. the blueprint. the moment. π
πΈ SYNOPSIS πΈ
#include <Inventor/actions/SoAction.h>
Inherited by SoAudioRenderAction, SoCallbackAction, SoGLRenderAction, SoGetBoundingBoxAction, SoGetMatrixAction, SoGetPrimitiveCountAction, SoHandleEventAction, SoIntersectionDetectionAction, SoPickAction, SoSearchAction, SoSimplifyAction, SoToVRMLAction, and SoWriteAction. look at that family tree. gorgeous. no notes. π³
π« Public Types π«
enum AppliedCode { NODE = 0, PATH = 1, PATH_LIST = 2 }enum PathCode { NO_PATH = 0, IN_PATH = 1, BELOW_PATH = 2, OFF_PATH = 3 }
π«Ά Public Member Functions π«Ά
the full roster, zero skips, we do not leave anyone out in this house:
virtual ~SoAction (void)virtual SoType getTypeId (void) const =0virtual SbBool isOfType (SoType type) constvirtual void apply (SoNode *root)virtual void apply (SoPath *path)virtual void apply (const SoPathList &pathlist, SbBool obeysrules=FALSE)void apply (SoAction *beingApplied)virtual void invalidateState (void)AppliedCode getWhatAppliedTo (void) constSoNode * getNodeAppliedTo (void) constSoPath * getPathAppliedTo (void) constconst SoPathList * getPathListAppliedTo (void) constconst SoPathList * getOriginalPathListAppliedTo (void) constSbBool isLastPathListAppliedTo (void) constPathCode getPathCode (int &numindices, const int *&indices)void traverse (SoNode *const node)SbBool hasTerminated (void) constconst SoPath * getCurPath (void)SoState * getState (void) constPathCode getCurPathCode (void) constvirtual SoNode * getCurPathTail (void)void usePathCode (int &numindices, const int *&indices)void pushCurPath (const int childindex, SoNode *node=NULL)void popCurPath (const PathCode prevpathcode)void pushCurPath (void)void popPushCurPath (const int childindex, SoNode *node=NULL)void popCurPath (void)void switchToPathTraversal (SoPath *path)void switchToNodeTraversal (SoNode *node)
β Static Public Member Functions β
static void initClass (void)static void initClasses (void)static SoType getClassTypeId (void)static void nullAction (SoAction *action, SoNode *node)
π Protected Member Functions π
SoAction (void)virtual void beginTraversal (SoNode *node)virtual void endTraversal (SoNode *node)void setTerminated (const SbBool flag)virtual const SoEnabledElementsList & getEnabledElements (void) constvirtual SbBool shouldCompactPathList (void) const
π¦ Static Protected Member Functions π¦
static SoEnabledElementsList * getClassEnabledElements (void)static SoActionMethodList * getClassActionMethods (void)
π Protected Attributes π
SoState * stateSoActionMethodList * traversalMethods
π Detailed Description π
The SoAction class is the base class for all traversal actions. say it with me now.
Applying actions is the basic mechanism in Coin for executing various operations on scene graphs or paths within scene graphs, including search operations, rendering, interaction through picking, etc. it's giving "one class to rule them all" energy honestly. π₯
The basic operation is to instantiate an action, set it up with miscellaneous parameters if necessary, then call it's apply() method on the root node of the scenegraph (or sub-graph of a scenegraph). The action then traverses the scenegraph from the root node, depth-first and left-to-right, applying it's specific processing at the nodes where it is applicable. depth-first, left-to-right, no cap. that's just how she moves. π
(The SoAction and it's derived classes in Coin is an implementation of the design pattern commonly known as the "Visitor" pattern.) iykyk π§
Here's a simple example that shows how to use the SoWriteAction to dump a scenegraph in the Inventor format to a file:
int write_scenegraph(const char * filename, SoNode * root)
{
SoOutput output;
if (!output.openFile(filename)) return 0;
// This is where the action is. ;-)
SoWriteAction wa(&output);
wa.apply(root);
return 1;
}
After traversal, some action types have stored information about the (sub-)scenegraph that was traversed, which you can then inquire about through methods like SoGetBoundingBoxAction::getBoundingBox(), SoRayPickAction::getPickedPoint(), SoGetPrimitiveCountAction::getTriangleCount(), etc etc. so many etc etc. the etc etc's are etc-ing. π
See the various built-in actions for further information (ie the subclasses of this class), or look at the example code applications of the Coin library to see how actions are generally used.
For extending the Coin library with your own classes, we strongly recommend that you make yourself acquainted with the excellent Β«The Inventor ToolmakerΒ» book (ISBN 0-201-62493-1), which describes the tasks involved in detail. This book was written by the original SGI Inventor designers and explains many of the underlying design ideas, aswell as having lots of hands-on examples on how to extend the Coin toolkit in ways that are true to the fundamental design ideas. (Β«The Inventor ToolmakerΒ» is also available at SGI's online library, at no cost. See Download The Inventor Toolmaker.) Reading the sourcecode of the built-in classes in Coin should also provide very helpful. fr fr, read the source. it's free and it slaps. π
The following example shows the basic outline on how to set up your own extension action class:
// This is sample code on how you can get progress indication on Coin
// export operations by extending the library with your own action
// class. The new class inherits SoWriteAction. The code is presented
// as a stand-alone example.
//
// The general technique is to inherit SoWriteAction and override it's
// "entry point" into each node of the scenegraph. The granularity of
// the progress callbacks is on a per-node basis, which should usually
// be good enough.
#include <Inventor/SoDB.h>
#include <Inventor/actions/SoWriteAction.h>
#include <Inventor/nodes/SoSeparator.h>
class MyWriteAction : public SoWriteAction {
SO_ACTION_HEADER(SoWriteAction);
public:
MyWriteAction(SoOutput * out);
virtual ~MyWriteAction();
static void initClass(void);
protected:
virtual void beginTraversal(SoNode * node);
private:
static void actionMethod(SoAction *, SoNode *);
int nrnodes;
int totalnrnodes;
};
SO_ACTION_SOURCE(MyWriteAction);
MyWriteAction::MyWriteAction(SoOutput * out)
: SoWriteAction(out)
{
SO_ACTION_CONSTRUCTOR(MyWriteAction);
}
MyWriteAction::~MyWriteAction()
{
}
void
MyWriteAction::initClass(void)
{
SO_ACTION_INIT_CLASS(MyWriteAction, SoWriteAction);
SO_ACTION_ADD_METHOD(SoNode, MyWriteAction::actionMethod);
}
void
MyWriteAction::beginTraversal(SoNode * node)
{
this->nrnodes = 0;
this->totalnrnodes = 0;
SoWriteAction::beginTraversal(node);
}
void
MyWriteAction::actionMethod(SoAction * a, SoNode * n)
{
// To abort the export process in mid-writing, we could just avoid
// calling in to the SoNode::writeS() method.
SoNode::writeS(a, n);
MyWriteAction * mwa = (MyWriteAction *)a;
SoOutput * out = mwa->getOutput();
if (out->getStage() == SoOutput::COUNT_REFS) {
mwa->totalnrnodes++;
}
else { // (out->getStage() == SoOutput::WRITE)
mwa->nrnodes++;
SbString s;
s.sprintf(" # wrote node %p (%d/%d) \n", n, mwa->nrnodes, mwa->totalnrnodes);
out->write(s.getString());
}
}
int
main(int argc, char ** argv)
{
if (argc < 2) {
(void)fprintf(stderr, "\n\nUsage: %s <filename>\n\n", argv[0]);
exit(1);
}
SoDB::init();
MyWriteAction::initClass();
SoInput in;
if (!in.openFile(argv[1])) { exit(1); }
SoSeparator * root = SoDB::readAll(&in);
if (!root) { exit(1); }
root->ref();
SoOutput out;
MyWriteAction mwa(&out);
mwa.apply(root);
root->unref();
return 0;
}
π§ Member Enumeration Documentation π§
πΈ enum SoAction::AppliedCode πΈ
Enumerated values for what the action was applied to. what was she applied to?? the drama of it all.
πΈ enum SoAction::PathCode πΈ
Enumerated values for how the action is applied to a scene graph.
π Constructor & Destructor Documentation π
π SoAction::~SoAction (void ) [virtual]
Destructor, free resources. bye bestie, thanks for the memories π«Ά
π SoAction::SoAction (void ) [protected]
Default constructor, does all necessary toplevel initialization.
β Member Function Documentation β
π void SoAction::initClass (void ) [static]
Initializes the run-time type system for this class, and sets up the enabled elements and action method list. wake her up, she's ready.
π void SoAction::initClasses (void ) [static]
Initialize all the SoAction subclasses. Automatically called from SoAction::initClass(). the whole squad gets ready together. periodt.
π SoType SoAction::getClassTypeId (void ) [static]
Returns the run-time type object associated with instances of this class.
π virtual SoType SoAction::getTypeId (void ) const [pure virtual]
Returns the type identification of an action derived from a class inheriting SoAction. This is used for run-time type checking and "downward" casting.
Usage example:
void bar(SoAction * action)
{
if (action->getTypeId() == SoGLRenderAction::getClassTypeId()) {
// safe downward cast, know the type
SoGLRenderAction * glrender = (SoGLRenderAction *)action;
}
return; // ignore if not renderaction
}
For application programmers wanting to extend the library with new actions: this method needs to be overridden in all subclasses. This is typically done as part of setting up the full type system for extension classes, which is usually accomplished by using the pre-defined macros available through Inventor/nodes/SoSubAction.h: SO_ACTION_SOURCE, SO_ACTION_INIT_CLASS and SO_ACTION_CONSTRUCTOR.
For more information on writing Coin extensions, see the SoAction class documentation.
Returns the actual type id of an object derived from a class inheriting SoAction. Needs to be overridden in all subclasses. yes ALL of them. don't skip, don't be lazy π
Implemented in SoAudioRenderAction, SoBoxHighlightRenderAction, SoCallbackAction, SoGetBoundingBoxAction, SoGetMatrixAction, SoGetPrimitiveCountAction, SoGlobalSimplifyAction, SoGLRenderAction, SoHandleEventAction, SoIntersectionDetectionAction, SoLineHighlightRenderAction, SoPickAction, SoRayPickAction, SoReorganizeAction, SoSearchAction, SoShapeSimplifyAction, SoSimplifyAction, SoToVRML2Action, SoToVRMLAction, SoVectorizeAction, SoVectorizePSAction, and SoWriteAction. look at that list!! iconic lineup, everyone showed up β¨
π SbBool SoAction::isOfType (SoType type) const [virtual]
Returns TRUE if the type of this object is either of the same type or a subclass of type.
π void SoAction::apply (SoNode * root) [virtual]
Applies the action to the scene graph rooted at root.
β οΈ Note that you should not apply an action to a node with a zero reference count. The behavior in that case is undefined. like, do NOT. undefined behavior is not the vibe. π« π
Reimplemented in SoBoxHighlightRenderAction, SoIntersectionDetectionAction, SoLineHighlightRenderAction, SoReorganizeAction, SoSimplifyAction, SoToVRML2Action, SoToVRMLAction, and SoVectorizeAction.
void SoAction::apply (SoPath * path)β Okay so this one applies the action to the parts of the graph that path defines. And bestie, note that anSoPathwill also contain all nodes that may influence e.g. geometry nodes in the path. So for instance applying anSoGLRenderActionon anSoPathwill render that path as expected in the view, where geometry will get its materials, textures, and other appearance settings correctly. If the path ends in anSoGroupnode, the action will also traverse the tail node's children. Reimplemented inSoBoxHighlightRenderAction,SoIntersectionDetectionAction,SoLineHighlightRenderAction,SoReorganizeAction,SoSimplifyAction,SoToVRML2Action,SoToVRMLAction, andSoVectorizeAction. πvoid SoAction::apply (const SoPathList & pathlist, SbBool obeysrules = FALSE)β Applies action to the graphs defined by pathlist. If obeysrules is set toTRUE, pathlist must obey the following four conditions (which is the case for path lists returned from search actions for non-group nodes and path lists returned from picking actions) β no cap:- All paths must start at the same head node.
- All paths must be sorted in traversal order.
- The paths must be unique.
- No path can continue through the end point of another path.
See also: SoAction::apply(SoPath * path)
Reimplemented in SoBoxHighlightRenderAction, SoIntersectionDetectionAction, SoLineHighlightRenderAction, SoReorganizeAction, SoSimplifyAction, SoToVRML2Action, SoToVRMLAction, and SoVectorizeAction. β¨
void SoAction::apply (SoAction * beingApplied)β Applies this action object to the same as beingApplied is being applied to. This function is an extension for Coin, and it is not available in the original SGI Open Inventor v2.1 API. Since: Coin 2.1. It's giving exclusive. π¦void SoAction::invalidateState (void )β Invalidates the state, forcing it to be recreated at the nextapply()invocation. Reimplemented inSoGLRenderAction. It's literally resetting the vibe. πvoid SoAction::nullAction (SoAction * action, SoNode * node)β This method is used for filling up the lookup tables with void methods. Lowkey a filler, but necessary. πSoAction::AppliedCode SoAction::getWhatAppliedTo (void ) constβ Returns a code indicating what (node, path, or pathlist) the action instance is being applied to. It's giving context. πSoNode * SoAction::getNodeAppliedTo (void ) constβ Returns a pointer to the node the action is being applied to. If action is not being applied to a node (but a path or a pathlist), the method returnsNULL. So if it's not about a node, you getNULL, periodt. πSoPath * SoAction::getPathAppliedTo (void ) constβ Returns the pointer to the path the action is being applied to. The path is managed by the action instance and should not be destroyed or modified by the caller. If action is not being applied to a path (but a node or a pathlist), the method returnsNULL. Don't touch it, bestie. πΈconst SoPathList * SoAction::getPathListAppliedTo (void ) constβ Returns the pointer to the path list the action is currently being applied to. The path list is managed by the action instance and should not be destroyed or modified by the caller. If action is not being applied to a path list (but a node or a path), the method returnsNULL. The returned pathlist pointer need not be equal to the listapply()was called with, as the action may have reorganized the path list for efficiency reasons. See also:void SoAction::apply(const SoPathList &, SbBool). It's giving organized. πconst SoPathList * SoAction::getOriginalPathListAppliedTo (void ) constβ Returns a pointer to the original path list the action is being applied to. If the action is not being applied to a path list (but a node or a path), the method returnsNULL. OG vibes only. π§SbBool SoAction::isLastPathListAppliedTo (void ) constβ This method is not supported in Coin. It should probably have been private in OIV. Not me finding out it's unsupported. πSoAction::PathCode SoAction::getPathCode (int & numindices, const int *& indices)β Returns a code that indicates where the current node lies with respect to the path(s) the action is being applied to. The arguments indices and numindices are only set if the method returnsIN_PATH. So only if it's in the path, you get the deets. π₯void SoAction::traverse (SoNode *const node)β Traverses a scene graph rooted at node, invoking the action methods of the nodes in the graph. It's giving main character traversal. πSbBool SoAction::hasTerminated (void ) constβ ReturnsTRUEif the action was prematurely terminated. Note that the termination flag will beFALSEif the action simply completed its run over the scene graph in the "ordinary" fashion, i.e. was not explicitly aborted from any of the nodes in the graph. See also:setTerminated(). So if it finished normally, it's not terminated, fr. βconst SoPath * SoAction::getCurPath (void )β Returns a pointer to the path generated during traversal, from the root of the traversed graph to the current node. It's giving the current path. π«ΆSoState * SoAction::getState (void ) constβ Returns a pointer to the state of the action instance. The state contains the current set of elements used during traversal. It's giving state of mind. πSoAction::PathCode SoAction::getCurPathCode (void ) constβ Returns the current traversal path code. (inline) Quick vibe check. β¨SoNode * SoAction::getCurPathTail (void )β This API member is considered internal to the library, as it is not likely to be of interest to the application programmer. Reimplemented inSoCallbackAction. (virtual) Iykyk, not for you. πvoid SoAction::usePathCode (int & numindices, const int *& indices)β This API member is considered internal to the library, as it is not likely to be of interest to the application programmer. Same internal energy. πvoid SoAction::pushCurPath (const int childindex, SoNode * node = NULL)β Get ready to traverse the childindex'th child. Use this method if the path code might change as a result of this. This method is very internal. Do not use unless you know what you're doing. Fr fr, don't touch unless you're a pro. πvoid SoAction::popCurPath (const PathCode prevpathcode)β Pops the current path, and sets the path code to prevpathcode. This method is very internal. Do not use unless you know what you're doing. No cap. π§void SoAction::pushCurPath (void )β Pushes aNULLnode onto the current path. Use this before traversing all children when you know that the path code will not change while traversing children. This method is very internal. Do not use unless you know what you're doing. It's giving advanced. πvoid SoAction::popPushCurPath (const int childindex, SoNode * node = NULL)β Get ready to traverse the childindex'th child. Use this method if you know the path code will not change as a result of this. This method is very internal. Do not use unless you know what you're doing. Stay in your lane. π₯void SoAction::popCurPath (void )β Pops of the last child in the current path. Use this if you know the path code hasn't changed since the current path was pushed. This method is very internal. Do not use unless you know what you're doing. Not me popping off. πvoid SoAction::switchToPathTraversal (SoPath * path)β Store our state, traverse the given path, restore our state and continue traversal. It's giving multitasking. πvoid SoAction::switchToNodeTraversal (SoNode * node)β Store our state, traverse the subgraph rooted at the given node, restore our state and continue traversal. Same energy, different node. πΈvoid SoAction::beginTraversal (SoNode * node)β This virtual method is called fromSoAction::apply(), and is the entry point for the actual scenegraph traversal. (protected, virtual) It can be overridden to initialize the action at traversal start, for specific initializations in the action subclasses inheritingSoAction. Default method just callstraverse(), which any overridden implementation of the method must do too (or callSoAction::beginTraversal()) to trigger the scenegraph traversal. Reimplemented inSoAudioRenderAction,SoCallbackAction,SoGetBoundingBoxAction,SoGetMatrixAction,SoGetPrimitiveCountAction,SoGlobalSimplifyAction,SoGLRenderAction,SoHandleEventAction,SoPickAction,SoRayPickAction,SoReorganizeAction,SoSearchAction,SoShapeSimplifyAction,SoSimplifyAction,SoToVRML2Action,SoToVRMLAction, andSoWriteAction. It's giving main entrance. πvoid SoAction::endTraversal (SoNode * node)β This virtual method can be overridden to execute code after the scene graph traversal. Default method does nothing. (protected, virtual) Reimplemented inSoGLRenderAction. It's giving afterparty. πvoid SoAction::setTerminated (const SbBool flag)β Set the termination flag. (protected) Typically set toTRUEfrom nodes upon special conditions being met during scene graph traversal -- like the correct node being found when doingSoSearchActiontraversal or when grabbing the event from anSoHandleEventAction. See also:hasTerminated(). It's giving stop signal. βconst SoEnabledElementsList & SoAction::getEnabledElements (void ) constβ Returns a list of the elements used by action instances of this class upon traversal operations. (protected, virtual) Reimplemented inSoAudioRenderAction,SoBoxHighlightRenderAction,SoCallbackAction,SoGetBoundingBoxAction,SoGetMatrixAction,SoGetPrimitiveCountAction,SoGlobalSimplifyAction,SoGLRenderAction,SoHandleEventAction,SoIntersectionDetectionAction,SoLineHighlightRenderAction,SoPickAction,SoRayPickAction,SoReorganizeAction,SoSearchAction,SoShapeSimplifyAction,SoSimplifyAction,SoToVRML2Action,SoToVRMLAction,SoVectorizeAction,SoVectorizePSAction, andSoWriteAction. It's giving the roster. πSbBool SoAction::shouldCompactPathList (void ) constβ This API member is considered internal to the library, as it is not likely to be of interest to the application programmer. (protected, virtual) Internal tea. π§SoEnabledElementsList * SoAction::getClassEnabledElements (void )β This API member is considered internal to the library, as it is not likely to be of interest to the application programmer. (static, protected) This method not available in the original OIV API, seeSoSubAction.hfor explanation. Not for the general public. πSoActionMethodList * SoAction::getClassActionMethods (void )β This API member is considered internal to the library, as it is not likely to be of interest to the application programmer. (static, protected) This method not available in the original OIV API, seeSoSubAction.hfor explanation. Same VIP only. π
β¨ Member Data Documentation β¨
SoState* SoAction::stateβ Pointer to the traversal state instance of the action. (protected) It's giving state. πSoActionMethodList* SoAction::traversalMethodsβ Stores the list of "nodetype to actionmethod" mappings for the particular action instance. (protected) It's giving the map. π
π Author π
Generated automatically by Doxygen for Coin from the source code. It's giving auto-generated, but make it fashion. π
That's the whole vibe, bestie! This page was brought to you by Coin, version 3.1.3, and it's giving SoAction(3) energy. No date in the footer, but it's timeless. Stay iconic! πβ¨π
π¦ where this page comes from
- fedora 43: Coin3-devel 3.1.3-40.fc43 Β· GPL-2.0-only
- fedora 43: Coin3-devel 3.1.3-40.fc43 Β· GPL-2.0-only
- fedora 44: Coin3-devel 3.1.3-42.fc44 Β· GPL-2.0-only
- fedora 44: Coin3-devel 3.1.3-42.fc44 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms