VTK  9.0.1
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 =========================================================================*/
41 #ifndef vtkImageReader2_h
42 #define vtkImageReader2_h
43 
44 #include "vtkIOImageModule.h" // For export macro
45 #include "vtkImageAlgorithm.h"
46 
47 class vtkStringArray;
48 
49 #define VTK_FILE_BYTE_ORDER_BIG_ENDIAN 0
50 #define VTK_FILE_BYTE_ORDER_LITTLE_ENDIAN 1
51 
52 class VTKIOIMAGE_EXPORT vtkImageReader2 : public vtkImageAlgorithm
53 {
54 public:
55  static vtkImageReader2* New();
57  void PrintSelf(ostream& os, vtkIndent indent) override;
58 
60 
64  virtual void SetFileName(const char*);
65  vtkGetStringMacro(FileName);
67 
69 
76  virtual void SetFileNames(vtkStringArray*);
77  vtkGetObjectMacro(FileNames, vtkStringArray);
79 
81 
88  virtual void SetFilePrefix(const char*);
89  vtkGetStringMacro(FilePrefix);
91 
93 
97  virtual void SetFilePattern(const char*);
98  vtkGetStringMacro(FilePattern);
100 
106  virtual void SetMemoryBuffer(const void*);
107  virtual const void* GetMemoryBuffer() { return this->MemoryBuffer; }
108 
112  virtual void SetMemoryBufferLength(vtkIdType buflen);
113  vtkIdType GetMemoryBufferLength() { return this->MemoryBufferLength; }
114 
120  virtual void SetDataScalarType(int type);
121  virtual void SetDataScalarTypeToFloat() { this->SetDataScalarType(VTK_FLOAT); }
122  virtual void SetDataScalarTypeToDouble() { this->SetDataScalarType(VTK_DOUBLE); }
123  virtual void SetDataScalarTypeToInt() { this->SetDataScalarType(VTK_INT); }
124  virtual void SetDataScalarTypeToUnsignedInt() { this->SetDataScalarType(VTK_UNSIGNED_INT); }
125  virtual void SetDataScalarTypeToShort() { this->SetDataScalarType(VTK_SHORT); }
126  virtual void SetDataScalarTypeToUnsignedShort() { this->SetDataScalarType(VTK_UNSIGNED_SHORT); }
127  virtual void SetDataScalarTypeToChar() { this->SetDataScalarType(VTK_CHAR); }
128  virtual void SetDataScalarTypeToSignedChar() { this->SetDataScalarType(VTK_SIGNED_CHAR); }
129  virtual void SetDataScalarTypeToUnsignedChar() { this->SetDataScalarType(VTK_UNSIGNED_CHAR); }
130 
132 
135  vtkGetMacro(DataScalarType, int);
137 
139 
142  vtkSetMacro(NumberOfScalarComponents, int);
143  vtkGetMacro(NumberOfScalarComponents, int);
145 
147 
150  vtkSetVector6Macro(DataExtent, int);
151  vtkGetVector6Macro(DataExtent, int);
153 
155 
158  vtkSetMacro(FileDimensionality, int);
159  int GetFileDimensionality() { return this->FileDimensionality; }
161 
163 
166  vtkSetVector3Macro(DataSpacing, double);
167  vtkGetVector3Macro(DataSpacing, double);
169 
171 
174  vtkSetVector3Macro(DataOrigin, double);
175  vtkGetVector3Macro(DataOrigin, double);
177 
179 
182  vtkSetVectorMacro(DataDirection, double, 9);
183  vtkGetVectorMacro(DataDirection, double, 9);
185 
187 
190  unsigned long GetHeaderSize();
191  unsigned long GetHeaderSize(unsigned long slice);
193 
198  virtual void SetHeaderSize(unsigned long size);
199 
201 
216  virtual int GetDataByteOrder();
217  virtual void SetDataByteOrder(int);
218  virtual const char* GetDataByteOrderAsString();
220 
222 
226  vtkSetMacro(FileNameSliceOffset, int);
227  vtkGetMacro(FileNameSliceOffset, int);
229 
231 
236  vtkSetMacro(FileNameSliceSpacing, int);
237  vtkGetMacro(FileNameSliceSpacing, int);
239 
241 
244  vtkSetMacro(SwapBytes, vtkTypeBool);
245  virtual vtkTypeBool GetSwapBytes() { return this->SwapBytes; }
246  vtkBooleanMacro(SwapBytes, vtkTypeBool);
248 
249  istream* GetFile() { return this->File; }
250  vtkGetVectorMacro(DataIncrements, unsigned long, 4);
251 
252  virtual int OpenFile();
253  void CloseFile();
254  virtual void SeekFile(int i, int j, int k);
255 
257 
261  vtkBooleanMacro(FileLowerLeft, vtkTypeBool);
262  vtkGetMacro(FileLowerLeft, vtkTypeBool);
263  vtkSetMacro(FileLowerLeft, vtkTypeBool);
265 
267 
270  virtual void ComputeInternalFileName(int slice);
271  vtkGetStringMacro(InternalFileName);
273 
283  virtual int CanReadFile(const char* vtkNotUsed(fname)) { return 0; }
284 
290  virtual const char* GetFileExtensions() { return nullptr; }
291 
293 
296  virtual const char* GetDescriptiveName() { return nullptr; }
297 
298 protected:
300  ~vtkImageReader2() override;
302 
304 
306  char* FileName;
307  char* FilePrefix;
308  char* FilePattern;
311 
312  const void* MemoryBuffer;
314 
315  istream* File;
316  unsigned long DataIncrements[4];
317  int DataExtent[6];
319 
321  unsigned long HeaderSize;
323  unsigned long ManualHeaderSize;
324 
325  double DataSpacing[3];
326  double DataOrigin[3];
327  double DataDirection[9];
328 
331 
333  vtkInformationVector* outputVector) override;
334  virtual void ExecuteInformation();
336  virtual void ComputeDataIncrements();
337 
338 private:
339  vtkImageReader2(const vtkImageReader2&) = delete;
340  void operator=(const vtkImageReader2&) = delete;
341 };
342 
343 #endif
general representation of visualization data
Definition: vtkDataObject.h:60
Generic algorithm superclass for image algs.
Superclass of binary file readers.
virtual void ComputeDataIncrements()
virtual int CanReadFile(const char *vtkNotUsed(fname))
Return non zero if the reader can read the given file name.
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()
virtual int OpenFile()
virtual void SetFilePrefix(const char *)
Specify file prefix for the image file or files.
unsigned long GetHeaderSize(unsigned long slice)
virtual void SetMemoryBufferLength(vtkIdType buflen)
Specify the in memory image buffer length.
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 const char * GetDataByteOrderAsString()
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.
virtual void SetFileName(const char *)
Specify file name for the image file.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void SetDataScalarTypeToInt()
virtual void SetDataScalarTypeToDouble()
~vtkImageReader2() override
virtual void SetDataScalarTypeToChar()
unsigned long HeaderSize
virtual void SetDataByteOrderToLittleEndian()
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 SetFilePattern(const char *)
The snprintf-style format string used to build filename from FilePrefix and slice number.
virtual void SetDataScalarTypeToUnsignedChar()
virtual const void * GetMemoryBuffer()
const void * MemoryBuffer
virtual void SetDataByteOrder(int)
virtual void SetDataByteOrderToBigEndian()
These methods should be used instead of the SwapBytes methods.
istream * GetFile()
unsigned long ManualHeaderSize
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 vtkTypeBool GetSwapBytes()
a simple class to control print indentation
Definition: vtkIndent.h:34
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:46
int vtkIdType
Definition: vtkType.h:338
#define VTK_UNSIGNED_INT
Definition: vtkType.h:49
#define VTK_DOUBLE
Definition: vtkType.h:53
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:45
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:47
#define VTK_INT
Definition: vtkType.h:48
#define VTK_SIGNED_CHAR
Definition: vtkType.h:44
#define VTK_FLOAT
Definition: vtkType.h:52
#define VTK_CHAR
Definition: vtkType.h:43