VTK  9.0.1
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(const void*);
107  virtual const 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); }
126  virtual void SetDataScalarTypeToUnsignedShort() { this->SetDataScalarType(VTK_UNSIGNED_SHORT); }
127  virtual void SetDataScalarTypeToChar() { this->SetDataScalarType(VTK_CHAR); }
128  virtual void SetDataScalarTypeToSignedChar() { this->SetDataScalarType(VTK_SIGNED_CHAR); }
129  virtual void SetDataScalarTypeToUnsignedChar() { this->SetDataScalarType(VTK_UNSIGNED_CHAR); }
130 
132 
135  vtkGetMacro(DataScalarType, int);
137 
139 
142  vtkSetMacro(NumberOfScalarComponents, int);
143  vtkGetMacro(NumberOfScalarComponents, int);
145 
147 
150  vtkSetVector6Macro(DataExtent, int);
151  vtkGetVector6Macro(DataExtent, int);
153 
155 
158  vtkSetMacro(FileDimensionality, int);
159  int GetFileDimensionality() { return this->FileDimensionality; }
161 
163 
166  vtkSetVector3Macro(DataSpacing, double);
167  vtkGetVector3Macro(DataSpacing, double);
169 
171 
174  vtkSetVector3Macro(DataOrigin, double);
175  vtkGetVector3Macro(DataOrigin, double);
177 
179 
182  vtkSetVectorMacro(DataDirection, double, 9);
183  vtkGetVectorMacro(DataDirection, double, 9);
185 
187 
190  unsigned long GetHeaderSize();
191  unsigned long GetHeaderSize(unsigned long slice);
193 
198  virtual void SetHeaderSize(unsigned long size);
199 
201 
214  virtual void SetDataByteOrderToBigEndian();
215  virtual void SetDataByteOrderToLittleEndian();
216  virtual int GetDataByteOrder();
217  virtual void SetDataByteOrder(int);
218  virtual const char* GetDataByteOrderAsString();
220 
222 
226  vtkSetMacro(FileNameSliceOffset, int);
227  vtkGetMacro(FileNameSliceOffset, int);
229 
231 
236  vtkSetMacro(FileNameSliceSpacing, int);
237  vtkGetMacro(FileNameSliceSpacing, int);
239 
241 
244  vtkSetMacro(SwapBytes, vtkTypeBool);
245  virtual vtkTypeBool GetSwapBytes() { return this->SwapBytes; }
246  vtkBooleanMacro(SwapBytes, vtkTypeBool);
248 
249  istream* GetFile() { return this->File; }
250  vtkGetVectorMacro(DataIncrements, unsigned long, 4);
251 
252  virtual int OpenFile();
253  void CloseFile();
254  virtual void SeekFile(int i, int j, int k);
255 
257 
261  vtkBooleanMacro(FileLowerLeft, vtkTypeBool);
262  vtkGetMacro(FileLowerLeft, vtkTypeBool);
263  vtkSetMacro(FileLowerLeft, vtkTypeBool);
265 
267 
270  virtual void ComputeInternalFileName(int slice);
271  vtkGetStringMacro(InternalFileName);
273 
283  virtual int CanReadFile(const char* vtkNotUsed(fname)) { return 0; }
284 
290  virtual const char* GetFileExtensions() { return nullptr; }
291 
293 
296  virtual const char* GetDescriptiveName() { return nullptr; }
297 
298 protected:
299  vtkImageReader2();
300  ~vtkImageReader2() override;
302 
304 
306  char* FileName;
307  char* FilePrefix;
308  char* FilePattern;
311 
312  const void* MemoryBuffer;
314 
315  istream* File;
316  unsigned long DataIncrements[4];
317  int DataExtent[6];
319 
321  unsigned long HeaderSize;
323  unsigned long ManualHeaderSize;
324 
325  double DataSpacing[3];
326  double DataOrigin[3];
327  double DataDirection[9];
328 
331 
332  int RequestInformation(vtkInformation* request, vtkInformationVector** inputVector,
333  vtkInformationVector* outputVector) override;
334  virtual void ExecuteInformation();
336  virtual void ComputeDataIncrements();
337 
338 private:
339  vtkImageReader2(const vtkImageReader2&) = delete;
340  void operator=(const vtkImageReader2&) = delete;
341 };
342 
343 #endif
virtual const void * GetMemoryBuffer()
#define VTK_UNSIGNED_INT
Definition: vtkType.h:49
istream * GetFile()
Store vtkAlgorithm input/output information.
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:47
vtkIdType MemoryBufferLength
int GetFileDimensionality()
The number of dimensions stored in a file.
virtual void SetDataScalarTypeToUnsignedChar()
a vtkAbstractArray subclass for strings
virtual void ExecuteDataWithInformation(vtkDataObject *output, vtkInformation *outInfo)
This is a convenience method that is implemented in many subclasses instead of RequestData.
int vtkIdType
Definition: vtkType.h:338
const void * MemoryBuffer
vtkIdType GetMemoryBufferLength()
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_DOUBLE
Definition: vtkType.h:53
unsigned long ManualHeaderSize
#define VTK_FLOAT
Definition: vtkType.h:52
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 vtkTypeBool GetSwapBytes()
Set/Get the byte swapping to explicitly swap the bytes of a file.
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
Subclasses can reimplement this method to collect information from their inputs and set information f...
virtual void SetDataScalarTypeToUnsignedShort()
#define VTK_SHORT
Definition: vtkType.h:46
#define VTK_CHAR
Definition: vtkType.h:43
vtkTypeBool FileLowerLeft
virtual void SetDataScalarTypeToUnsignedInt()
unsigned long HeaderSize
Superclass of binary file readers.
vtkTypeBool SwapBytes
virtual void SetDataScalarTypeToInt()
#define VTK_SIGNED_CHAR
Definition: vtkType.h:44
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:45
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.
general representation of visualization data
Definition: vtkDataObject.h:59
#define VTK_INT
Definition: vtkType.h:48
vtkStringArray * FileNames