00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _SO_VOLUME_RENDER_
00024 #define _SO_VOLUME_RENDER_
00025
00026 #include <Inventor/caches/SoCache.h>
00027 #include <Inventor/nodes/SoShape.h>
00028 #include <Inventor/nodes/SoShaderParameter.h>
00029 #include <Inventor/nodes/SoGroup.h>
00030 #include <Inventor/nodes/SoTextureUnit.h>
00031 #include <Inventor/fields/SoSFBool.h>
00032 #include <Inventor/fields/SoSFBitMask.h>
00033 #include <Inventor/fields/SoSFEnum.h>
00034 #include <Inventor/fields/SoSFFloat.h>
00035 #include <Inventor/fields/SoSFVec3f.h>
00036 #include <Inventor/fields/SoSFInt32.h>
00037 #include <Inventor/SbBox.h>
00038
00039 #include <Inventor/STL/vector>
00040 #include <Inventor/STL/map>
00041
00042 #include <VolumeViz/nodes/SoVolumeShape.h>
00043
00044 #include <VolumeViz/LDM/SoLDMTileID.h>
00045
00046 class SbProjection;
00047 class SoFrameBufferObject;
00048 class SoGLProgramGLSL;
00049 class SoGLTexture;
00050 class SoVRImageSpaceEffects;
00051 class SoLDMTileID;
00052 class SoLdmSubDivisionIsosurfacePolicy;
00053 class SoLdmSubDivisionPolicy;
00054 class SoLdmSubDivisionTransferFunctionPolicy;
00055 class SoShaderProgram;
00056 class SoVolumeGroup;
00057 class SoVolumeIsosurface;
00058 class SoVolumeRenderInterface;
00059 class SoVolumeRenderRaycast;
00060 class SoVolumeRenderLdm;
00061 class SoVolumeRenderLdm;
00062 class SoVolumeRenderPaging;
00063 class SoVolumeRenderingQuality;
00064 class SoVolumeStateVr;
00065 class SoVolumeRenderDetail;
00066 class SoNodeSensor;
00067 class SoVolumeOffscreenImpl;
00068 class SoProgressIndicator;
00069
00070 #ifdef _WIN32
00071 #pragma warning( push )
00072 #pragma warning(disable:4251)
00073 #endif
00074
00793 class SoVolumeRender : public SoVolumeShape {
00794 SO_NODE_HEADER( SoVolumeRender );
00795
00796 public:
00797
00801 enum LowResMode
00802 {
00806 DECREASE_NONE = 1,
00813 DECREASE_SLICES = 1 << 1,
00818 DECREASE_SCREEN_RESOLUTION = 1 << 2
00819 } ;
00820
00821
00823 enum NumSlicesControl {
00828 ALL,
00833 MANUAL,
00856 AUTOMATIC,
00864 MAIN_AXIS
00865 };
00866
00897 SoMFInt32 dataSetIds;
00898
00911 SoSFEnum numSlicesControl;
00912
00921 SoSFInt32 numSlices;
00922
00940 SoSFBitMask lowResMode;
00941
00949 SoSFInt32 lowScreenResolutionScale;
00950
00951
00968 SoSFBool subdivideTile;
00969
00980 SoSFBool fixedNumSlicesInRoi;
00981
00998 SoSFInt32 projectedTileSubdivision;
00999
01009 SoSFBool opacityCorrection;
01010
01016 enum RenderMode
01017 {
01020 VOLUME_RENDERING = 0,
01021
01024 MIN_INTENSITY_PROJECTION,
01025
01028 MAX_INTENSITY_PROJECTION,
01029
01036 SUM_INTENSITY_PROJECTION,
01037
01044 AVERAGE_INTENSITY_PROJECTION,
01045
01056 MAX_INTENSITY_DIFFERENCE_ACCUMULATION,
01057
01066 INTENSITY_DIFFERENCE_ACCUMULATION,
01067
01073 MAX_GRADIENT_DIFFERENCE_ACCUMULATION,
01074
01080 GRADIENT_DIFFERENCE_ACCUMULATION
01081 };
01082
01089 SoSFEnum renderMode;
01090
01095 enum SamplingAlignment
01096 {
01098 VIEW_ALIGNED = 0,
01100 DATA_ALIGNED,
01103 BOUNDARY_ALIGNED,
01122 SMOOTH_BOUNDARY_ALIGNED,
01123 };
01124
01152 SoSFEnum samplingAlignment;
01153
01170 SoSFFloat opacityThreshold;
01171
01175 SoVolumeRender();
01176
01205 void setRenderProgress(SoProgressIndicator* ps) { m_renderProgress = ps; }
01206
01210 enum AbortCode {
01214 CONTINUE,
01219 ABORT,
01223 SKIP
01224 };
01225
01229 typedef AbortCode SoVolumeRenderAbortCB(int totalElems, int thisElem, void *userData);
01230
01250 void setAbortCallback( SoVolumeRenderAbortCB *func, void *userData = NULL);
01251
01252
01253 #if 1 SoDEPRECATED
01273 SoSFBool lighting;
01274 SoDEPRECATED
01280 SoSFVec3f lightDirection;
01281 SoDEPRECATED
01287 SoSFFloat lightIntensity;
01288
01289 #endif
01291 #if 1 SoDEPRECATED
01300 SoSFBool viewAlignedSlices;
01301
01302 #endif
01304
01305 private:
01307 virtual void computeBBox(SoAction *, SbBox3f &box, SbVec3f ¢er);
01308
01310 virtual void rayPick(SoRayPickAction *action);
01311
01312
01313 private:
01314
01316 static void initClass();
01317
01319 static void exitClass();
01320
01324 SoVolumeRenderingQuality* getVolumeRenderingQuality( SoState* state ) const;
01325
01329 SoVolumeOffscreenImpl* getVolumeOffscreenImpl() const;
01330
01331 #if 1 SoDEPRECATED
01334
01335 #endif
01339 bool needOivDepth(SoState* state);
01340
01345 bool needRttColor(SoState* state) const;
01346
01349 bool needRttEdgeDetect(SoState* state) const;
01350
01353 bool needRttBoundaryDepth(SoState* state) const;
01354
01357 bool needRttBoundaryColor(SoState* state) const;
01358
01360 SamplingAlignment getSamplingAlignment(SoState* state) const;
01361
01363 void removeDsFromRegList(SoDataSet* pDs);
01364
01366 virtual void notify(SoNotList *list);
01367
01371 void onUserInteractionChange(SoState*state, bool stopMoving);
01372
01373
01374 private:
01375
01376 virtual ~SoVolumeRender();
01377
01378 void createVolumeRender( SoState* state );
01379
01380 void generatePrimitives(SoAction *action);
01381
01382 void doRendering(SoGLRenderAction *action);
01383
01384 void setupVolumeRenderInterface(SoState* state);
01385
01386 SoDetail *createTriangleDetail(SoRayPickAction *,
01387 const SoPrimitiveVertex *v1,
01388 const SoPrimitiveVertex *,
01389 const SoPrimitiveVertex *,
01390 SoPickedPoint *);
01391
01396 void beginOffscreenRendering( SoGLRenderAction* action );
01397
01402 void endOffscreenRendering( SoGLRenderAction* action );
01403
01407 void setupFrontToBackGlState(SoState* state);
01408
01413 SbBool shouldGLRender(SoGLRenderAction *renderAction, SbBool isPointsOrLines);
01414
01415
01416 SoINTERNAL private:
01417
01419 virtual void ldmAction(SoLdmValuationAction* action);
01420
01421
01422 private:
01423
01424 #if 1 SoDEPRECATED
01426 SoSFBool useEarlyZ;SoDEPRECATED
01428 SoSFInt32 numEarlyZPasses;SoDEPRECATED
01430 SoSFBool gpuVertexGen;
01431 #endif
01434 void fillDetail(SoRayPickAction* rpa, SoVolumeRenderDetail* detail, const SoLDM::DataSetIdPair& idPair);
01435
01436 void genPrimDataSet(SoAction* action, const SoLDM::DataSetIdPair& idPair);
01437
01439 bool canSubdivideTiles(SoState* state);
01440
01442 bool isRaycastingEnabled(SoState* state) const;
01443
01444 SoVolumeRenderAbortCB *m_abortCBfunc;
01445 void *m_abortCBuserData;
01446 void GLRenderTex2D3D(SoGLRenderAction* action);
01447
01451 void useOffscreenRendering(SoGLRenderAction* action);
01452
01456 void initInternalShaders();
01457
01458 void setupDepthPeelingTextures(SoGLRenderAction *action);
01459
01460 void rayPickDataSet(SoRayPickAction* action, const SoLDM::DataSetIdPair& idPair);
01461
01463 SoVRImageSpaceEffects* m_imageSpaceEffects;
01464
01471 int m_vpScale;
01472
01475 int m_lowScreenResScale;
01476
01477 SoShaderParameter1i *m_opacityTex;
01478 SoGLProgramGLSL* m_binaryOpacityComposeShader;
01479
01480 SoShaderProgram* m_writeFragShader;
01481
01482 SoVolumeIsosurface* m_volumeIsosurface;
01483
01487 void deleteShadersFboTextures();
01488
01492 void updateLowResScale( SoState* state );
01493
01497 void registerCtxId(const SoLDM::DsVector &dsVector, int ctxId);
01498
01502 void unregisterCtxId(const SoLDM::DsVector &dsVector, int ctxId);
01503
01505 bool m_useLowResMove;
01506
01508 bool m_useLowNumSliceMove;
01509
01510 SoVolumeRenderLdm* m_vriLdm;
01511 SoVolumeRenderRaycast* m_vriRaycast;
01512 SoVolumeRenderInterface* m_vri;
01513
01514 bool m_frontToBackComposition;
01515
01516
01517 SoLDM::DsVector m_prevDsList;
01518
01519
01520 static void volDataDeleteCB(void* data, SoSensor *sensor);
01521
01522
01523 int m_prevRegisteredCtxId;
01524
01525 SoVolumeStateVr* m_vs;
01526
01527 SoProgressIndicator* m_renderProgress;
01528 SoVolumeOffscreenImpl* m_volumeOffscreenImpl;
01529
01530
01531 std::map<SoDataSet*, SoNodeSensor*> m_mapDsSensor;
01532
01533 friend class SoVolumeRenderInterface;
01534 friend class SoVolumeRenderLdm;
01535 friend class SoVolumeRenderRaycast;
01536
01537 SoRef<SoGroup> m_depthPeelingSG;
01538 SoRef<SoGroup> m_depthPeelingColorTexGroup;
01539 SoRef<SoTextureUnit> m_depthPeelingColorTexUnit;
01540 SoRef<SoGroup> m_depthPeelingDepthTexGroup;
01541 SoRef<SoTextureUnit> m_depthPeelingDepthTexUnit;
01542 };
01543
01544 #if defined(_WIN32)
01545 #pragma warning( pop )
01546 #endif
01547
01548 #endif // _SO_VOLUME_RENDER_
01549
01550
01551