SoGetBoundingBoxAction(3)

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

🌸 SoGetBoundingBoxAction(3) 🌸

okay bestie, welcome to the Library Functions Manual page for SoGetBoundingBoxAction(3) β€” she's the one who does math about how much space your stuff takes up, and honestly? iconic behavior. let's get into it πŸ’…


✨ NAME ✨

SoGetBoundingBoxAction β€” the class that calculates bounding boxes for nodes and subgraphs. that's it, that's her whole job, and she's obsessed with it. πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <Inventor/actions/SoGetBoundingBoxAction.h>

Inherits SoAction. yes she's a nepo baby, but like, a deserving one. πŸ‘‘

πŸ’œ Public Types

enum ResetType { TRANSFORM = 0x1, BBOX = 0x2, ALL = TRANSFORM | BBOX }

πŸ’œ Public Types inherited from SoAction

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

  • virtual SoType getTypeId (void) const
  • SoGetBoundingBoxAction (const SbViewportRegion &vp)
  • virtual ~SoGetBoundingBoxAction (void)
  • void setViewportRegion (const SbViewportRegion &newregion)
  • const SbViewportRegion & getViewportRegion (void) const
  • SbBox3f getBoundingBox (void) const
  • SbXfBox3f & getXfBoundingBox (void)
  • const SbVec3f & getCenter (void) const
  • void setInCameraSpace (const SbBool flag)
  • SbBool isInCameraSpace (void) const
  • void setResetPath (const SoPath *path, const SbBool resetbefore=TRUE, const ResetType what=ALL)
  • const SoPath * getResetPath (void) const
  • SbBool isResetPath (void) const
  • SbBool isResetBefore (void) const
  • SoGetBoundingBoxAction::ResetType getWhatReset (void) const
  • void checkResetBefore (void)
  • void checkResetAfter (void)
  • void extendBy (const SbBox3f &box)
  • void extendBy (const SbXfBox3f &box)
  • void setCenter (const SbVec3f &center, const SbBool transformcenter)
  • SbBool isCenterSet (void) const
  • void resetCenter (void)

🌈 Public Member Functions inherited from SoAction

  • virtual ~SoAction (void)
  • virtual SbBool isOfType (SoType type) const
  • virtual 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) 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

  • 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

  • virtual const SoEnabledElementsList & getEnabledElements (void) const
  • virtual void beginTraversal (SoNode *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)
  • static SoActionMethodList * getClassActionMethods (void)

πŸ’– Static Protected Member Functions inherited from SoAction

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

🫢 Additional Inherited Members

Protected Attributes inherited from SoAction:

  • SoState * state
  • SoActionMethodList * traversalMethods

🧚 Detailed Description 🧚

okay so, the SoGetBoundingBoxAction class calculates bounding boxes for nodes and subgraphs. that's the whole vibe. πŸ“¦

if you apply this action to a path or a scene graph root, it will calculate the bounding box and the center point of the geometry contained within the scene. two for one, we love a multitasker. ✨

and here's the thing β€” you don't have to apply an SoGetBoundingBoxAction to the root of a scene. nope. when you use the action, you'll get the bounding box of the node you're applying it to plus that node's sub-tree in the scene graph (if it has any). so it's like, localized. 🎯

the calculated bounding box will be in the local coordinates of that sub-tree. but if you apply it to a scene graph root node, then the calculated bounding box will be in global coordinates. context matters bestie, fr fr. 🌍

the use of bounding boxes is ubiquitous within the Coin library. like, everywhere. it's needed for the correct execution of, and for performance enhancements during, rendering, picking, caching, culling, etc. so yeah, she's kind of a big deal. πŸ’…

SoSeparator nodes are aggressively caching the results of bounding box calculations β€” aggressively!! β€” so that they're really only re-calculated whenever the scenegraph rooted below any SoSeparator node has been modified. which means applying this action to scenegraphs, or parts of scenegraphs, should be very quick on successive runs for "static" parts of the scene. speed. ⚑

⚠️ note that the algorithm used is not guaranteed to always give an exact bounding box: it combines bounding boxes in pairs and extends one of them to contain the other. since the boxes need not be parallel to the principal axes, the new box might not be a perfect fit for the box not extended (it's coordinate system has been changed). so like… close enough is the whole strategy here, no cap.
⚠️ also note that what is returned from getBoundingBox() will be projected so as to be oriented along the principal axes, which can often cause it to become quite a lot larger than what it was before projection. 😭 for client code to obtain the best bounding box that Coin can calculate (and which will usually be exact), you need to use the getXfBoundingBox() method after having applied the SoGetBoundingBoxAction. that's the good one. that's the main character method. πŸ‘‘

🌸 See also 🌸

  • SoSeparator::boundingBoxCaching

πŸ’œ Member Enumeration Documentation πŸ’œ

enum SoGetBoundingBoxAction::ResetType

this API member is considered internal to the library, as it is not likely to be of interest to the application programmer. so like, don't worry about her, she's doing her own thing behind the scenes. πŸ™ˆ


🌈 Constructor & Destructor Documentation 🌈

SoGetBoundingBoxAction::SoGetBoundingBoxAction (const SbViewportRegion & vp)

Constructor. ✨

okay so it might seem unnecessary to have to pass in a viewport region argument to calculate bounding boxes, but there's a good reason for this, I promise: a few shape nodes need to know the viewport region to calculate their bounding box β€” these include SoText2 and SoImage, among others. πŸ“

what's particular about these shapes is that they're fundamentally 2D shapes, but they're being rendered on the screen "surface" as if they were in a 3D scene. (this is possible because we can match each pixel's depth value against the 3D shapes in the scene.) so like, they're cosplaying as 3D, and honestly? slay. 🎭

to compute an accurate 3D bounding box of a shape rendered in 2D on the screen "surface", you need to "de-project" the screen-space area it occupies to a 2D rectangle placed at some depth in the scene. this "de-projecting" operation needs to know about the dimensions of the viewport. see? not random at all. πŸ¦‹

also, some 3D shapes β€” like for instance SoNurbsSurface β€” get slightly distorted if there's an SoComplexity node in the scenegraph with the SoComplexity::value field set to SCREEN_SPACE. then it's also necessary to know the viewport region to find out how to accurately calculate the bounding box of those shapes. so many reasons. so many. 😀

you would usually want to pass in a viewport region equal to the layout of the current renderarea canvas. if you have a viewer or So@Gui@RenderArea available, you can get hold of the viewport region data simply by doing:

const SbViewportRegion & vpreg = viewer->getViewportRegion();

(if you don't have a viewer or renderarea available in your application at the point where you want to get the bounding box, it probably doesn't matter much what you set it to. the accuracy of the bounding box calculation might be slightly wrong versus the actual rendered appearance of the scene, but this is usually not noticable.) so like, chill, it's fine. 🫢

SoGetBoundingBoxAction::~SoGetBoundingBoxAction (void ) [virtual]

Destructor. she's done, she's logging off, she ate and left no crumbs. πŸ’€


…and bestie we are not done yet, there's way more coming in part 2 πŸ‘€πŸ’–

πŸ’– MEMBER FUNCTION DOCUMENTATION πŸ’–


🌟 SoType SoGetBoundingBoxAction::getTypeId (void ) const [virtual]

okay so bestie, this one hands you the type identification of an action that derives from SoAction. What's it for? Run-time type checking and "downward" casting. very demure, very type-safe.

Usage example, copy it exactly, no cap:

void bar(SoAction * action)
{
  if (action->getTypeId() == SoGLRenderAction::getClassTypeId()) {
    // safe downward cast, know the type
    SoGLRenderAction * glrender = (SoGLRenderAction *)action;
  }
  return; // ignore if not renderaction
}

So if you're an application programmer who wants to extend the library with new actions: this method needs to be overridden in all subclasses. That's usually done as part of setting up the whole full type system for your extension classes, and you typically pull that off with the pre-defined macros available through Inventor/nodes/SoSubAction.h: SO_ACTION_SOURCE, SO_ACTION_INIT_CLASS and SO_ACTION_CONSTRUCTOR.

Want the full tea on writing Coin extensions? Go read the SoAction class documentation, it's all there.

Returns the actual type id of an object derived from a class inheriting SoAction. Needs to be overridden in all subclasses. πŸ’…

Implements SoAction.


🌟 void SoGetBoundingBoxAction::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. πŸ™ˆ


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

Also internal to the library, bestie β€” not likely to be of interest to the application programmer. πŸ™ˆ


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

Returns a list of the elements used by action instances of this class upon traversal operations. like, the full roster of elements it needs. ✨

Reimplemented from SoAction.


🌟 void SoGetBoundingBoxAction::setViewportRegion (const SbViewportRegion & newregion)

Set a new viewport region with this method, if it has changed from the one passed in with the constructor. that's it, that's the whole vibe. πŸ¦‹


🌟 const SbViewportRegion & SoGetBoundingBoxAction::getViewportRegion (void ) const

Returns the viewport region used by the action instance.


🌟 SbBox3f SoGetBoundingBoxAction::getBoundingBox (void ) const

Returns the projected bounding box after (or during) traversal. πŸŽ€


🌟 SbXfBox3f & SoGetBoundingBoxAction::getXfBoundingBox (void )

Returns the bounding box and transformation matrix to global coordinates. Use it after (or during) traversal.


🌟 const SbVec3f & SoGetBoundingBoxAction::getCenter (void ) const

Returns the center point of the scene after the action has been applied.

heads up: this might differ from the geometric center of the bounding box, because shape nodes may "weight" the center point according to various criteria (i.e. a faceset could for instance weight the center point according to the area within its bounding box where there are more polygons). πŸ‘‘

🌟 void SoGetBoundingBoxAction::setInCameraSpace (const SbBool on)

Sets whether the returned bounding box should be calculated in the coordinate system of the camera space or not.


🌟 SbBool SoGetBoundingBoxAction::isInCameraSpace (void ) const

Returns whether the bounding box returned is to be in camera space.


🌟 void SoGetBoundingBoxAction::setResetPath (const SoPath * path, const SbBool resetbefore = TRUE, const ResetType what = ALL)

Forces the computed bounding box to be reset and the transformation to be identity before or after the tail node of path, depending on the resetbefore argument. You can pass NULL for the path argument to disable this behavior entirely. πŸ’€

See also: getResetPath(), isResetPath(), isResetBefore(), getWhatReset()


🌟 const SoPath * SoGetBoundingBoxAction::getResetPath (void ) const

Returns the reset path (or NULL).

See also: setResetPath(), isResetPath(), isResetBefore(), getWhatReset()


🌟 SbBool SoGetBoundingBoxAction::isResetPath (void ) const

Returns whether a reset path is set or not.

See also: setResetPath(), getResetPath(), isResetBefore(), getWhatReset()


🌟 SbBool SoGetBoundingBoxAction::isResetBefore (void ) const

Returns whether the bounding box and transformation is reset before or after the tail node of the reset path.

See also: setResetPath(), getResetPath(), isResetPath(), getWhatReset()


🌟 SoGetBoundingBoxAction::ResetType SoGetBoundingBoxAction::getWhatReset (void ) const

Returns what type of reset has been specified for the reset path.

See also: setResetPath(), getResetPath(), isResetPath(), isResetBefore()


🌟 void SoGetBoundingBoxAction::checkResetBefore (void )

This API member is considered internal to the library, as it is not likely to be of interest to the application programmer. πŸ™ˆ

Called before node traversal of each node (from SoNode action method).


🌟 void SoGetBoundingBoxAction::checkResetAfter (void )

This API member is considered internal to the library, as it is not likely to be of interest to the application programmer. πŸ™ˆ

Called after node traversal of each node (from SoNode action method).


🌟 void SoGetBoundingBoxAction::extendBy (const SbBox3f & box)

Extend the bounding box by the given box. Called from nodes during traversal. 🫢

Should usually not be of interest to application programmers β€” unless you're extending Coin with your own shapenode extension classes. iykyk.


🌟 void SoGetBoundingBoxAction::extendBy (const SbXfBox3f & box)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.


🌟 void SoGetBoundingBoxAction::setCenter (const SbVec3f & centerarg, const SbBool transformcenter)

This API member is considered internal to the library, as it is not likely to be of interest to the application programmer. πŸ™ˆ

Set a new center point during traversal.


🌟 SbBool SoGetBoundingBoxAction::isCenterSet (void ) const

This API member is considered internal to the library, as it is not likely to be of interest to the application programmer. πŸ™ˆ

Query about the center point during traversal.


🌟 void SoGetBoundingBoxAction::resetCenter (void )

This API member is considered internal to the library, as it is not likely to be of interest to the application programmer. πŸ™ˆ

Reset the scene center point during traversal.


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

This virtual method is called from SoAction::apply(), and it's the entry point for the actual scenegraph traversal. main character energy fr. ✨

You can override it to initialize the action at traversal start β€” for specific initializations in the action subclasses inheriting SoAction.

The default method just calls traverse(), and any overridden implementation of the method must do that too (or call SoAction::beginTraversal()) to trigger the scenegraph traversal. don't skip this part bestie, nothing will happen and you'll be so confused. 😭

Reimplemented from SoAction.


πŸ¦‹ AUTHOR πŸ¦‹

Generated automatically by Doxygen for Coin from the source code. so iconic of it honestly.


and that's a wrap on the SoGetBoundingBoxAction(3) page bestie!! πŸ’– this one shipped as Coin, Version 3.1.3, dated SoGetBoundingBoxAction(3) β€” go forth and bound those boxes, you absolute legend. πŸŒˆπŸ’…πŸŽ€

πŸ“¦ where this page comes from