00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 #ifndef _SO_INDEXED_NURBS_SURFACE_
00051 #define _SO_INDEXED_NURBS_SURFACE_
00052
00053 #include <Inventor/fields/SoSFInt32.h>
00054 #include <Inventor/fields/SoMFFloat.h>
00055 #include <Inventor/fields/SoMFInt32.h>
00056 #include <Inventor/nodes/SoShape.h>
00057 #include <Inventor/nodes/SoNurbsGroup.h>
00058 #include <Inventor/threads/SbThreadLocalStorage.h>
00059 #include <Inventor/caches/SoVBOMgr.h>
00060
00061 class SoState;
00062 class SoIndexedNurbsSurfaceCache;
00063 class SoNurbsBREPAction;
00064 class SoBrep;
00065 class Pquad_tess_param;
00066 class GLUnurbs;
00067 class SbThreadRWMutex;
00068
00162 class SoIndexedNurbsSurface : public SoShape {
00163
00164 SO_NODE_HEADER(SoIndexedNurbsSurface);
00165
00166 public:
00170 SoSFInt32 numUControlPoints;
00171
00175 SoSFInt32 numVControlPoints;
00176
00180 SoMFInt32 coordIndex;
00181
00185 SoMFFloat uKnotVector;
00186
00190 SoMFFloat vKnotVector;
00191
00195 SoSFInt32 numSControlPoints;
00196
00200 SoSFInt32 numTControlPoints;
00201
00205 SoMFInt32 textureCoordIndex;
00206
00210 SoMFFloat sKnotVector;
00211
00215 SoMFFloat tKnotVector;
00216
00220 SoIndexedNurbsSurface();
00221
00222 private:
00223 virtual void GLRender(SoGLRenderAction *action);
00224 virtual void rayPick(SoRayPickAction *action);
00225 virtual void getPrimitiveCount(SoGetPrimitiveCountAction *action);
00226 virtual void getBoundingBox(SoGetBoundingBoxAction *action);
00227
00228
00229 virtual void computeBBox(SoAction *action, SbBox3f &box, SbVec3f ¢er);
00230
00231
00232 private:
00233 static void initClass();
00234 static void exitClass();
00235
00236 void invalidateCache();
00237 SoIndexedNurbsSurfaceCache *getNurbsCache() const { return nurbsCache; }
00238
00239 private:
00240
00241 virtual void generatePrimitives(SoAction *action);
00242
00243 float setTesselationParams(SoAction* action,
00244 const SoNurbsGroup::NurbsProperty &nurbsProperty,
00245 int steps,
00246 Pquad_tess_param &quad_tess_param);
00247
00248 ~SoIndexedNurbsSurface();
00249
00250 private:
00251 SoIndexedNurbsSurfaceCache *nurbsCache;
00252
00253 SbThreadRWMutex *nurbsCacheMutex;
00254
00255 int isValid(SoState *state, SbBool renderAction);
00256
00257
00258 void tesselateNURBS_G5G(SoAction *action,
00259 SbBool doTextures,
00260 int32_t steps,
00261 SoBrep *brep,
00262 SoNurbsGroup::NurbsProperty &nurbsProperty);
00263 void tesselateNURBS_G5G(SoAction *action, SbBool doTextures, int32_t steps);
00264
00265
00266 void drawNURBS_G5G(SoAction *action, SbBool doTextures, int32_t steps);
00267
00268
00269 void drawNURBS_GLU(GLUnurbs *nurbsObj, SoState *state, SbBool doTextures);
00270
00271
00272
00273 int computeSteps(SoState *state);
00274 int computePixelTolerance(SoState *state);
00275 int computeScreenSpaceSteps(SoState *state);
00276
00277 void createNurbsCache(SoState *state, SbBool isShadered);
00278
00279
00280 inline SoVBOMgr *getVBOMgr() const
00281 { return (SoVBOMgr*)(m_VBOMgr.getValue()); }
00282 SoVBOMgr* allocateVBO(SoState* state);
00283 void deleteVBO(SoState *state);
00284
00285 SbThreadStorage<SoVBOMgr*> m_VBOMgr;
00286 };
00287
00288 #endif
00289
00290