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-2014 BY FEI S.A.S, *** 00042 *** MERIGNAC, FRANCE *** 00043 *** ALL RIGHTS RESERVED *** 00044 **=======================================================================*/ 00045 /*======================================================================= 00046 ** Modified by : VSG (MMM YYYY) 00047 **=======================================================================*/ 00048 00049 00050 #ifndef _SO_POINT_SET_ 00051 #define _SO_POINT_SET_ 00052 00053 #include <Inventor/fields/SoSFInt32.h> 00054 #include <Inventor/nodes/SoNonIndexedShape.h> 00055 00056 class SoState; 00057 class SoTextureCoordinateBundle; 00058 class SoTextureCoordinate3Bundle; 00059 00061 // 00062 // Class: SoPointSet 00063 // 00064 // Set of points, using the current coordinates. The startIndex field 00065 // gives the starting coordinate index for the first point. The number of 00066 // points to draw is determined by the numPoints field. 00067 // 00069 00070 // This value, when used in the numPoints field, means use the rest of 00071 // the coordinates as points 00072 #define SO_POINT_SET_USE_REST_OF_POINTS (-1) 00073 00156 class SoPointSet : public SoNonIndexedShape { 00157 00158 SO_NODE_HEADER(SoPointSet); 00159 00160 public: 00164 SoSFInt32 numPoints; 00165 00169 SoPointSet(); 00170 00171 private: 00173 virtual void GLRender(SoGLRenderAction *action); 00174 00179 virtual void getBoundingBox(SoGetBoundingBoxAction *action); 00180 00182 virtual void getPrimitiveCount(SoGetPrimitiveCountAction *action); 00183 00184 // Computes bounding box 00185 virtual void computeBBox( SoAction *action, SbBox3f &box, SbVec3f ¢er ); 00186 00187 private: 00188 // returns the number of PARTS 00189 inline int getNumParts(void) const { return totalNumVertices; } // PARTS are points (by convention) 00190 // returns the number of FACES 00191 inline int getNumFaces(void) const { return totalNumVertices; } // FACES are points (by convention) 00192 00193 // returns the number of vertices needed 00194 int getNumVerticesNeeded(void) const; 00195 00196 // Checks if enough vertices, normals, textureCoord, colors...etc... 00197 bool check_RenderVectors( SoState *state, bool bUseTexCoordsAnyway ); 00198 00199 00201 static void initClass(); 00203 static void exitClass(); 00204 00205 virtual void callDEBUGGLRender(SoGLRenderAction *action,uint32_t useTexCoordsAnyway); 00206 00207 00208 private: 00209 // Generates points representing point set 00210 virtual void generatePrimitives(SoAction *action); 00211 virtual void invokePointCallbacks_(SoAction *action, const SoPrimitiveVertex *v, const uint32_t index); 00212 00213 // check if normal should be generated or not. 00214 virtual void shouldGenerateNormals(SoGLRenderAction *action,const SoShapeStyleElement *shapeStyle); 00215 00216 // check if glrender should be called 00217 virtual SbBool shouldGLRender(SoGLRenderAction *action, SbBool isPointsOrLines = FALSE); 00218 00219 //Free memory 00220 virtual void exitRender(SoState *state,int stateFlag, 00221 SoTextureCoordinateBundle *tcb, 00222 SoTextureCoordinate3Bundle *tc3b); 00223 00224 // count the number of primitives in the shape 00225 virtual void countPrim(); 00226 00227 // really do the rendering part 00228 virtual void doRendering(SoGLRenderAction *action, const SoShapeStyleElement* shapeStyle); 00229 00230 // invalid test 00231 virtual SbBool numPrimInvalid(){return totalNumVertices < 0 ;} 00232 00233 //return number of primitives 00234 virtual int getNumPrim(){return totalNumVertices;} 00235 00236 // return num vertices 00237 virtual int getNumVert(); 00238 00239 //max auto caching test 00240 virtual int getMaxTestValueForAutoCache(){return totalNumVertices;} 00241 00242 //min auto caching test 00243 virtual int getMinTestValueForAutoCache(){return totalNumVertices;} 00244 00245 // says that rendering is PointOrLine 00246 virtual SbBool isRenderingPointsOrLines(SoGLRenderAction *action); 00247 00248 // Overrides standard method to create an SoPointDetail instance 00249 virtual SoDetail * createPointDetail(SoRayPickAction *action, 00250 const SoPrimitiveVertex *v, 00251 SoPickedPoint *pp); 00252 00254 virtual ~SoPointSet(); 00255 00257 virtual void notify(SoNotList *list); 00258 00259 SoINTERNAL private: 00260 00261 #ifndef HIDDEN_FROM_DOC 00262 00263 void generatePrimitives_( SoAction *action ); 00264 #endif // HIDDEN_FROM_DOC 00265 00266 private: 00267 //No decimation is done when SoComplexity::value >= complexity threshold. 00268 float m_complexityThreshold; 00269 00270 // Returns TRUE if materials/normals are bound to individual points 00271 SbBool areMaterialsPerPoint(SoAction *action) const; 00272 SbBool areNormalsPerPoint(SoAction *action) const; 00273 // internally manage SO_POINT_SET_USE_REST_OF_VERTICES 00274 bool m_usingUSE_REST; 00275 bool m_nvNotifyEnabled; 00276 inline void setNvNotifyEnabled(const bool nvNotifyEnabled) 00277 { m_nvNotifyEnabled = nvNotifyEnabled; } 00278 inline bool getNvNotifyEnabled() const 00279 {return m_nvNotifyEnabled;} 00280 00281 bool doRenderingVBO(SoGLRenderAction *action, const SoShapeStyleElement* shapeStyle); 00282 00283 //Returns the pitch of the decimation caused by a SoComplexity Node. 00284 //Returns 1 otherwise. 00285 unsigned int getDecimationPitch(SoState* state) const; 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 int totalNumVertices; 00293 }; 00294 00295 inline SbBool 00296 SoPointSet::isRenderingPointsOrLines(SoGLRenderAction *) 00297 { 00298 return TRUE; 00299 } 00300 00301 #endif /* _SO_POINT_SET_ */ 00302 00303