00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00055 #ifndef __vtkImageReader_h
00056 #define __vtkImageReader_h
00057
00058 #include "vtkImageSource.h"
00059 #include "vtkTransform.h"
00060
00061 #define VTK_FILE_BYTE_ORDER_BIG_ENDIAN 0
00062 #define VTK_FILE_BYTE_ORDER_LITTLE_ENDIAN 1
00063
00064 class VTK_EXPORT vtkImageReader : public vtkImageSource
00065 {
00066 public:
00067 static vtkImageReader *New();
00068 vtkTypeMacro(vtkImageReader,vtkImageSource);
00069 void PrintSelf(ostream& os, vtkIndent indent);
00070
00074 void SetFileName(const char *);
00075 vtkGetStringMacro(FileName);
00076
00080 void SetFilePrefix(const char *);
00081 vtkGetStringMacro(FilePrefix);
00082
00084 void SetFilePattern(const char *);
00085 vtkGetStringMacro(FilePattern);
00086
00091 void SetDataScalarType(int type);
00092 void SetDataScalarTypeToFloat(){this->SetDataScalarType(VTK_FLOAT);}
00093 void SetDataScalarTypeToDouble(){this->SetDataScalarType(VTK_DOUBLE);}
00094 void SetDataScalarTypeToInt(){this->SetDataScalarType(VTK_INT);}
00095 void SetDataScalarTypeToShort(){this->SetDataScalarType(VTK_SHORT);}
00096 void SetDataScalarTypeToUnsignedShort()
00097 {this->SetDataScalarType(VTK_UNSIGNED_SHORT);}
00098 void SetDataScalarTypeToUnsignedChar()
00099 {this->SetDataScalarType(VTK_UNSIGNED_CHAR);}
00100
00102 vtkGetMacro(DataScalarType, int);
00103
00105 vtkSetMacro(NumberOfScalarComponents,int);
00106 vtkGetMacro(NumberOfScalarComponents,int);
00107
00109 vtkSetVector6Macro(DataExtent,int);
00110 vtkGetVector6Macro(DataExtent,int);
00111
00114 vtkSetVector6Macro(DataVOI,int);
00115 vtkGetVector6Macro(DataVOI,int);
00116
00118 vtkSetMacro(FileDimensionality, int);
00119 int GetFileDimensionality() {return this->FileDimensionality;}
00120
00122 vtkSetVector3Macro(DataSpacing,float);
00123 vtkGetVector3Macro(DataSpacing,float);
00124
00126 vtkSetVector3Macro(DataOrigin,float);
00127 vtkGetVector3Macro(DataOrigin,float);
00128
00130 int GetHeaderSize();
00131 int GetHeaderSize(int slice);
00132
00135 void SetHeaderSize(int size);
00136
00138 vtkGetMacro(DataMask,unsigned short);
00139 void SetDataMask(int val)
00140 {if (val == this->DataMask) { return; }
00141 this->DataMask = ((unsigned short)(val)); this->Modified();}
00142
00146 vtkSetObjectMacro(Transform,vtkTransform);
00147 vtkGetObjectMacro(Transform,vtkTransform);
00148
00159 void SetDataByteOrderToBigEndian();
00160 void SetDataByteOrderToLittleEndian();
00161 int GetDataByteOrder();
00162 void SetDataByteOrder(int);
00163 const char *GetDataByteOrderAsString();
00164
00166 vtkSetMacro(SwapBytes,int);
00167 int GetSwapBytes() {return this->SwapBytes;}
00168 vtkBooleanMacro(SwapBytes,int);
00169
00170
00171 ifstream *GetFile() {return this->File;}
00172 vtkGetVectorMacro(DataIncrements,unsigned long,4);
00173
00174
00175
00176
00177 void ComputeInverseTransformedExtent(int inExtent[6],
00178 int outExtent[6]);
00179 void ComputeInverseTransformedIncrements(int inIncr[3],
00180 int outIncr[3]);
00181
00182 void OpenFile();
00183 void OpenAndSeekFile(int extent[6], int slice);
00184
00187 vtkBooleanMacro(FileLowerLeft, int);
00188 vtkGetMacro(FileLowerLeft, int);
00189 vtkSetMacro(FileLowerLeft, int);
00190
00192 void ComputeInternalFileName(int slice);
00193 vtkGetStringMacro(InternalFileName);
00194
00195
00196 protected:
00197 vtkImageReader();
00198 ~vtkImageReader();
00199 vtkImageReader(const vtkImageReader&) {};
00200 void operator=(const vtkImageReader&) {};
00201
00202 char *InternalFileName;
00203 char *FileName;
00204 char *FilePrefix;
00205 char *FilePattern;
00206 int NumberOfScalarComponents;
00207 int FileLowerLeft;
00208
00209 ifstream *File;
00210 unsigned long DataIncrements[4];
00211 int DataExtent[6];
00212 unsigned short DataMask;
00213 int SwapBytes;
00214
00215 int FileDimensionality;
00216 int HeaderSize;
00217 int DataScalarType;
00218 int ManualHeaderSize;
00219 int Initialized;
00220 vtkTransform *Transform;
00221
00222 void ComputeTransformedSpacing (float Spacing[3]);
00223 void ComputeTransformedOrigin (float origin[3]);
00224 void ComputeTransformedExtent(int inExtent[6],
00225 int outExtent[6]);
00226 void ComputeTransformedIncrements(int inIncr[3],
00227 int outIncr[3]);
00228
00229 int DataDimensions[3];
00230 float DataSpacing[3];
00231 float DataOrigin[3];
00232 int DataVOI[6];
00233
00234 void ExecuteInformation();
00235 void Execute() { this->vtkImageSource::Execute(); };
00236 void Execute(vtkImageData *data);
00237 virtual void ComputeDataIncrements();
00238 };
00239
00240 #endif