Open Inventor Reference
SoGetBoundingBoxAction Class Reference

Computes bounding box of a scene. More...

#include <Inventor/actions/SoGetBoundingBoxAction.h>

Inheritance diagram for SoGetBoundingBoxAction:
SoAction

List of all members.

Public Types

enum  ResetType { TRANSFORM = 0x01, BBOX = 0x02, ALL = 0x03 }
 set a path to do a resetTransform/resetBoundingBox on. More...

Public Member Functions

 SoGetBoundingBoxAction (const SbViewportRegion &viewportRegion)
 Constructor takes viewport region to use for picking.
virtual ~SoGetBoundingBoxAction ()
 Destructor.
void setViewportRegion (const SbViewportRegion &newRegion)
 Sets/returns current viewport region to use for action.
const SbViewportRegiongetViewportRegion () const
 Sets/returns current viewport region to use for action.
SbBox3f getBoundingBox () const
 Returns computed bounding box in world space.
SbXfBox3fgetXfBoundingBox ()
 Returns computed bounding box before transformation into world space.
const SbVec3fgetCenter () const
 Returns computed center point in world space.
void setInCameraSpace (SbBool 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.
SbBool isInCameraSpace () const
 Returns camera space flag.
void setResetPath (const SoPath *path, SbBool 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.
const SoPathgetResetPath () const
 Returns the current reset path, or NULL.
SbBool isResetPath () const
 Returns TRUE if the current reset path is not NULL.
SbBool isResetBefore () const
 Returns TRUE if the resetBefore flag was specified for the reset path.
SoGetBoundingBoxAction::ResetType getWhatReset () const
void checkResetBefore ()
 Call these methods at beginning and end (respectively) of the getBoundingBox action for each node.
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.
void extendBy (const SbXfBox3f &box)
void setCenter (const SbVec3f &center, SbBool 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.
SbBool isCenterSet () const
void resetCenter ()

Static Public Member Functions

static void initClass ()

Protected Member Functions

virtual void beginTraversal (SoNode *node)
 Initiates action on graph.

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

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 ( 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.

virtual SoGetBoundingBoxAction::~SoGetBoundingBoxAction ( ) [virtual]

Member Function Documentation

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

Reimplemented from SoAction.

void SoGetBoundingBoxAction::checkResetAfter ( )
void SoGetBoundingBoxAction::checkResetBefore ( )

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

void SoGetBoundingBoxAction::extendBy ( const SbXfBox3f box)
void SoGetBoundingBoxAction::extendBy ( const SbBox3f box)
SbBox3f SoGetBoundingBoxAction::getBoundingBox ( ) const [inline]

Definition at line 126 of file SoGetBoundingBoxAction.h.

const SbVec3f& SoGetBoundingBoxAction::getCenter ( ) const
const SoPath* SoGetBoundingBoxAction::getResetPath ( ) const [inline]

Definition at line 160 of file SoGetBoundingBoxAction.h.

const SbViewportRegion& SoGetBoundingBoxAction::getViewportRegion ( ) const [inline]

Definition at line 123 of file SoGetBoundingBoxAction.h.

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

Definition at line 165 of file SoGetBoundingBoxAction.h.

SbXfBox3f& SoGetBoundingBoxAction::getXfBoundingBox ( ) [inline]

Definition at line 129 of file SoGetBoundingBoxAction.h.

static void SoGetBoundingBoxAction::initClass ( ) [static]

Reimplemented from SoAction.

SbBool SoGetBoundingBoxAction::isCenterSet ( ) const
SbBool SoGetBoundingBoxAction::isInCameraSpace ( ) const [inline]

Definition at line 142 of file SoGetBoundingBoxAction.h.

SbBool SoGetBoundingBoxAction::isResetBefore ( ) const [inline]

Definition at line 164 of file SoGetBoundingBoxAction.h.

SbBool SoGetBoundingBoxAction::isResetPath ( ) const [inline]

Definition at line 162 of file SoGetBoundingBoxAction.h.

void SoGetBoundingBoxAction::resetCenter ( )
void SoGetBoundingBoxAction::setCenter ( const SbVec3f center,
SbBool  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.

void SoGetBoundingBoxAction::setInCameraSpace ( SbBool  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.

void SoGetBoundingBoxAction::setResetPath ( const SoPath path,
SbBool  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.

void SoGetBoundingBoxAction::setViewportRegion ( const SbViewportRegion newRegion)

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