VTK  9.2.6
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(VTK_FILEPATH const char*);
71  vtkGetFilePathMacro(FileName);
73 
75 
82  virtual void SetFileNames(vtkStringArray*);
83  vtkGetObjectMacro(FileNames, vtkStringArray);
85 
87 
94  virtual void SetFilePrefix(VTK_FILEPATH const char*);
95  vtkGetFilePathMacro(FilePrefix);
97 
99 
103  virtual void SetFilePattern(VTK_FILEPATH const char*);
104  vtkGetFilePathMacro(FilePattern);
106 
112  virtual void SetMemoryBuffer(const void*);
113  virtual const 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); }
132  virtual void SetDataScalarTypeToUnsignedShort() { this->SetDataScalarType(VTK_UNSIGNED_SHORT); }
133  virtual void SetDataScalarTypeToChar() { this->SetDataScalarType(VTK_CHAR); }
134  virtual void SetDataScalarTypeToSignedChar() { this->SetDataScalarType(VTK_SIGNED_CHAR); }
135  virtual void SetDataScalarTypeToUnsignedChar() { this->SetDataScalarType(VTK_UNSIGNED_CHAR); }
136 
138 
141  vtkGetMacro(DataScalarType, int);
143 
145 
148  vtkSetMacro(NumberOfScalarComponents, int);
149  vtkGetMacro(NumberOfScalarComponents, int);
151 
153 
156  vtkSetVector6Macro(DataExtent, int);
157  vtkGetVector6Macro(DataExtent, int);
159 
161 
164  vtkSetMacro(FileDimensionality, int);
165  int GetFileDimensionality() { return this->FileDimensionality; }
167 
169 
172  vtkSetVector3Macro(DataSpacing, double);
173  vtkGetVector3Macro(DataSpacing, double);
175 
177 
180  vtkSetVector3Macro(DataOrigin, double);
181  vtkGetVector3Macro(DataOrigin, double);
183 
185 
188  vtkSetVectorMacro(DataDirection, double, 9);
189  vtkGetVectorMacro(DataDirection, double, 9);
191 
193 
196  unsigned long GetHeaderSize();
197  unsigned long GetHeaderSize(unsigned long slice);
199 
204  virtual void SetHeaderSize(unsigned long size);
205 
207 
220  virtual void SetDataByteOrderToBigEndian();
221  virtual void SetDataByteOrderToLittleEndian();
222  virtual int GetDataByteOrder();
223  virtual void SetDataByteOrder(int);
224  virtual const char* GetDataByteOrderAsString();
226 
228 
232  vtkSetMacro(FileNameSliceOffset, int);
233  vtkGetMacro(FileNameSliceOffset, int);
235 
237 
242  vtkSetMacro(FileNameSliceSpacing, int);
243  vtkGetMacro(FileNameSliceSpacing, int);
245 
247 
250  vtkSetMacro(SwapBytes, vtkTypeBool);
251  virtual vtkTypeBool GetSwapBytes() { return this->SwapBytes; }
252  vtkBooleanMacro(SwapBytes, vtkTypeBool);
254 
255  istream* GetFile() { return this->File; }
256  vtkGetVectorMacro(DataIncrements, unsigned long, 4);
257 
258  virtual int OpenFile();
259  void CloseFile();
260  virtual void SeekFile(int i, int j, int k);
261 
263 
267  vtkBooleanMacro(FileLowerLeft, vtkTypeBool);
268  vtkGetMacro(FileLowerLeft, vtkTypeBool);
269  vtkSetMacro(FileLowerLeft, vtkTypeBool);
271 
273 
276  virtual void ComputeInternalFileName(int slice);
277  vtkGetFilePathMacro(InternalFileName);
279 
289  virtual int CanReadFile(VTK_FILEPATH const char* vtkNotUsed(fname)) { return 0; }
290 
296  virtual const char* GetFileExtensions() { return nullptr; }
297 
299 
302  virtual const char* GetDescriptiveName() { return nullptr; }
303 
304 protected:
305  vtkImageReader2();
306  ~vtkImageReader2() override;
308 
310 
312  char* FileName;
313  char* FilePrefix;
314  char* FilePattern;
317 
318  const void* MemoryBuffer;
320 
321  istream* File;
322  unsigned long DataIncrements[4];
323  int DataExtent[6];
325 
327  unsigned long HeaderSize;
329  unsigned long ManualHeaderSize;
330 
331  double DataSpacing[3];
332  double DataOrigin[3];
333  double DataDirection[9];
334 
337 
338  int RequestInformation(vtkInformation* request, vtkInformationVector** inputVector,
339  vtkInformationVector* outputVector) override;
340  virtual void ExecuteInformation();
342  virtual void ComputeDataIncrements();
343 
344 private:
345  vtkImageReader2(const vtkImageReader2&) = delete;
346  void operator=(const vtkImageReader2&) = delete;
347 };
348 
349 #endif
virtual const void * GetMemoryBuffer()
#define VTK_UNSIGNED_INT
Definition: vtkType.h:51
istream * GetFile()
Store vtkAlgorithm input/output information.
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:49
vtkIdType MemoryBufferLength
int GetFileDimensionality()
The number of dimensions stored in a file.
virtual void SetDataScalarTypeToUnsignedChar()
virtual int CanReadFile(VTK_FILEPATH const char *vtkNotUsed(fname))
Return non zero if the reader can read the given file name.
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:332
const void * MemoryBuffer
vtkIdType GetMemoryBufferLength()
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_DOUBLE
Definition: vtkType.h:55
unsigned long ManualHeaderSize
#define VTK_FLOAT
Definition: vtkType.h:54
virtual void SetDataScalarTypeToChar()
virtual void SetDataScalarTypeToShort()
a simple class to control print indentation
Definition: vtkIndent.h:39
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:48
#define VTK_CHAR
Definition: vtkType.h:45
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:46
#define VTK_FILEPATH
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:47
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:65
#define VTK_INT
Definition: vtkType.h:50
vtkStringArray * FileNames