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_NURBS_SURFACE_
00051 #define _SO_NURBS_SURFACE_
00052
00053 #include <Inventor/fields/SoMFFloat.h>
00054 #include <Inventor/fields/SoSFFloat.h>
00055 #include <Inventor/fields/SoSFInt32.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 SoNurbsSurfaceCache;
00063 class SoNurbsBREPAction;
00064 class SoBrep;
00065 class Pquad_tess_param;
00066 class GLUnurbs;
00067 class SbThreadRWMutex;
00068
00161 class SoNurbsSurface : public SoShape {
00162
00163 SO_NODE_HEADER(SoNurbsSurface);
00164
00165 public:
00170 SoSFInt32 numUControlPoints;
00171
00176 SoSFInt32 numVControlPoints;
00177
00182 SoSFInt32 numSControlPoints;
00183
00188 SoSFInt32 numTControlPoints;
00189
00194 SoMFFloat uKnotVector;
00195
00200 SoMFFloat vKnotVector;
00201
00206 SoMFFloat sKnotVector;
00207
00212 SoMFFloat tKnotVector;
00213
00217 SoNurbsSurface();
00218
00219 private:
00220 virtual void GLRender(SoGLRenderAction *action);
00221 virtual void rayPick(SoRayPickAction *action);
00222 virtual void getPrimitiveCount(SoGetPrimitiveCountAction *action);
00223 virtual void getBoundingBox(SoGetBoundingBoxAction *action);
00224
00225
00226 virtual void computeBBox(SoAction *action, SbBox3f &box, SbVec3f ¢er);
00227
00228 private:
00229 static void initClass();
00230 static void exitClass();
00231
00232 SbBool needBREPUpdate(SoNurbsBREPAction *action);
00233 void invalidateCache();
00234 void fillBREP(SoAction *action, SoBrep *brep,
00235 SbBool doTexture, SoNurbsGroup::NurbsProperty &nurbsProperty);
00236
00237 SoNurbsSurfaceCache *getNurbsCache() const { return nurbsCache; }
00238 SoNurbsSurfaceCache *getNurbsCacheUVs() const { return nurbsCacheUVs; }
00239
00240
00241 static int computeSteps(SoState *state);
00242
00243 private:
00244
00245 virtual void generatePrimitives(SoAction *action);
00246
00247 float setTesselationParams(
00248 SoAction* action,
00249 const SoNurbsGroup::NurbsProperty &nurbsProperty,
00250 int steps,
00251 Pquad_tess_param &quad_tess_param);
00252
00253 ~SoNurbsSurface();
00254
00255
00256 private:
00257 SoNurbsSurfaceCache *nurbsCache;
00258 SoNurbsSurfaceCache *nurbsCacheUVs;
00259
00260 SbThreadRWMutex *nurbsCacheMutex;
00261
00262 int isValid(SoState *state, SbBool renderAction);
00263
00264
00265 void tesselateNURBS_G5G(SoAction *action,
00266 SbBool doTextures,
00267 int32_t steps,
00268 SoBrep *brep,
00269 SoNurbsGroup::NurbsProperty &nurbsProperty);
00270 void tesselateNURBS_G5G(SoAction *action, SbBool doTextures, int32_t steps);
00271
00272
00273 void drawNURBS_G5G(SoAction *action, SbBool doTextures, int32_t steps);
00274
00275
00276 void drawNURBS_GLU(GLUnurbs *nurbsObj, SoState *state, SbBool doTextures);
00277
00278
00279 int computePixelTolerance(SoState *state);
00280
00281
00282 int computeScreenSpaceSteps(SoState *state);
00283
00284 void createNurbsCache(SoState *state, SbBool isShadered);
00285
00286
00287 inline SoVBOMgr *getVBOMgr() const
00288 { return (SoVBOMgr*)(m_VBOMgr.getValue()); }
00289 SoVBOMgr* allocateVBO(SoState* state);
00290 void deleteVBO(SoState *state);
00291
00292 SbThreadStorage<SoVBOMgr*> m_VBOMgr;
00293 };
00294
00295 #endif
00296
00297