00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _SO_VOLUME_GROUP_
00025 #define _SO_VOLUME_GROUP_
00026
00027 #include <VolumeViz/nodes/SoVolumeRender.h>
00028 #include <Inventor/nodes/SoSeparator.h>
00029 #include <Inventor/nodes/SoFaceSet.h>
00030
00031 #if defined(_WIN32)
00032 #pragma warning(push)
00033 #pragma warning(disable: 4251) // 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'
00034 #endif
00035
00036 class SoGLObjectCache;
00037 class SoLDMVirtualTexture;
00038 class SoVolumeOffscreenImpl;
00039
00125 class SoVolumeGroup : public SoSeparator {
00126
00127 SO_NODE_HEADER( SoVolumeGroup );
00128
00129 public:
00134 SoSFBool multiVolumes;
00135
00139 SoVolumeGroup();
00140
00141
00142
00143 private:
00144
00161 enum VGState
00162 {
00166 REGISTERING_VR,
00170 COLLECTING_SLICE,
00174 RENDERING,
00175 };
00176
00177 struct VGSlice {
00178
00179
00180 float distance;
00181 SoLDMVirtualTexture* texID;
00182 int numVertices;
00183 SbVec3f vertices[6];
00184 const SoVolumeRender* vr;
00185 SoRef<SoFaceSet> faceSet;
00186 };
00187
00188 struct VRInfo {
00189 SoPath* path;
00190 SoVolumeRenderingQuality* vrq;
00191
00192 int vpScale;
00193
00194 float sliceDensity;
00195 };
00196
00202 virtual bool affectsPath() const;
00203
00204 static void initClass();
00205 static void exitClass();
00206
00207 void addVolume( SoState* state, const SbVec3f& planeNormal, const float sliceSpacing, const SoPath* vrPath, const SoVolumeRender* vr, SoVolumeRenderingQuality* vrq, int vpScale, float sliceDensity );
00208 void addSlice( SoLDMVirtualTexture* vt, int numVertices, SbVec3f* vertices, const SoVolumeRender* vr );
00209 VGState getVGState() const { return m_vgState; };
00210
00211
00212 int getEdgeDetectFragDataId() const;
00213
00214 const VRInfo* getVrInfo( const SoVolumeRender* vr );
00215 const VGSlice* getVgSlice( const size_t index );
00216 const VGSlice* getCurrentVgSlice();
00217
00218 private:
00220 virtual void GLRenderBelowPath(SoGLRenderAction *action);
00222 virtual void GLRenderInPath(SoGLRenderAction *action);
00223
00224 private:
00225
00226 virtual ~SoVolumeGroup();
00227
00228 private:
00229
00230 typedef std::map<const SoVolumeRender*, VRInfo> VRInfoMap;
00231
00232 SoVolumeOffscreenImpl* m_volumeOffscreenImpl;
00233
00235 SoVRImageSpaceEffects* m_imageSpaceEffects;
00236
00240 static void clearVRInfoStruct(const VRInfoMap::value_type& p);
00241
00245 SoRef<SoFaceSet> buildFaceSet( const std::vector<int>& numVertices, const std::vector<SbVec3f>& vertices );
00246
00247 VGState m_vgState;
00248 VRInfoMap m_vrInfoMap;
00249
00253 std::vector<VGSlice*> m_slices;
00254 size_t m_currentSlice;
00255
00260 int m_currentVolume;
00261
00262 SbMatrix m_currentMatrix, m_currentMatrixInv;
00263 SbVec3f m_currentPlane;
00264
00265 SoRef<SoFaceSet> m_currentFaceSet;
00266 SoRef<SoVertexProperty> m_currentVp;
00267
00268 void sortSlices();
00269 void renderSlices(SoState *state);
00270 static bool compareSlice(const VGSlice *s1, const VGSlice *s2);
00271
00278 bool preRender(SoGLRenderAction *action, int &numberOfVolume);
00282 void postRender(SoGLRenderAction *action, int numberOfVolume);
00283
00284 void setVGSlice(VGSlice* slice, float distance, SoLDMVirtualTexture* vt, int numVertices, SbVec3f vertices[], const SoVolumeRender* vr);
00285
00290 void beginOffscreenRendering( SoGLRenderAction* action );
00291
00296 void endOffscreenRendering( SoGLRenderAction* action );
00297
00302 bool needRttColor(SoState* state) const;
00303
00306 bool needRttEdgeDetect(SoState* state) const;
00307
00310 int getEdgeDetect2DMethod(SoState* state) const;
00311
00313 int getLowResolutionScale(SoState* state) const;
00314
00316 void updateVRQ(int bitmask, std::vector<int>& bitMaskVector);
00317
00319 void restoreVRQ(const std::vector<int>& bitMaskVector);
00320
00321 };
00322
00323 #if defined(_WIN32)
00324 #pragma warning(pop)
00325 #endif
00326
00327 #endif // _SO_VOLUME_GROUP_
00328
00329
00330