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
00250 class SoUniformGridClipping : public SoTexture2 {
00251 SO_NODE_HEADER(SoUniformGridClipping);
00252
00253 public:
00257 SoUniformGridClipping();
00258
00264 SoSFBox3f extent;
00265
00267 enum Axis {
00269 X,
00271 Y,
00273 Z
00274 };
00275
00282 SoSFEnum axis;
00283
00298 SoSFFloat thickness;
00299
00306 SoSFBool clipBelow;
00307
00314 SoSFBool clipAbove;
00315
00322 SoSFFloat undefinedValue;
00323
00333 static SbBool isSupported(SoState* state=NULL) ;
00334
00338 static int getMaxNumberOfUniformGrids(SoState* state=NULL);
00339
00340 #if 1
00342 #ifndef VolumeViz_EXPORTS
00343 SoDEPRECATED
00344 SoSFBox3f size;
00345 #else
00346
00350 SoSFBox3f size;
00351 #endif
00352
00353 #endif
00355 private:
00356 virtual void GLRender(SoGLRenderAction *action);
00357 virtual void getBoundingBox(SoGetBoundingBoxAction *action);
00358 virtual void doAction(SoAction *action);
00359 virtual void doActionOnRTT(SoAction *action);
00360 virtual void rayPick(SoRayPickAction *action);
00361
00362 private:
00363
00373 SoSFBool revertMode;
00374
00375 static void initClass() ;
00376 static void exitClass() ;
00377
00379 int getTexUnit() { return m_texUnit; }
00380
00381
00382 void setClipmapUniforms(SoGLRenderAction* action, SoShaderProgram* prog, const std::vector<SoUniformGridClipping *> &grids);
00383 void setPlaneUniforms(SoGLRenderAction* action, SoShaderProgram* prog, const std::vector<SoUniformGridClipping *> &grids);
00384 void setZScaleUniform(SoGLRenderAction* action, SoShaderProgram* prog, const std::vector<SoUniformGridClipping *> &grids);
00385 virtual void setClipParamUniforms(SoGLRenderAction* action, SoShaderProgram* prog, const std::vector<SoUniformGridClipping *> &grids);
00386
00387
00388 virtual SbBool isCulled(const SbBox3f &box);
00389
00392 const SbBox3i32& cropBBox(SoState* state, SoVolumeData* vd);
00393
00395 virtual void notify(SoNotList *list);
00396
00398 virtual void fieldHasChanged( SoField *field );
00399
00400 static void setVVizUniform(SoGLRenderAction* action);
00401
00403 void installTexture( SoGLRenderAction* action );
00404
00405 private:
00406
00408 virtual ~SoUniformGridClipping();
00409
00412 SbBox3f getBBox();
00413
00414 private:
00415 enum IntersectionType
00416 {
00417 ALL_OUT,
00418 ALL_IN,
00419 INTERSECT
00420 };
00421
00422 virtual void getMinMax(float &min, float &max);
00423
00425 bool isCroppedBboxCacheValid(SoState *state);
00426
00430 template <typename T> void findMinMax(float& min, float& max);
00431
00432
00433 int m_texUnit;
00434
00435
00436
00437
00438
00439
00440 SbMatrix m_localModelMat;
00441 SbMatrix m_localModelView;
00442 SbVec3f m_planeCoords[4];
00443 float m_zScale;
00444
00445
00446 float m_minHeight, m_maxHeight;
00447 SbBool m_recomputeMinMax;
00448
00449 SoCache* m_croppedBoxCache;
00450 SbBox3i32 m_croppedBox;
00451 };
00452
00453 #endif
00454
00455
00456