00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef __mitkVolume_h
00012 #define __mitkVolume_h
00013
00014 #include "mitkDataObject.h"
00015
00064 class MITK_COMMON_API mitkVolume : public mitkDataObject
00065 {
00066 public:
00067 MITK_TYPE(mitkVolume, mitkDataObject)
00068
00069 virtual void PrintSelf(ostream& os);
00070
00071 mitkVolume();
00072
00076 virtual void Initialize();
00077
00082 virtual int GetDataObjectType() const { return MITK_VOLUME; }
00083
00090 void SetDimensions(int dims[3])
00091 {
00092 m_Dimensions[0] = dims[0];
00093 m_Dimensions[1] = dims[1];
00094 m_Dimensions[2] = dims[2];
00095 this->_computeIncrements();
00096 }
00097
00107 void GetDimensions(int dims[3]) const
00108 {
00109 dims[0] = m_Dimensions[0];
00110 dims[1] = m_Dimensions[1];
00111 dims[2] = m_Dimensions[2];
00112 }
00113
00118 void SetWidth(int w) { m_Dimensions[0] = w; this->_computeIncrements(); }
00119
00124 int GetWidth() const { return m_Dimensions[0]; }
00125
00130 void SetHeight(int h) { m_Dimensions[1] = h; this->_computeIncrements(); }
00131
00136 int GetHeight() const { return m_Dimensions[1]; }
00137
00142 void SetSliceNum(int s) { m_Dimensions[2] = s; }
00143
00147 void SetImageNum(int s) { this->SetSliceNum(s); }
00148
00153 int GetSliceNum() const { return m_Dimensions[2]; }
00154
00158 int GetImageNum() const { return this->GetSliceNum(); }
00159
00165 int GetDimensionality() const
00166 {
00167 if (m_Dimensions[2]==1)
00168 {
00169 return 2;
00170 }
00171 else
00172 {
00173 return 3;
00174 }
00175
00176 }
00177
00184 void SetSpacings(float s[3])
00185 {
00186 m_Spacings[0] = s[0];
00187 m_Spacings[1] = s[1];
00188 m_Spacings[2] = s[2];
00189 }
00190
00200 void GetSpacings(float s[3]) const
00201 {
00202 s[0] = m_Spacings[0];
00203 s[1] = m_Spacings[1];
00204 s[2] = m_Spacings[2];
00205 }
00206
00211 void SetSpacingX(float px) { m_Spacings[0] = px; }
00212
00217 float GetSpacingX() const { return m_Spacings[0]; }
00218
00223 void SetSpacingY(float py) { m_Spacings[1] = py; }
00224
00229 float GetSpacingY() const { return m_Spacings[1]; }
00230
00235 void SetSpacingZ(float pz) { m_Spacings[2] = pz; }
00236
00241 float GetSpacingZ() const { return m_Spacings[2]; }
00242
00250 void SetChannelNum(int n) { m_NumberOfChannel = n; this->_computeIncrements(); }
00251
00255 void SetNumberOfChannel(int n) { this->SetChannelNum(n); }
00256
00264 int GetChannelNum() const { return m_NumberOfChannel; }
00265
00269 int GetNumberOfChannel() const { return this->GetChannelNum(); }
00270
00280 void GetIncrements(int incs[3]) const
00281 {
00282 incs[0] = m_Increments[0];
00283 incs[1] = m_Increments[1];
00284 incs[2] = m_Increments[2];
00285 }
00286
00297 int GetIncrementX() const { return m_Increments[0]; }
00298
00309 int GetIncrementY() const { return m_Increments[1]; }
00310
00322 int GetIncrementZ() const { return m_Increments[2]; }
00323
00334 double GetData(int x, int y, int z, int c = 0);
00335
00339 void GetPointGradient(int i, int j, int k, float g[3]);
00340
00345 double GetDataTypeMin() const { return m_DataTypeMin; }
00346
00351 double GetDataTypeMax() const { return m_DataTypeMax; }
00352
00361 void SetWindowWidth(float wWidth) { m_WindowWidth = wWidth; m_HasWidthCenter = true; }
00362
00371 void SetWindowCenter(float wCenter) { m_WindowCenter = wCenter; m_HasWidthCenter = true; }
00372
00377 float GetWindowWidth();
00378
00383 float GetWindowCenter();
00384
00390 void GetWidthCenter(float &wWidth, float &wCenter);
00391
00397 bool HasWidthCenter() const {return m_HasWidthCenter;}
00398
00403 int GetDataTypeSize() const { return m_DataTypeSize; }
00404
00419 void SetDataType(int data_type);
00420
00435 int GetDataType() const { return m_DataType; }
00436
00440 void SetDataTypeToFloat() { this->SetDataType(MITK_FLOAT); }
00441
00445 void SetDataTypeToDouble() { this->SetDataType(MITK_DOUBLE); }
00446
00450 void SetDataTypeToInt() { this->SetDataType(MITK_INT); }
00451
00455 void SetDataTypeToUnsignedInt() { this->SetDataType(MITK_UNSIGNED_INT); }
00456
00460 void SetDataTypeToLong() { this->SetDataType(MITK_LONG); }
00461
00465 void SetDataTypeToUnsignedLong() { this->SetDataType(MITK_UNSIGNED_LONG); }
00466
00470 void SetDataTypeToShort() { this->SetDataType(MITK_SHORT); }
00471
00475 void SetDataTypeToUnsignedShort() { this->SetDataType(MITK_UNSIGNED_SHORT); }
00476
00480 void SetDataTypeToUnsignedChar() { this->SetDataType(MITK_UNSIGNED_CHAR); }
00481
00485 void SetDataTypeToChar() { this->SetDataType(MITK_CHAR); }
00486
00495 void GetMinMaxValue(int sliceIdx, double &minValue, double &maxValue, bool needRecalculate = false);
00496
00504 void GetMinMaxValue(double &minValue, double &maxValue, bool needRecalculate = false);
00505
00509 virtual void ShallowCopy(mitkDataObject *src);
00510
00514 virtual void DeepCopy(mitkDataObject *src);
00515
00524 virtual void FreezeSlice(int sliceIdx) {}
00525
00531 virtual void UnFreezeSlice(int sliceIdx) {}
00532
00539 virtual void const* GetData() const = 0;
00540
00549 virtual void* GetData() = 0;
00550
00554 void* GetSliceData(int sliceIdx) { return this->GetSliceForReadWrite(sliceIdx); }
00555
00565 virtual void const* GetSliceForRead(int sliceIdx) = 0;
00566
00578 virtual void* GetSliceForWrite(int sliceIdx) = 0;
00579
00589 virtual void* GetSliceForReadWrite(int sliceIdx) = 0;
00590
00599 virtual bool ReadSliceData(int sliceIdx, void *dst) = 0;
00600
00609 virtual bool ReadYZSliceData(int xIdx, void *dst) = 0;
00610
00619 virtual bool ReadXZSliceData(int yIdx, void *dst) = 0;
00620
00636 virtual bool GetArbitrarySlice(int w, int h, double o[3], double ux[3], double uy[3], void *dst) = 0;
00637
00646 virtual bool WriteSliceData(int sliceIdx, void const *src) = 0;
00647
00668 virtual bool ReadSubVolume(int x, int y, int z, int w, int h, int d, int &tw, int &th, int &td, void *dst) = 0;
00669
00670 virtual bool ReadSubVolume(int x, int y, int z, int w, int h, int d,
00671 int dstx, int dsty, int dstz, int dstw, int dsth, int dstd,
00672 void *dst, bool zeropad=true) = 0;
00673
00674 virtual bool ReadSubVolume(int x, int y, int z, int w, int h, int d, void *dst, bool zeropad=true) = 0;
00675
00696 virtual bool WriteSubVolume(int x, int y, int z, int w, int h, int d, int &tw, int &th, int &td, void const *src) = 0;
00697
00706 virtual bool Allocate() = 0;
00707
00708 virtual void PrepareSlicesForRead(int startSliceIdx,int sliceNum=1,bool freeze=false){};
00709 virtual void PrepareSlicesForWrite(int startSliceIdx,int sliceNum=1,bool freeze=false){};
00710
00711 protected:
00712 virtual ~mitkVolume();
00713 void _computeIncrements();
00714 void _clearMinMaxCache();
00715
00716 int m_Dimensions[3];
00717 int m_Increments[3];
00718 float m_Spacings[3];
00719
00720 int m_DataType;
00721 int m_NumberOfChannel;
00722
00723 float m_WindowWidth;
00724 float m_WindowCenter;
00725 bool m_HasWidthCenter;
00726 bool m_IsFirstWidthCenter;
00727
00728 double *m_MinArray;
00729 double *m_MaxArray;
00730 unsigned char *m_MinMaxFlags;
00731
00732 int m_DataTypeSize;
00733 double m_DataTypeMin;
00734 double m_DataTypeMax;
00735
00736
00737
00738 private:
00739 mitkVolume(const mitkVolume&);
00740 void operator=(const mitkVolume&);
00741
00742 };
00743
00744
00745
00746
00747
00748 #endif
00749
00750