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 **=======================================================================*/ 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-2019 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_QUAD_MESH_ 00051 #define _SO_QUAD_MESH_ 00052 00053 #include <Inventor/fields/SoSFInt32.h> 00054 #include <Inventor/nodes/SoNonIndexedShape.h> 00055 #include <Inventor/SbPImpl.h> 00056 00057 SO_PIMPL_PUBLIC_DECLARATION(SoQuadMesh) 00058 00059 00060 // 00061 // Class: SoQuadMesh 00062 // 00063 // Shape node with implicit quadrilateral connectivity. The number of 00064 // vertices in each row and column of the quadMesh is given by the 00065 // verticesPerRow and verticesPerColumn fields. The current 00066 // coordinates are taken in order (starting at startIndex) to form 00067 // the rows of the quadMesh; i.e., the first verticesPerColumn vertices 00068 // form the first row of the quadMesh, the next verticesPerColumn 00069 // vertices form the next row, and so on. It is an error if there are 00070 // not enough coordinates. If materials or normals are bound to 00071 // vertices, they will begin at startIndex, as well; otherwise, they 00072 // will start at index 0. 00073 // 00075 00158 class SoQuadMesh : public SoNonIndexedShape 00159 { 00160 SO_NODE_HEADER(SoQuadMesh); 00161 SO_PIMPL_PUBLIC_HEADER(SoQuadMesh) 00162 00163 public: 00164 // Fields 00168 SoSFInt32 verticesPerColumn; 00172 SoSFInt32 verticesPerRow; 00173 00177 SoQuadMesh(); 00178 00179 private: 00181 virtual void GLRender( SoGLRenderAction* action ); 00182 00183 // Generates default normals using the given normal bundle. 00184 // Returns TRUE. 00185 virtual void generateDefaultNormals( SoState* state, 00186 const SbVec3f* coords, 00187 int numCoords, 00188 SoNormalBundle* nb, 00189 SbBool storeRef = FALSE ); 00190 00192 virtual void shouldGenerateTangents( SoGLRenderAction* /*action*/, const SoShapeStyleElement* /*shapeStyle*/ ) {} 00193 00195 virtual void getPrimitiveCount( SoGetPrimitiveCountAction* action ); 00196 00197 private: 00198 int getNumRows() const; // returns the number of Rows 00199 int getNumCols() const; // returns the number of Columns 00200 int getNumQuads() const; // returns the number of Quads 00201 int getNumMeshVerts() const; // returns the number of vertices of the Quad Mesh 00202 00203 // Generic version of Generate default normals 00204 void generateDefaultNormals_QuadMesh( SoState* state, const SbVec3f* vecPQuadCoord[], SbVec3f normals[] ); 00205 00206 //Typedef of pointer to method on QuadMesh; 00207 //This will be used to simplify declaration and initialization. 00208 typedef void (SoQuadMesh::*PMQM)( SoGLRenderAction* ); 00209 00210 static void initClass(); 00211 static void exitClass(); 00212 00213 // return num vertices 00214 virtual int getNumVert( SoState* state = NULL ); 00215 00216 // Blow vpCache when vertexProperty field changes: 00217 virtual void notify( SoNotList* list ); 00218 00219 //return number of primitives 00220 virtual int getNumPrim( SoState* state = NULL ); 00221 00222 private: 00223 00224 // This enum is used to indicate the current material or normal binding 00225 enum Binding { 00226 OVERALL, 00227 PER_ROW, 00228 PER_QUAD, 00229 PER_VERTEX 00230 }; 00231 // Generates triangles representing rows 00232 virtual void generatePrimitives( SoAction* action ); 00233 00234 //Approx number of primitives 00235 virtual void countPrim( SoState* state = NULL ); 00236 00237 // render function 00238 void doRendering( SoGLRenderAction* action, const SoShapeStyleElement* shapeStyle ); 00239 00240 // Overrides standard method to create an SoFaceDetail instance 00241 virtual SoDetail* createTriangleDetail( SoRayPickAction* action, 00242 const SoPrimitiveVertex* v1, 00243 const SoPrimitiveVertex* v2, 00244 const SoPrimitiveVertex* v3, 00245 SoPickedPoint* pp ); 00246 00247 virtual ~SoQuadMesh(); 00248 00249 private: 00250 00251 // Returns current normal binding from action's state 00252 Binding getNormalBinding( SoAction* action, SoNormalBundle* nb ); 00253 }; 00254 00255 #endif /* _SO_QUAD_MESH_ */ 00256 00257