VTK
vtkImageReader2.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkImageReader2.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
41 #ifndef vtkImageReader2_h
42 #define vtkImageReader2_h
43 
44 #include "vtkIOImageModule.h" // For export macro
45 #include "vtkImageAlgorithm.h"
46 
47 class vtkStringArray;
48 
49 #define VTK_FILE_BYTE_ORDER_BIG_ENDIAN 0
50 #define VTK_FILE_BYTE_ORDER_LITTLE_ENDIAN 1
51 
52 class VTKIOIMAGE_EXPORT vtkImageReader2 : public vtkImageAlgorithm
53 {
54 public:
55  static vtkImageReader2 *New();
57  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
58 
60 
64  virtual void SetFileName(const char *);
65  vtkGetStringMacro(FileName);
67 
69 
76  virtual void SetFileNames(vtkStringArray *);
77  vtkGetObjectMacro(FileNames, vtkStringArray);
79 
81 
88  virtual void SetFilePrefix(const char *);
89  vtkGetStringMacro(FilePrefix);
91 
93 
97  virtual void SetFilePattern(const char *);
98  vtkGetStringMacro(FilePattern);
100 
106  virtual void SetMemoryBuffer(void *);
107  virtual void *GetMemoryBuffer() { return this->MemoryBuffer; }
108 
112  virtual void SetMemoryBufferLength(vtkIdType buflen);
113  vtkIdType GetMemoryBufferLength() { return this->MemoryBufferLength; }
114 
120  virtual void SetDataScalarType(int type);
121  virtual void SetDataScalarTypeToFloat(){this->SetDataScalarType(VTK_FLOAT);}
122  virtual void SetDataScalarTypeToDouble(){this->SetDataScalarType(VTK_DOUBLE);}
123  virtual void SetDataScalarTypeToInt(){this->SetDataScalarType(VTK_INT);}
124  virtual void SetDataScalarTypeToUnsignedInt(){this->SetDataScalarType(VTK_UNSIGNED_INT);}
125  virtual void SetDataScalarTypeToShort(){this->SetDataScalarType(VTK_SHORT);}
127  {this->SetDataScalarType(VTK_UNSIGNED_SHORT);}
128  virtual void SetDataScalarTypeToChar()
129  {this->SetDataScalarType(VTK_CHAR);}
131  {this->SetDataScalarType(VTK_SIGNED_CHAR);}
133  {this->SetDataScalarType(VTK_UNSIGNED_CHAR);}
134 
136 
139  vtkGetMacro(DataScalarType, int);
141 
143 
146  vtkSetMacro(NumberOfScalarComponents,int);
147  vtkGetMacro(NumberOfScalarComponents,int);
149 
151 
154  vtkSetVector6Macro(DataExtent,int);
155  vtkGetVector6Macro(DataExtent,int);
157 
159 
162  vtkSetMacro(FileDimensionality, int);
163  int GetFileDimensionality() {return this->FileDimensionality;}
165 
167 
170  vtkSetVector3Macro(DataSpacing,double);
171  vtkGetVector3Macro(DataSpacing,double);
173 
175 
178  vtkSetVector3Macro(DataOrigin,double);
179  vtkGetVector3Macro(DataOrigin,double);
181 
183 
186  unsigned long GetHeaderSize();
187  unsigned long GetHeaderSize(unsigned long slice);
189 
194  virtual void SetHeaderSize(unsigned long size);
195 
197 
210  virtual void SetDataByteOrderToBigEndian();
211  virtual void SetDataByteOrderToLittleEndian();
212  virtual int GetDataByteOrder();
213  virtual void SetDataByteOrder(int);
214  virtual const char *GetDataByteOrderAsString();
216 
218 
222  vtkSetMacro(FileNameSliceOffset,int);
223  vtkGetMacro(FileNameSliceOffset,int);
225 
227 
232  vtkSetMacro(FileNameSliceSpacing,int);
233  vtkGetMacro(FileNameSliceSpacing,int);
235 
236 
238 
241  vtkSetMacro(SwapBytes,int);
242  virtual int GetSwapBytes() {return this->SwapBytes;}
243  vtkBooleanMacro(SwapBytes,int);
245 
246  ifstream *GetFile() {return this->File;}
247  vtkGetVectorMacro(DataIncrements,unsigned long,4);
248 
249  virtual int OpenFile();
250  virtual void SeekFile(int i, int j, int k);
251 
253 
257  vtkBooleanMacro(FileLowerLeft, int);
258  vtkGetMacro(FileLowerLeft, int);
259  vtkSetMacro(FileLowerLeft, int);
261 
263 
266  virtual void ComputeInternalFileName(int slice);
267  vtkGetStringMacro(InternalFileName);
269 
279  virtual int CanReadFile(const char* vtkNotUsed(fname))
280  {
281  return 0;
282  }
283 
289  virtual const char* GetFileExtensions()
290  {
291  return 0;
292  }
293 
295 
298  virtual const char* GetDescriptiveName()
299  {
300  return 0;
301  }
302 protected:
303  vtkImageReader2();
304  ~vtkImageReader2() VTK_OVERRIDE;
306 
307  vtkStringArray *FileNames;
308 
309  char *InternalFileName;
310  char *FileName;
311  char *FilePrefix;
312  char *FilePattern;
313  int NumberOfScalarComponents;
314  int FileLowerLeft;
315 
316  void *MemoryBuffer;
317  vtkIdType MemoryBufferLength;
318 
319  ifstream *File;
320  unsigned long DataIncrements[4];
321  int DataExtent[6];
322  int SwapBytes;
323 
324  int FileDimensionality;
325  unsigned long HeaderSize;
326  int DataScalarType;
327  unsigned long ManualHeaderSize;
328 
329  double DataSpacing[3];
330  double DataOrigin[3];
331 
332  int FileNameSliceOffset;
333  int FileNameSliceSpacing;
334 
335  int RequestInformation(vtkInformation* request,
336  vtkInformationVector** inputVector,
337  vtkInformationVector* outputVector) VTK_OVERRIDE;
338  virtual void ExecuteInformation();
339  void ExecuteDataWithInformation(vtkDataObject *data, vtkInformation *outInfo) VTK_OVERRIDE;
340  virtual void ComputeDataIncrements();
341 private:
342  vtkImageReader2(const vtkImageReader2&) VTK_DELETE_FUNCTION;
343  void operator=(const vtkImageReader2&) VTK_DELETE_FUNCTION;
344 };
345 
346 #endif
#define VTK_UNSIGNED_INT
Definition: vtkType.h:55
Store vtkAlgorithm input/output information.
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:53
int GetFileDimensionality()
The number of dimensions stored in a file.
virtual void SetDataScalarTypeToUnsignedChar()
a vtkAbstractArray subclass for strings
int vtkIdType
Definition: vtkType.h:345
vtkIdType GetMemoryBufferLength()
#define VTK_DOUBLE
Definition: vtkType.h:59
#define VTK_FLOAT
Definition: vtkType.h:58
virtual int CanReadFile(const char *vtkNotUsed(fname))
Return non zero if the reader can read the given file name.
virtual void SetDataScalarTypeToChar()
virtual void SetDataScalarTypeToShort()
a simple class to control print indentation
Definition: vtkIndent.h:33
virtual void SetDataScalarTypeToSignedChar()
virtual void SetDataScalarTypeToUnsignedShort()
#define VTK_SHORT
Definition: vtkType.h:52
#define VTK_CHAR
Definition: vtkType.h:49
vtkGetStringMacro(ExtensionsString)
Returns a string listing all available extensions.
ifstream * GetFile()
virtual void SetDataScalarTypeToUnsignedInt()
Superclass of binary file readers.
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
virtual void SetDataScalarTypeToInt()
#define VTK_SIGNED_CHAR
Definition: vtkType.h:50
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:51
virtual void SetDataScalarTypeToDouble()
virtual void SetDataScalarTypeToFloat()
virtual const char * GetFileExtensions()
Get the file extensions for this format.
Generic algorithm superclass for image algs.
Store zero or more vtkInformation instances.
static vtkAlgorithm * New()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual const char * GetDescriptiveName()
Return a descriptive name for the file format that might be useful in a GUI.
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
general representation of visualization data
Definition: vtkDataObject.h:58
#define VTK_INT
Definition: vtkType.h:54
virtual int GetSwapBytes()
Set/Get the byte swapping to explicitly swap the bytes of a file.
virtual void * GetMemoryBuffer()