00001 /*======================================================================= 00002 * Copyright 1991-1996, Silicon Graphics, Inc. 00003 * ALL RIGHTS RESERVED 00004 * 00005 * UNPUBLISHED -- Rights reserved under the copyright laws of the United 00006 * States. Use of a copyright notice is precautionary only and does not 00007 * imply publication or disclosure. 00008 * 00009 * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND: 00010 * Use, duplication or disclosure by the Government is subject to restrictions 00011 * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights 00012 * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or 00013 * in similar or successor clauses in the FAR, or the DOD or NASA FAR 00014 * Supplement. Contractor/manufacturer is Silicon Graphics, Inc., 00015 * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311. 00016 * 00017 * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY 00018 * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION, 00019 * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY 00020 * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON 00021 * GRAPHICS, INC. 00022 **=======================================================================*/ 00023 /*======================================================================= 00024 ** Author : Paul S. Strauss (MMM yyyy) 00025 **=======================================================================*/ 00026 /*======================================================================= 00027 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), *** 00028 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. *** 00029 *** *** 00030 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS *** 00031 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR *** 00032 *** WRITTEN AUTHORIZATION OF FEI S.A.S. *** 00033 *** *** 00034 *** RESTRICTED RIGHTS LEGEND *** 00035 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS *** 00036 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN *** 00037 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT *** 00038 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN *** 00039 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. *** 00040 *** *** 00041 *** COPYRIGHT (C) 1996-2023 BY FEI S.A.S, *** 00042 *** BORDEAUX, FRANCE *** 00043 *** ALL RIGHTS RESERVED *** 00044 **=======================================================================*/ 00045 /*======================================================================= 00046 ** Modified by : VSG (MMM YYYY) 00047 **=======================================================================*/ 00048 00049 00050 #ifndef _SO_GET_BOUNDING_BOX_ACTION_ 00051 #define _SO_GET_BOUNDING_BOX_ACTION_ 00052 00053 #include <Inventor/SbBox.h> 00054 #include <Inventor/SbViewportRegion.h> 00055 #include <Inventor/actions/SoSubAction.h> 00056 00058 // 00059 // Class: SoGetBoundingBoxAction 00060 // 00061 // For computing a bounding box enclosing objects defined by a scene 00062 // graph. The box is a rectangular prism whose sides are aligned with 00063 // the coordinate axes, and is represented as an SbBox3f. It also 00064 // computes the center point, which is defined differently for 00065 // different objects. 00066 // 00068 00171 class SoGetBoundingBoxAction : public SoAction 00172 { 00173 SO_ACTION_HEADER(SoGetBoundingBoxAction); 00174 00175 public: 00187 SoGetBoundingBoxAction(const SbViewportRegion &viewportRegion); 00188 00189 // Destructor 00190 #ifndef HIDDEN_FROM_DOC 00191 virtual ~SoGetBoundingBoxAction(); 00192 #endif // HIDDEN_FROM_DOC 00193 00197 void setViewportRegion(const SbViewportRegion &newRegion); 00198 00202 const SbViewportRegion &getViewportRegion() const; 00203 00207 SbBox3f getBoundingBox() const; 00208 00212 SbXfBox3f &getXfBoundingBox(); 00213 00217 const SbVec3f &getCenter() const; 00218 00225 void setInCameraSpace(SbBool flag); 00226 00230 SbBool isInCameraSpace() const; 00231 00235 enum ResetType { // Which things get reset: 00239 TRANSFORM = 0x01, 00243 BBOX = 0x02, 00247 ALL = 0x03 00248 }; 00249 00256 void setResetPath(const SoPath *path, 00257 SbBool resetBefore = TRUE, 00258 ResetType what = ALL); 00262 const SoPath *getResetPath() const; 00266 SbBool isResetPath() const; 00270 SbBool isResetBefore() const; 00274 SoGetBoundingBoxAction::ResetType getWhatReset() const; 00275 00276 private: 00277 00278 // Call these methods at beginning and end (respectively) of 00279 // the getBoundingBox action for each node. (SoNode calls these in 00280 // its static method for this action.) 00281 void checkResetBefore(); 00282 void checkResetAfter(); 00283 00284 // Extends the current bounding box by the given bounding box, 00285 // after transforming it by the current value of the 00286 // SoLocalBBoxMatrixElement 00287 void extendBy(const SbBox3f &box); 00288 void extendBy(const SbXfBox3f &box); 00289 00290 void extendBy(const SbBox3d &box); 00291 void extendBy(const SbXfBox3d &box); 00292 00293 // Sets the center of the bounding box to the given point, which, 00294 // if transformCenter is TRUE, is first transformed by the current 00295 // value of the SoLocalBBoxMatrixElement. After this is called, 00296 // isCenterSet will return TRUE, unless resetCenter is called. 00297 // Shapes should setCenter() to whatever is appropriate (e.g. 00298 // left-justified text might set the center to be the start of the 00299 // string) with transformCenter set to TRUE. Groups are 00300 // responsible for averaging the centers if more than one shape 00301 // sets the center; when setting the center to the average of 00302 // transformed centers, pass FALSE for transformCenter. 00303 void setCenter(const SbVec3f ¢er, SbBool transformCenter); 00304 void setCenter(const SbVec3d ¢er, SbBool transformCenter); 00305 00306 SbBool isCenterSet() const; 00307 void resetCenter(); 00308 00309 private: 00310 static void initClass(); 00311 static void exitClass(); 00312 00321 void setIgnoreScreenSpaceBoundingBoxes(bool flag); 00322 00326 bool ignoreScreenSpaceBoundingBoxes() const; 00327 00328 private: 00329 // Initiates action on graph 00330 virtual void beginTraversal(SoNode *node); 00331 00332 private: 00333 SbXfBox3f box; // Bounding box 00334 SbVec3f center; // Center point 00335 SbBool cameraSpace; // Bounding box in camera space? 00336 const SoPath *resetPath; // path to reset transform 00337 SbBool resetBefore; // reset before or after? 00338 ResetType resetWhat; // which things get reset? 00339 SbViewportRegion vpRegion; // Current viewport region 00340 SbBool centerSet; // setCenter() called? 00341 00342 bool m_ignoreScreenSpaceBoundingBoxes; 00343 00344 // check to see if the reset parameters are met, if so, do the 00345 // reset transform and reset bbox 00346 void checkReset(SbBool resetBefore); 00347 00348 }; 00349 00350 #endif /* _SO_GET_BOUNDING_BOX_ACTION_ */ 00351 00352