VTK
dox/IO/vtkMetaImageReader.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkMetaImageReader.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00065 #ifndef __vtkMetaImageReader2_h
00066 #define __vtkMetaImageReader2_h
00067 
00068 #include "vtkImageReader2.h"
00069 
00070 //BTX
00071 namespace vtkmetaio { class MetaImage; } // forward declaration  
00072 //ETX
00073 
00074 class VTK_IO_EXPORT vtkMetaImageReader : public vtkImageReader2
00075 {
00076 public:
00077   vtkTypeMacro(vtkMetaImageReader,vtkImageReader2);
00078   void PrintSelf(ostream& os, vtkIndent indent);
00079 
00081   static vtkMetaImageReader *New();
00082 
00083   virtual const char * GetFileExtensions() 
00084     { return ".mhd .mha"; }
00085 
00086   virtual const char * GetDescriptiveName() 
00087     { return "MetaIO Library: MetaImage"; }
00088 
00089   // These duplicate functions in vtkImageReader2, vtkMedicalImageReader.
00090   double * GetPixelSpacing()
00091     { return this->GetDataSpacing(); }
00092   int GetWidth()
00093     { return (this->GetDataExtent()[1] - this->GetDataExtent()[0] + 1); }
00094   int GetHeight()
00095     { return (this->GetDataExtent()[3] - this->GetDataExtent()[2] + 1); }
00096   double * GetImagePositionPatient()
00097     { return this->GetDataOrigin(); }
00098   int GetNumberOfComponents()
00099     { return this->GetNumberOfScalarComponents(); }
00100   int GetPixelRepresentation()
00101     { return this->GetDataScalarType(); }
00102   int GetDataByteOrder(void);
00103 
00104   vtkGetMacro(RescaleSlope, double);
00105   vtkGetMacro(RescaleOffset, double);
00106   vtkGetMacro(BitsAllocated, int);
00107   vtkGetStringMacro(DistanceUnits);
00108   vtkGetStringMacro(AnatomicalOrientation);
00109   vtkGetMacro(GantryAngle, double); 
00110   vtkGetStringMacro(PatientName);
00111   vtkGetStringMacro(PatientID);
00112   vtkGetStringMacro(Date);
00113   vtkGetStringMacro(Series);
00114   vtkGetStringMacro(ImageNumber);
00115   vtkGetStringMacro(Modality);
00116   vtkGetStringMacro(StudyID);
00117   vtkGetStringMacro(StudyUID);
00118   vtkGetStringMacro(TransferSyntaxUID);
00119 
00121   virtual int CanReadFile(const char* name);
00122 
00123 protected:
00124   vtkMetaImageReader();
00125   ~vtkMetaImageReader();
00126 
00127   // These functions make no sense for this (or most) file readers
00128   // and should be hidden from the user...but then the getsettest fails.
00129   /*virtual void SetFilePrefix(const char * arg) 
00130     { vtkImageReader2::SetFilePrefix(arg); }
00131   virtual void SetFilePattern(const char * arg)
00132     { vtkImageReader2::SetFilePattern(arg); }
00133   virtual void SetDataScalarType(int type) 
00134     { vtkImageReader2::SetDataScalarType(type); }
00135   virtual void SetDataScalarTypeToFloat()
00136     { this->SetDataScalarType(VTK_FLOAT); }
00137   virtual void SetDataScalarTypeToDouble()
00138     { this->SetDataScalarType(VTK_DOUBLE); }
00139   virtual void SetDataScalarTypeToInt()
00140     { this->SetDataScalarType(VTK_INT); }
00141   virtual void SetDataScalarTypeToShort()
00142     { this->SetDataScalarType(VTK_SHORT); }
00143   virtual void SetDataScalarTypeToUnsignedShort()
00144     {this->SetDataScalarType(VTK_UNSIGNED_SHORT);}
00145   virtual void SetDataScalarTypeToUnsignedChar()
00146     {this->SetDataScalarType(VTK_UNSIGNED_CHAR);}
00147   vtkSetMacro(NumberOfScalarComponents, int);
00148   vtkSetVector6Macro(DataExtent, int);
00149   vtkSetMacro(FileDimensionality, int);
00150   vtkSetVector3Macro(DataSpacing, double);
00151   vtkSetVector3Macro(DataOrigin, double);
00152   vtkSetMacro(HeaderSize, unsigned long); 
00153   unsigned long GetHeaderSize(unsigned long) 
00154     { return 0; }
00155   virtual void SetDataByteOrderToBigEndian()
00156     { this->SetDataByteOrderToBigEndian(); }
00157   virtual void SetDataByteOrderToLittleEndian()
00158     { this->SetDataByteOrderToBigEndian(); }
00159   virtual void SetDataByteOrder(int order)
00160     { this->SetDataByteOrder(order); }
00161   vtkSetMacro(FileNameSliceOffset,int);
00162   vtkSetMacro(FileNameSliceSpacing,int);
00163   vtkSetMacro(SwapBytes, int);
00164   virtual int OpenFile() 
00165     { return vtkImageReader2::OpenFile(); }
00166   virtual void SeekFile(int i, int j, int k) 
00167     { vtkImageReader2::SeekFile(i, j, k); }
00168   vtkSetMacro(FileLowerLeft, int);
00169   virtual void ComputeInternalFileName(int slice) 
00170     { vtkImageReader2::ComputeInternalFileName(slice); }
00171   vtkGetStringMacro(InternalFileName)
00172   const char * GetDataByteOrderAsString(void) 
00173     { return vtkImageReader2::GetDataByteOrderAsString(); }
00174   unsigned long GetHeaderSize(void) 
00175     { return vtkImageReader2::GetHeaderSize(); }*/
00176 
00177   void ExecuteInformation();
00178   void ExecuteData(vtkDataObject *out);
00179   virtual int RequestInformation(vtkInformation * request,
00180                          vtkInformationVector ** inputVector,
00181                          vtkInformationVector * outputVector);
00182 
00183 private:
00184   vtkMetaImageReader(const vtkMetaImageReader&);  // Not implemented.
00185   void operator=(const vtkMetaImageReader&);  // Not implemented.
00186 
00187 //BTX
00188   vtkmetaio::MetaImage *MetaImagePtr;
00189 //ETX
00190 
00191   double GantryAngle;
00192   char PatientName[255];
00193   char PatientID[255];
00194   char Date[255];
00195   char Series[255];
00196   char Study[255];
00197   char ImageNumber[255];
00198   char Modality[255];
00199   char StudyID[255];
00200   char StudyUID[255];
00201   char TransferSyntaxUID[255];
00202 
00203   double RescaleSlope;
00204   double RescaleOffset;
00205   int BitsAllocated;
00206   char DistanceUnits[255];
00207   char AnatomicalOrientation[255];
00208 };
00209 
00210 #endif
00211 
00212 
00213