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
44 #ifndef vtkImageReader2_h
45 #define vtkImageReader2_h
46 
47 #include "vtkIOImageModule.h" // For export macro
48 #include "vtkImageAlgorithm.h"
49 
50 VTK_ABI_NAMESPACE_BEGIN
51 class vtkStringArray;
52 
53 #define VTK_FILE_BYTE_ORDER_BIG_ENDIAN 0
54 #define VTK_FILE_BYTE_ORDER_LITTLE_ENDIAN 1
55 
56 class VTKIOIMAGE_EXPORT vtkImageReader2 : public vtkImageAlgorithm
57 {
58 public:
59  static vtkImageReader2* New();
61  void PrintSelf(ostream& os, vtkIndent indent) override;
62 
64 
68  virtual void SetFileName(VTK_FILEPATH const char*);
71 
73 
80  virtual void SetFileNames(vtkStringArray*);
81  vtkGetObjectMacro(FileNames, vtkStringArray);
83 
85 
92  virtual void SetFilePrefix(VTK_FILEPATH const char*);
93  vtkGetFilePathMacro(FilePrefix);
95 
97 
101  virtual void SetFilePattern(VTK_FILEPATH const char*);
102  vtkGetFilePathMacro(FilePattern);
104 
110  virtual void SetMemoryBuffer(const void*);
111  virtual const void* GetMemoryBuffer() { return this->MemoryBuffer; }
112 
116  virtual void SetMemoryBufferLength(vtkIdType buflen);
117  vtkIdType GetMemoryBufferLength() { return this->MemoryBufferLength; }
118 
124  virtual void SetDataScalarType(int type);
125  virtual void SetDataScalarTypeToFloat() { this->SetDataScalarType(VTK_FLOAT); }
126  virtual void SetDataScalarTypeToDouble() { this->SetDataScalarType(VTK_DOUBLE); }
127  virtual void SetDataScalarTypeToInt() { this->SetDataScalarType(VTK_INT); }
128  virtual void SetDataScalarTypeToUnsignedInt() { this->SetDataScalarType(VTK_UNSIGNED_INT); }
129  virtual void SetDataScalarTypeToShort() { this->SetDataScalarType(VTK_SHORT); }
130  virtual void SetDataScalarTypeToUnsignedShort() { this->SetDataScalarType(VTK_UNSIGNED_SHORT); }
131  virtual void SetDataScalarTypeToChar() { this->SetDataScalarType(VTK_CHAR); }
132  virtual void SetDataScalarTypeToSignedChar() { this->SetDataScalarType(VTK_SIGNED_CHAR); }
133  virtual void SetDataScalarTypeToUnsignedChar() { 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  vtkSetVectorMacro(DataDirection, double, 9);
187  vtkGetVectorMacro(DataDirection, double, 9);
189 
191 
194  unsigned long GetHeaderSize();
195  unsigned long GetHeaderSize(unsigned long slice);
197 
202  virtual void SetHeaderSize(unsigned long size);
203 
205 
220  virtual int GetDataByteOrder();
221  virtual void SetDataByteOrder(int);
222  virtual const char* GetDataByteOrderAsString();
224 
226 
230  vtkSetMacro(FileNameSliceOffset, int);
231  vtkGetMacro(FileNameSliceOffset, int);
233 
235 
240  vtkSetMacro(FileNameSliceSpacing, int);
241  vtkGetMacro(FileNameSliceSpacing, int);
243 
245 
248  vtkSetMacro(SwapBytes, vtkTypeBool);
249  virtual vtkTypeBool GetSwapBytes() { return this->SwapBytes; }
250  vtkBooleanMacro(SwapBytes, vtkTypeBool);
252 
253  istream* GetFile() { return this->File; }
254  vtkGetVectorMacro(DataIncrements, unsigned long, 4);
255 
256  virtual int OpenFile();
257  void CloseFile();
258  virtual void SeekFile(int i, int j, int k);
259 
261 
265  vtkBooleanMacro(FileLowerLeft, vtkTypeBool);
266  vtkGetMacro(FileLowerLeft, vtkTypeBool);
267  vtkSetMacro(FileLowerLeft, vtkTypeBool);
269 
271 
274  virtual void ComputeInternalFileName(int slice);
275  vtkGetFilePathMacro(InternalFileName);
277 
287  virtual int CanReadFile(VTK_FILEPATH const char* vtkNotUsed(fname)) { return 0; }
288 
294  virtual const char* GetFileExtensions() { return nullptr; }
295 
297 
300  virtual const char* GetDescriptiveName() { return nullptr; }
301 
302 protected:
304  ~vtkImageReader2() override;
306 
308 
310  char* FileName;
311  char* FilePrefix;
312  char* FilePattern;
315 
316  const void* MemoryBuffer;
318 
319  istream* 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  double DataDirection[9];
332 
335 
337  vtkInformationVector* outputVector) override;
338  virtual void ExecuteInformation();
340  virtual void ComputeDataIncrements();
341 
342 private:
343  vtkImageReader2(const vtkImageReader2&) = delete;
344  void operator=(const vtkImageReader2&) = delete;
345 };
346 
347 VTK_ABI_NAMESPACE_END
348 #endif
general representation of visualization data
Definition: vtkDataObject.h:64
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:38
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