VTK  9.2.5
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 =========================================================================*/
156 #ifndef vtkImageReader2_h
157 #define vtkImageReader2_h
158 
159 #include "vtkIOImageModule.h" // For export macro
160 #include "vtkImageAlgorithm.h"
161 
162 class vtkStringArray;
163 
164 #define VTK_FILE_BYTE_ORDER_BIG_ENDIAN 0
165 #define VTK_FILE_BYTE_ORDER_LITTLE_ENDIAN 1
166 
167 class VTKIOIMAGE_EXPORT vtkImageReader2 : public vtkImageAlgorithm
168 {
169 public:
170  static vtkImageReader2* New();
172  void PrintSelf(ostream& os, vtkIndent indent) override;
173 
175 
179  virtual void SetFileName(VTK_FILEPATH const char*);
182 
184 
191  virtual void SetFileNames(vtkStringArray*);
192  vtkGetObjectMacro(FileNames, vtkStringArray);
194 
196 
203  virtual void SetFilePrefix(VTK_FILEPATH const char*);
204  vtkGetFilePathMacro(FilePrefix);
206 
208 
212  virtual void SetFilePattern(VTK_FILEPATH const char*);
213  vtkGetFilePathMacro(FilePattern);
215 
221  virtual void SetMemoryBuffer(const void*);
222  virtual const void* GetMemoryBuffer() { return this->MemoryBuffer; }
223 
227  virtual void SetMemoryBufferLength(vtkIdType buflen);
228  vtkIdType GetMemoryBufferLength() { return this->MemoryBufferLength; }
229 
235  virtual void SetDataScalarType(int type);
236  virtual void SetDataScalarTypeToFloat() { this->SetDataScalarType(VTK_FLOAT); }
237  virtual void SetDataScalarTypeToDouble() { this->SetDataScalarType(VTK_DOUBLE); }
238  virtual void SetDataScalarTypeToInt() { this->SetDataScalarType(VTK_INT); }
239  virtual void SetDataScalarTypeToUnsignedInt() { this->SetDataScalarType(VTK_UNSIGNED_INT); }
240  virtual void SetDataScalarTypeToShort() { this->SetDataScalarType(VTK_SHORT); }
241  virtual void SetDataScalarTypeToUnsignedShort() { this->SetDataScalarType(VTK_UNSIGNED_SHORT); }
242  virtual void SetDataScalarTypeToChar() { this->SetDataScalarType(VTK_CHAR); }
243  virtual void SetDataScalarTypeToSignedChar() { this->SetDataScalarType(VTK_SIGNED_CHAR); }
244  virtual void SetDataScalarTypeToUnsignedChar() { this->SetDataScalarType(VTK_UNSIGNED_CHAR); }
245 
247 
250  vtkGetMacro(DataScalarType, int);
252 
254 
257  vtkSetMacro(NumberOfScalarComponents, int);
258  vtkGetMacro(NumberOfScalarComponents, int);
260 
262 
265  vtkSetVector6Macro(DataExtent, int);
266  vtkGetVector6Macro(DataExtent, int);
268 
270 
273  vtkSetMacro(FileDimensionality, int);
274  int GetFileDimensionality() { return this->FileDimensionality; }
276 
278 
281  vtkSetVector3Macro(DataSpacing, double);
282  vtkGetVector3Macro(DataSpacing, double);
284 
286 
289  vtkSetVector3Macro(DataOrigin, double);
290  vtkGetVector3Macro(DataOrigin, double);
292 
294 
297  vtkSetVectorMacro(DataDirection, double, 9);
298  vtkGetVectorMacro(DataDirection, double, 9);
300 
302 
305  unsigned long GetHeaderSize();
306  unsigned long GetHeaderSize(unsigned long slice);
308 
313  virtual void SetHeaderSize(unsigned long size);
314 
316 
331  virtual int GetDataByteOrder();
332  virtual void SetDataByteOrder(int);
333  virtual const char* GetDataByteOrderAsString();
335 
337 
341  vtkSetMacro(FileNameSliceOffset, int);
342  vtkGetMacro(FileNameSliceOffset, int);
344 
346 
351  vtkSetMacro(FileNameSliceSpacing, int);
352  vtkGetMacro(FileNameSliceSpacing, int);
354 
356 
359  vtkSetMacro(SwapBytes, vtkTypeBool);
360  virtual vtkTypeBool GetSwapBytes() { return this->SwapBytes; }
361  vtkBooleanMacro(SwapBytes, vtkTypeBool);
363 
364  istream* GetFile() { return this->File; }
365  vtkGetVectorMacro(DataIncrements, unsigned long, 4);
366 
367  virtual int OpenFile();
368  void CloseFile();
369  virtual void SeekFile(int i, int j, int k);
370 
372 
376  vtkBooleanMacro(FileLowerLeft, vtkTypeBool);
377  vtkGetMacro(FileLowerLeft, vtkTypeBool);
378  vtkSetMacro(FileLowerLeft, vtkTypeBool);
380 
382 
385  virtual void ComputeInternalFileName(int slice);
386  vtkGetFilePathMacro(InternalFileName);
388 
398  virtual int CanReadFile(VTK_FILEPATH const char* vtkNotUsed(fname)) { return 0; }
399 
405  virtual const char* GetFileExtensions() { return nullptr; }
406 
408 
411  virtual const char* GetDescriptiveName() { return nullptr; }
412 
413 protected:
415  ~vtkImageReader2() override;
417 
419 
421  char* FileName;
422  char* FilePrefix;
423  char* FilePattern;
426 
427  const void* MemoryBuffer;
429 
430  istream* File;
431  unsigned long DataIncrements[4];
432  int DataExtent[6];
434 
436  unsigned long HeaderSize;
438  unsigned long ManualHeaderSize;
439 
440  double DataSpacing[3];
441  double DataOrigin[3];
442  double DataDirection[9];
443 
446 
448  vtkInformationVector* outputVector) override;
449  virtual void ExecuteInformation();
451  virtual void ComputeDataIncrements();
452 
453 private:
454  vtkImageReader2(const vtkImageReader2&) = delete;
455  void operator=(const vtkImageReader2&) = delete;
456 };
457 
458 #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:119
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
a vtkAbstractArray subclass for strings
@ type
Definition: vtkX3D.h:522
@ size
Definition: vtkX3D.h:259
@ data
Definition: vtkX3D.h:321
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_SHORT
Definition: vtkType.h:48
int vtkIdType
Definition: vtkType.h:332
#define VTK_UNSIGNED_INT
Definition: vtkType.h:51
#define VTK_DOUBLE
Definition: vtkType.h:55
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:47
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:49
#define VTK_INT
Definition: vtkType.h:50
#define VTK_SIGNED_CHAR
Definition: vtkType.h:46
#define VTK_FLOAT
Definition: vtkType.h:54
#define VTK_CHAR
Definition: vtkType.h:45
#define VTK_FILEPATH