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 : AJO (May 2011) 00048 **=======================================================================*/ 00049 00050 00051 #ifndef _SO_INDEXED_FACE_SET_ 00052 #define _SO_INDEXED_FACE_SET_ 00053 00054 #include <Inventor/nodes/SoIndexedShape.h> 00055 #include <Inventor/sys/SoGLType.h> 00056 00058 // 00059 // Class: SoIndexedFaceSet 00060 // 00061 // Indexed set of faces. Each face consists of 3 or more vertices, 00062 // each of which is denoted by an integer index (from the coordIndex 00063 // field) into the current coordinates. Depending on the current 00064 // material and normal binding values, the materials and normals for 00065 // the faces or vertices may be accessed in order or indexed. If they 00066 // are indexed, the materialIndex and normalIndex fields are used. 00067 // 00069 00070 00071 // This coordinate index indicates that the current face ends and the 00072 // next face begins. Use this for simple (1 contour) polygons. 00073 #define SO_END_FACE_INDEX (-1) 00074 00075 // If SoShapeHints is used with a windingType other than NO_WINDING_TYPE, 00076 // this coordinate index indicates that the current contour ends 00077 // and the next contour begins. 00078 #define SO_END_CONTOUR_INDEX (-1) 00079 00080 // This coordinate index indicates that the current complex face (block 00081 // of contours) ends. 00082 #define SO_END_POLYGON_INDEX (-2) 00083 00084 class SoNormalBundle; 00085 class SoShapeStyleElement; 00086 class SoVolumeIndexedFaceSet; 00087 00088 SO_PIMPL_PUBLIC_DECLARATION(SoIndexedFaceSet) 00089 00090 00247 class SoIndexedFaceSet : public SoIndexedShape 00248 { 00249 SO_NODE_HEADER(SoIndexedFaceSet); 00250 SO_PIMPL_PUBLIC_HEADER(SoIndexedFaceSet) 00251 00252 public: 00253 00257 SoIndexedFaceSet(); 00258 00259 private: 00260 // Implements actions 00261 virtual void GLRender( SoGLRenderAction* action ); 00262 00263 // Generates default normals using the given normal bundle. 00264 // Returns TRUE. 00265 virtual void generateDefaultNormals( SoState* state, 00266 const SbVec3f* coords, 00267 int numCoords, 00268 SoNormalBundle* nb, 00269 SbBool storeRef = FALSE); 00270 00272 virtual void shouldGenerateTangents( SoGLRenderAction* /*action*/, const SoShapeStyleElement* /*shapeStyle*/ ) {} 00273 00274 virtual void getPrimitiveCount( SoGetPrimitiveCountAction* action ); 00275 virtual void rayPick(SoRayPickAction *action); 00276 00277 private: 00278 00279 static void initClass(); 00280 static void exitClass(); 00281 00282 // set numTris/Quads/Faces to -1 when notified 00283 virtual void notify( SoNotList* list ); 00284 00285 // Compute the number of vertices. This is just an approximation, 00286 //so using 5 verts per unknown polygon is close enough. 00287 virtual int getNumPrim( SoState* state = NULL ); 00288 00289 private: 00290 // This enum is used to indicate the current material or normal binding 00291 enum Binding { 00292 OVERALL, 00293 PER_FACE, 00294 PER_FACE_INDEXED, 00295 PER_VERTEX, 00296 PER_VERTEX_INDEXED 00297 }; 00298 00299 //Whether to check or not shapeHints 00300 virtual SbBool shouldCheckShapeHints(){ return TRUE;} 00301 00302 virtual SbBool shouldGenerateTexture3DCoordinates(){return TRUE;} 00303 00304 virtual void callSetupIndices( SoState* state, const SoShapeStyleElement* shapeStyle, uint32_t useTexCoordsAnyway ); 00305 00306 //Whether to check or not 3d tex coords 00307 virtual SbBool checkTex3Coords(){return TRUE;} 00308 00309 virtual SbBool shapeHintsTest( SoState* state = NULL ); 00310 00311 int getNumPrim( int& _numTris, int& _numQuads, int& _numFaces ); 00312 00313 virtual void countPrim( SoState* state = NULL ); 00314 00315 // Generates triangles representing faces 00316 virtual void generatePrimitives( SoAction* action ); 00317 00318 // render function 00319 virtual void doRendering( SoGLRenderAction* action, const SoShapeStyleElement* shapeStyle ); 00320 00321 // Overrides standard method to create an SoFaceDetail instance 00322 virtual SoDetail* createTriangleDetail( SoRayPickAction* action, 00323 const SoPrimitiveVertex* v1, 00324 const SoPrimitiveVertex* v2, 00325 const SoPrimitiveVertex* v3, 00326 SoPickedPoint* pp ); 00327 00328 //When tesselating complex polygons, keep the result cached 00329 virtual bool hasGeneratePrimitiveCache() 00330 { 00331 return true; 00332 } 00333 00334 // destructor 00335 virtual ~SoIndexedFaceSet(); 00336 }; 00337 00338 #endif /* _SO_INDEXED_FACE_SET_ */ 00339 00340 00341