Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

igtlImageMessage.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Open IGT Link Library
00004   Module:    $HeadURL: http://svn.na-mic.org/NAMICSandBox/trunk/OpenIGTLink/Source/igtlImageMessage.h $
00005   Language:  C++
00006   Date:      $Date: 2011-03-24 00:08:23 -0400 (Thu, 24 Mar 2011) $
00007   Version:   $Revision: 7354 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010 
00011   This software is distributed WITHOUT ANY WARRANTY; without even
00012   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00013   PURPOSE.  See the above copyright notices for more information.
00014 
00015 =========================================================================*/
00016 
00017 #ifndef __igtlImageMessage_h
00018 #define __igtlImageMessage_h
00019 
00020 #include "igtlObject.h"
00021 //#include "igtlMacros.h"
00022 #include "igtlMacro.h"
00023 #include "igtlMath.h"
00024 #include "igtlMessageBase.h"
00025 
00026 namespace igtl
00027 {
00028 
00029 class IGTLCommon_EXPORT GetImageMessage: public MessageBase
00030 {
00031 public:
00032   typedef GetImageMessage                Self;
00033   typedef MessageBase                    Superclass;
00034   typedef SmartPointer<Self>             Pointer;
00035   typedef SmartPointer<const Self>       ConstPointer;
00036 
00037   igtlTypeMacro(igtl::GetImageMessage, igtl::MessageBase);
00038   igtlNewMacro(igtl::GetImageMessage);
00039 
00040 protected:
00041   GetImageMessage() : MessageBase() { this->m_DefaultBodyType  = "GET_IMAGE"; };
00042   ~GetImageMessage() {};
00043 protected:
00044   virtual int  GetBodyPackSize() { return 0; };
00045   virtual int  PackBody()        { AllocatePack(); return 1; };
00046   virtual int  UnpackBody()      { return 1; };
00047 };
00048 
00049 
00050 class IGTLCommon_EXPORT ImageMessage: public MessageBase
00051 {
00052 public:
00053   typedef ImageMessage              Self;
00054   typedef MessageBase               Superclass;
00055   typedef SmartPointer<Self>        Pointer;
00056   typedef SmartPointer<const Self>  ConstPointer;
00057 
00058   igtlTypeMacro(igtl::ImageMessage, igtl::MessageBase)
00059   igtlNewMacro(igtl::ImageMessage);
00060 
00061 public:
00062 
00063   enum {
00064     COORDINATE_LPS,
00065     COORDINATE_RAS
00066   };
00067 
00068   enum {
00069     ENDIAN_BIG,
00070     ENDIAN_LITTLE
00071   };
00072 
00073   enum {
00074     DTYPE_SCALAR = 1,
00075     DTYPE_VECTOR = 3
00076   };
00077 
00078   enum {
00079     TYPE_INT8    = 2,
00080     TYPE_UINT8   = 3,
00081     TYPE_INT16   = 4,
00082     TYPE_UINT16  = 5,
00083     TYPE_INT32   = 6,
00084     TYPE_UINT32  = 7,
00085     TYPE_FLOAT32 = 10,
00086     TYPE_FLOAT64 = 11
00087   };
00088 
00089 
00090 public:
00091 
00092   // Image dimensions.
00093   // SetDimensions() should be called prior to SetSubVolume(), since SetDimensions()
00094   // sets subvolume parameters automatically assuming that subvolume = entire volume.
00095   void SetDimensions(int s[3]);
00096   void SetDimensions(int i, int j, int k);
00097   void GetDimensions(int s[3]);
00098   void GetDimensions(int &i, int &j, int &k);
00099 
00100   // Sub-volume dimensions and offset.
00101   // SetSubVolume() should be called after calling SetDiemensions(), since SetDimensions()
00102   // reset the subvolume parameters automatically.
00103   int  SetSubVolume(int dim[3], int off[3]);
00104   int  SetSubVolume(int dimi, int dimj, int dimk, int offi, int offj, int offk);
00105   void GetSubVolume(int dim[3], int off[3]);
00106   void GetSubVolume(int &dimi, int &dimj, int &dimk, int &offi, int &offj, int &offk);
00107 
00108   // Spacings
00109   void SetSpacing(float s[3]);
00110   void SetSpacing(float si, float sj, float sk);
00111   void GetSpacing(float s[3]);
00112   void GetSpacing(float &si, float &sj, float &sk);
00113 
00114   // Origin coordinate
00115   void SetOrigin(float p[3]);
00116   void SetOrigin(float px, float py, float pz);
00117   void GetOrigin(float p[3]);
00118   void GetOrigin(float &px, float &py, float &pz);
00119 
00120   // Image orientation
00121   void SetNormals(float o[3][3]);
00122   void SetNormals(float t[3], float s[3], float n[3]);
00123   void GetNormals(float o[3][3]);
00124   void GetNormals(float t[3], float s[3], float n[3]);
00125 
00126   // Number of components
00127   void SetNumComponents(int num);
00128   int  GetNumComponents();
00129 
00130   // Origin/orientation matrix
00131   void SetMatrix(Matrix4x4& mat);
00132   void GetMatrix(Matrix4x4& mat);
00133 
00134   // Image scalar type
00135   void SetScalarType(int t)    { scalarType = t; };
00136   void SetScalarTypeToInt8()   { scalarType = TYPE_INT8; };
00137   void SetScalarTypeToUint8()  { scalarType = TYPE_UINT8; };
00138   void SetScalarTypeToInt16()  { scalarType = TYPE_INT16; };
00139   void SetScalarTypeToUint16() { scalarType = TYPE_UINT16; };
00140   void SetScalarTypeToInt32()  { scalarType = TYPE_INT32; };
00141   void SetScalarTypeToUint32() { scalarType = TYPE_UINT32; };
00142   int  GetScalarType()         { return scalarType; };
00143   int  GetScalarSize()         { return ScalarSizeTable[scalarType]; };
00144   int  GetScalarSize(int type) { return ScalarSizeTable[type]; };
00145 
00146   // Endian of image scalar (default is ENDIAN_BIG)
00147   void SetEndian(int e)        { endian = e; };
00148   int  GetEndian()             { return endian; };
00149 
00150   // TBD: Should returned value be 64-bit integer?
00151   int  GetImageSize()
00152   {
00153     return dimensions[0]*dimensions[1]*dimensions[2]*GetScalarSize()*numComponents;
00154   };
00155 
00156   int  GetSubVolumeImageSize()
00157   {
00158     return subDimensions[0]*subDimensions[1]*subDimensions[2]*GetScalarSize()*numComponents;
00159   };
00160 
00161   void  AllocateScalars();
00162   void* GetScalarPointer();
00163 
00164 protected:
00165   ImageMessage();
00166   ~ImageMessage();
00167   
00168 protected:
00169 
00170   virtual int  GetBodyPackSize();
00171   virtual int  PackBody();
00172   virtual int  UnpackBody();
00173   
00174   int    dimensions[3];
00175   float  spacing[3];
00176   int    subDimensions[3];
00177   int    subOffset[3];
00178 
00179   Matrix4x4 matrix;
00180 
00181   int    endian;
00182   int    dataType;
00183   int    numComponents;
00184   int    scalarType;
00185   int    coordinate;
00186 
00187   unsigned char*  m_ImageHeader;
00188   unsigned char*  m_Image;
00189 
00190   int ScalarSizeTable[12];
00191 };
00192 
00193 
00194 } // namespace igtl
00195 
00196 #endif // _igtlImageMessage_h
00197 
00198 
00199 

Generated at Mon May 2 2011 03:56:12 for OpenIGTLink by doxygen 1.7.3 written by Dimitri van Heesch, © 1997-2000