SoToVRML2Action(3)

πŸ“¦ version 3.1.3, in fedora 43, fedora 44

πŸ’– SoToVRML2Action(3) β€” Library Functions Manual πŸ’–

okay bestie, sit down, hydrate, because we're about to learn about SoToVRML2Action together and honestly? she's iconic. ✨


🌸 NAME 🌸

SoToVRML2Action β€” the class that builds you a whole new scene graph, using only VRML97/VRML2 nodes. no cap, that's literally her whole job. πŸ’…


✨ SYNOPSIS ✨

#include <Inventor/actions/SoToVRML2Action.h>

Inherits SoToVRMLAction. (she comes from good stock, we love a legacy queen πŸ‘‘)

πŸŽ€ Public Member Functions πŸŽ€

these are her own methods, the ones she brings to the group chat:

  • virtual SoType getTypeId (void) const β€” hands over her type id, virtual style
  • SoToVRML2Action (void) β€” the constructor. she's here, she's born, she's ready πŸ¦‹
  • virtual ~SoToVRML2Action (void) β€” the destructor, also virtual, also slaying
  • virtual void apply (SoNode *node) β€” run the whole action on a SoNode
  • virtual void apply (SoPath *path) β€” run it on a SoPath instead
  • virtual void apply (const SoPathList &pathlist, SbBool obeysrules=FALSE) β€” run it on a whole SoPathList; obeysrules defaults to FALSE
  • class SoVRMLGroup * getVRML2SceneGraph (void) const β€” gimme gimme the fresh new VRML2 scene graph 🫢
  • void reuseAppearanceNodes (SbBool appearance) β€” set whether appearance nodes get reused
  • SbBool doReuseAppearanceNodes (void) const β€” asks her: are we reusing appearance nodes tho?
  • void reusePropertyNodes (SbBool property) β€” set whether property nodes get reused
  • SbBool doReusePropertyNodes (void) const β€” the answer on property-node reuse
  • void reuseGeometryNodes (SbBool geometry) β€” set whether geometry nodes get reused
  • SbBool doReuseGeometryNodes (void) const β€” the answer on geometry-node reuse

πŸ’œ Public Member Functions inherited from SoToVRMLAction πŸ’œ

the family recipes she inherited, verbatim:

SoToVRMLAction (void)
virtual ~SoToVRMLAction (void)
SoNode * getVRMLSceneGraph (void) const
void expandSoFile (SbBool flag)
SbBool areSoFileExpanded (void) const
void setUrlName (const SbString name)
SbString getUrlName (void) const
void writeTexCoords (SbBool flag)
SbBool areTexCoordWritten (void) const
void expandTexture2Node (SbBool flag)
SbBool areTexture2NodeExpanded (void) const
void keepUnknownNodes (SbBool flag)
SbBool areUnknownNodeKept (void) const
void convertInlineNodes (SbBool flag)
SbBool doConvertInlineNodes (void) const
void conditionalConversion (SbBool flag)
SbBool doConditionalConversion (void) const
void setVerbosity (SbBool flag)
SbBool isVerbose (void) const

🌈 Public Member Functions inherited from SoAction 🌈

and here's the whole SoAction inheritance tree, because we do not gatekeep:

virtual ~SoAction (void)
virtual SbBool isOfType (SoType type) const
void apply (SoAction *beingApplied)
virtual void invalidateState (void)
AppliedCode getWhatAppliedTo (void) const
SoNode * getNodeAppliedTo (void) const
SoPath * getPathAppliedTo (void) const
const SoPathList * getPathListAppliedTo (void) const
const SoPathList * getOriginalPathListAppliedTo (void) const
SbBool isLastPathListAppliedTo (void) const
PathCode getPathCode (int &numindices, const int *&indices)
void traverse (SoNode *const node)
SbBool hasTerminated (void) const
const SoPath * getCurPath (void)
SoState * getState (void) const
PathCode getCurPathCode (void) const
virtual 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 ⭐

the static girlies, no instance required:

  • static SoType getClassTypeId (void) β€” the class-level type id
  • static void addMethod (const SoType type, SoActionMethod method) β€” register an action method
  • static void enableElement (const SoType type, const int stackindex) β€” enable an element at a given stack index
  • static void initClass (void) β€” set the class up. do this, fr fr

πŸ“ Static Public Member Functions inherited from SoToVRMLAction πŸ“

static SoType getClassTypeId (void)
static void addMethod (const SoType type, SoActionMethod method)
static void enableElement (const SoType type, const int stackindex)
static void initClass (void)

🌸 Static Public Member Functions inherited from SoAction 🌸

static void initClass (void)
static void initClasses (void)
static SoType getClassTypeId (void)
static void nullAction (SoAction *action, SoNode *node)

🧚 Protected Member Functions 🧚

for the inner circle only:

  • virtual const SoEnabledElementsList & getEnabledElements (void) const β€” coughs up the enabled elements list
  • virtual void beginTraversal (SoNode *node) β€” kicks off the traversal on a node

πŸ’œ Protected Member Functions inherited from SoAction πŸ’œ

SoAction (void)
virtual void endTraversal (SoNode *node)
void setTerminated (const SbBool flag)
virtual SbBool shouldCompactPathList (void) const

πŸŽ€ Static Protected Member Functions πŸŽ€

  • static SoEnabledElementsList * getClassEnabledElements (void) β€” the class-level enabled elements list
  • static SoActionMethodList * getClassActionMethods (void) β€” the class-level action methods list

πŸ’œ Static Protected Member Functions inherited from SoToVRMLAction πŸ’œ

static SoEnabledElementsList * getClassEnabledElements (void)
static SoActionMethodList * getClassActionMethods (void)

πŸ’œ Static Protected Member Functions inherited from SoAction πŸ’œ

static SoEnabledElementsList * getClassEnabledElements (void)
static SoActionMethodList * getClassActionMethods (void)

πŸ‘‘ Additional Inherited Members πŸ‘‘

Public Types inherited from SoAction β€” the enum moment:

enum AppliedCode { NODE = 0, PATH = 1, PATH_LIST = 2 }
enum PathCode { NO_PATH = 0, IN_PATH = 1, BELOW_PATH = 2, OFF_PATH = 3 }

Protected Attributes inherited from SoAction β€” yes she has public-ish attributes, live with it:

SoState * state
SoActionMethodList * traversalMethods

πŸ”₯ Detailed Description πŸ”₯

so. The SoToVRML2Action class builds a new scene graph, using only VRML97/VRML2 nodes.

This action is your go-to for converting a scene graph made of VRML1/Coin nodes into a brand new scene graph that uses nothing but VRML97/VRML2 nodes. glow-up complete. ✨

Because VRML1/Coin and VRML2 are just built different (VRML2 doesn't really have a traversal state, periodt), the resulting scene graph will typically be a lil bit larger. to keep that from getting out of hand, the action tries to re-use nodes whenever it possibly can. resourceful queen. πŸ’…

VRML1 nodes get converted straight to their direct VRML2 equivalent, no drama. Coin nodes with no VRML2 equivalent? They get converted to IndexedFaceSet. And listen β€” if the DrawStyle is POINTS, all the geometry gets built using PointSet; if it's LINES, then IndexedLineSet is what you get.

okay here's a basic usage example, and it's a complete, stand-alone program because we don't do half-finished snippets in this house:

#include <Inventor/SoDB.h>
#include <Inventor/SoInteraction.h>
#include <Inventor/SoInput.h>
#include <Inventor/SoOutput.h>
#include <Inventor/actions/SoWriteAction.h>
#include <Inventor/actions/SoToVRML2Action.h>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/VRMLnodes/SoVRMLGroup.h>

int
main(int argc, char *argv[])
{
  SoDB::init();
  SoInteraction::init();
  SoInput in;
  in.openFile(argv[1]);
  printf("Reading...\n");
  SoSeparator *root = SoDB::readAll(&in);

  if (root) {
    root->ref();
    SbString hdr = in.getHeader();
    in.closeFile();

    printf("Converting...\n");
    SoToVRML2Action tovrml2;
    tovrml2.apply(root);
    SoVRMLGroup *newroot = tovrml2.getVRML2SceneGraph();
    newroot->ref();
    root->unref();

    printf("Writing...\n");

    SoOutput out;
    out.openFile("out.wrl");
    out.setHeaderString("#VRML V2.0 utf8");
    SoWriteAction wra(&out);
    wra.apply(newroot);
    out.closeFile();

    newroot->unref();
  }

  return 0;
}
⚠️ bestie, important: if VRML97 support is not present in the Coin library, this action does nothing and getVRML2SceneGraph always returns NULL. so don't come crying to me, check your build first 😭

πŸ’« See also πŸ’«

SoToVRMLAction

⏳ Since ⏳

  • Coin 2.0
  • TGS Inventor 2.5

πŸ› οΈ Constructor & Destructor Documentation πŸ› οΈ

SoToVRML2Action::SoToVRML2Action (void )

Constructor. that's it, that's the vibe. she has arrived. πŸ¦‹

SoToVRML2Action::~SoToVRML2Action (void ) [virtual]

The destructor. she's leaving, gracefully, virtually. 🫢

πŸ’… Member Function Documentation πŸ’…

SoType SoToVRML2Action::getTypeId (void ) const [virtual]

Okay bestie, this one returns the type identification of an action derived from a class inheriting SoAction. It's giving run-time type checking and "downward" casting energy. ✨

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. No cap. 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. Periodt. πŸ’–

Reimplemented from SoToVRMLAction.


void SoToVRML2Action::addMethod (const SoType type, SoActionMethod method) [static]

This API member is considered internal to the library, as it is not likely to be of interest to the application programmer. Lowkey just vibes for the library devs. 🫢


void SoToVRML2Action::enableElement (const SoType type, const int stackindex) [static]

This API member is considered internal to the library, as it is not likely to be of interest to the application programmer. Same energy, bestie. πŸ’…


const SoEnabledElementsList & SoToVRML2Action::getEnabledElements (void ) const [protected], [virtual]

Returns a list of the elements used by action instances of this class upon traversal operations. It's literally the VIP guest list for this action's traversal. πŸ‘‘

Reimplemented from SoToVRMLAction.


void SoToVRML2Action::apply (SoNode * root) [virtual]

Applies the action to the scene graph rooted at root. Slay. πŸ¦‹

Note that you should not apply an action to a node with a zero reference count. The behavior in that case is undefined. No cap, that's undefined behavior territory. πŸ’€

Reimplemented from SoToVRMLAction.


void SoToVRML2Action::apply (SoPath * path) [virtual]

Applies the action to the parts of the graph defined by path. Main character energy only for that path. ✨

Note that an SoPath will also contain all nodes that may influence e.g. geometry nodes in the path. So for instance applying an SoGLRenderAction on an SoPath will render that path as expected in the view, where geometry will get its materials, textures, and other appearance settings correctly. It's giving full context, bestie. πŸŽ€

If the path ends in an SoGroup node, the action will also traverse the tail node's children. So don't forget the kids. πŸ™ˆ

Reimplemented from SoToVRMLAction.


void SoToVRML2Action::apply (const SoPathList & pathlist, SbBool obeysrules = FALSE) [virtual]

Applies action to the graphs defined by pathlist. If obeysrules is set to TRUE, 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):

  • 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 from SoToVRMLAction.


SoVRMLGroup * SoToVRML2Action::getVRML2SceneGraph (void ) const

Return a pointer to the root node of the generated scenegraph of only VRML2 / VRML97 nodes. It's giving VRML97 only, no mixing. 🌈

Will return NULL if VRML97 support was not compiled into the library. So if you get nothing, that's why. 😭


void SoToVRML2Action::reuseAppearanceNodes (SbBool appearance)

Set the flag deciding if appearance nodes should be reused if possible. The default is FALSE. Ngl, reuse is not the vibe yet.

Please note that support for reusing Appearance nodes is not implemented yet. So don't hold your breath, bestie. πŸ’€


SbBool SoToVRML2Action::doReuseAppearanceNodes (void ) const

Get the flag deciding if appearance nodes should be reused if possible. The default is FALSE.

Please note that support for reusing Appearance nodes is not implemented yet, so this method will always return FALSE. It's giving false hope, but fr fr it's just false. πŸ™ˆ


void SoToVRML2Action::reusePropertyNodes (SbBool property)

Set the flag deciding if property nodes should be reused if possible. The default is FALSE. Lowkey just a flag, no drama.


SbBool SoToVRML2Action::doReusePropertyNodes (void ) const

Get the flag deciding if property nodes should be reused if possible. The default is FALSE. That's it, that's the tea. πŸ“


void SoToVRML2Action::reuseGeometryNodes (SbBool geometry)

Set the flag deciding if geometry nodes should be reused if possible. The default is FALSE.

Please note that support for reusing Geometry nodes is not implemented yet. So yeah, flag exists, behavior doesn't. 😭


SbBool SoToVRML2Action::doReuseGeometryNodes (void ) const

Get the flag deciding if geometry nodes should be reused if possible. The default is FALSE.

Please note that support for reusing Geometry nodes is not implemented yet, so this function will always return FALSE. Periodt. πŸ’…


void SoToVRML2Action::beginTraversal (SoNode * node) [protected], [virtual]

This virtual method is called from SoAction::apply(), and is the entry point for the actual scenegraph traversal. It's literally the main character of traversal. πŸ‘‘

It can be overridden to initialize the action at traversal start, for specific initializations in the action subclasses inheriting SoAction. Customize your vibe check here. ✨

Default method just calls traverse(), which any overridden implementation of the method must do too (or call SoAction::beginTraversal()) to trigger the scenegraph traversal. Don't skip the trigger, bestie. πŸ”₯

Reimplemented from SoToVRMLAction.


πŸ‘‘ Author πŸ‘‘

Generated automatically by Doxygen for Coin from the source code. No human wrote this, it's just Doxygen doing its thing. πŸ€–πŸ’–


Coin Version 3.1.3 β€” that's the version, and this whole page is SoToVRML2Action(3). Thanks for reading, bestie, you ate that. πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from