Open Inventor Reference
SoGetBoundingBoxAction Class Reference

Computes bounding box of a scene. More...

#include <Inventor/actions/SoGetBoundingBoxAction.h>

Inheritance diagram for SoGetBoundingBoxAction:
SoAction

Public Types

enum  ResetType { TRANSFORM = 0x01 , BBOX = 0x02 , ALL = 0x03 }
 set a path to do a resetTransform/resetBoundingBox on. More...
 
- Public Types inherited from SoAction
enum  AppliedCode { NODE , PATH , PATH_LIST }
 This enum is used to determine what the action is being applied to. More...
 
enum  PathCode { NO_PATH , IN_PATH , BELOW_PATH , OFF_PATH }
 This enum may be used during traversal of nodes to indicate where the node is with respect to the path being traversed. More...
 

Public Member Functions

 SoGetBoundingBoxAction (const SbViewportRegion &viewportRegion)
 Constructor takes viewport region to use for picking. More...
 
virtual ~SoGetBoundingBoxAction ()
 Destructor. More...
 
void setViewportRegion (const SbViewportRegion &newRegion)
 Sets/returns current viewport region to use for action. More...
 
const SbViewportRegiongetViewportRegion () const
 Sets/returns current viewport region to use for action. More...
 
SbBox3f getBoundingBox () const
 Returns computed bounding box in world space. More...
 
SbXfBox3fgetXfBoundingBox ()
 Returns computed bounding box before transformation into world space. More...
 
const SbVec3fgetCenter () const
 Returns computed center point in world space. More...
 
void setInCameraSpace (bool flag)
 Set this flag to TRUE if you want the returned bounding box to be in the space of whatever camera is in the graph. More...
 
bool isInCameraSpace () const
 Returns camera space flag. More...
 
void setResetPath (const SoPath *path, bool resetBefore=TRUE, ResetType what=ALL)
 If a non-NULL path is specified, the action will reset the computed bounding box to be empty and/or the current transformation to identity. More...
 
const SoPathgetResetPath () const
 Returns the current reset path, or NULL. More...
 
bool isResetPath () const
 Returns TRUE if the current reset path is not NULL. More...
 
bool isResetBefore () const
 Returns TRUE if the resetBefore flag was specified for the reset path. More...
 
SoGetBoundingBoxAction::ResetType getWhatReset () const
 
void checkResetBefore ()
 Call these methods at beginning and end (respectively) of the getBoundingBox action for each node. More...
 
void checkResetAfter ()
 
void extendBy (const SbBox3f &box)
 Extends the current bounding box by the given bounding box, after transforming it by the current value of the SoLocalBBoxMatrixElement. More...
 
void extendBy (const SbXfBox3f &box)
 
void setCenter (const SbVec3f &center, bool transformCenter)
 Sets the center of the bounding box to the given point, which, if transformCenter is TRUE, is first transformed by the current value of the SoLocalBBoxMatrixElement. More...
 
bool isCenterSet () const
 
void resetCenter ()
 
- Public Member Functions inherited from SoAction
virtual ~SoAction ()
 Destructor. More...
 
virtual SoType getTypeId () const =0
 Returns the type identifier for a specific instance. More...
 
bool isOfType (SoType type) const
 Returns TRUE if this instance is of the type specified in type or is derived from that type. More...
 
virtual void apply (SoNode *node)
 
virtual void apply (SoPath *path)
 
virtual void apply (const SoPathList &pathList, bool obeysRules=FALSE)
 Initiates an action on the graph defined either by a node, path, or list of paths. More...
 
virtual void invalidateState ()
 Invalidates the current traversal state in the action, forcing it to be recreated when the action is next applied. More...
 
AppliedCode getWhatAppliedTo () const
 Returns code indicating what action is being applied to. More...
 
SoNodegetNodeAppliedTo () const
 These returns a pointer to the node, path, or path list the action is being applied to. More...
 
SoPathgetPathAppliedTo () const
 
const SoPathListgetPathListAppliedTo () const
 A single path list may be split into several, one for each different head node. More...
 
const SoPathListgetOriginalPathListAppliedTo () const
 
bool isLastPathListAppliedTo () const
 
PathCode getPathCode (int &numIndices, const int *&indices)
 Returns path code based on where current node (the node at the end of the current path) lies with respect to the path(s) the action is being applied to. More...
 
void traverse (SoNode *node)
 Does traversal of a graph rooted by a node. More...
 
bool hasTerminated () const
 Returns TRUE if the traversal has reached a termination condition. More...
 
const SoPathgetCurPath ()
 Returns a pointer to the path accumulated during traversal, i.e., the chain of nodes from the root of the traversed graph to the current node being traversed. More...
 
SoStategetState () const
 Get the state from the action. More...
 
PathCode getCurPathCode () const
 These methods maintain the current path accumulated so far during traversal. More...
 
void pushCurPath (int childIndex)
 
void popCurPath (PathCode prevPathCode)
 
virtual SoNodegetCurPathTail ()
 This is virtual, so that SoCallbackAction can use current node. More...
 
void usePathCode (int &numIndices, const int *&indices)
 called by inline getPathCode: More...
 
void pushCurPath ()
 Optimized versions of push/pop when we know path codes won't change: More...
 
void popPushCurPath (int childIndex)
 
void popCurPath ()
 
const SoLightweightPathgetCurrentLightweightPath () const
 Returns the current "light" path. More...
 
void setCurrentLightweightPath (const SoLightweightPath &path)
 Sets the current "light" path. More...
 

Static Public Member Functions

static void initClass ()
 
- Static Public Member Functions inherited from SoAction
static SoType getClassTypeId ()
 Returns the type identifier for this class. More...
 
static void nullAction (SoAction *, SoNode *)
 Null action method that can be stored in lookup table when desired. More...
 
static void initClass ()
 
static void initClasses ()
 Initialize ALL Inventor action classes. More...
 

Protected Member Functions

virtual void beginTraversal (SoNode *node)
 Initiates action on graph. More...
 
- Protected Member Functions inherited from SoAction
 SoAction ()
 Constructor. More...
 
virtual const SoEnabledElementsListgetEnabledElements () const
 Returns the list of enabled elements for a given action subclass. More...
 
void setTerminated (bool flag)
 Allows subclass instance to indicate that traversal has reached a termination condition. More...
 
virtual bool shouldCompactPathLists () const
 This method is used when applying an action to an SoPathList. More...
 

Additional Inherited Members

- Protected Attributes inherited from SoAction
SoStatestate
 Traversal state. More...
 
SoActionMethodListtraversalMethods
 The list of what to do when. More...
 
- Static Protected Attributes inherited from SoAction
static SoEnabledElementsListenabledElements
 Holds list of enabled elements for the SoAction class. More...
 
static SoActionMethodListmethods
 ... and the methods More...
 

Detailed Description

This class is used to compute a 3D bounding box enclosing objects defined by a scene graph. The box is a rectangular prism. The action also computes the center point, which is defined differently for different objects. (For example, the center of an SoFaceSet is the average of its vertices' coordinates.) For a group, the center point is defined as the average of the centers of all shapes in it.

Each bounding box is calculated as a SbXfBox3f, where the transformation matrix is defined so that the bounding box can be stored in the object space of the SoShape. When two bounding boxes are combined by a group node, the combination is performed so as to produce the smaller untransformed box. The result of the calculation by the action can be returned as an SbXfBox3f or as a world-space-aligned SbBox3f.

To calculate the bounding box of a subgraph bounded by two paths, specify the left edge of the subgraph with setResetPath(), and apply the action to the path that defines the right edge of the subgraph. The accumulated bounding box and transformation will be reset when the tail of the reset path is traversed.

If the subgraph being traversed does not contain any shapes, the returned bounding box will be empty (that is, box.isEmpty() will return TRUE).

See Also
SbBox3f, SbXfBox3f, SoGetMatrixAction

Definition at line 104 of file SoGetBoundingBoxAction.h.

Member Enumeration Documentation

◆ ResetType

The default is to do the reset right before the given path. Which things get reset:

Enumerator
TRANSFORM 

Transformation.

BBOX 

Bounding Box.

ALL 

Both Transform and Bounding Box.

Definition at line 147 of file SoGetBoundingBoxAction.h.

Constructor & Destructor Documentation

◆ SoGetBoundingBoxAction()

SoGetBoundingBoxAction::SoGetBoundingBoxAction ( const SbViewportRegion viewportRegion)

Even though the bounding box computation may not involve a window per se, some nodes need this information to determine their size and placement.

◆ ~SoGetBoundingBoxAction()

virtual SoGetBoundingBoxAction::~SoGetBoundingBoxAction ( )
virtual

Member Function Documentation

◆ beginTraversal()

virtual void SoGetBoundingBoxAction::beginTraversal ( SoNode node)
protectedvirtual

Reimplemented from SoAction.

◆ checkResetAfter()

void SoGetBoundingBoxAction::checkResetAfter ( )

◆ checkResetBefore()

void SoGetBoundingBoxAction::checkResetBefore ( )

(SoNode calls these in its static method for this action.)

◆ extendBy() [1/2]

void SoGetBoundingBoxAction::extendBy ( const SbBox3f box)

◆ extendBy() [2/2]

void SoGetBoundingBoxAction::extendBy ( const SbXfBox3f box)

◆ getBoundingBox()

SbBox3f SoGetBoundingBoxAction::getBoundingBox ( ) const
inline

Definition at line 126 of file SoGetBoundingBoxAction.h.

◆ getCenter()

const SbVec3f& SoGetBoundingBoxAction::getCenter ( ) const

◆ getResetPath()

const SoPath* SoGetBoundingBoxAction::getResetPath ( ) const
inline

Definition at line 160 of file SoGetBoundingBoxAction.h.

◆ getViewportRegion()

const SbViewportRegion& SoGetBoundingBoxAction::getViewportRegion ( ) const
inline

Definition at line 123 of file SoGetBoundingBoxAction.h.

◆ getWhatReset()

SoGetBoundingBoxAction::ResetType SoGetBoundingBoxAction::getWhatReset ( ) const
inline

Definition at line 165 of file SoGetBoundingBoxAction.h.

◆ getXfBoundingBox()

SbXfBox3f& SoGetBoundingBoxAction::getXfBoundingBox ( )
inline

Definition at line 129 of file SoGetBoundingBoxAction.h.

◆ initClass()

static void SoGetBoundingBoxAction::initClass ( )
static

◆ isCenterSet()

bool SoGetBoundingBoxAction::isCenterSet ( ) const

◆ isInCameraSpace()

bool SoGetBoundingBoxAction::isInCameraSpace ( ) const
inline

Definition at line 142 of file SoGetBoundingBoxAction.h.

◆ isResetBefore()

bool SoGetBoundingBoxAction::isResetBefore ( ) const
inline

Definition at line 164 of file SoGetBoundingBoxAction.h.

◆ isResetPath()

bool SoGetBoundingBoxAction::isResetPath ( ) const
inline

Definition at line 162 of file SoGetBoundingBoxAction.h.

◆ resetCenter()

void SoGetBoundingBoxAction::resetCenter ( )

◆ setCenter()

void SoGetBoundingBoxAction::setCenter ( const SbVec3f center,
bool  transformCenter 
)

After this is called, isCenterSet will return TRUE, unless resetCenter is called. Shapes should setCenter() to whatever is appropriate (e.g. left-justified text might set the center to be the start of the string) with transformCenter set to TRUE. Groups are responsible for averaging the centers if more than one shape sets the center; when setting the center to the average of transformed centers, pass FALSE for transformCenter.

◆ setInCameraSpace()

void SoGetBoundingBoxAction::setInCameraSpace ( bool  flag)
inline

Camera space is defined to have the viewpoint at the origin, with the direction of view along the negative z axis. This space can be used to determine distances of objects from the camera.

Definition at line 139 of file SoGetBoundingBoxAction.h.

◆ setResetPath()

void SoGetBoundingBoxAction::setResetPath ( const SoPath path,
bool  resetBefore = TRUE,
ResetType  what = ALL 
)

The resetBefore flag indicates whether to perform the reset before or after the tail node of the path is traversed.

◆ setViewportRegion()

void SoGetBoundingBoxAction::setViewportRegion ( const SbViewportRegion newRegion)

The documentation for this class was generated from the following file: