VTK  9.3.20240418
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
144 #ifndef vtkImageReader2_h
145 #define vtkImageReader2_h
146 
147 #include "vtkIOImageModule.h" // For export macro
148 #include "vtkImageAlgorithm.h"
149 
150 VTK_ABI_NAMESPACE_BEGIN
151 class vtkStringArray;
152 
153 #define VTK_FILE_BYTE_ORDER_BIG_ENDIAN 0
154 #define VTK_FILE_BYTE_ORDER_LITTLE_ENDIAN 1
155 
156 class VTKIOIMAGE_EXPORT vtkImageReader2 : public vtkImageAlgorithm
157 {
158 public:
159  static vtkImageReader2* New();
161  void PrintSelf(ostream& os, vtkIndent indent) override;
162 
164 
168  virtual void SetFileName(VTK_FILEPATH const char*);
171 
173 
180  virtual void SetFileNames(vtkStringArray*);
181  vtkGetObjectMacro(FileNames, vtkStringArray);
183 
185 
192  virtual void SetFilePrefix(VTK_FILEPATH const char*);
193  vtkGetFilePathMacro(FilePrefix);
195 
197 
201  virtual void SetFilePattern(VTK_FILEPATH const char*);
202  vtkGetFilePathMacro(FilePattern);
204 
210  virtual void SetMemoryBuffer(const void*);
211  virtual const void* GetMemoryBuffer() { return this->MemoryBuffer; }
212 
216  virtual void SetMemoryBufferLength(vtkIdType buflen);
217  vtkIdType GetMemoryBufferLength() { return this->MemoryBufferLength; }
218 
224  virtual void SetDataScalarType(int type);
225  virtual void SetDataScalarTypeToFloat() { this->SetDataScalarType(VTK_FLOAT); }
226  virtual void SetDataScalarTypeToDouble() { this->SetDataScalarType(VTK_DOUBLE); }
227  virtual void SetDataScalarTypeToInt() { this->SetDataScalarType(VTK_INT); }
228  virtual void SetDataScalarTypeToUnsignedInt() { this->SetDataScalarType(VTK_UNSIGNED_INT); }
229  virtual void SetDataScalarTypeToShort() { this->SetDataScalarType(VTK_SHORT); }
230  virtual void SetDataScalarTypeToUnsignedShort() { this->SetDataScalarType(VTK_UNSIGNED_SHORT); }
231  virtual void SetDataScalarTypeToChar() { this->SetDataScalarType(VTK_CHAR); }
232  virtual void SetDataScalarTypeToSignedChar() { this->SetDataScalarType(VTK_SIGNED_CHAR); }
233  virtual void SetDataScalarTypeToUnsignedChar() { this->SetDataScalarType(VTK_UNSIGNED_CHAR); }
234 
236 
239  vtkGetMacro(DataScalarType, int);
241 
243 
246  vtkSetMacro(NumberOfScalarComponents, int);
247  vtkGetMacro(NumberOfScalarComponents, int);
249 
251 
254  vtkSetVector6Macro(DataExtent, int);
255  vtkGetVector6Macro(DataExtent, int);
257 
259 
262  vtkSetMacro(FileDimensionality, int);
263  int GetFileDimensionality() { return this->FileDimensionality; }
265 
267 
270  vtkSetVector3Macro(DataSpacing, double);
271  vtkGetVector3Macro(DataSpacing, double);
273 
275 
278  vtkSetVector3Macro(DataOrigin, double);
279  vtkGetVector3Macro(DataOrigin, double);
281 
283 
286  vtkSetVectorMacro(DataDirection, double, 9);
287  vtkGetVectorMacro(DataDirection, double, 9);
289 
291 
294  unsigned long GetHeaderSize();
295  unsigned long GetHeaderSize(unsigned long slice);
297 
302  virtual void SetHeaderSize(unsigned long size);
303 
305 
320  virtual int GetDataByteOrder();
321  virtual void SetDataByteOrder(int);
322  virtual const char* GetDataByteOrderAsString();
324 
326 
330  vtkSetMacro(FileNameSliceOffset, int);
331  vtkGetMacro(FileNameSliceOffset, int);
333 
335 
340  vtkSetMacro(FileNameSliceSpacing, int);
341  vtkGetMacro(FileNameSliceSpacing, int);
343 
345 
348  vtkSetMacro(SwapBytes, vtkTypeBool);
349  virtual vtkTypeBool GetSwapBytes() { return this->SwapBytes; }
350  vtkBooleanMacro(SwapBytes, vtkTypeBool);
352 
353  istream* GetFile() { return this->File; }
354  vtkGetVectorMacro(DataIncrements, unsigned long, 4);
355 
356  virtual int OpenFile();
357  void CloseFile();
358  virtual void SeekFile(int i, int j, int k);
359 
361 
365  vtkBooleanMacro(FileLowerLeft, vtkTypeBool);
366  vtkGetMacro(FileLowerLeft, vtkTypeBool);
367  vtkSetMacro(FileLowerLeft, vtkTypeBool);
369 
371 
374  virtual void ComputeInternalFileName(int slice);
375  vtkGetFilePathMacro(InternalFileName);
377 
387  virtual int CanReadFile(VTK_FILEPATH const char* vtkNotUsed(fname)) { return 0; }
388 
394  virtual const char* GetFileExtensions() { return nullptr; }
395 
397 
400  virtual const char* GetDescriptiveName() { return nullptr; }
401 
402 protected:
404  ~vtkImageReader2() override;
406 
408 
410  char* FileName;
411  char* FilePrefix;
412  char* FilePattern;
415 
416  const void* MemoryBuffer;
418 
419  istream* File;
420  unsigned long DataIncrements[4];
421  int DataExtent[6];
423 
425  unsigned long HeaderSize;
427  unsigned long ManualHeaderSize;
428 
429  double DataSpacing[3];
430  double DataOrigin[3];
431  double DataDirection[9];
432 
435 
437  vtkInformationVector* outputVector) override;
438  virtual void ExecuteInformation();
440  virtual void ComputeDataIncrements();
441 
442 private:
443  vtkImageReader2(const vtkImageReader2&) = delete;
444  void operator=(const vtkImageReader2&) = delete;
445 };
446 
447 VTK_ABI_NAMESPACE_END
448 #endif
general representation of visualization data
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:108
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