SoGetBoundingBoxAction Class |
Computes bounding box of a scene.
Namespace: OIV.Inventor.Actions
The SoGetBoundingBoxAction type exposes the following members.
Name | Description | |
---|---|---|
SoGetBoundingBoxAction | Constructor. |
Name | Description | |
---|---|---|
Apply(SoNode) | Initiates an action on the graph defined by a node. | |
Apply(SoPath) | Initiates an action on the graph defined by a path. | |
Apply(SoPathList) | Calls Apply(pathList, false). (Inherited from SoAction.) | |
Apply(SoPathList, Boolean) | Initiates an action on the graph defined by a list of paths. | |
CheckResetAfter | ||
CheckResetBefore | ||
ClearApplyResult | When applied, an action may reference nodes or create objects (e.g. | |
EnableElement | ||
EnableElements | Obsolete.
Returns the list of enabled elements for a given action subclass.
(Inherited from SoAction.) | |
Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) | |
ExtendBy(SbBox3d) | ||
ExtendBy(SbBox3f) | ||
ExtendBy(SbXfBox3d) | ||
ExtendBy(SbXfBox3f) | ||
ForwardTraversal(SoNode) | Traverse a node that is not part of the current scenegraph. | |
ForwardTraversal(SoPath) | Traverse a path that is not part of the current scenegraph. | |
GetBoundingBox | Returns computed bounding box in world space. | |
GetCenter | Returns computed center point in world space. | |
GetContinueActionInBranchFlag | This function indicates if the action must stop in the current branch. | |
GetCurPath | 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. | |
GetDistribMode | Returns the distribution mode of this action across a cluster (ScaleViz-Cluster only). | |
GetHashCode |
Overrides GetHashCode().
(Inherited from SoNetBase.) | |
GetNodeAppliedTo | Returns the node the action is being applied to. | |
GetOriginalPathListAppliedTo | Returns the original path list the action is being applied to. | |
GetPathAppliedTo | Returns the path the action is being applied to. | |
GetPathCode | 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. | |
GetPathListAppliedTo | Returns the path list the action is being applied to. | |
GetPipeId | Gets pipe identifier in the range [1..N] associated to this render action while running a ScaleViz Multipipe configuration. | |
GetResetPath | Returns the current reset path, or NULL. | |
GetSceneManager | Return the OIV.Inventor.SoSceneManager associated with this action. | |
GetState | Gets the state from the action. | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
GetViewportRegion | Returns current viewport region to use for action. | |
GetWhatAppliedTo | Returns code indicating what action is being applied to. | |
GetWhatReset | Returns what flags were specified to be reset for the reset path. | |
GetXfBoundingBox | Returns computed bounding box before transformation into world space. | |
HasTerminated | Returns true if the traversal has reached a termination condition. | |
InvalidateState | Invalidates the current traversal state in the action, forcing it to be recreated when the action is next applied. | |
IsBeingApplied | Returns true if this action is currently being applied. | |
IsCenterSet | ||
IsInCameraSpace | Returns camera space flag. | |
IsLastPathListAppliedTo | Returns true if the current list is the last one from the original. | |
IsResetBefore | Returns true if the resetBefore flag was specified for the reset path. | |
IsResetPath | Returns true if the current reset path is not NULL. | |
IsUsingAlternateRep | Returns true if current action is using alternate representations. | |
PostDelayedTraversal | Method called by SoMultiPassManager after delayed pass traversals. | |
PreDelayedTraversal | Method called by SoMultiPassManager before delayed pass traversals. | |
ResetCenter | ||
ResetContinueActionInBranchFlag | This function resets the continue action flag. | |
SetCenter(SbVec3d, Boolean) | ||
SetCenter(SbVec3f, Boolean) | ||
SetInCameraSpace | Set this flag to true if you want the returned bounding box to be in the space of whatever camera is in the graph. | |
SetPipeId | Sets pipe identifier in the range [1..N] associated to this render action while running a ScaleViz Multipipe configuration. | |
SetResetPath(SoPath) | Calls SetResetPath(path, true, OIV.Inventor.Actions.SoGetBoundingBoxAction.ResetTypes( .SoGetBoundingBoxAction.ALL )). | |
SetResetPath(SoPath, Boolean) | Calls SetResetPath(path, resetBefore, OIV.Inventor.Actions.SoGetBoundingBoxAction.ResetTypes( .SoGetBoundingBoxAction.ALL )). | |
SetResetPath(SoPath, Boolean, SoGetBoundingBoxActionResetTypes) | 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. | |
SetSceneManager | Set the scene manager associated with this action (if any ). | |
SetUpState | Creates state if it is NULL or it is no longer valid because new elements have been enabled since it was created. | |
SetViewportRegion | Sets current viewport region to use for action. | |
StopActionInBranch | This function stops the action in the current Scene Graph branch. | |
ToString | Returns a string that represents the current object. (Inherited from Object.) | |
Traverse | Does traversal of a graph rooted by a node. | |
UseAlternateRep | Tell the action to use alternate representations during traversal when available. |
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 OIV.Inventor.Nodes.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 OIV.Inventor.SbXfBox3f, where the transformation matrix is defined so that the bounding box can be stored in the object space of the OIV.Inventor.Nodes.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 OIV.Inventor.Nodes.SoShape nodes. The application can accomodate this by using OIV.Inventor.Nodes.SoBBox nodes. The result of the calculation by the action can be returned as an OIV.Inventor.SbXfBox3f or as a world-space-aligned OIV.Inventor.SbBox3f.
To calculate the bounding box of a subgraph bounded by two paths, specify the left edge of the subgraph with OIV.Inventor.Actions.SoGetBoundingBoxAction.SetResetPath(OIV.Inventor.SoPath, System.Boolean, OIV.Inventor.Actions.SoGetBoundingBoxAction.ResetTypes), 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 OIV.Inventor.Nodes.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 OIV.Inventor.Nodes.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 OIV.Inventor.Actions.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 OIV.Inventor.Nodes.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 OIV.Inventor.Actions.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 OIV.Inventor.Nodes.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 OIV.Inventor.Nodes.SoDrawStyle, shapes that are clipped out because of an OIV.Inventor.Nodes.SoClipPlane, etc. Use OIV.Inventor.Nodes.SoBBox if necessary to exclude shapes from the bounding box computation.
Using the correct viewport region is critical when computing the bounding box of OIV.Inventor.Nodes.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: OIV.Inventor.Elements.SoViewportRegionElement
SoGetBoundingBoxAction gba = new SoGetBoundingBoxAction( viewer.GetViewportRegion() );
gba.Apply( root );
SbBox3f bbox = gba.GetBoundingBox();