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
00059 #ifndef __vtkImageReader_h
00060 #define __vtkImageReader_h
00061
00062 #include "vtkImageSource.h"
00063 #include "vtkTransform.h"
00064
00065 #define VTK_FILE_BYTE_ORDER_BIG_ENDIAN 0
00066 #define VTK_FILE_BYTE_ORDER_LITTLE_ENDIAN 1
00067
00068 class VTK_IO_EXPORT vtkImageReader : public vtkImageSource
00069 {
00070 public:
00071 static vtkImageReader *New();
00072 vtkTypeMacro(vtkImageReader,vtkImageSource);
00073 void PrintSelf(ostream& os, vtkIndent indent);
00074
00076
00079 void SetFileName(const char *);
00080 vtkGetStringMacro(FileName);
00082
00084
00087 void SetFilePrefix(const char *);
00088 vtkGetStringMacro(FilePrefix);
00090
00092
00093 void SetFilePattern(const char *);
00094 vtkGetStringMacro(FilePattern);
00096
00098
00100 vtkSetMacro(FileNameSliceOffset,int);
00101 vtkGetMacro(FileNameSliceOffset,int);
00103
00105
00108 vtkSetMacro(FileNameSliceSpacing,int);
00109 vtkGetMacro(FileNameSliceSpacing,int);
00111
00113
00117 void SetDataScalarType(int type);
00118 void SetDataScalarTypeToFloat(){this->SetDataScalarType(VTK_FLOAT);}
00119 void SetDataScalarTypeToDouble(){this->SetDataScalarType(VTK_DOUBLE);}
00120 void SetDataScalarTypeToInt(){this->SetDataScalarType(VTK_INT);}
00121 void SetDataScalarTypeToShort(){this->SetDataScalarType(VTK_SHORT);}
00122 void SetDataScalarTypeToUnsignedShort()
00123 {this->SetDataScalarType(VTK_UNSIGNED_SHORT);}
00124 void SetDataScalarTypeToUnsignedChar()
00125 {this->SetDataScalarType(VTK_UNSIGNED_CHAR);}
00127
00129
00130 vtkGetMacro(DataScalarType, int);
00132
00134
00135 vtkSetMacro(NumberOfScalarComponents,int);
00136 vtkGetMacro(NumberOfScalarComponents,int);
00138
00140
00141 vtkSetVector6Macro(DataExtent,int);
00142 vtkGetVector6Macro(DataExtent,int);
00144
00146
00148 vtkSetVector6Macro(DataVOI,int);
00149 vtkGetVector6Macro(DataVOI,int);
00151
00153
00154 vtkSetMacro(FileDimensionality, int);
00155 int GetFileDimensionality() {return this->FileDimensionality;}
00157
00159
00160 vtkSetVector3Macro(DataSpacing,float);
00161 vtkGetVector3Macro(DataSpacing,float);
00163
00165
00166 vtkSetVector3Macro(DataOrigin,float);
00167 vtkGetVector3Macro(DataOrigin,float);
00169
00171
00172 unsigned long GetHeaderSize();
00173 unsigned long GetHeaderSize(int slice);
00175
00178 void SetHeaderSize(unsigned long size);
00179
00181
00182 vtkGetMacro(DataMask,unsigned short);
00183 void SetDataMask(int val)
00184 {if (val == this->DataMask) { return; }
00185 this->DataMask = ((unsigned short)(val)); this->Modified();}
00187
00189
00192 vtkSetObjectMacro(Transform,vtkTransform);
00193 vtkGetObjectMacro(Transform,vtkTransform);
00195
00197
00207 void SetDataByteOrderToBigEndian();
00208 void SetDataByteOrderToLittleEndian();
00209 int GetDataByteOrder();
00210 void SetDataByteOrder(int);
00211 const char *GetDataByteOrderAsString();
00213
00215
00216 vtkSetMacro(SwapBytes,int);
00217 int GetSwapBytes() {return this->SwapBytes;}
00218 vtkBooleanMacro(SwapBytes,int);
00220
00221
00222 ifstream *GetFile() {return this->File;}
00223 vtkGetVectorMacro(DataIncrements,unsigned long,4);
00224
00225
00226
00227
00228 void ComputeInverseTransformedExtent(int inExtent[6],
00229 int outExtent[6]);
00230 void ComputeInverseTransformedIncrements(int inIncr[3],
00231 int outIncr[3]);
00232
00233 void OpenFile();
00234 void OpenAndSeekFile(int extent[6], int slice);
00235
00237
00239 vtkBooleanMacro(FileLowerLeft, int);
00240 vtkGetMacro(FileLowerLeft, int);
00241 vtkSetMacro(FileLowerLeft, int);
00243
00245
00246 void ComputeInternalFileName(int slice);
00247 vtkGetStringMacro(InternalFileName);
00249
00250
00251 protected:
00252 vtkImageReader();
00253 ~vtkImageReader();
00254
00255 char *InternalFileName;
00256 char *FileName;
00257 char *FilePrefix;
00258 char *FilePattern;
00259 int NumberOfScalarComponents;
00260 int FileLowerLeft;
00261 int FileNameSliceOffset;
00262 int FileNameSliceSpacing;
00263
00264 ifstream *File;
00265 unsigned long DataIncrements[4];
00266 int DataExtent[6];
00267 unsigned short DataMask;
00268 int SwapBytes;
00269
00270 int FileDimensionality;
00271 unsigned long HeaderSize;
00272 int DataScalarType;
00273 int ManualHeaderSize;
00274 int Initialized;
00275 vtkTransform *Transform;
00276
00277 void ComputeTransformedSpacing (float Spacing[3]);
00278 void ComputeTransformedOrigin (float origin[3]);
00279 void ComputeTransformedExtent(int inExtent[6],
00280 int outExtent[6]);
00281 void ComputeTransformedIncrements(int inIncr[3],
00282 int outIncr[3]);
00283
00284 int DataDimensions[3];
00285 float DataSpacing[3];
00286 float DataOrigin[3];
00287 int DataVOI[6];
00288
00289 void ExecuteInformation();
00290 void ExecuteData(vtkDataObject *data);
00291 virtual void ComputeDataIncrements();
00292 private:
00293 vtkImageReader(const vtkImageReader&);
00294 void operator=(const vtkImageReader&);
00295 };
00296
00297 #endif