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
00052 #ifndef __vtkImageReader2_h
00053 #define __vtkImageReader2_h
00054
00055 #include "vtkImageSource.h"
00056
00057 #define VTK_FILE_BYTE_ORDER_BIG_ENDIAN 0
00058 #define VTK_FILE_BYTE_ORDER_LITTLE_ENDIAN 1
00059
00060 class VTK_IO_EXPORT vtkImageReader2 : public vtkImageSource
00061 {
00062 public:
00063 static vtkImageReader2 *New();
00064 vtkTypeMacro(vtkImageReader2,vtkImageSource);
00065 void PrintSelf(ostream& os, vtkIndent indent);
00066
00068
00071 void SetFileName(const char *);
00072 vtkGetStringMacro(FileName);
00074
00076
00079 void SetFilePrefix(const char *);
00080 vtkGetStringMacro(FilePrefix);
00082
00084
00085 void SetFilePattern(const char *);
00086 vtkGetStringMacro(FilePattern);
00088
00090
00093 void SetDataScalarType(int type);
00094 void SetDataScalarTypeToFloat(){this->SetDataScalarType(VTK_FLOAT);}
00095 void SetDataScalarTypeToDouble(){this->SetDataScalarType(VTK_DOUBLE);}
00096 void SetDataScalarTypeToInt(){this->SetDataScalarType(VTK_INT);}
00097 void SetDataScalarTypeToShort(){this->SetDataScalarType(VTK_SHORT);}
00098 void SetDataScalarTypeToUnsignedShort()
00099 {this->SetDataScalarType(VTK_UNSIGNED_SHORT);}
00100 void SetDataScalarTypeToUnsignedChar()
00101 {this->SetDataScalarType(VTK_UNSIGNED_CHAR);}
00103
00105
00106 vtkGetMacro(DataScalarType, int);
00108
00110
00111 vtkSetMacro(NumberOfScalarComponents,int);
00112 vtkGetMacro(NumberOfScalarComponents,int);
00114
00116
00117 vtkSetVector6Macro(DataExtent,int);
00118 vtkGetVector6Macro(DataExtent,int);
00120
00122
00123 vtkSetMacro(FileDimensionality, int);
00124 int GetFileDimensionality() {return this->FileDimensionality;}
00126
00128
00129 vtkSetVector3Macro(DataSpacing,float);
00130 vtkGetVector3Macro(DataSpacing,float);
00132
00134
00135 vtkSetVector3Macro(DataOrigin,float);
00136 vtkGetVector3Macro(DataOrigin,float);
00138
00140
00141 int GetHeaderSize();
00142 int GetHeaderSize(int slice);
00144
00147 void SetHeaderSize(int size);
00148
00150
00160 void SetDataByteOrderToBigEndian();
00161 void SetDataByteOrderToLittleEndian();
00162 int GetDataByteOrder();
00163 void SetDataByteOrder(int);
00164 const char *GetDataByteOrderAsString();
00166
00168
00169 vtkSetMacro(SwapBytes,int);
00170 int GetSwapBytes() {return this->SwapBytes;}
00171 vtkBooleanMacro(SwapBytes,int);
00173
00174
00175 ifstream *GetFile() {return this->File;}
00176 vtkGetVectorMacro(DataIncrements,unsigned long,4);
00177
00178
00179 void OpenFile();
00180 void SeekFile(int i, int j, int k);
00181
00183
00185 vtkBooleanMacro(FileLowerLeft, int);
00186 vtkGetMacro(FileLowerLeft, int);
00187 vtkSetMacro(FileLowerLeft, int);
00189
00191
00192 void ComputeInternalFileName(int slice);
00193 vtkGetStringMacro(InternalFileName);
00195
00196 protected:
00197 vtkImageReader2();
00198 ~vtkImageReader2();
00199
00200 char *InternalFileName;
00201 char *FileName;
00202 char *FilePrefix;
00203 char *FilePattern;
00204 int NumberOfScalarComponents;
00205 int FileLowerLeft;
00206
00207 ifstream *File;
00208 unsigned long DataIncrements[4];
00209 int DataExtent[6];
00210 int SwapBytes;
00211
00212 int FileDimensionality;
00213 int HeaderSize;
00214 int DataScalarType;
00215 int ManualHeaderSize;
00216
00217 float DataSpacing[3];
00218 float DataOrigin[3];
00219
00220 virtual void ExecuteInformation();
00221 virtual void ExecuteData(vtkDataObject *data);
00222 virtual void ComputeDataIncrements();
00223 private:
00224 vtkImageReader2(const vtkImageReader2&);
00225 void operator=(const vtkImageReader2&);
00226 };
00227
00228 #endif