Open Inventor Release 2024.1.3
 
Loading...
Searching...
No Matches
SoGetBoundingBoxAction.h
1/*=======================================================================
2 * Copyright 1991-1996, Silicon Graphics, Inc.
3 * ALL RIGHTS RESERVED
4 *
5 * UNPUBLISHED -- Rights reserved under the copyright laws of the United
6 * States. Use of a copyright notice is precautionary only and does not
7 * imply publication or disclosure.
8 *
9 * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
10 * Use, duplication or disclosure by the Government is subject to restrictions
11 * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
12 * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
13 * in similar or successor clauses in the FAR, or the DOD or NASA FAR
14 * Supplement. Contractor/manufacturer is Silicon Graphics, Inc.,
15 * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
16 *
17 * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
18 * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
19 * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
20 * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
21 * GRAPHICS, INC.
22**=======================================================================*/
23/*=======================================================================
24** Author : Paul S. Strauss (MMM yyyy)
25**=======================================================================*/
26/*=======================================================================
27 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
28 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
29 *** ***
30 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
31 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
32 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
33 *** ***
34 *** RESTRICTED RIGHTS LEGEND ***
35 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
36 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
37 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
38 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
39 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
40 *** ***
41 *** COPYRIGHT (C) 1996-2023 BY FEI S.A.S, ***
42 *** BORDEAUX, FRANCE ***
43 *** ALL RIGHTS RESERVED ***
44**=======================================================================*/
45/*=======================================================================
46** Modified by : VSG (MMM YYYY)
47**=======================================================================*/
48
49
50#ifndef _SO_GET_BOUNDING_BOX_ACTION_
51#define _SO_GET_BOUNDING_BOX_ACTION_
52
53#include <Inventor/SbBox.h>
54#include <Inventor/SbViewportRegion.h>
55#include <Inventor/actions/SoSubAction.h>
56
58//
59// Class: SoGetBoundingBoxAction
60//
61// For computing a bounding box enclosing objects defined by a scene
62// graph. The box is a rectangular prism whose sides are aligned with
63// the coordinate axes, and is represented as an SbBox3f. It also
64// computes the center point, which is defined differently for
65// different objects.
66//
68
172{
173 SO_ACTION_HEADER(SoGetBoundingBoxAction);
174
175 public:
188
189 // Destructor
190#ifndef HIDDEN_FROM_DOC
191 virtual ~SoGetBoundingBoxAction();
192#endif // HIDDEN_FROM_DOC
193
197 void setViewportRegion(const SbViewportRegion &newRegion);
198
203
208
213
217 const SbVec3f &getCenter() const;
218
226
231
235 enum ResetType { // Which things get reset:
239 TRANSFORM = 0x01,
243 BBOX = 0x02,
247 ALL = 0x03
248 };
249
256 void setResetPath(const SoPath *path,
257 SbBool resetBefore = TRUE,
258 ResetType what = ALL);
262 const SoPath *getResetPath() const;
275
276 private:
277
278 // Call these methods at beginning and end (respectively) of
279 // the getBoundingBox action for each node. (SoNode calls these in
280 // its static method for this action.)
281 void checkResetBefore();
282 void checkResetAfter();
283
284 // Extends the current bounding box by the given bounding box,
285 // after transforming it by the current value of the
286 // SoLocalBBoxMatrixElement
287 void extendBy(const SbBox3f &box);
288 void extendBy(const SbXfBox3f &box);
289
290 void extendBy(const SbBox3d &box);
291 void extendBy(const SbXfBox3d &box);
292
293 // Sets the center of the bounding box to the given point, which,
294 // if transformCenter is TRUE, is first transformed by the current
295 // value of the SoLocalBBoxMatrixElement. After this is called,
296 // isCenterSet will return TRUE, unless resetCenter is called.
297 // Shapes should setCenter() to whatever is appropriate (e.g.
298 // left-justified text might set the center to be the start of the
299 // string) with transformCenter set to TRUE. Groups are
300 // responsible for averaging the centers if more than one shape
301 // sets the center; when setting the center to the average of
302 // transformed centers, pass FALSE for transformCenter.
303 void setCenter(const SbVec3f &center, SbBool transformCenter);
304 void setCenter(const SbVec3d &center, SbBool transformCenter);
305
306 SbBool isCenterSet() const;
307 void resetCenter();
308
309 private:
310 static void initClass();
311 static void exitClass();
312
321 void setIgnoreScreenSpaceBoundingBoxes(bool flag);
322
326 bool ignoreScreenSpaceBoundingBoxes() const;
327
328 private:
329 // Initiates action on graph
330 virtual void beginTraversal(SoNode *node);
331
332 private:
333 SbXfBox3f box; // Bounding box
334 SbVec3f center; // Center point
335 SbBool cameraSpace; // Bounding box in camera space?
336 const SoPath *resetPath; // path to reset transform
337 SbBool resetBefore; // reset before or after?
338 ResetType resetWhat; // which things get reset?
339 SbViewportRegion vpRegion; // Current viewport region
340 SbBool centerSet; // setCenter() called?
341
342 bool m_ignoreScreenSpaceBoundingBoxes;
343
344 // check to see if the reset parameters are met, if so, do the
345 // reset transform and reset bbox
346 void checkReset(SbBool resetBefore);
347
348};
349
350#endif /* _SO_GET_BOUNDING_BOX_ACTION_ */
351
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> 3D box class.
Definition SbBox.h:972
3D box class.
Definition SbBox.h:649
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> 3D vector class ...
Definition SbVec.h:1214
3D vector class.
Definition SbVec.h:932
Class for representing a viewport.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> 3D box with an a...
Definition SbBox.h:1513
3D box with an associated transformation matrix.
Definition SbBox.h:1250
Abstract base class for all actions.
Definition SoAction.h:132
Computes bounding box of a scene.
SbBool isInCameraSpace() const
Returns camera space flag.
SbXfBox3f & getXfBoundingBox()
Returns computed bounding box before transformation into world space.
void setViewportRegion(const SbViewportRegion &newRegion)
Sets current viewport region to use for action.
SbBool isResetPath() const
Returns TRUE if the current reset path is not NULL.
const SbVec3f & getCenter() const
Returns computed center point in world space.
SoGetBoundingBoxAction(const SbViewportRegion &viewportRegion)
Constructor.
SbBool isResetBefore() const
Returns TRUE if the resetBefore flag was specified for the reset path.
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 ...
const SbViewportRegion & getViewportRegion() const
Returns current viewport region to use for action.
const SoPath * getResetPath() const
Returns the current reset path, or NULL.
ResetType
Set a path to do a resetTransform/resetBoundingBox on.
@ ALL
Both transform and bounding box.
SbBox3f getBoundingBox() const
Returns computed bounding box in world space.
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 t...
SoGetBoundingBoxAction::ResetType getWhatReset() const
Returns what flags were specified to be reset for the reset path.
Abstract base class for all database nodes.
Definition SoNode.h:145
Path that points to a list of hierarchical nodes.
Definition SoPath.h:187
int SbBool
Boolean type.
Definition SbBase.h:87