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 ** Modified by : Gavin Bell (MMM yyyy) 00026 **=======================================================================*/ 00027 /*======================================================================= 00028 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), *** 00029 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. *** 00030 *** *** 00031 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS *** 00032 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR *** 00033 *** WRITTEN AUTHORIZATION OF FEI S.A.S. *** 00034 *** *** 00035 *** RESTRICTED RIGHTS LEGEND *** 00036 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS *** 00037 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN *** 00038 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT *** 00039 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN *** 00040 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. *** 00041 *** *** 00042 *** COPYRIGHT (C) 1996-2020 BY FEI S.A.S, *** 00043 *** BORDEAUX, FRANCE *** 00044 *** ALL RIGHTS RESERVED *** 00045 **=======================================================================*/ 00046 /*======================================================================= 00047 ** Modified by : VSG (MMM YYYY) 00048 **=======================================================================*/ 00049 00050 00051 #ifndef _SO_VRMLELEVATION_GRID_ 00052 #define _SO_VRMLELEVATION_GRID_ 00053 00054 #include <Inventor/fields/SoSFFloat.h> 00055 #include <Inventor/fields/SoSFBool.h> 00056 #include <Inventor/nodes/SoNode.h> 00057 #include <Inventor/VRMLnodes/SoVRMLGridShape.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: SoVRMLElevationGrid 00073 // 00074 // Creates a rectangular grid of varying height useful in modeling 00075 // terrain. 00076 // 00078 00079 class SoNormalBundle; 00080 class SoCoordinateElement; 00081 class SoShapeStyleElement; 00082 class SoDEPRECATED SoVRMLElevationGrid : public SoVRMLGridShape { 00205 00206 SO_NODE_HEADER(SoVRMLElevationGrid); 00207 00208 public: 00209 // Fields 00210 00216 SoSFBool ccw; 00229 SoSFBool solid; 00236 SoSFFloat creaseAngle; 00237 00241 SoVRMLElevationGrid(); 00242 00243 private: 00244 // Implements actions 00245 virtual void GLRender(SoGLRenderAction *action); 00246 virtual void generatePick(SoRayPickAction *action, SoNode *node); 00247 virtual void getPrimitiveCount(SoGetPrimitiveCountAction *action); 00248 00249 00250 // Generates default normals using the given normal bundle. 00251 // Returns TRUE. 00252 virtual SbBool generateDefaultNormals(SoState *state, 00253 SoNormalBundle *nb); 00254 // This handles bounding box computation for all shapes derived 00255 // from this class. It sets the bounding box to contain all 00256 // vertices of the shape, assuming that the shape uses the 00257 // coordinates indexed by all non-negative values in the 00258 // coordIndex field. It also sets the center to the average of the 00259 // vertices' coordinates. 00260 virtual void computeBBox(SoAction *action, SbBox3f &box, 00261 SbVec3f ¢er); 00262 00263 // Typedef of pointer to method on IndexedFaceSet; 00264 // This will be used to simplify declaration and initialization. 00265 typedef void (SoVRMLElevationGrid::*PMFS)(SoGLRenderAction *); 00266 00267 private: 00268 static void initClass(); 00269 static void exitClass(); 00270 00271 private: 00272 // This enum is used to indicate the current material or normal binding 00273 enum Binding { 00274 OVERALL, PER_ROW, PER_QUAD, PER_VERTEX 00275 }; 00276 void setupCoordinates(SoVRMLCoordinate *myCoord); 00277 // Generates triangles representing faces 00278 virtual void generatePrimitives(SoAction *action); 00279 00280 // Per-instance mutex to protect access to the normalCache 00281 SbThreadRWMutex *normalCacheMutex; 00282 00283 // Per-instance mutex to protect access to the vpCache 00284 SbThreadRWMutex *vpCacheMutex; 00285 00286 // Overrides standard method to create an SoFaceDetail instance 00287 virtual SoDetail * createTriangleDetail(SoRayPickAction *action, 00288 const SoPrimitiveVertex *v1, 00289 const SoPrimitiveVertex *v2, 00290 const SoPrimitiveVertex *v3, 00291 SoPickedPoint *pp); 00292 ~SoVRMLElevationGrid(); 00293 00294 private: 00295 SbVec3f *generatedNormals; // Array of generated normals 00296 void doRendering(SoGLRenderAction *action, const SoShapeStyleElement* shapeStyle); 00297 00298 // Saves normal binding when generating primitives for picking 00299 Binding savedNormalBinding; 00300 00301 // Returns current material or normal binding from action's state 00302 Binding getMaterialBinding() const; 00303 Binding getNormalBinding(SoAction* action, SoNormalBundle* nb); 00304 00305 // Returns index (of material or normal) based on given binding 00306 static int getBindIndex(Binding binding, int vert, 00307 int row, int quad); 00308 00309 // Figures out normals, if necessary. 00310 SbBool figureNormals(SoState *state, SoNormalBundle *nb); 00311 00312 // set numTris/Quads/Faces to -1 when notified 00313 //virtual void notify(SoNotList *list); 00314 00315 // This stores the total number of vertices; we use this 00316 // information to influence Separator's auto-caching algorithm 00317 // (shapes with very few triangles should be cached because 00318 // traversing them can be expensive, shapes with lots of triangles 00319 // shouldn't be cached because they'll take up too much memory). 00320 00321 // Number of quads 00322 int numQuads, totalNumVertices; 00323 00324 // Set number of triangles/quads/faces, based on coordIndex array. 00325 void setupNumTrisQuadsFaces(); 00326 00327 // This stores the total number of vertices; we use this 00328 // information to influence Separator's auto-caching algorithm 00329 // (shapes with very few triangles should be cached because 00330 // traversing them can be expensive, shapes with lots of triangles 00331 // shouldn't be cached because they'll take up too much memory). 00332 SbBool genNorms; 00333 00334 static const int AUTO_CACHE_MIN_WITHOUT_VP; 00335 static const int AUTO_CACHE_MAX; 00336 00337 }; 00338 00339 00340 00341 #if defined(OIV_IGNORE_VRML_DEPRECATED) 00342 #pragma pop_macro("SoDEPRECATED_TYPEDEF") 00343 #pragma pop_macro("SoDEPRECATED_CLASS") 00344 #endif 00345 00346 #endif /* _SO_VRMLELEVATION_GRID_ */ 00347