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-2020 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_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 00162 class SoPointSet : public SoNonIndexedShape { 00163 00164 SO_NODE_HEADER(SoPointSet); 00165 00166 public: 00170 SoSFInt32 numPoints; 00171 00175 SoPointSet(); 00176 00177 private: 00179 virtual void GLRender(SoGLRenderAction *action); 00180 00185 virtual void getBoundingBox(SoGetBoundingBoxAction *action); 00186 00188 virtual void getPrimitiveCount(SoGetPrimitiveCountAction *action); 00189 00190 // Computes bounding box 00191 virtual void computeBBox( SoAction *action, SbBox3f &box, SbVec3f ¢er ); 00192 00193 private: 00194 // returns the number of PARTS 00195 inline int getNumParts(void) const { return totalNumVertices; } // PARTS are points (by convention) 00196 // returns the number of FACES 00197 inline int getNumFaces(void) const { return totalNumVertices; } // FACES are points (by convention) 00198 00199 // returns the number of vertices needed 00200 int getNumVerticesNeeded(void) const; 00201 00202 // Checks if enough vertices, normals, textureCoord, colors...etc... 00203 bool check_RenderVectors( SoState *state, bool bUseTexCoordsAnyway ); 00204 00205 00207 static void initClass(); 00209 static void exitClass(); 00210 00211 virtual void callDEBUGGLRender(SoGLRenderAction *action,uint32_t useTexCoordsAnyway); 00212 00213 00214 private: 00215 // Generates points representing point set 00216 virtual void generatePrimitives(SoAction *action); 00217 virtual void invokePointCallbacks_(SoAction *action, const SoPrimitiveVertex *v, const uint32_t index); 00218 00219 // check if normal should be generated or not. 00220 virtual void shouldGenerateNormals(SoGLRenderAction *action,const SoShapeStyleElement *shapeStyle); 00221 00222 // check if glrender should be called 00223 virtual SbBool shouldGLRender(SoGLRenderAction *action, SbBool isPointsOrLines = FALSE); 00224 00225 //Free memory 00226 virtual void exitRender(SoState *state,int stateFlag, 00227 SoTextureCoordinateBundle *tcb, 00228 SoTextureCoordinate3Bundle *tc3b); 00229 00230 // count the number of primitives in the shape 00231 virtual void countPrim(); 00232 00233 // really do the rendering part 00234 virtual void doRendering(SoGLRenderAction *action, const SoShapeStyleElement* shapeStyle); 00235 00236 // invalid test 00237 virtual SbBool numPrimInvalid(){return totalNumVertices < 0 ;} 00238 00239 //return number of primitives 00240 virtual int getNumPrim(){return totalNumVertices;} 00241 00242 // return num vertices 00243 virtual int getNumVert(); 00244 00245 //max auto caching test 00246 virtual int getMaxTestValueForAutoCache(){return totalNumVertices;} 00247 00248 //min auto caching test 00249 virtual int getMinTestValueForAutoCache(){return totalNumVertices;} 00250 00251 // says that rendering is PointOrLine 00252 virtual SbBool isRenderingPointsOrLines(SoGLRenderAction *action); 00253 00254 // Overrides standard method to create an SoPointDetail instance 00255 virtual SoDetail * createPointDetail(SoRayPickAction *action, 00256 const SoPrimitiveVertex *v, 00257 SoPickedPoint *pp); 00258 00260 virtual ~SoPointSet(); 00261 00263 virtual void notify(SoNotList *list); 00264 00265 SoINTERNAL private: 00266 00267 #ifndef HIDDEN_FROM_DOC 00268 00269 void generatePrimitives_( SoAction *action ); 00270 #endif // HIDDEN_FROM_DOC 00271 00272 private: 00273 //No decimation is done when SoComplexity::value >= complexity threshold. 00274 float m_complexityThreshold; 00275 00276 // Returns TRUE if materials/normals are bound to individual points 00277 SbBool areMaterialsPerPoint(SoAction *action) const; 00278 SbBool areNormalsPerPoint(SoAction *action) const; 00279 // internally manage SO_POINT_SET_USE_REST_OF_VERTICES 00280 bool m_usingUSE_REST; 00281 bool m_nvNotifyEnabled; 00282 inline void setNvNotifyEnabled(const bool nvNotifyEnabled) 00283 { m_nvNotifyEnabled = nvNotifyEnabled; } 00284 inline bool getNvNotifyEnabled() const 00285 {return m_nvNotifyEnabled;} 00286 00287 bool doRenderingVBO(SoGLRenderAction *action, const SoShapeStyleElement* shapeStyle); 00288 00289 //Returns the pitch of the decimation caused by a SoComplexity Node. 00290 //Returns 1 otherwise. 00291 unsigned int getDecimationPitch(SoState* state) const; 00292 00293 // This stores the total number of vertices; we use this 00294 // information to influence Separator's auto-caching algorithm 00295 // (shapes with very few triangles should be cached because 00296 // traversing them can be expensive, shapes with lots of triangles 00297 // shouldn't be cached because they'll take up too much memory). 00298 int totalNumVertices; 00299 }; 00300 00301 inline SbBool 00302 SoPointSet::isRenderingPointsOrLines(SoGLRenderAction *) 00303 { 00304 return TRUE; 00305 } 00306 00307 #endif /* _SO_POINT_SET_ */ 00308 00309