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 : Gavin Bell (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-2020 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_VRMLLOD_ 00051 #define _SO_VRMLLOD_ 00052 00053 #include <Inventor/fields/SoMFFloat.h> 00054 #include <Inventor/fields/SoSFVec3f.h> 00055 #include <Inventor/fields/SoMFNode.h> 00056 #include <Inventor/fields/SoSFNode.h> 00057 #include <Inventor/VRMLnodes/SoVRMLParent.h> 00058 00059 00060 #if defined(OIV_IGNORE_VRML_DEPRECATED) 00061 #include <SoDeprecationRules.h> 00062 #pragma push_macro("SoDEPRECATED_CLASS") 00063 #pragma push_macro("SoDEPRECATED_TYPEDEF") 00064 #undef SoDEPRECATED_CLASS 00065 #undef SoDEPRECATED_TYPEDEF 00066 #define SoDEPRECATED_CLASS(x,y) 00067 #define SoDEPRECATED_TYPEDEF(x,y) 00068 #endif 00069 00071 // 00072 // Class: SoVRMLLOD 00073 // 00074 // Level-of-detail group node. The levels of this node typically 00075 // represent the same object or objects at varying levels of detail, 00076 // from highest detail to lowest. The world-space distance of the 00077 // eye from the transformed center of the VRMLLOD is computed, and one 00078 // level is drawn, based on the values in the ranges field. 00079 // 00080 // More precisely, if the distance from the eyepoint to the 00081 // transformed center is D and the ranges array contains LAST_RANGE+1 00082 // values (numbered 0...LAST_RANGE), then: 00083 // 00084 // D < ranges[0] : Level 0 is drawn 00085 // ranges[i-1] < D < ranges[i] : Level i is drawn 00086 // D > ranges[LAST_RANGE] : Level LAST_RANGE+1 is drawn 00087 // 00088 // So, you should specify N ranges and N+1 levels. If you specify 00089 // too few levels, the last level will be used for the extra 00090 // ranges. If you specify too few ranges, the extra levels will 00091 // never be used. 00092 // 00093 // Add an SoInfo node as a level if you want a level of detail 00094 // that doesn't draw anything. 00095 // 00097 class SoDEPRECATED SoVRMLLOD : public SoVRMLParent { 00243 00244 SO_NODE_HEADER(SoVRMLLOD); 00245 00246 public: 00247 // Fields 00252 SoMFFloat range; 00258 SoSFVec3f center; 00279 SoMFNode level; 00283 SoVRMLLOD(); 00287 SoVRMLLOD(int nLevels); 00291 virtual SbBool affectsState() const; 00295 void addLevel(SoNode *level1); 00296 00300 void insertLevel(SoNode *level1, int newLevelIndex); 00301 00305 SoNode * getLevel(int index) const; 00306 00310 int findLevel(const SoNode *level1) const; 00311 00315 int getNumLevels() const; 00316 00320 void removeLevel(int index); 00321 00325 void removeLevel(SoNode *level1) 00326 { removeLevel(findLevel(level1)); } 00327 00331 void removeAllLevels(); 00332 00336 void replaceLevel(int index, SoNode *newLevel); 00337 00341 void replaceLevel(SoNode *oldLevel, SoNode *newLevel) 00342 { replaceLevel(findLevel(oldLevel), newLevel); } 00343 00344 private: 00345 // Implement actions: 00346 virtual void doAction(SoAction *action); 00347 virtual void callback(SoCallbackAction *action); 00348 virtual void GLRender(SoGLRenderAction *action); 00349 virtual void rayPick(SoRayPickAction *action); 00350 virtual void getBoundingBox(SoGetBoundingBoxAction *action); 00351 virtual void search(SoSearchAction *action); 00352 virtual void write(SoWriteAction *writeAction); 00353 virtual void getPrimitiveCount(SoGetPrimitiveCountAction *action); 00354 00355 // These methods make render traversal faster by implementing 00356 // different rendering paths corresponding to different action 00357 // path codes. 00358 virtual void GLRenderBelowPath(SoGLRenderAction *action); 00359 virtual void GLRenderInPath(SoGLRenderAction *action); 00360 virtual void GLRenderOffPath(SoGLRenderAction *action); 00361 00362 private: 00363 static void initClass(); 00364 static void exitClass(); 00365 00366 // Adds a child as last one in group 00367 void addChild(SoNode *child); 00368 00369 // Adds a child so that it becomes the one with the given index 00370 void insertChild(SoNode *child, int newChildIndex); 00371 00372 // Returns pointer to nth child node 00373 SoNode * getChild(int index) const; 00374 00375 // Finds index of given child within group 00376 int findChild(const SoNode *child) const; 00377 00378 // Returns number of children 00379 int getNumChildren() const; 00380 00381 // Removes child with given index from group 00382 void removeChild(int index); 00383 00384 // Removes first instance of given child from group 00385 void removeChild(SoNode *child) 00386 { removeChild(findChild(child)); } 00387 00388 // Removes all children from group 00389 void removeAllChildren(); 00390 00391 // Replaces child with given index with new child 00392 void replaceChild(int index, SoNode *newChild); 00393 00394 // Replaces first instance of given child with new child 00395 void replaceChild(SoNode *oldChild, SoNode *newChild) 00396 { replaceChild(findChild(oldChild), newChild); } 00397 00398 // Copies the contents of the given node into this instance. The 00399 // default implementation copies just field values and the name. 00400 virtual void copyContents(const SoFieldContainer *fromFC, SbBool copyConnections); 00401 00402 private: 00403 virtual ~SoVRMLLOD(); 00404 virtual void notify(SoNotList *); 00405 virtual SbBool readInstance(SoInput *in, unsigned short flags); 00406 int internalSetValue; 00407 SoMFNode addChildren; //eventIn 00408 SoMFNode removeChildren; //eventIn 00409 void processAddChildren(); 00410 void processRemoveChildren(); 00411 00412 00413 virtual int whichToTraverse(SoAction *); 00414 }; 00415 00416 00417 00418 #if defined(OIV_IGNORE_VRML_DEPRECATED) 00419 #pragma pop_macro("SoDEPRECATED_TYPEDEF") 00420 #pragma pop_macro("SoDEPRECATED_CLASS") 00421 #endif 00422 00423 #endif /* _SO_VRMLLOD_ */ 00424