Open Inventor Release 2024.2.0
 
Loading...
Searching...
No Matches
SoGetBoundingBoxAction Class Reference

Computes bounding box of a scene. More...

#include <Inventor/actions/SoGetBoundingBoxAction.h>

+ Inheritance diagram for SoGetBoundingBoxAction:

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  DistribMode {
  LOCAL_ONLY ,
  CLUSTER_ONLY ,
  ALL
}
 This is used to define the way an action is distributed across a cluster. More...
 
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

virtual SoType getTypeId () const
 Returns the type identifier for this specific instance.
 
 SoGetBoundingBoxAction (const SbViewportRegion &viewportRegion)
 Constructor.
 
void setViewportRegion (const SbViewportRegion &newRegion)
 Sets current viewport region to use for action.
 
const SbViewportRegiongetViewportRegion () const
 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
 Returns what flags were specified to be reset for the reset path.
 
- Public Member Functions inherited from SoAction
virtual ~SoAction ()
 Destructor.
 
virtual void apply (SoNode *node)
 Initiates an action on the graph defined by a node.
 
virtual void apply (SoPath *path)
 Initiates an action on the graph defined by a path.
 
virtual void apply (const SoPathList &pathList, SbBool obeysRules=FALSE)
 Initiates an action on the graph defined by a list of paths.
 
virtual void clearApplyResult ()
 When applied, an action may reference nodes or create objects (e.g.
 
virtual void invalidateState ()
 Invalidates the current traversal state in the action, forcing it to be recreated when the action is next applied.
 
void stopActionInBranch ()
 This function stops the action in the current Scene Graph branch.
 
SbBool getContinueActionInBranchFlag () const
 This function indicates if the action must stop in the current branch.
 
void resetContinueActionInBranchFlag ()
 This function resets the continue action flag.
 
void useAlternateRep (const SbBool enable)
 Tell the action to use alternate representations during traversal when available.
 
SbBool isUsingAlternateRep () const
 Returns TRUE if current action is using alternate representations.
 
void setSceneManager (SoSceneManager *mgr)
 Set the scene manager associated with this action (if any ).
 
SoSceneManagergetSceneManager () const
 Return the SoSceneManager associated with this action.
 
virtual void forwardTraversal (SoNode *node)
 Traverse a node that is not part of the current scenegraph.
 
virtual void forwardTraversal (SoPath *path)
 Traverse a path that is not part of the current scenegraph.
 
DistribMode getDistribMode () const
 Returns the distribution mode of this action across a cluster (ScaleViz-Cluster only).
 
AppliedCode getWhatAppliedTo () const
 Returns code indicating what action is being applied to.
 
SoNodegetNodeAppliedTo () const
 Returns the node the action is being applied to.
 
SoPathgetPathAppliedTo () const
 Returns the path the action is being applied to.
 
const SoPathListgetPathListAppliedTo () const
 Returns the path list the action is being applied to.
 
const SoPathListgetOriginalPathListAppliedTo () const
 Returns the original path list the action is being applied to.
 
SbBool isLastPathListAppliedTo () const
 Returns TRUE if the current list is the last one from the original.
 
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.
 
PathCode getPathCodeMI (int &numIndices, const int *&indices, const int *&instanceIndices)
 Extender API: available to programmers who wish to extend the toolkit
 
void traverse (SoNode *node)
 Does traversal of a graph rooted by a node.
 
SbBool hasTerminated () const
 Returns TRUE if the traversal has reached a termination condition.
 
const SoPathgetCurPath ()
 Returns the path accumulated during traversal, i.e., the chain of nodes from the root of the traversed graph to the current node being traversed.
 
SoStategetState () const
 Gets the state from the action.
 
virtual void setUpState ()
 Creates state if it is NULL or it is no longer valid because new elements have been enabled since it was created.
 
void setPipeId (int id)
 Sets pipe identifier in the range [1..N] associated to this render action while running a ScaleViz Multipipe configuration.
 
int getPipeId () const
 Gets pipe identifier in the range [1..N] associated to this render action while running a ScaleViz Multipipe configuration.
 
bool isBeingApplied ()
 Returns TRUE if this action is currently being applied.
 
virtual bool preDelayedTraversal ()
 Method called by SoMultiPassManager before delayed pass traversals.
 
virtual void postDelayedTraversal ()
 Method called by SoMultiPassManager after delayed pass traversals.
 
- Public Member Functions inherited from SoTypedObject
SbBool isOfType (const SoType &type) const
 Returns TRUE if this object is of the type specified in type or is derived from that type.
 
template<typename TypedObjectClass >
SbBool isOfType () const
 Returns TRUE if this object is of the type of class TypedObjectClass or is derived from that class.
 

Static Public Member Functions

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

Detailed Description

Computes bounding box of a scene.

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 an 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 object-space box. Note that this does not necessarily yield the smallest world-space-aligned box, especially in the case of few SoShape nodes. The application can accomodate this by using SoBBox nodes.
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, SbBox3f::isEmpty() will return TRUE).

The SoBBox node can be used to specify the bounding box for a shape or portion of the scene graph. This is useful, for example, to avoid the cost of computing the bounding box of a large (or frequently changing) geometry. The SoBBox node can also be used to specify that a shape or portion of the scene graph should not be included in the bounding box calculation. This is useful, for example, to avoid considering screen aligned "annotation" graphics like legends.

Bounding boxes are used internally by Open Inventor to optimize rendering, picking, culling and other operations. For example, the standard viewer classes apply an SoGetBoundingBoxAction to the scene graph when automatic adjustment of the near and far clipping planes is enabled (which is the default).

Bounding boxes are cached by some grouping nodes, primarily SoSeparator. When this action is applied to a scene graph, it will use the cached bounding box whenever possible. So querying the bounding box of a (relatively) static scene graph is normally very fast. Open Inventor automatically detects when bounding caches become invalid and they are re-computed the next time an SoGetBoundingBoxAction is applied.

NOTES:

  • The bounding box will only include shapes that are actually traversed.
    For example the bounding box will not include shapes under an SoSwitch with whichChild set to SO_SWITCH_NONE.
  • The action does not consider the visibility of shapes that are traversed.
    In other words the bounding box will include shapes that are invisible because of an SoDrawStyle, shapes that are clipped out because of an SoClipPlane, etc. Use SoBBox if necessary to exclude shapes from the bounding box computation.
  • Using the correct viewport region is critical when computing the bounding box of SoText2 (and a few other screen space related) nodes.
    However the bounding box of most shape nodes does not depend on the size of the viewport region and an approximate value may be passed to the constructor.

Sets: SoViewportRegionElement

EXAMPLE

SEE ALSO

SbBox3f, SbXfBox3f, SoGetMatrixAction, SoBBox

Definition at line 171 of file SoGetBoundingBoxAction.h.

Member Enumeration Documentation

◆ ResetType

Set a path to do a resetTransform/resetBoundingBox on.

The default is to do the reset right before the given path.

Enumerator
TRANSFORM 

Transformation.

BBOX 

Bounding box.

ALL 

Both transform and bounding box.

Definition at line 235 of file SoGetBoundingBoxAction.h.

Constructor & Destructor Documentation

◆ SoGetBoundingBoxAction()

SoGetBoundingBoxAction::SoGetBoundingBoxAction ( const SbViewportRegion viewportRegion)

Constructor.


Even though the bounding box computation may not involve a window per se, some nodes need the size of the viewport to determine their size in 3D coordinates. For example the size of an SoText2 is a fixed value in device coordinates, but the corresponding size in 3D depends on the current camera.

Usually it is convenient to get the actual viewport region from the viewer as shown in the example above. However if the scene graph does not contain any viewport dependent nodes then any values can be used.

Member Function Documentation

◆ getBoundingBox()

SbBox3f SoGetBoundingBoxAction::getBoundingBox ( ) const

Returns computed bounding box in world space.

◆ getCenter()

const SbVec3f & SoGetBoundingBoxAction::getCenter ( ) const

Returns computed center point in world space.

◆ getClassTypeId()

static SoType SoGetBoundingBoxAction::getClassTypeId ( )
static

Returns the type identifier for this class.


◆ getResetPath()

const SoPath * SoGetBoundingBoxAction::getResetPath ( ) const

Returns the current reset path, or NULL.

◆ getTypeId()

virtual SoType SoGetBoundingBoxAction::getTypeId ( ) const
virtual

Returns the type identifier for this specific instance.

Implements SoTypedObject.

◆ getViewportRegion()

const SbViewportRegion & SoGetBoundingBoxAction::getViewportRegion ( ) const

Returns current viewport region to use for action.

◆ getWhatReset()

SoGetBoundingBoxAction::ResetType SoGetBoundingBoxAction::getWhatReset ( ) const

Returns what flags were specified to be reset for the reset path.

◆ getXfBoundingBox()

SbXfBox3f & SoGetBoundingBoxAction::getXfBoundingBox ( )

Returns computed bounding box before transformation into world space.

◆ isInCameraSpace()

SbBool SoGetBoundingBoxAction::isInCameraSpace ( ) const

Returns camera space flag.

◆ isResetBefore()

SbBool SoGetBoundingBoxAction::isResetBefore ( ) const

Returns TRUE if the resetBefore flag was specified for the reset path.

◆ isResetPath()

SbBool SoGetBoundingBoxAction::isResetPath ( ) const

Returns TRUE if the current reset path is not NULL.

◆ setInCameraSpace()

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

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.

◆ setResetPath()

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

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)

Sets current viewport region to use for action.


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