VTK  9.3.0
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*);
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 
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:
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 
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
general representation of visualization data
Definition: vtkDataObject.h:55
Generic algorithm superclass for image algs.
Superclass of binary file readers.
virtual void ComputeDataIncrements()
vtkGetFilePathMacro(FilePrefix)
Specify file prefix for the image file or files.
vtkTypeBool FileLowerLeft
void ExecuteDataWithInformation(vtkDataObject *data, vtkInformation *outInfo) override
This is a convenience method that is implemented in many subclasses instead of RequestData.
unsigned long GetHeaderSize()
Get the size of the header computed by this object.
virtual int GetDataByteOrder()
These methods should be used instead of the SwapBytes methods.
vtkGetFilePathMacro(InternalFileName)
Set/Get the internal file name.
virtual int OpenFile()
unsigned long GetHeaderSize(unsigned long slice)
Get the size of the header computed by this object.
virtual void SetMemoryBufferLength(vtkIdType buflen)
Specify the in memory image buffer length.
int GetFileDimensionality()
The number of dimensions stored in a file.
vtkTypeBool SwapBytes
virtual void SetMemoryBuffer(const void *)
Specify the in memory image buffer.
static vtkImageReader2 * New()
virtual const char * GetFileExtensions()
Get the file extensions for this format.
virtual void SetDataScalarTypeToSignedChar()
int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
Subclasses can reimplement this method to collect information from their inputs and set information f...
virtual void SetFileName(VTK_FILEPATH const char *)
Specify file name for the image file.
virtual int CanReadFile(VTK_FILEPATH const char *vtkNotUsed(fname))
Return non zero if the reader can read the given file name.
virtual const char * GetDataByteOrderAsString()
These methods should be used instead of the SwapBytes methods.
virtual void ComputeInternalFileName(int slice)
Set/Get the internal file name.
virtual void SetDataScalarType(int type)
Set the data type of pixels in the file.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void SetDataScalarTypeToInt()
vtkGetFilePathMacro(FilePattern)
The snprintf-style format string used to build filename from FilePrefix and slice number.
virtual void SetDataScalarTypeToDouble()
vtkGetFilePathMacro(FileName)
Specify file name for the image file.
~vtkImageReader2() override
Return a descriptive name for the file format that might be useful in a GUI.
virtual void SetDataScalarTypeToChar()
unsigned long HeaderSize
vtkImageReader2()
Return a descriptive name for the file format that might be useful in a GUI.
virtual void SetDataByteOrderToLittleEndian()
These methods should be used instead of the SwapBytes methods.
vtkIdType MemoryBufferLength
virtual void SetHeaderSize(unsigned long size)
If there is a tail on the file, you want to explicitly set the header size.
virtual void SetDataScalarTypeToUnsignedChar()
virtual const void * GetMemoryBuffer()
const void * MemoryBuffer
virtual void SetDataByteOrder(int)
These methods should be used instead of the SwapBytes methods.
virtual void SetDataByteOrderToBigEndian()
These methods should be used instead of the SwapBytes methods.
istream * GetFile()
unsigned long ManualHeaderSize
virtual void SetFilePrefix(VTK_FILEPATH const char *)
Specify file prefix for the image file or files.
virtual void SetDataScalarTypeToFloat()
virtual void SetDataScalarTypeToShort()
virtual void SeekFile(int i, int j, int k)
virtual void SetFileNames(vtkStringArray *)
Specify a list of file names.
virtual void SetDataScalarTypeToUnsignedShort()
vtkStringArray * FileNames
vtkIdType GetMemoryBufferLength()
virtual void SetDataScalarTypeToUnsignedInt()
virtual void ExecuteInformation()
virtual const char * GetDescriptiveName()
Return a descriptive name for the file format that might be useful in a GUI.
virtual void SetFilePattern(VTK_FILEPATH const char *)
The snprintf-style format string used to build filename from FilePrefix and slice number.
virtual vtkTypeBool GetSwapBytes()
Set/Get the byte swapping to explicitly swap the bytes of a file.
a simple class to control print indentation
Definition: vtkIndent.h:29
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
a vtkAbstractArray subclass for strings
@ type
Definition: vtkX3D.h:516
@ size
Definition: vtkX3D.h:253
@ data
Definition: vtkX3D.h:315
int vtkTypeBool
Definition: vtkABI.h:64
#define VTK_SHORT
Definition: vtkType.h:36
int vtkIdType
Definition: vtkType.h:315
#define VTK_UNSIGNED_INT
Definition: vtkType.h:39
#define VTK_DOUBLE
Definition: vtkType.h:43
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:35
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:37
#define VTK_INT
Definition: vtkType.h:38
#define VTK_SIGNED_CHAR
Definition: vtkType.h:34
#define VTK_FLOAT
Definition: vtkType.h:42
#define VTK_CHAR
Definition: vtkType.h:33
#define VTK_FILEPATH