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 : SGI (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 : Julien SALLANNE (Jun 2009) 00047 **=======================================================================*/ 00048 00049 #ifndef _SO_VRMLGEOELEVATIONGRID_ 00050 #define _SO_VRMLGEOELEVATIONGRID_ 00051 00052 #include <Inventor/fields/SoSFVec3f.h> 00053 #include <Inventor/fields/SoSFInt32.h> 00054 #include <Inventor/fields/SoMFFloat.h> 00055 #include <Inventor/fields/SoSFFloat.h> 00056 #include <Inventor/fields/SoMFString.h> 00057 #include <Inventor/nodes/SoGeoProjection.h> 00058 #include <Inventor/VRMLnodes/SoVRMLElevationGrid.h> 00059 #include <Inventor/VRMLnodes/SoVRMLGridShape.h> 00060 00061 00062 #if defined(OIV_IGNORE_VRML_DEPRECATED) 00063 #include <SoDeprecationRules.h> 00064 #pragma push_macro("SoDEPRECATED_CLASS") 00065 #pragma push_macro("SoDEPRECATED_TYPEDEF") 00066 #undef SoDEPRECATED_CLASS 00067 #undef SoDEPRECATED_TYPEDEF 00068 #define SoDEPRECATED_CLASS(x,y) 00069 #define SoDEPRECATED_TYPEDEF(x,y) 00070 #endif 00071 00072 class SoVRMLTextureCoordinate; 00073 class SoDEPRECATED SoVRMLGeoElevationGrid : public SoVRMLElevationGrid { 00174 00175 SO_NODE_HEADER(SoVRMLGeoElevationGrid); 00176 00177 public: 00178 // Fields 00184 SoSFFloat yScale; 00185 00190 SoSFVec3f geoGridOrigin; 00191 00207 SoMFString geoSystem; 00208 00212 SoSFNode geoOrigin; 00213 00217 SoVRMLGeoElevationGrid(); 00218 00219 private: 00220 // Implements actions 00221 virtual void GLRender(SoGLRenderAction *action); 00222 00223 00224 // Generates default normals using the given normal bundle. 00225 // Returns TRUE. 00226 virtual SbBool generateDefaultNormals(SoState *state, 00227 SoNormalBundle *nb); 00228 // This handles bounding box computation for all shapes derived 00229 // from this class. It sets the bounding box to contain all 00230 // vertices of the shape, assuming that the shape uses the 00231 // coordinates indexed by all non-negative values in the 00232 // coordIndex field. It also sets the center to the average of the 00233 // vertices' coordinates. 00234 virtual void computeBBox(SoAction *action, SbBox3f &box, 00235 SbVec3f ¢er); 00236 00237 // Typedef of pointer to method on IndexedFaceSet; 00238 // This will be used to simplify declaration and initialization. 00239 typedef void (SoVRMLGeoElevationGrid::*PMFS)(SoGLRenderAction *); 00240 00241 private: 00242 static void initClass(); 00243 static void exitClass(); 00244 00245 private: 00246 // This enum is used to indicate the current material or normal binding 00247 enum Binding { 00248 OVERALL, PER_ROW, PER_QUAD, PER_VERTEX 00249 }; 00250 void setupCoordinates(SoAction *action, SoVRMLCoordinate *myCoord, SoVRMLTextureCoordinate *myTexCoord); 00251 // Generates triangles representing faces 00252 virtual void generatePrimitives(SoAction *action); 00253 00254 // Per-instance mutex to protect access to the normalCache 00255 SbThreadRWMutex *normalCacheMutex; 00256 00257 // Per-instance mutex to protect access to the vpCache 00258 SbThreadRWMutex *vpCacheMutex; 00259 00260 ~SoVRMLGeoElevationGrid(); 00261 00262 private: 00263 SoVRMLTextureCoordinate *myTexCoord; 00264 00265 float computeHeight(int index); 00266 00267 SbVec3f *generatedNormals; // Array of generated normals 00268 void doRendering(SoGLRenderAction *action, const SoShapeStyleElement* shapeStyle); 00269 00270 // Saves normal binding when generating primitives for picking 00271 Binding savedNormalBinding; 00272 00273 // Returns current material or normal binding from action's state 00274 Binding getMaterialBinding() const; 00275 Binding getNormalBinding(SoAction* action, SoNormalBundle* nb); 00276 00277 // Returns index (of material or normal) based on given binding 00278 static int getBindIndex(Binding binding, int vert, 00279 int row, int quad); 00280 00281 // Figures out normals, if necessary. 00282 SbBool figureNormals(SoState *state, SoNormalBundle *nb); 00283 00284 // set numTris/Quads/Faces to -1 when notified 00285 //virtual void notify(SoNotList *list); 00286 00287 // This stores the total number of vertices; we use this 00288 // information to influence Separator's auto-caching algorithm 00289 // (shapes with very few triangles should be cached because 00290 // traversing them can be expensive, shapes with lots of triangles 00291 // shouldn't be cached because they'll take up too much memory). 00292 00293 // Number of quads 00294 int numQuads, totalNumVertices; 00295 00296 // Set number of triangles/quads/faces, based on coordIndex array. 00297 void setupNumTrisQuadsFaces(); 00298 00299 // This stores the total number of vertices; we use this 00300 // information to influence Separator's auto-caching algorithm 00301 // (shapes with very few triangles should be cached because 00302 // traversing them can be expensive, shapes with lots of triangles 00303 // shouldn't be cached because they'll take up too much memory). 00304 SbBool genNorms; 00305 00306 static const int AUTO_CACHE_MIN_WITHOUT_VP; 00307 static const int AUTO_CACHE_MAX; 00308 00309 }; 00310 00311 00312 00313 00314 #if defined(OIV_IGNORE_VRML_DEPRECATED) 00315 #pragma pop_macro("SoDEPRECATED_TYPEDEF") 00316 #pragma pop_macro("SoDEPRECATED_CLASS") 00317 #endif 00318 00319 #endif /* _SO_VRMLGEOELEVATIONGRID_ */ 00320