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-2016 BY FEI S.A.S, *** 00042 *** MERIGNAC, 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 00170 class SoGetBoundingBoxAction : public SoAction 00171 { 00172 SO_ACTION_HEADER(SoGetBoundingBoxAction); 00173 00174 public: 00186 SoGetBoundingBoxAction(const SbViewportRegion &viewportRegion); 00187 00188 // Destructor 00189 #ifndef HIDDEN_FROM_DOC 00190 virtual ~SoGetBoundingBoxAction(); 00191 #endif // HIDDEN_FROM_DOC 00192 00196 void setViewportRegion(const SbViewportRegion &newRegion); 00197 00201 const SbViewportRegion &getViewportRegion() const; 00202 00206 SbBox3f getBoundingBox() const; 00207 00211 SbXfBox3f &getXfBoundingBox(); 00212 00216 const SbVec3f &getCenter() const; 00217 00224 void setInCameraSpace(SbBool flag); 00225 00229 SbBool isInCameraSpace() const; 00230 00234 enum ResetType { // Which things get reset: 00238 TRANSFORM = 0x01, 00242 BBOX = 0x02, 00246 ALL = 0x03 00247 }; 00248 00255 void setResetPath(const SoPath *path, 00256 SbBool resetBefore = TRUE, 00257 ResetType what = ALL); 00261 const SoPath *getResetPath() const; 00265 SbBool isResetPath() const; 00269 SbBool isResetBefore() const; 00273 SoGetBoundingBoxAction::ResetType getWhatReset() const; 00274 00275 private: 00276 00277 // Call these methods at beginning and end (respectively) of 00278 // the getBoundingBox action for each node. (SoNode calls these in 00279 // its static method for this action.) 00280 void checkResetBefore(); 00281 void checkResetAfter(); 00282 00283 // Extends the current bounding box by the given bounding box, 00284 // after transforming it by the current value of the 00285 // SoLocalBBoxMatrixElement 00286 void extendBy(const SbBox3f &box); 00287 void extendBy(const SbXfBox3f &box); 00288 00289 void extendBy(const SbBox3d &box); 00290 void extendBy(const SbXfBox3d &box); 00291 00292 // Sets the center of the bounding box to the given point, which, 00293 // if transformCenter is TRUE, is first transformed by the current 00294 // value of the SoLocalBBoxMatrixElement. After this is called, 00295 // isCenterSet will return TRUE, unless resetCenter is called. 00296 // Shapes should setCenter() to whatever is appropriate (e.g. 00297 // left-justified text might set the center to be the start of the 00298 // string) with transformCenter set to TRUE. Groups are 00299 // responsible for averaging the centers if more than one shape 00300 // sets the center; when setting the center to the average of 00301 // transformed centers, pass FALSE for transformCenter. 00302 void setCenter(const SbVec3f ¢er, SbBool transformCenter); 00303 void setCenter(const SbVec3d ¢er, SbBool transformCenter); 00304 00305 SbBool isCenterSet() const; 00306 void resetCenter(); 00307 00308 private: 00309 static void initClass(); 00310 static void exitClass(); 00311 00320 void setIgnoreScreenSpaceBoundingBoxes(bool flag); 00321 00325 bool ignoreScreenSpaceBoundingBoxes() const; 00326 00327 private: 00328 // Initiates action on graph 00329 virtual void beginTraversal(SoNode *node); 00330 00331 private: 00332 SbXfBox3f box; // Bounding box 00333 SbVec3f center; // Center point 00334 SbBool cameraSpace; // Bounding box in camera space? 00335 const SoPath *resetPath; // path to reset transform 00336 SbBool resetBefore; // reset before or after? 00337 ResetType resetWhat; // which things get reset? 00338 SbViewportRegion vpRegion; // Current viewport region 00339 SbBool centerSet; // setCenter() called? 00340 00341 bool m_ignoreScreenSpaceBoundingBoxes; 00342 00343 // check to see if the reset parameters are met, if so, do the 00344 // reset transform and reset bbox 00345 void checkReset(SbBool resetBefore); 00346 00347 }; 00348 00349 #endif /* _SO_GET_BOUNDING_BOX_ACTION_ */ 00350 00351