Class SoGetBoundingBoxAction
- java.lang.Object
- 
- com.openinventor.inventor.Inventor
- 
- com.openinventor.inventor.actions.SoAction
- 
- com.openinventor.inventor.actions.SoGetBoundingBoxAction
 
 
 
- 
 public class SoGetBoundingBoxAction extends SoAction 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 anSoFaceSetis 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 theSoShape. 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 fewSoShapenodes. The application can accomodate this by usingSoBBoxnodes.
 The result of the calculation by the action can be returned as anSbXfBox3for as a world-space-alignedSbBox3f.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 SoBBoxnode 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. TheSoBBoxnode 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 SoGetBoundingBoxActionto 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 anSoGetBoundingBoxActionis applied.NOTES: - The bounding box will only include shapes that are actually traversed. 
 For example the bounding box will not include shapes under anSoSwitchwith 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 anSoDrawStyle, shapes that are clipped out because of anSoClipPlane, etc. UseSoBBoxif 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: SoViewportRegionElementEXAMPLE // Get bounding box using current viewport on screen SoGetBoundingBoxAction action = new SoGetBoundingBoxAction( viewer.getArea().getViewportRegion() ); action.apply( root ); SbBox3f bbox = action.getBoundingBox(); - See Also:
- SbBox3f,- SbXfBox3f,- SoGetMatrixAction,- SoBBox
 
- The bounding box will only include shapes that are actually traversed. 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classSoGetBoundingBoxAction.ResetTypesSet a path to do a resetTransform/resetBoundingBox on.- 
Nested classes/interfaces inherited from class com.openinventor.inventor.actions.SoActionSoAction.AppliedCodes, SoAction.DistribModes, SoAction.PathCodes, SoAction.PathIndices
 - 
Nested classes/interfaces inherited from class com.openinventor.inventor.InventorInventor.ConstructorCommand
 
- 
 - 
Field Summary- 
Fields inherited from class com.openinventor.inventor.InventorVERBOSE_LEVEL, ZeroHandle
 
- 
 - 
Constructor SummaryConstructors Constructor Description SoGetBoundingBoxAction(SbViewportRegion viewportRegion)Constructor.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckResetAfter()voidcheckResetBefore()static voidenableElement(java.lang.Class<? extends Inventor> t, int stkIndex)voidextendBy(SbBox3d box)voidextendBy(SbBox3f box)voidextendBy(SbXfBox3d box)voidextendBy(SbXfBox3f box)SbBox3fgetBoundingBox()Returns computed bounding box in world space.SbVec3fgetCenter()Returns computed center point in world space.SoPathgetResetPath()Returns the current reset path, or NULL.SbViewportRegiongetViewportRegion()Returns current viewport region to use for action.SoGetBoundingBoxAction.ResetTypesgetWhatReset()Returns what flags were specified to be reset for the reset path.SbXfBox3fgetXfBoundingBox()Returns computed bounding box before transformation into world space.booleanisCenterSet()booleanisInCameraSpace()Returns camera space flag.booleanisResetBefore()Returns true if the resetBefore flag was specified for the reset path.booleanisResetPath()Returns true if the current reset path is not NULL.voidresetCenter()voidsetCenter(SbVec3d center, boolean transformCenter)voidsetCenter(SbVec3f center, boolean transformCenter)voidsetInCameraSpace(boolean 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.voidsetResetPath(SoPath path)Calls setResetPath(path, true, SoGetBoundingBoxAction.ResetTypes.valueOf( SoGetBoundingBoxAction.ResetTypes.ALL.getValue() )).voidsetResetPath(SoPath path, boolean resetBefore)Calls setResetPath(path, resetBefore, SoGetBoundingBoxAction.ResetTypes.valueOf( SoGetBoundingBoxAction.ResetTypes.ALL.getValue() )).voidsetResetPath(SoPath path, boolean resetBefore, SoGetBoundingBoxAction.ResetTypes what)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.voidsetViewportRegion(SbViewportRegion newRegion)Sets current viewport region to use for action.- 
Methods inherited from class com.openinventor.inventor.actions.SoActionapply, apply, clearApplyResult, forwardTraversal, forwardTraversal, getContinueActionInBranchFlag, getCurPath, getDistribMode, getNodeAppliedTo, getOriginalPathListAppliedTo, getPathAppliedTo, getPathCode, getPathListAppliedTo, getPipeId, getSceneManager, getState, getWhatAppliedTo, hasTerminated, invalidateState, isBeingApplied, isLastPathListAppliedTo, isUsingAlternateRep, nullAction, postDelayedTraversal, preDelayedTraversal, resetContinueActionInBranchFlag, setPipeId, setSceneManager, setUpState, stopActionInBranch, traverse, useAlternateRep
 - 
Methods inherited from class com.openinventor.inventor.Inventordispose, getNativeResourceHandle
 
- 
 
- 
- 
- 
Constructor Detail- 
SoGetBoundingBoxActionpublic SoGetBoundingBoxAction(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 anSoText2is 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. 
 
- 
 - 
Method Detail- 
setResetPathpublic void setResetPath(SoPath path) Calls setResetPath(path, true, SoGetBoundingBoxAction.ResetTypes.valueOf( SoGetBoundingBoxAction.ResetTypes.ALL.getValue() )).
 - 
setResetPathpublic void setResetPath(SoPath path, boolean resetBefore) Calls setResetPath(path, resetBefore, SoGetBoundingBoxAction.ResetTypes.valueOf( SoGetBoundingBoxAction.ResetTypes.ALL.getValue() )).
 - 
getCenterpublic SbVec3f getCenter() Returns computed center point in world space.
 - 
setInCameraSpacepublic void setInCameraSpace(boolean 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.
 - 
isInCameraSpacepublic boolean isInCameraSpace() Returns camera space flag.
 - 
resetCenterpublic void resetCenter() 
 - 
setResetPathpublic void setResetPath(SoPath path, boolean resetBefore, SoGetBoundingBoxAction.ResetTypes what) 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.
 - 
getXfBoundingBoxpublic SbXfBox3f getXfBoundingBox() Returns computed bounding box before transformation into world space.
 - 
setViewportRegionpublic void setViewportRegion(SbViewportRegion newRegion) Sets current viewport region to use for action.
 - 
getViewportRegionpublic SbViewportRegion getViewportRegion() Returns current viewport region to use for action.
 - 
getBoundingBoxpublic SbBox3f getBoundingBox() Returns computed bounding box in world space.
 - 
enableElementpublic static void enableElement(java.lang.Class<? extends Inventor> t, int stkIndex) 
 - 
getResetPathpublic SoPath getResetPath() Returns the current reset path, or NULL.
 - 
extendBypublic void extendBy(SbXfBox3f box) 
 - 
extendBypublic void extendBy(SbBox3d box) 
 - 
extendBypublic void extendBy(SbXfBox3d box) 
 - 
checkResetAfterpublic void checkResetAfter() 
 - 
checkResetBeforepublic void checkResetBefore() 
 - 
extendBypublic void extendBy(SbBox3f box) 
 - 
setCenterpublic void setCenter(SbVec3d center, boolean transformCenter) 
 - 
isResetPathpublic boolean isResetPath() Returns true if the current reset path is not NULL.
 - 
isCenterSetpublic boolean isCenterSet() 
 - 
getWhatResetpublic SoGetBoundingBoxAction.ResetTypes getWhatReset() Returns what flags were specified to be reset for the reset path.
 - 
setCenterpublic void setCenter(SbVec3f center, boolean transformCenter) 
 - 
isResetBeforepublic boolean isResetBefore() Returns true if the resetBefore flag was specified for the reset path.
 
- 
 
-