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 #ifndef SO_UNIFORM_GRID_CLIPPING
00026 #define SO_UNIFORM_GRID_CLIPPING
00027
00028 #include <Inventor/nodes/SoTexture2.h>
00029 #include <Inventor/fields/SoSFBox3f.h>
00030 #include <Inventor/SbBox.h>
00031 #include <Inventor/STL/vector>
00032 #include <LDM/SoLDMTileID.h>
00033
00034 class SoShaderObject;
00035 class SoShaderProgram;
00036 class SoFragmentShader;
00037 class SoVertexShader;
00038 class SoState;
00039 class SoVolumeData;
00040 class SoROI;
00041 class SoLDMNodeFrontMgrOctree;
00042 class SoCache;
00043
00249 class SoUniformGridClipping : public SoTexture2 {
00250 SO_NODE_HEADER(SoUniformGridClipping);
00251
00252 public:
00256 SoUniformGridClipping();
00257
00263 SoSFBox3f extent;
00264
00266 enum Axis {
00268 X,
00270 Y,
00272 Z
00273 };
00274
00281 SoSFEnum axis;
00282
00297 SoSFFloat thickness;
00298
00305 SoSFBool clipBelow;
00306
00313 SoSFBool clipAbove;
00314
00321 SoSFFloat undefinedValue;
00322
00332 static SbBool isSupported(SoState* state=NULL) ;
00333
00337 static int getMaxNumberOfUniformGrids(SoState* state=NULL);
00338
00339 #if 1
00341 #ifndef VolumeViz_EXPORTS
00342 SoDEPRECATED
00343 SoSFBox3f size;
00344 #else
00345
00349 SoSFBox3f size;
00350 #endif
00351
00352 #endif
00354 private:
00355 virtual void GLRender(SoGLRenderAction *action);
00356 virtual void getBoundingBox(SoGetBoundingBoxAction *action);
00357 virtual void doAction(SoAction *action);
00358 virtual void doActionOnRTT(SoAction *action);
00359 virtual void rayPick(SoRayPickAction *action);
00360
00361 private:
00362
00372 SoSFBool revertMode;
00373
00374 static void initClass() ;
00375 static void exitClass() ;
00376
00378 int getTexUnit() { return m_texUnit; }
00379
00380
00381 void setClipmapUniforms(SoGLRenderAction* action, SoShaderProgram* prog, const std::vector<SoUniformGridClipping *> &grids);
00382 void setPlaneUniforms(SoGLRenderAction* action, SoShaderProgram* prog, const std::vector<SoUniformGridClipping *> &grids);
00383 void setZScaleUniform(SoGLRenderAction* action, SoShaderProgram* prog, const std::vector<SoUniformGridClipping *> &grids);
00384 virtual void setClipParamUniforms(SoGLRenderAction* action, SoShaderProgram* prog, const std::vector<SoUniformGridClipping *> &grids);
00385
00386
00387 virtual SbBool isCulled(const SbBox3f &box);
00388
00391 const SbBox3i32& cropBBox(SoState* state, SoVolumeData* vd);
00392
00394 virtual void notify(SoNotList *list);
00395
00397 virtual void fieldHasChanged( SoField *field );
00398
00399 static void setVVizUniform(SoGLRenderAction* action);
00400
00402 void installTexture( SoGLRenderAction* action );
00403
00404 private:
00405
00407 virtual ~SoUniformGridClipping();
00408
00411 SbBox3f getBBox();
00412
00413 private:
00414 enum IntersectionType
00415 {
00416 ALL_OUT,
00417 ALL_IN,
00418 INTERSECT
00419 };
00420
00421 virtual void getMinMax(float &min, float &max);
00422
00424 bool isCroppedBboxCacheValid(SoState *state);
00425
00429 template <typename T> void findMinMax(float& min, float& max);
00430
00431
00432 int m_texUnit;
00433
00434
00435
00436
00437
00438
00439 SbMatrix m_localModelMat;
00440 SbMatrix m_localModelView;
00441 SbVec3f m_planeCoords[4];
00442 float m_zScale;
00443
00444
00445 float m_minHeight, m_maxHeight;
00446 SbBool m_recomputeMinMax;
00447
00448 SoCache* m_croppedBoxCache;
00449 SbBox3i32 m_croppedBox;
00450 };
00451
00452 #endif
00453
00454
00455