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 
214  virtual void SetDataByteOrderToBigEndian();
215  virtual void SetDataByteOrderToLittleEndian();
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:
299  vtkImageReader2();
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 
332  int RequestInformation(vtkInformation* request, vtkInformationVector** inputVector,
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
vtkImageReader2::FileName
char * FileName
Definition: vtkImageReader2.h:306
vtkImageReader2::FileLowerLeft
vtkTypeBool FileLowerLeft
Definition: vtkImageReader2.h:310
vtkImageReader2::MemoryBuffer
const void * MemoryBuffer
Definition: vtkImageReader2.h:312
vtkX3D::type
@ type
Definition: vtkX3D.h:522
vtkIdType
int vtkIdType
Definition: vtkType.h:338
VTK_UNSIGNED_INT
#define VTK_UNSIGNED_INT
Definition: vtkType.h:49
vtkImageReader2::SetDataScalarTypeToUnsignedInt
virtual void SetDataScalarTypeToUnsignedInt()
Definition: vtkImageReader2.h:124
vtkX3D::data
@ data
Definition: vtkX3D.h:321
vtkImageReader2::SetDataScalarTypeToChar
virtual void SetDataScalarTypeToChar()
Definition: vtkImageReader2.h:127
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:35
VTK_UNSIGNED_SHORT
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:47
vtkImageReader2::SetDataScalarTypeToFloat
virtual void SetDataScalarTypeToFloat()
Definition: vtkImageReader2.h:121
vtkImageReader2::FilePrefix
char * FilePrefix
Definition: vtkImageReader2.h:307
vtkImageAlgorithm::ExecuteDataWithInformation
virtual void ExecuteDataWithInformation(vtkDataObject *output, vtkInformation *outInfo)
This is a convenience method that is implemented in many subclasses instead of RequestData.
vtkImageReader2::SwapBytes
vtkTypeBool SwapBytes
Definition: vtkImageReader2.h:318
vtkImageAlgorithm.h
vtkImageReader2::GetFileExtensions
virtual const char * GetFileExtensions()
Get the file extensions for this format.
Definition: vtkImageReader2.h:290
vtkImageReader2::SetDataScalarTypeToUnsignedShort
virtual void SetDataScalarTypeToUnsignedShort()
Definition: vtkImageReader2.h:126
vtkImageReader2::DataScalarType
int DataScalarType
Definition: vtkImageReader2.h:322
vtkImageAlgorithm
Generic algorithm superclass for image algs.
Definition: vtkImageAlgorithm.h:37
vtkImageReader2::GetMemoryBuffer
virtual const void * GetMemoryBuffer()
Definition: vtkImageReader2.h:107
vtkImageReader2::FilePattern
char * FilePattern
Definition: vtkImageReader2.h:308
vtkImageReader2::FileDimensionality
int FileDimensionality
Definition: vtkImageReader2.h:320
vtkImageReader2::GetFile
istream * GetFile()
Definition: vtkImageReader2.h:249
vtkImageReader2::File
istream * File
Definition: vtkImageReader2.h:315
vtkImageAlgorithm::RequestInformation
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
Subclasses can reimplement this method to collect information from their inputs and set information f...
vtkImageReader2::FileNameSliceSpacing
int FileNameSliceSpacing
Definition: vtkImageReader2.h:330
VTK_CHAR
#define VTK_CHAR
Definition: vtkType.h:43
vtkImageReader2::MemoryBufferLength
vtkIdType MemoryBufferLength
Definition: vtkImageReader2.h:313
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkImageReader2::InternalFileName
char * InternalFileName
Definition: vtkImageReader2.h:305
VTK_FLOAT
#define VTK_FLOAT
Definition: vtkType.h:52
VTK_DOUBLE
#define VTK_DOUBLE
Definition: vtkType.h:53
VTK_UNSIGNED_CHAR
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:45
vtkImageReader2::GetDescriptiveName
virtual const char * GetDescriptiveName()
Return a descriptive name for the file format that might be useful in a GUI.
Definition: vtkImageReader2.h:296
vtkX3D::size
@ size
Definition: vtkX3D.h:259
vtkImageReader2
Superclass of binary file readers.
Definition: vtkImageReader2.h:52
vtkImageReader2::SetDataScalarTypeToShort
virtual void SetDataScalarTypeToShort()
Definition: vtkImageReader2.h:125
vtkImageReader2::SetDataScalarTypeToSignedChar
virtual void SetDataScalarTypeToSignedChar()
Definition: vtkImageReader2.h:128
vtkImageReader2::GetSwapBytes
virtual vtkTypeBool GetSwapBytes()
Definition: vtkImageReader2.h:245
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:73
vtkImageReader2::GetFileDimensionality
int GetFileDimensionality()
Definition: vtkImageReader2.h:159
vtkImageReader2::SetDataScalarTypeToUnsignedChar
virtual void SetDataScalarTypeToUnsignedChar()
Definition: vtkImageReader2.h:129
vtkImageAlgorithm::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkAlgorithm::New
static vtkAlgorithm * New()
VTK_SHORT
#define VTK_SHORT
Definition: vtkType.h:46
vtkImageReader2::HeaderSize
unsigned long HeaderSize
Definition: vtkImageReader2.h:321
VTK_SIGNED_CHAR
#define VTK_SIGNED_CHAR
Definition: vtkType.h:44
vtkStringArray
a vtkAbstractArray subclass for strings
Definition: vtkStringArray.h:36
vtkImageReader2::FileNames
vtkStringArray * FileNames
Definition: vtkImageReader2.h:303
vtkImageReader2::NumberOfScalarComponents
int NumberOfScalarComponents
Definition: vtkImageReader2.h:309
vtkImageReader2::SetDataScalarTypeToDouble
virtual void SetDataScalarTypeToDouble()
Definition: vtkImageReader2.h:122
VTK_INT
#define VTK_INT
Definition: vtkType.h:48
vtkImageReader2::FileNameSliceOffset
int FileNameSliceOffset
Definition: vtkImageReader2.h:329
vtkImageReader2::ManualHeaderSize
unsigned long ManualHeaderSize
Definition: vtkImageReader2.h:323
vtkImageReader2::CanReadFile
virtual int CanReadFile(const char *vtkNotUsed(fname))
Return non zero if the reader can read the given file name.
Definition: vtkImageReader2.h:283
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:59
vtkImageReader2::GetMemoryBufferLength
vtkIdType GetMemoryBufferLength()
Definition: vtkImageReader2.h:113
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkImageReader2::SetDataScalarTypeToInt
virtual void SetDataScalarTypeToInt()
Definition: vtkImageReader2.h:123