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 : Nick Thompson (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_VRMLTRIANGLESET2D_ 00052 #define _SO_VRMLTRIANGLESET2D_ 00053 00054 #include <Inventor/SbLinear.h> 00055 #include <Inventor/fields/SoMFVec2f.h> 00056 #include <Inventor/fields/SoSFBool.h> 00057 #include <Inventor/VRMLnodes/SoVRMLGeometry.h> 00058 #include <Inventor/VRMLnodes/SoVRMLCoordinate.h> 00059 #include <Inventor/nodes/SoVertexProperty.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 SoCoordinateElement; 00073 class SoNormalBundle; 00074 class SoState; 00075 class SoNormalCache; 00076 00078 // 00079 // Class: SoVRMLTriangleSet2D 00080 // 00081 // Specifies a set of triangles 00082 // 00084 class SoDEPRECATED SoVRMLTriangleSet2D : public SoVRMLGeometry { 00149 00150 SO_NODE_HEADER(SoVRMLTriangleSet2D); 00151 00152 public: 00153 00154 // Fields 00159 SoMFVec2f vertices; 00165 SoSFBool solid; 00169 SoVRMLTriangleSet2D(); 00170 00171 private: 00172 // Implements actions 00173 virtual void GLRender(SoGLRenderAction *action); 00174 virtual void generatePick(SoRayPickAction *action, SoNode *node); 00175 virtual void getPrimitiveCount(SoGetPrimitiveCountAction *action); 00176 00177 // Generates default normals using the given normal bundle. 00178 // Returns TRUE. 00179 virtual SbBool generateDefaultNormals(SoState *state, SoNormalBundle *nb); 00180 00181 00182 // Computes bounding box of cone 00183 virtual void computeBBox(SoAction *action, SbBox3f &box, 00184 SbVec3f ¢er); 00185 00186 // Typedef of pointer to method on FaceSet; 00187 // This will be used to simplify declaration and initialization. 00188 typedef void ( SoVRMLTriangleSet2D::*PMFS)(SoGLRenderAction *); 00189 00190 private: 00191 static void initClass(); 00192 static void exitClass(); 00193 00194 // Returns the current normal cache, or NULL if there is none. 00195 // This method was protected prior to OIV version 3.0. 00196 // Normal cache will only exist if the node has been traversed 00197 // by a render action and Inventor needed to compute normals. 00198 SoNormalCache *getNormalCache() const { return normalCache; } 00199 00200 // Redefines this to invalidate normal cache 00201 virtual void notify(SoNotList *list); 00202 00203 private: 00204 // This enum is used to indicate the current material or normal binding 00205 enum Binding { 00206 OVERALL, PER_FACE, PER_VERTEX 00207 }; 00208 // Sets up a cache to hold normals. This assumes the cache depends 00209 // on only the current coordinates, shape hints, and crease angle. 00210 void setNormalCache(SoState *state, 00211 int numNormals, 00212 const SbVec3f *normals, 00213 const SoNormalBindingElement::Binding binding 00214 ); 00215 // Per-instance mutex to protect access to the vpCache 00216 SbThreadRWMutex *vpCacheMutex; 00217 00218 // vpCache stores information from one render to the next about 00219 // what information needs to be grabbed from the state, etc. 00220 SoVRMLVertexPropertyCache vpCache; 00221 00222 // Generates triangles representing a cone 00223 virtual void generatePrimitives(SoAction *action); 00224 00225 // Overrides standard method to create an SoFaceDetail instance 00226 virtual SoDetail * createTriangleDetail(SoRayPickAction *action, 00227 const SoPrimitiveVertex *v1, 00228 const SoPrimitiveVertex *v2, 00229 const SoPrimitiveVertex *v3, 00230 SoPickedPoint *pp); 00231 virtual ~SoVRMLTriangleSet2D(); 00232 00233 private: 00234 00235 Binding getNormalBinding(SoAction *action, 00236 SoNormalBundle *nb); 00237 00238 // Figures out normals, if necessary. 00239 SbBool figureNormals(SoState *state, SoNormalBundle *nb); 00240 00241 // Set number of triangles/quads/faces, based on coordIndex array. 00242 void setupTris(SoAction *action); 00243 00244 // Number of triangles 00245 int numTris; 00246 00247 // render function 00248 void doRendering(SoGLRenderAction *action, const SoShapeStyleElement* shapeStyle); 00249 00250 static const int AUTO_CACHE_FS_MIN_WITHOUT_VP; 00251 00252 static const int AUTO_CACHE_FS_MAX; 00253 00254 // This allows instances to cache normals that have been generated 00255 SoNormalCache *normalCache; 00256 SoVRMLCoordinate *m_array; 00257 int numVerts; 00258 }; 00259 00260 00261 00262 #if defined(OIV_IGNORE_VRML_DEPRECATED) 00263 #pragma pop_macro("SoDEPRECATED_TYPEDEF") 00264 #pragma pop_macro("SoDEPRECATED_CLASS") 00265 #endif 00266 00267 #endif /* _SO_VRMLTRIANGLESET2D_ */ 00268