VTK  9.2.6
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=========================================================================*/
56#ifndef vtkImageReader2_h
57#define vtkImageReader2_h
58
59#include "vtkIOImageModule.h" // For export macro
60#include "vtkImageAlgorithm.h"
61
62class vtkStringArray;
63
64#define VTK_FILE_BYTE_ORDER_BIG_ENDIAN 0
65#define VTK_FILE_BYTE_ORDER_LITTLE_ENDIAN 1
66
67class VTKIOIMAGE_EXPORT vtkImageReader2 : public vtkImageAlgorithm
68{
69public:
72 void PrintSelf(ostream& os, vtkIndent indent) override;
73
75
79 virtual void SetFileName(VTK_FILEPATH const char*);
82
84
92 vtkGetObjectMacro(FileNames, vtkStringArray);
94
96
103 virtual void SetFilePrefix(VTK_FILEPATH const char*);
106
108
112 virtual void SetFilePattern(VTK_FILEPATH const char*);
115
121 virtual void SetMemoryBuffer(const void*);
122 virtual const void* GetMemoryBuffer() { return this->MemoryBuffer; }
123
127 virtual void SetMemoryBufferLength(vtkIdType buflen);
128 vtkIdType GetMemoryBufferLength() { return this->MemoryBufferLength; }
129
135 virtual void SetDataScalarType(int type);
136 virtual void SetDataScalarTypeToFloat() { this->SetDataScalarType(VTK_FLOAT); }
137 virtual void SetDataScalarTypeToDouble() { this->SetDataScalarType(VTK_DOUBLE); }
138 virtual void SetDataScalarTypeToInt() { this->SetDataScalarType(VTK_INT); }
139 virtual void SetDataScalarTypeToUnsignedInt() { this->SetDataScalarType(VTK_UNSIGNED_INT); }
140 virtual void SetDataScalarTypeToShort() { this->SetDataScalarType(VTK_SHORT); }
141 virtual void SetDataScalarTypeToUnsignedShort() { this->SetDataScalarType(VTK_UNSIGNED_SHORT); }
142 virtual void SetDataScalarTypeToChar() { this->SetDataScalarType(VTK_CHAR); }
143 virtual void SetDataScalarTypeToSignedChar() { this->SetDataScalarType(VTK_SIGNED_CHAR); }
144 virtual void SetDataScalarTypeToUnsignedChar() { this->SetDataScalarType(VTK_UNSIGNED_CHAR); }
145
147
150 vtkGetMacro(DataScalarType, int);
152
154
157 vtkSetMacro(NumberOfScalarComponents, int);
158 vtkGetMacro(NumberOfScalarComponents, int);
160
162
165 vtkSetVector6Macro(DataExtent, int);
166 vtkGetVector6Macro(DataExtent, int);
168
170
173 vtkSetMacro(FileDimensionality, int);
174 int GetFileDimensionality() { return this->FileDimensionality; }
176
178
181 vtkSetVector3Macro(DataSpacing, double);
182 vtkGetVector3Macro(DataSpacing, double);
184
186
189 vtkSetVector3Macro(DataOrigin, double);
190 vtkGetVector3Macro(DataOrigin, double);
192
194
197 vtkSetVectorMacro(DataDirection, double, 9);
198 vtkGetVectorMacro(DataDirection, double, 9);
200
202
205 unsigned long GetHeaderSize();
206 unsigned long GetHeaderSize(unsigned long slice);
208
213 virtual void SetHeaderSize(unsigned long size);
214
216
231 virtual int GetDataByteOrder();
232 virtual void SetDataByteOrder(int);
233 virtual const char* GetDataByteOrderAsString();
235
237
241 vtkSetMacro(FileNameSliceOffset, int);
242 vtkGetMacro(FileNameSliceOffset, int);
244
246
251 vtkSetMacro(FileNameSliceSpacing, int);
252 vtkGetMacro(FileNameSliceSpacing, int);
254
256
259 vtkSetMacro(SwapBytes, vtkTypeBool);
260 virtual vtkTypeBool GetSwapBytes() { return this->SwapBytes; }
261 vtkBooleanMacro(SwapBytes, vtkTypeBool);
263
264 istream* GetFile() { return this->File; }
265 vtkGetVectorMacro(DataIncrements, unsigned long, 4);
266
267 virtual int OpenFile();
268 void CloseFile();
269 virtual void SeekFile(int i, int j, int k);
270
272
276 vtkBooleanMacro(FileLowerLeft, vtkTypeBool);
277 vtkGetMacro(FileLowerLeft, vtkTypeBool);
278 vtkSetMacro(FileLowerLeft, vtkTypeBool);
280
282
285 virtual void ComputeInternalFileName(int slice);
286 vtkGetFilePathMacro(InternalFileName);
288
298 virtual int CanReadFile(VTK_FILEPATH const char* vtkNotUsed(fname)) { return 0; }
299
305 virtual const char* GetFileExtensions() { return nullptr; }
306
308
311 virtual const char* GetDescriptiveName() { return nullptr; }
312
313protected:
317
319
321 char* FileName;
326
327 const void* MemoryBuffer;
329
330 istream* File;
331 unsigned long DataIncrements[4];
332 int DataExtent[6];
334
336 unsigned long HeaderSize;
338 unsigned long ManualHeaderSize;
339
340 double DataSpacing[3];
341 double DataOrigin[3];
342 double DataDirection[9];
343
346
348 vtkInformationVector* outputVector) override;
349 virtual void ExecuteInformation();
351 virtual void ComputeDataIncrements();
352
353private:
354 vtkImageReader2(const vtkImageReader2&) = delete;
355 void operator=(const vtkImageReader2&) = delete;
356};
357
358#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
istream * GetFile()
void ExecuteDataWithInformation(vtkDataObject *data, vtkInformation *outInfo) override
This is a convenience method that is implemented in many subclasses instead of RequestData.
virtual const void * GetMemoryBuffer()
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.
virtual void SetDataScalarTypeToSignedChar()
virtual const char * GetDataByteOrderAsString()
These methods should be used instead of the SwapBytes methods.
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 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()
virtual const char * GetFileExtensions()
Get the file extensions for this format.
vtkGetFilePathMacro(FilePattern)
The snprintf-style format string used to build filename from FilePrefix and slice number.
virtual void SetDataScalarTypeToDouble()
virtual const char * GetDescriptiveName()
Return a descriptive name for the file format that might be useful in a GUI.
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()
const void * MemoryBuffer
virtual void SetDataByteOrder(int)
These methods should be used instead of the SwapBytes methods.
static vtkImageReader2 * New()
virtual void SetDataByteOrderToBigEndian()
These methods should be used instead of the SwapBytes methods.
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 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:49
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
a vtkAbstractArray subclass for strings
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