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_LINE_SET_ 00051 #define _SO_LINE_SET_ 00052 00053 #include <Inventor/fields/SoMFInt32.h> 00054 #include <Inventor/nodes/SoNonIndexedShape.h> 00055 00056 class SoState; 00057 class SoTextureCoordinateBundle; 00058 class SoTextureCoordinate3Bundle; 00059 00061 // 00062 // Class: SoLineSet 00063 // 00064 // Set of (poly)lines. Each line consists of 2 or more vertices, 00065 // taken in order from the current coordinates, which are joined to 00066 // form segments. The startIndex field gives the starting coordinate 00067 // index for the first line. If materials or normals are bound to 00068 // vertices, they will begin at that index, as well; otherwise, they 00069 // will start at index 0. The number of vertices in each polyline is 00070 // determined by successive entries in the numVertices field. 00071 // 00073 00074 00075 #ifndef IV_STRICT 00076 // Deprecated feature; specifying USE_REST_OF_VERTICES as the last 00077 // value in the numVertices field will use all the points in the 00078 // coordinate array. 00079 #define SO_LINE_SET_USE_REST_OF_VERTICES (-1) 00080 #endif 00081 00082 00170 class SoLineSet : public SoNonIndexedShape { 00171 00172 SO_NODE_HEADER(SoLineSet); 00173 00174 public: 00178 SoMFInt32 numVertices; 00179 00183 SoLineSet(); 00184 00185 private: 00187 virtual void GLRender(SoGLRenderAction *action); 00188 00193 virtual void getBoundingBox(SoGetBoundingBoxAction *action); 00194 00196 virtual void getPrimitiveCount(SoGetPrimitiveCountAction *action); 00197 00198 private: 00199 inline int getNumPolyLines(void) const { return numVertices.getNum(); } 00200 // returns the number of PARTS 00201 inline int getNumParts(void) const { return totalNumVertices - getNumPolyLines(); } // PARTS are segment 00202 00203 // returns the number of FACES 00204 inline int getNumFaces(void) const { return getNumPolyLines(); } // FACES are polylines 00205 00206 // returns the number of vertices needed 00207 int getNumVerticesNeeded(void) const; 00208 00209 // Checks if enough vertices, normals, textureCoord, colors...etc... 00210 bool check_RenderVectors( SoState *state, bool bUseTexCoordsAnyway ); 00211 00212 00214 static void initClass(); 00216 static void exitClass(); 00217 00218 virtual void callDEBUGGLRender(SoGLRenderAction *action,uint32_t useTexCoordsAnyway); 00219 00220 private: 00221 // Generates line segments representing line set 00222 virtual void generatePrimitives(SoAction *action); 00223 00224 // check if normal should be generated or not. 00225 virtual void shouldGenerateNormals(SoGLRenderAction *action,const SoShapeStyleElement *shapeStyle); 00226 00227 //Free memory 00228 virtual void exitRender(SoState *state,int stateFlag, 00229 SoTextureCoordinateBundle *tcb, 00230 SoTextureCoordinate3Bundle *tc3b); 00231 00232 // count the number of primitives in the shape 00233 virtual void countPrim(); 00234 00235 // really do the rendering part 00236 virtual void doRendering(SoGLRenderAction *action, const SoShapeStyleElement* shapeStyle); 00237 00238 // invalid test 00239 virtual SbBool numPrimInvalid(){return totalNumVertices < 0 ;} 00240 00241 //return number of primitives 00242 virtual int getNumPrim(){return totalNumVertices;} 00243 00244 // return num vertices 00245 virtual int getNumVert(); 00246 00247 //max auto caching test 00248 virtual int getMaxTestValueForAutoCache(){return totalNumVertices;} 00249 00250 //min auto caching test 00251 virtual int getMinTestValueForAutoCache(){return totalNumVertices;} 00252 00253 // says that rendering is PointOrLine 00254 virtual SbBool isRenderingPointsOrLines(SoGLRenderAction *action); 00255 00256 // Overrides standard method to create an SoLineDetail instance 00257 virtual SoDetail * createLineSegmentDetail(SoRayPickAction *action, 00258 const SoPrimitiveVertex *v1, 00259 const SoPrimitiveVertex *v2, 00260 SoPickedPoint *pp); 00261 00263 virtual ~SoLineSet(); 00264 00266 virtual void notify(SoNotList *list); 00267 00268 private: 00269 // This enum is used to indicate the current material or normal binding 00270 enum Binding { 00271 OVERALL, PER_LINE, PER_SEGMENT, PER_VERTEX 00272 }; 00273 00274 // Returns current material or normal binding from action's state 00275 static Binding getMaterialBinding(SoAction *action); 00276 static Binding getNormalBinding(SoAction *action); 00277 00278 // internally manage SO_LINE_SET_USE_REST_OF_VERTICES 00279 bool m_usingUSE_REST; 00280 bool m_nvNotifyEnabled; 00281 inline void setNvNotifyEnabled(const bool nvNotifyEnabled) 00282 { m_nvNotifyEnabled = nvNotifyEnabled; } 00283 inline bool getNvNotifyEnabled() const 00284 {return m_nvNotifyEnabled;} 00285 00286 // This stores the total number of vertices; we use this 00287 // information to influence Separator's auto-caching algorithm 00288 // (shapes with very few triangles should be cached because 00289 // traversing them can be expensive, shapes with lots of triangles 00290 // shouldn't be cached because they'll take up too much memory). 00291 int totalNumVertices; 00292 }; 00293 00294 inline SbBool 00295 SoLineSet::isRenderingPointsOrLines(SoGLRenderAction *) 00296 { 00297 return TRUE; 00298 } 00299 00300 #endif /* _SO_LINE_SET_ */ 00301 00302