VTK  9.3.1
vtkImageReader2.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
35 #ifndef vtkImageReader2_h
36 #define vtkImageReader2_h
37 
38 #include "vtkIOImageModule.h" // For export macro
39 #include "vtkImageAlgorithm.h"
40 
41 VTK_ABI_NAMESPACE_BEGIN
42 class vtkStringArray;
43 
44 #define VTK_FILE_BYTE_ORDER_BIG_ENDIAN 0
45 #define VTK_FILE_BYTE_ORDER_LITTLE_ENDIAN 1
46 
47 class VTKIOIMAGE_EXPORT vtkImageReader2 : public vtkImageAlgorithm
48 {
49 public:
50  static vtkImageReader2* New();
52  void PrintSelf(ostream& os, vtkIndent indent) override;
53 
55 
59  virtual void SetFileName(VTK_FILEPATH const char*);
60  vtkGetFilePathMacro(FileName);
62 
64 
71  virtual void SetFileNames(vtkStringArray*);
72  vtkGetObjectMacro(FileNames, vtkStringArray);
74 
76 
83  virtual void SetFilePrefix(VTK_FILEPATH const char*);
84  vtkGetFilePathMacro(FilePrefix);
86 
88 
92  virtual void SetFilePattern(VTK_FILEPATH const char*);
93  vtkGetFilePathMacro(FilePattern);
95 
101  virtual void SetMemoryBuffer(const void*);
102  virtual const void* GetMemoryBuffer() { return this->MemoryBuffer; }
103 
107  virtual void SetMemoryBufferLength(vtkIdType buflen);
108  vtkIdType GetMemoryBufferLength() { return this->MemoryBufferLength; }
109 
115  virtual void SetDataScalarType(int type);
116  virtual void SetDataScalarTypeToFloat() { this->SetDataScalarType(VTK_FLOAT); }
117  virtual void SetDataScalarTypeToDouble() { this->SetDataScalarType(VTK_DOUBLE); }
118  virtual void SetDataScalarTypeToInt() { this->SetDataScalarType(VTK_INT); }
119  virtual void SetDataScalarTypeToUnsignedInt() { this->SetDataScalarType(VTK_UNSIGNED_INT); }
120  virtual void SetDataScalarTypeToShort() { this->SetDataScalarType(VTK_SHORT); }
121  virtual void SetDataScalarTypeToUnsignedShort() { this->SetDataScalarType(VTK_UNSIGNED_SHORT); }
122  virtual void SetDataScalarTypeToChar() { this->SetDataScalarType(VTK_CHAR); }
123  virtual void SetDataScalarTypeToSignedChar() { this->SetDataScalarType(VTK_SIGNED_CHAR); }
124  virtual void SetDataScalarTypeToUnsignedChar() { this->SetDataScalarType(VTK_UNSIGNED_CHAR); }
125 
127 
130  vtkGetMacro(DataScalarType, int);
132 
134 
137  vtkSetMacro(NumberOfScalarComponents, int);
138  vtkGetMacro(NumberOfScalarComponents, int);
140 
142 
145  vtkSetVector6Macro(DataExtent, int);
146  vtkGetVector6Macro(DataExtent, int);
148 
150 
153  vtkSetMacro(FileDimensionality, int);
154  int GetFileDimensionality() { return this->FileDimensionality; }
156 
158 
161  vtkSetVector3Macro(DataSpacing, double);
162  vtkGetVector3Macro(DataSpacing, double);
164 
166 
169  vtkSetVector3Macro(DataOrigin, double);
170  vtkGetVector3Macro(DataOrigin, double);
172 
174 
177  vtkSetVectorMacro(DataDirection, double, 9);
178  vtkGetVectorMacro(DataDirection, double, 9);
180 
182 
185  unsigned long GetHeaderSize();
186  unsigned long GetHeaderSize(unsigned long slice);
188 
193  virtual void SetHeaderSize(unsigned long size);
194 
196 
209  virtual void SetDataByteOrderToBigEndian();
210  virtual void SetDataByteOrderToLittleEndian();
211  virtual int GetDataByteOrder();
212  virtual void SetDataByteOrder(int);
213  virtual const char* GetDataByteOrderAsString();
215 
217 
221  vtkSetMacro(FileNameSliceOffset, int);
222  vtkGetMacro(FileNameSliceOffset, int);
224 
226 
231  vtkSetMacro(FileNameSliceSpacing, int);
232  vtkGetMacro(FileNameSliceSpacing, int);
234 
236 
239  vtkSetMacro(SwapBytes, vtkTypeBool);
240  virtual vtkTypeBool GetSwapBytes() { return this->SwapBytes; }
241  vtkBooleanMacro(SwapBytes, vtkTypeBool);
243 
244  istream* GetFile() { return this->File; }
245  vtkGetVectorMacro(DataIncrements, unsigned long, 4);
246 
247  virtual int OpenFile();
248  void CloseFile();
249  virtual void SeekFile(int i, int j, int k);
250 
252 
256  vtkBooleanMacro(FileLowerLeft, vtkTypeBool);
257  vtkGetMacro(FileLowerLeft, vtkTypeBool);
258  vtkSetMacro(FileLowerLeft, vtkTypeBool);
260 
262 
265  virtual void ComputeInternalFileName(int slice);
266  vtkGetFilePathMacro(InternalFileName);
268 
278  virtual int CanReadFile(VTK_FILEPATH const char* vtkNotUsed(fname)) { return 0; }
279 
285  virtual const char* GetFileExtensions() { return nullptr; }
286 
288 
291  virtual const char* GetDescriptiveName() { return nullptr; }
292 
293 protected:
294  vtkImageReader2();
295  ~vtkImageReader2() override;
297 
299 
301  char* FileName;
302  char* FilePrefix;
303  char* FilePattern;
306 
307  const void* MemoryBuffer;
309 
310  istream* File;
311  unsigned long DataIncrements[4];
312  int DataExtent[6];
314 
316  unsigned long HeaderSize;
318  unsigned long ManualHeaderSize;
319 
320  double DataSpacing[3];
321  double DataOrigin[3];
322  double DataDirection[9];
323 
326 
327  int RequestInformation(vtkInformation* request, vtkInformationVector** inputVector,
328  vtkInformationVector* outputVector) override;
329  virtual void ExecuteInformation();
331  virtual void ComputeDataIncrements();
332 
333 private:
334  vtkImageReader2(const vtkImageReader2&) = delete;
335  void operator=(const vtkImageReader2&) = delete;
336 };
337 
338 VTK_ABI_NAMESPACE_END
339 #endif
virtual const void * GetMemoryBuffer()
#define VTK_UNSIGNED_INT
Definition: vtkType.h:39
istream * GetFile()
Store vtkAlgorithm input/output information.
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:37
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:315
const void * MemoryBuffer
vtkIdType GetMemoryBufferLength()
int vtkTypeBool
Definition: vtkABI.h:64
#define VTK_DOUBLE
Definition: vtkType.h:43
unsigned long ManualHeaderSize
#define VTK_FLOAT
Definition: vtkType.h:42
virtual void SetDataScalarTypeToChar()
virtual void SetDataScalarTypeToShort()
a simple class to control print indentation
Definition: vtkIndent.h:28
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:36
#define VTK_CHAR
Definition: vtkType.h:33
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:34
#define VTK_FILEPATH
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:35
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:54
#define VTK_INT
Definition: vtkType.h:38
vtkStringArray * FileNames