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 _SB_IMAGE_DATA_ACCESSOR_H_
00025 #define _SB_IMAGE_DATA_ACCESSOR_H_
00026
00027 #include <ImageViz/SoImageViz.h>
00028 #include <Inventor/SbVec.h>
00029 #include <ImageViz/SbChannelList.h>
00030 #include <Inventor/SbBox.h>
00031 #include <ImageViz/SbImageDataVoxel.h>
00032 #include <Inventor/misc/SoRefCounter.h>
00033
00034 class SoImageDataAdapter;
00035 class SoMemoryDataAdapter;
00036
00057 class SbImageDataAccessor
00058 {
00059 public:
00060
00071 class Region
00072 {
00073 public:
00080 virtual SbVec4i32 getPosition(uint64_t i) const = 0;
00081
00088 virtual SbVec4i32 getSize() const = 0;
00089
00091 virtual uint64_t getNumVoxel() const = 0;
00092
00098 virtual SbBox4i32 getExtent() const = 0;
00099 };
00100
00104 class SubVolumeRegion : public Region
00105 {
00106 public:
00108 SubVolumeRegion(const SbBox3i32& subVolume);
00109
00114 virtual SbVec4i32 getPosition(uint64_t i) const;
00115
00120 virtual SbVec4i32 getSize() const { return m_bbox.getSize(); }
00121
00123 virtual uint64_t getNumVoxel() const;
00124
00128 virtual SbBox4i32 getExtent() const { return m_bbox; }
00129
00130 private:
00131
00132 SubVolumeRegion() {}
00133
00134 private:
00135
00138 SbBox4i32 m_bbox;
00139 };
00140
00143 static SubVolumeRegion createFullRegion(SoImageDataAdapter* image);
00144
00147 static SubVolumeRegion createSliceRegion(SoImageDataAdapter* image, uint32_t sliceNumber);
00148
00156 SbImageDataVoxel getVoxel(const SbVec4i32& pos );
00157
00169 double getVoxel( int x, int y, int z = 0, int t = 0, int c = 0 );
00170
00181 bool setVoxel( double value, int x, int y, int z = 0, int t = 0, int c = 0 );
00182
00193 bool getRow( SoCpuBufferObject* values, int y, int z = 0, int t = 0, int c = 0 );
00194
00198 bool getRow( std::vector<double>& values, int y, int z = 0, int t = 0, int c = 0 );
00199
00210 bool setRow( const SoCpuBufferObject* values, int y, int z = 0, int t = 0, int c = 0 );
00211
00215 bool setRow( const std::vector<double>& values, int y, int z = 0, int t = 0, int c = 0 );
00216
00227 bool getColumn( SoCpuBufferObject* values, int x, int z = 0, int t = 0, int c = 0 );
00228
00232 bool getColumn( std::vector<double>& values, int x, int z = 0, int t = 0, int c = 0 );
00233
00244 bool setColumn( const SoCpuBufferObject* values, int x, int z = 0, int t = 0, int c = 0 );
00245
00249 bool setColumn( const std::vector<double>& values, int x, int z = 0, int t = 0, int c = 0 );
00250
00262 SoMemoryDataAdapter* copyRegion(const Region& region, const SbChannelList& channels);
00263
00275 SoMemoryDataAdapter* copyRegion(const Region& region);
00276
00278 SoImageDataAdapter* getImageAdapter() const { return m_image; }
00279
00280 private:
00281
00283 friend class SoImageDataAdapter;
00284 SbImageDataAccessor(SoImageDataAdapter* image);
00285
00286 private:
00287
00289 SbImageDataAccessor() {};
00290
00292 SbImageDataAccessor& operator=(const SbImageDataAccessor&) { return *this; }
00293 SbImageDataAccessor (SbImageDataAccessor&) {}
00294
00295
00298 template <typename IMAGE_TYPE, typename REGION>
00299 SoMemoryDataAdapter* copyRegionGeneric(const REGION& region, const SbChannelList& channelList);
00300
00306 template <typename IMAGE_TYPE>
00307 void getVoxelInternal(const SbVec4i32& pos, SoCpuBufferObject* voxelBuff);
00308
00310 static bool checkRegionConsistency( const Region& region );
00311
00314 SoImageDataAdapter* m_image;
00315 };
00316
00317 #endif // _SB_IMAGE_DATA_ACCESSOR_H_
00318
00319