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) 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,vtkTypeBool);
242  virtual vtkTypeBool GetSwapBytes() {return this->SwapBytes;}
243  vtkBooleanMacro(SwapBytes,vtkTypeBool);
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, vtkTypeBool);
258  vtkGetMacro(FileLowerLeft, vtkTypeBool);
259  vtkSetMacro(FileLowerLeft, vtkTypeBool);
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 nullptr;
292  }
293 
295 
298  virtual const char* GetDescriptiveName()
299  {
300  return nullptr;
301  }
302 protected:
303  vtkImageReader2();
304  ~vtkImageReader2() override;
306 
308 
310  char *FileName;
311  char *FilePrefix;
312  char *FilePattern;
315 
318 
319  ifstream *File;
320  unsigned long DataIncrements[4];
321  int DataExtent[6];
323 
325  unsigned long HeaderSize;
327  unsigned long ManualHeaderSize;
328 
329  double DataSpacing[3];
330  double DataOrigin[3];
331 
334 
335  int RequestInformation(vtkInformation* request,
336  vtkInformationVector** inputVector,
337  vtkInformationVector* outputVector) override;
338  virtual void ExecuteInformation();
340  virtual void ComputeDataIncrements();
341 private:
342  vtkImageReader2(const vtkImageReader2&) = delete;
343  void operator=(const vtkImageReader2&) = delete;
344 };
345 
346 #endif
vtkImageReader2::FileName
char * FileName
Definition: vtkImageReader2.h:310
vtkImageReader2::File
ifstream * File
Definition: vtkImageReader2.h:319
vtkImageReader2::FileLowerLeft
vtkTypeBool FileLowerLeft
Definition: vtkImageReader2.h:314
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:124
vtkX3D::data
Definition: vtkX3D.h:315
vtkImageReader2::SetDataScalarTypeToChar
virtual void SetDataScalarTypeToChar()
Definition: vtkImageReader2.h:128
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:35
VTK_UNSIGNED_SHORT
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:53
vtkImageReader2::SetDataScalarTypeToFloat
virtual void SetDataScalarTypeToFloat()
Definition: vtkImageReader2.h:121
vtkImageReader2::FilePrefix
char * FilePrefix
Definition: vtkImageReader2.h:311
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:322
vtkImageAlgorithm.h
vtkImageReader2::GetMemoryBuffer
virtual void * GetMemoryBuffer()
Definition: vtkImageReader2.h:107
vtkImageReader2::GetFileExtensions
virtual const char * GetFileExtensions()
Get the file extensions for this format.
Definition: vtkImageReader2.h:289
vtkImageReader2::SetDataScalarTypeToUnsignedShort
virtual void SetDataScalarTypeToUnsignedShort()
Definition: vtkImageReader2.h:126
vtkImageReader2::DataScalarType
int DataScalarType
Definition: vtkImageReader2.h:326
vtkImageAlgorithm
Generic algorithm superclass for image algs.
Definition: vtkImageAlgorithm.h:37
vtkImageReader2::FilePattern
char * FilePattern
Definition: vtkImageReader2.h:312
vtkImageReader2::FileDimensionality
int FileDimensionality
Definition: vtkImageReader2.h:324
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:333
VTK_CHAR
#define VTK_CHAR
Definition: vtkType.h:49
vtkImageReader2::MemoryBufferLength
vtkIdType MemoryBufferLength
Definition: vtkImageReader2.h:317
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkImageReader2::InternalFileName
char * InternalFileName
Definition: vtkImageReader2.h:309
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:298
vtkX3D::size
Definition: vtkX3D.h:253
vtkImageReader2
Superclass of binary file readers.
Definition: vtkImageReader2.h:52
vtkImageReader2::SetDataScalarTypeToShort
virtual void SetDataScalarTypeToShort()
Definition: vtkImageReader2.h:125
vtkImageReader2::SetDataScalarTypeToSignedChar
virtual void SetDataScalarTypeToSignedChar()
Definition: vtkImageReader2.h:130
vtkImageReader2::GetSwapBytes
virtual vtkTypeBool GetSwapBytes()
Definition: vtkImageReader2.h:242
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:80
vtkImageReader2::GetFileDimensionality
int GetFileDimensionality()
Definition: vtkImageReader2.h:163
vtkImageReader2::SetDataScalarTypeToUnsignedChar
virtual void SetDataScalarTypeToUnsignedChar()
Definition: vtkImageReader2.h:132
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:246
VTK_SHORT
#define VTK_SHORT
Definition: vtkType.h:52
vtkImageReader2::HeaderSize
unsigned long HeaderSize
Definition: vtkImageReader2.h:325
VTK_SIGNED_CHAR
#define VTK_SIGNED_CHAR
Definition: vtkType.h:50
vtkStringArray
a vtkAbstractArray subclass for strings
Definition: vtkStringArray.h:36
vtkImageReader2::FileNames
vtkStringArray * FileNames
Definition: vtkImageReader2.h:307
vtkImageReader2::NumberOfScalarComponents
int NumberOfScalarComponents
Definition: vtkImageReader2.h:313
vtkImageReader2::SetDataScalarTypeToDouble
virtual void SetDataScalarTypeToDouble()
Definition: vtkImageReader2.h:122
VTK_INT
#define VTK_INT
Definition: vtkType.h:54
vtkImageReader2::FileNameSliceOffset
int FileNameSliceOffset
Definition: vtkImageReader2.h:332
vtkImageReader2::ManualHeaderSize
unsigned long ManualHeaderSize
Definition: vtkImageReader2.h:327
vtkImageReader2::CanReadFile
virtual int CanReadFile(const char *vtkNotUsed(fname))
Return non zero if the reader can read the given file name.
Definition: vtkImageReader2.h:279
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:58
vtkImageReader2::MemoryBuffer
void * MemoryBuffer
Definition: vtkImageReader2.h:316
vtkImageReader2::GetMemoryBufferLength
vtkIdType GetMemoryBufferLength()
Definition: vtkImageReader2.h:113
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkImageReader2::SetDataScalarTypeToInt
virtual void SetDataScalarTypeToInt()
Definition: vtkImageReader2.h:123