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 =========================================================================*/
47 #ifndef vtkImageReader2_h
48 #define vtkImageReader2_h
49 
50 #include "vtkIOImageModule.h" // For export macro
51 #include "vtkImageAlgorithm.h"
52 
53 class vtkStringArray;
54 
55 #define VTK_FILE_BYTE_ORDER_BIG_ENDIAN 0
56 #define VTK_FILE_BYTE_ORDER_LITTLE_ENDIAN 1
57 
58 class VTKIOIMAGE_EXPORT vtkImageReader2 : public vtkImageAlgorithm
59 {
60 public:
61  static vtkImageReader2 *New();
63  void PrintSelf(ostream& os, vtkIndent indent) override;
64 
66 
70  virtual void SetFileName(const char *);
71  vtkGetStringMacro(FileName);
73 
75 
82  virtual void SetFileNames(vtkStringArray *);
83  vtkGetObjectMacro(FileNames, vtkStringArray);
85 
87 
94  virtual void SetFilePrefix(const char *);
95  vtkGetStringMacro(FilePrefix);
97 
99 
103  virtual void SetFilePattern(const char *);
104  vtkGetStringMacro(FilePattern);
106 
112  virtual void SetMemoryBuffer(void *);
113  virtual void *GetMemoryBuffer() { return this->MemoryBuffer; }
114 
118  virtual void SetMemoryBufferLength(vtkIdType buflen);
119  vtkIdType GetMemoryBufferLength() { return this->MemoryBufferLength; }
120 
126  virtual void SetDataScalarType(int type);
127  virtual void SetDataScalarTypeToFloat(){this->SetDataScalarType(VTK_FLOAT);}
128  virtual void SetDataScalarTypeToDouble(){this->SetDataScalarType(VTK_DOUBLE);}
129  virtual void SetDataScalarTypeToInt(){this->SetDataScalarType(VTK_INT);}
130  virtual void SetDataScalarTypeToUnsignedInt(){this->SetDataScalarType(VTK_UNSIGNED_INT);}
131  virtual void SetDataScalarTypeToShort(){this->SetDataScalarType(VTK_SHORT);}
133  {this->SetDataScalarType(VTK_UNSIGNED_SHORT);}
134  virtual void SetDataScalarTypeToChar()
135  {this->SetDataScalarType(VTK_CHAR);}
137  {this->SetDataScalarType(VTK_SIGNED_CHAR);}
139  {this->SetDataScalarType(VTK_UNSIGNED_CHAR);}
140 
142 
145  vtkGetMacro(DataScalarType, int);
147 
149 
152  vtkSetMacro(NumberOfScalarComponents,int);
153  vtkGetMacro(NumberOfScalarComponents,int);
155 
157 
160  vtkSetVector6Macro(DataExtent,int);
161  vtkGetVector6Macro(DataExtent,int);
163 
165 
168  vtkSetMacro(FileDimensionality, int);
169  int GetFileDimensionality() {return this->FileDimensionality;}
171 
173 
176  vtkSetVector3Macro(DataSpacing,double);
177  vtkGetVector3Macro(DataSpacing,double);
179 
181 
184  vtkSetVector3Macro(DataOrigin,double);
185  vtkGetVector3Macro(DataOrigin,double);
187 
189 
192  unsigned long GetHeaderSize();
193  unsigned long GetHeaderSize(unsigned long slice);
195 
200  virtual void SetHeaderSize(unsigned long size);
201 
203 
216  virtual void SetDataByteOrderToBigEndian();
217  virtual void SetDataByteOrderToLittleEndian();
218  virtual int GetDataByteOrder();
219  virtual void SetDataByteOrder(int);
220  virtual const char *GetDataByteOrderAsString();
222 
224 
228  vtkSetMacro(FileNameSliceOffset,int);
229  vtkGetMacro(FileNameSliceOffset,int);
231 
233 
238  vtkSetMacro(FileNameSliceSpacing,int);
239  vtkGetMacro(FileNameSliceSpacing,int);
241 
242 
244 
247  vtkSetMacro(SwapBytes,vtkTypeBool);
248  virtual vtkTypeBool GetSwapBytes() {return this->SwapBytes;}
249  vtkBooleanMacro(SwapBytes,vtkTypeBool);
251 
252  ifstream *GetFile() {return this->File;}
253  vtkGetVectorMacro(DataIncrements,unsigned long,4);
254 
255  virtual int OpenFile();
256  virtual void SeekFile(int i, int j, int k);
257 
259 
263  vtkBooleanMacro(FileLowerLeft, vtkTypeBool);
264  vtkGetMacro(FileLowerLeft, vtkTypeBool);
265  vtkSetMacro(FileLowerLeft, vtkTypeBool);
267 
269 
272  virtual void ComputeInternalFileName(int slice);
273  vtkGetStringMacro(InternalFileName);
275 
285  virtual int CanReadFile(const char* vtkNotUsed(fname))
286  {
287  return 0;
288  }
289 
295  virtual const char* GetFileExtensions()
296  {
297  return nullptr;
298  }
299 
301 
304  virtual const char* GetDescriptiveName()
305  {
306  return nullptr;
307  }
308 protected:
309  vtkImageReader2();
310  ~vtkImageReader2() override;
312 
314 
316  char *FileName;
317  char *FilePrefix;
318  char *FilePattern;
321 
324 
325  ifstream *File;
326  unsigned long DataIncrements[4];
327  int DataExtent[6];
329 
331  unsigned long HeaderSize;
333  unsigned long ManualHeaderSize;
334 
335  double DataSpacing[3];
336  double DataOrigin[3];
337 
340 
341  int RequestInformation(vtkInformation* request,
342  vtkInformationVector** inputVector,
343  vtkInformationVector* outputVector) override;
344  virtual void ExecuteInformation();
346  virtual void ComputeDataIncrements();
347 private:
348  vtkImageReader2(const vtkImageReader2&) = delete;
349  void operator=(const vtkImageReader2&) = delete;
350 };
351 
352 #endif
vtkImageReader2::FileName
char * FileName
Definition: vtkImageReader2.h:316
vtkImageReader2::File
ifstream * File
Definition: vtkImageReader2.h:325
vtkImageReader2::FileLowerLeft
vtkTypeBool FileLowerLeft
Definition: vtkImageReader2.h:320
vtkX3D::type
Definition: vtkX3D.h:516
vtkIdType
int vtkIdType
Definition: vtkType.h:347
VTK_UNSIGNED_INT
#define VTK_UNSIGNED_INT
Definition: vtkType.h:55
vtkImageReader2::SetDataScalarTypeToUnsignedInt
virtual void SetDataScalarTypeToUnsignedInt()
Definition: vtkImageReader2.h:130
vtkX3D::data
Definition: vtkX3D.h:315
vtkImageReader2::SetDataScalarTypeToChar
virtual void SetDataScalarTypeToChar()
Definition: vtkImageReader2.h:134
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:41
VTK_UNSIGNED_SHORT
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:53
vtkImageReader2::SetDataScalarTypeToFloat
virtual void SetDataScalarTypeToFloat()
Definition: vtkImageReader2.h:127
vtkImageReader2::FilePrefix
char * FilePrefix
Definition: vtkImageReader2.h:317
vtkImageAlgorithm::ExecuteDataWithInformation
virtual void ExecuteDataWithInformation(vtkDataObject *output, vtkInformation *outInfo)
This is a convenience method that is implemented in many subclasses instead of RequestData.
vtkImageReader2::SwapBytes
vtkTypeBool SwapBytes
Definition: vtkImageReader2.h:328
vtkImageAlgorithm.h
vtkImageReader2::GetMemoryBuffer
virtual void * GetMemoryBuffer()
Definition: vtkImageReader2.h:113
vtkImageReader2::GetFileExtensions
virtual const char * GetFileExtensions()
Get the file extensions for this format.
Definition: vtkImageReader2.h:295
vtkImageReader2::SetDataScalarTypeToUnsignedShort
virtual void SetDataScalarTypeToUnsignedShort()
Definition: vtkImageReader2.h:132
vtkImageReader2::DataScalarType
int DataScalarType
Definition: vtkImageReader2.h:332
vtkImageAlgorithm
Generic algorithm superclass for image algs.
Definition: vtkImageAlgorithm.h:40
vtkImageReader2::FilePattern
char * FilePattern
Definition: vtkImageReader2.h:318
vtkImageReader2::FileDimensionality
int FileDimensionality
Definition: vtkImageReader2.h:330
vtkImageAlgorithm::RequestInformation
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
Subclasses can reimplement this method to collect information from their inputs and set information f...
vtkImageReader2::FileNameSliceSpacing
int FileNameSliceSpacing
Definition: vtkImageReader2.h:339
VTK_CHAR
#define VTK_CHAR
Definition: vtkType.h:49
vtkImageReader2::MemoryBufferLength
vtkIdType MemoryBufferLength
Definition: vtkImageReader2.h:323
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkImageReader2::InternalFileName
char * InternalFileName
Definition: vtkImageReader2.h:315
VTK_FLOAT
#define VTK_FLOAT
Definition: vtkType.h:58
VTK_DOUBLE
#define VTK_DOUBLE
Definition: vtkType.h:59
VTK_UNSIGNED_CHAR
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:51
vtkImageReader2::GetDescriptiveName
virtual const char * GetDescriptiveName()
Return a descriptive name for the file format that might be useful in a GUI.
Definition: vtkImageReader2.h:304
vtkX3D::size
Definition: vtkX3D.h:253
vtkImageReader2
Superclass of binary file readers.
Definition: vtkImageReader2.h:58
vtkImageReader2::SetDataScalarTypeToShort
virtual void SetDataScalarTypeToShort()
Definition: vtkImageReader2.h:131
vtkImageReader2::SetDataScalarTypeToSignedChar
virtual void SetDataScalarTypeToSignedChar()
Definition: vtkImageReader2.h:136
vtkImageReader2::GetSwapBytes
virtual vtkTypeBool GetSwapBytes()
Definition: vtkImageReader2.h:248
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:86
vtkImageReader2::GetFileDimensionality
int GetFileDimensionality()
Definition: vtkImageReader2.h:169
vtkImageReader2::SetDataScalarTypeToUnsignedChar
virtual void SetDataScalarTypeToUnsignedChar()
Definition: vtkImageReader2.h:138
vtkImageAlgorithm::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkAlgorithm::New
static vtkAlgorithm * New()
vtkImageReader2::GetFile
ifstream * GetFile()
Definition: vtkImageReader2.h:252
VTK_SHORT
#define VTK_SHORT
Definition: vtkType.h:52
vtkImageReader2::HeaderSize
unsigned long HeaderSize
Definition: vtkImageReader2.h:331
VTK_SIGNED_CHAR
#define VTK_SIGNED_CHAR
Definition: vtkType.h:50
vtkStringArray
a vtkAbstractArray subclass for strings
Definition: vtkStringArray.h:42
vtkImageReader2::FileNames
vtkStringArray * FileNames
Definition: vtkImageReader2.h:313
vtkImageReader2::NumberOfScalarComponents
int NumberOfScalarComponents
Definition: vtkImageReader2.h:319
vtkImageReader2::SetDataScalarTypeToDouble
virtual void SetDataScalarTypeToDouble()
Definition: vtkImageReader2.h:128
VTK_INT
#define VTK_INT
Definition: vtkType.h:54
vtkImageReader2::FileNameSliceOffset
int FileNameSliceOffset
Definition: vtkImageReader2.h:338
vtkImageReader2::ManualHeaderSize
unsigned long ManualHeaderSize
Definition: vtkImageReader2.h:333
vtkImageReader2::CanReadFile
virtual int CanReadFile(const char *vtkNotUsed(fname))
Return non zero if the reader can read the given file name.
Definition: vtkImageReader2.h:285
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:64
vtkImageReader2::MemoryBuffer
void * MemoryBuffer
Definition: vtkImageReader2.h:322
vtkImageReader2::GetMemoryBufferLength
vtkIdType GetMemoryBufferLength()
Definition: vtkImageReader2.h:119
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkImageReader2::SetDataScalarTypeToInt
virtual void SetDataScalarTypeToInt()
Definition: vtkImageReader2.h:129