public class SoGetBoundingBoxAction extends SoAction
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 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, 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:
SoSwitch
with
whichChild set to SO_SWITCH_NONE.
SoDrawStyle
, shapes that are clipped out because of an SoClipPlane
, etc. Use SoBBox
if necessary to exclude shapes from the bounding box computation.
SoText2
(and a few other screen space related) nodes. Sets: SoViewportRegionElement
// Get bounding box using current viewport on screen SoGetBoundingBoxAction action = new SoGetBoundingBoxAction( viewer.getArea().getViewportRegion() ); action.apply( root ); SbBox3f bbox = action.getBoundingBox();
See also:
Modifier and Type | Class and Description |
---|---|
static class |
SoGetBoundingBoxAction.ResetTypes
Set a path to do a resetTransform/resetBoundingBox on.
|
SoAction.AppliedCodes, SoAction.DistribModes, SoAction.PathCodes, SoAction.PathIndices
Inventor.ConstructorCommand
VERBOSE_LEVEL, ZeroHandle
Constructor and Description |
---|
SoGetBoundingBoxAction(SbViewportRegion viewportRegion)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
checkResetAfter() |
void |
checkResetBefore() |
static void |
enableElement(java.lang.Class<? extends Inventor> t,
int stkIndex) |
void |
extendBy(SbBox3d box) |
void |
extendBy(SbBox3f box) |
void |
extendBy(SbXfBox3d box) |
void |
extendBy(SbXfBox3f box) |
SbBox3f |
getBoundingBox()
Returns computed bounding box in world space.
|
SbVec3f |
getCenter()
Returns computed center point in world space.
|
SoPath |
getResetPath()
Returns the current reset path, or NULL.
|
SbViewportRegion |
getViewportRegion()
Returns current viewport region to use for action.
|
SoGetBoundingBoxAction.ResetTypes |
getWhatReset()
Returns what flags were specified to be reset for the reset path.
|
SbXfBox3f |
getXfBoundingBox()
Returns computed bounding box before transformation into world space.
|
boolean |
isCenterSet() |
boolean |
isInCameraSpace()
Returns camera space flag.
|
boolean |
isResetBefore()
Returns true if the resetBefore flag was specified for the reset path.
|
boolean |
isResetPath()
Returns true if the current reset path is not NULL.
|
void |
resetCenter() |
void |
setCenter(SbVec3d center,
boolean transformCenter) |
void |
setCenter(SbVec3f center,
boolean transformCenter) |
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.
|
void |
setResetPath(SoPath path)
Calls setResetPath(path, true, SoGetBoundingBoxAction.ResetTypes.valueOf( SoGetBoundingBoxAction.ResetTypes.ALL.getValue() )).
|
void |
setResetPath(SoPath path,
boolean resetBefore)
Calls setResetPath(path, resetBefore, SoGetBoundingBoxAction.ResetTypes.valueOf( SoGetBoundingBoxAction.ResetTypes.ALL.getValue() )).
|
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.
|
void |
setViewportRegion(SbViewportRegion newRegion)
Sets current viewport region to use for action.
|
apply, apply, clearApplyResult, 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
dispose, getNativeResourceHandle
public SoGetBoundingBoxAction(SbViewportRegion viewportRegion)
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.
public void setResetPath(SoPath path)
public void setResetPath(SoPath path, boolean resetBefore)
public SbVec3f getCenter()
public void setInCameraSpace(boolean flag)
public boolean isInCameraSpace()
public void resetCenter()
public void setResetPath(SoPath path, boolean resetBefore, SoGetBoundingBoxAction.ResetTypes what)
public SbXfBox3f getXfBoundingBox()
public void setViewportRegion(SbViewportRegion newRegion)
public SbViewportRegion getViewportRegion()
public SbBox3f getBoundingBox()
public static void enableElement(java.lang.Class<? extends Inventor> t, int stkIndex)
public SoPath getResetPath()
public void extendBy(SbXfBox3f box)
public void extendBy(SbBox3d box)
public void extendBy(SbXfBox3d box)
public void checkResetAfter()
public void checkResetBefore()
public void extendBy(SbBox3f box)
public void setCenter(SbVec3d center, boolean transformCenter)
public boolean isResetPath()
public boolean isCenterSet()
public SoGetBoundingBoxAction.ResetTypes getWhatReset()
public void setCenter(SbVec3f center, boolean transformCenter)
public boolean isResetBefore()
Generated on July 31, 2019, Copyright © Thermo Fisher Scientific. All rights reserved. http://www.openinventor.com