#include <Inventor/actions/SoGetBoundingBoxAction.h>
Inheritance diagram for SoGetBoundingBoxAction:
Public Types | |
enum | ResetType { TRANSFORM = 0x1, BBOX = 0x2, ALL = TRANSFORM | BBOX } |
Public Member Functions | |
SoGetBoundingBoxAction (const SbViewportRegion &vp) | |
virtual | ~SoGetBoundingBoxAction () |
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 ¢er, const SbBool transformcenter) |
SbBool | isCenterSet (void) const |
void | resetCenter (void) |
Static Public Member Functions | |
void | initClass (void) |
Protected Member Functions | |
virtual void | beginTraversal (SoNode *node) |
The use of bounding boxes is ubiquitous within the Coin library. It is needed for the correct execution of and for performance enhancements during rendering, picking, caching, culling, etc.
Apply this action to a path or scene graph root to calculate the bounding box and the center point of the geometry contained within the scene.
SoSeparator nodes are aggressively caching the results of bounding box calculations, so that they are really only re-calculated whenever the scenegraph rooted below any SoSeparator node has been modified. This means that applying this action to scenegraphs, or parts of scenegraphs, should be very quick on successive runs for "static" parts of the scene.
Note: the algorithm used is not guaranteed to give an optimal bbox; it always considers two bounding boxes 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 is changed, and to make a perfect fit all objects contained within it would have to be re-examined).
|
This API member is considered internal to the library, as it is not likely to be of interest to the application programmer. |
|
Constructor. It might seem unnecessary to have to pass in a viewport region argument to calculate bounding boxes, but there is a good reason for this: a few shape nodes needs to know the viewport region to calculate their bounding box -- these include SoText2 and SoImage, among others. What is particular about these shapes is that they are fundamentally 2D shapes, but they are 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.) 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. 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 is also necessary to know the viewport region to find out how to accurately calculate the bounding box of those shapes. 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 available, you can get hold of the viewport region data simply by doing
(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.) |
|
Destructor. |
|
Initializes the run-time type system for this class, and sets up the enabled elements and action method list. Reimplemented from SoAction. |
|
Set a new viewport region with this method, if it has changed from the oned passed in with the constructor. |
|
Returns the viewport region used by the action instance. |
|
Returns the projected bounding box after (or during) traversal. |
|
Returns the bounding box and transformation matrix to global coordinates. Use after (or during) traversal. |
|
Returns center point of scene after the action has been applied. This might differ from the geometric center of the bounding box, as 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). |
|
Sets whether the returned bounding box should be calculated in the coordinate system of the camera space or not. |
|
Returns whether the bounding box returned is to be in camera space. |
|
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.
|
|
Returns the reset path (or
|
|
Returns whether a reset path is set or not.
|
|
Returns whether the bounding box and transformation is reset before or after the tail node of the reset path.
|
|
Returns what type of reset has been specified for the reset path.
|
|
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). |
|
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). |
|
Extend 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. |
|
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. |
|
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. |
|
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. |
|
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. |
|
This virtual method is called from SoAction::apply(), and is the entry point for the actual scenegraph traversal. It can be overridden to initialize the action at traversal start, for specific initializations in the action subclasses inheriting SoAction. Default method just calls traverse(), which any overridden implementation of the method must do too (or call SoAction::beginTraversal()) to trigger the scenegraph traversal. Reimplemented from SoAction. |