Open Inventor Reference
SoGetBoundingBoxAction.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * Further, this software is distributed without any warranty that it is
16  * free of the rightful claim of any third person regarding infringement
17  * or the like. Any license provided herein, whether implied or
18  * otherwise, applies only to this software file. Patent licenses, if
19  * any, provided herein do not apply to combinations of this program with
20  * other software, or any other product whatsoever.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with this library; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25  *
26  * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27  * Mountain View, CA 94043, or:
28  *
29  * http://www.sgi.com
30  *
31  * For further information regarding this notice, see:
32  *
33  * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
34  *
35  */
36 
37 
38 /*
39  * Copyright (C) 1990,91 Silicon Graphics, Inc.
40  *
41  _______________________________________________________________________
42  ______________ S I L I C O N G R A P H I C S I N C . ____________
43  |
44  | $Revision: 1.1.1.1 $
45  |
46  | Description:
47  | Defines the SoGetBoundingBoxAction class
48  |
49  | Author(s) : Paul S. Strauss
50  |
51  ______________ S I L I C O N G R A P H I C S I N C . ____________
52  _______________________________________________________________________
53  */
54 
55 #ifndef _SO_GET_BOUNDING_BOX_ACTION_
56 #define _SO_GET_BOUNDING_BOX_ACTION_
57 
59 #include <Inventor/SbBox.h>
62 
63 
66 
103 
105 
107 
108  public:
109 
114  SoGetBoundingBoxAction(const SbViewportRegion &viewportRegion);
115 
118 
120  void setViewportRegion(const SbViewportRegion &newRegion);
121 
123  const SbViewportRegion &getViewportRegion() const { return vpRegion; }
124 
126  SbBox3f getBoundingBox() const { return box.project(); }
127 
129  SbXfBox3f & getXfBoundingBox() { return box; }
130 
132  const SbVec3f & getCenter() const;
133 
139  void setInCameraSpace(bool flag) { cameraSpace = flag; }
140 
142  bool isInCameraSpace() const { return cameraSpace; }
143 
147  enum ResetType {
148  TRANSFORM = 0x01,
149  BBOX = 0x02,
150  ALL = 0x03
151  };
156  void setResetPath(const SoPath *path,
157  bool resetBefore = TRUE,
158  ResetType what = ALL);
160  const SoPath * getResetPath() const { return resetPath; }
162  bool isResetPath() const { return( resetPath != NULL); }
164  bool isResetBefore() const { return resetBefore; }
165  SoGetBoundingBoxAction::ResetType getWhatReset() const { return resetWhat;}
166 
167  SoEXTENDER public:
168 
174 
178  void extendBy(const SbBox3f &box);
179  void extendBy(const SbXfBox3f &box);
180 
191  void setCenter(const SbVec3f &center,
192  bool transformCenter);
193  bool isCenterSet() const;
194  void resetCenter();
195 
196  SoINTERNAL public:
197  static void initClass();
198 
199  protected:
201  virtual void beginTraversal(SoNode *node);
202 
203  private:
204  SbXfBox3f box;
205  SbVec3f center;
206  bool cameraSpace;
207  const SoPath *resetPath;
208  bool resetBefore;
209  ResetType resetWhat;
210  SbViewportRegion vpRegion;
211  bool centerSet;
212 
215  void checkReset(bool resetBefore);
216 };
217 
218 #endif /* _SO_GET_BOUNDING_BOX_ACTION_ */
#define SoEXTENDER
Provide inline template functions for abs, swap, min, max, and clamp.
Definition: SbBasic.h:154
#define TRUE
Definition: SbBasic.h:76
#define SoINTERNAL
Definition: SbBasic.h:155
#define INVENTOR_API
Disable some annoying warnings on MSVC 6.
Definition: SbSystem.h:81
#define SO_ACTION_HEADER(className)
Macros to be called within the class definition header for an action subclass:
Definition: SoSubAction.h:87
3D box class.
Definition: SbBox.h:81
3D vector class.
Definition: SbLinear.h:120
Class for representing a viewport.
3D box with an associated transformation matrix.
Definition: SbBox.h:228
Abstract base class for all actions.
Definition: SoAction.h:179
Computes bounding box of a scene.
const SbVec3f & getCenter() const
Returns computed center point in world space.
bool isResetPath() const
Returns TRUE if the current reset path is not NULL.
bool isInCameraSpace() const
Returns camera space flag.
void setViewportRegion(const SbViewportRegion &newRegion)
Sets/returns current viewport region to use for action.
void setResetPath(const SoPath *path, bool 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...
void setCenter(const SbVec3f &center, bool transformCenter)
Sets the center of the bounding box to the given point, which, if transformCenter is TRUE,...
void extendBy(const SbBox3f &box)
Extends the current bounding box by the given bounding box, after transforming it by the current valu...
bool isCenterSet() const
void checkResetBefore()
Call these methods at beginning and end (respectively) of the getBoundingBox action for each node.
virtual ~SoGetBoundingBoxAction()
Destructor.
SoGetBoundingBoxAction(const SbViewportRegion &viewportRegion)
Constructor takes viewport region to use for picking.
void extendBy(const SbXfBox3f &box)
virtual void beginTraversal(SoNode *node)
Initiates action on graph.
SbXfBox3f & getXfBoundingBox()
Returns computed bounding box before transformation into world space.
const SbViewportRegion & getViewportRegion() const
Sets/returns current viewport region to use for action.
ResetType
set a path to do a resetTransform/resetBoundingBox on.
bool isResetBefore() const
Returns TRUE if the resetBefore flag was specified for the reset path.
SbBox3f getBoundingBox() const
Returns computed bounding box in world space.
static void initClass()
const SoPath * getResetPath() const
Returns the current reset path, or NULL.
SoGetBoundingBoxAction::ResetType getWhatReset() const
void setInCameraSpace(bool flag)
Set this flag to TRUE if you want the returned bounding box to be in the space of whatever camera is ...
Abstract base class for all database nodes.
Definition: SoNode.h:103
Path that points to a list of hierarchical nodes.
Definition: SoPath.h:109