VTK  9.7.20260805
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
34
35#ifndef vtkImageReader2_h
36#define vtkImageReader2_h
37
38#include "vtkIOImageModule.h" // For export macro
39#include "vtkImageAlgorithm.h"
40#include "vtkResourceStream.h" // For stream
41#include "vtkSmartPointer.h" // For smart pointer
42
43VTK_ABI_NAMESPACE_BEGIN
44class vtkStringArray;
46
47#define VTK_FILE_BYTE_ORDER_BIG_ENDIAN 0
48#define VTK_FILE_BYTE_ORDER_LITTLE_ENDIAN 1
49
50class VTKIOIMAGE_EXPORT vtkImageReader2 : public vtkImageAlgorithm
51{
52public:
55 void PrintSelf(ostream& os, vtkIndent indent) override;
56
58
62 virtual void SetFileName(VTK_FILEPATH const char*);
65
67
75 vtkGetObjectMacro(FileNames, vtkStringArray);
77
79
89
91
92 * The std::format or printf style format string used to build filename from
93 * FilePrefix and slice number.
94 */
95 virtual void SetFilePattern(VTK_FILEPATH const char*);
98
100
105 vtkSetSmartPointerMacro(Stream, vtkResourceStream);
106 vtkGetSmartPointerMacro(Stream, vtkResourceStream);
108
114 virtual void SetDataScalarType(int type);
124
126
129 vtkGetMacro(DataScalarType, int);
131
133
136 vtkSetMacro(NumberOfScalarComponents, int);
137 vtkGetMacro(NumberOfScalarComponents, int);
139
141
144 vtkSetVector6Macro(DataExtent, int);
145 vtkGetVector6Macro(DataExtent, int);
147
149
152 vtkSetMacro(FileDimensionality, int);
155
157
160 vtkSetVector3Macro(DataSpacing, double);
161 vtkGetVector3Macro(DataSpacing, double);
163
165
168 vtkSetVector3Macro(DataOrigin, double);
169 vtkGetVector3Macro(DataOrigin, double);
171
173
176 vtkSetVectorMacro(DataDirection, double, 9);
177 vtkGetVectorMacro(DataDirection, double, 9);
179
181
184 unsigned long GetHeaderSize();
185 unsigned long GetHeaderSize(unsigned long slice);
187
192 virtual void SetHeaderSize(unsigned long size);
193
195
210 virtual int GetDataByteOrder();
211 virtual void SetDataByteOrder(int);
212 virtual const char* GetDataByteOrderAsString();
214
216
220 vtkSetMacro(FileNameSliceOffset, int);
221 vtkGetMacro(FileNameSliceOffset, int);
223
225
230 vtkSetMacro(FileNameSliceSpacing, int);
231 vtkGetMacro(FileNameSliceSpacing, int);
233
235
238 vtkSetMacro(SwapBytes, vtkTypeBool);
239 virtual vtkTypeBool GetSwapBytes() { return this->SwapBytes; }
240 vtkBooleanMacro(SwapBytes, vtkTypeBool);
242
243 istream* GetFile() { return this->File; }
244 vtkGetVectorMacro(DataIncrements, unsigned long, 4);
245
246 virtual int OpenFile();
247 void CloseFile();
248 virtual void SeekFile(int i, int j, int k);
249
251
255 vtkBooleanMacro(FileLowerLeft, vtkTypeBool);
259
261
264 virtual void ComputeInternalFileName(int slice);
267
269
280 virtual int CanReadFile(VTK_FILEPATH const char* vtkNotUsed(fname)) { return 0; }
281 virtual int CanReadFile(vtkResourceStream* vtkNotUsed(stream)) { return 0; }
283
289 virtual const char* GetFileExtensions() { return nullptr; }
290
292
295 virtual const char* GetDescriptiveName() { return nullptr; }
296
301
302protected:
306
308
310 char* FileName;
315
316 istream* File;
317 unsigned long DataIncrements[4];
320
322 unsigned long HeaderSize;
324 unsigned long ManualHeaderSize;
325
326 double DataSpacing[3];
327 double DataOrigin[3];
328 double DataDirection[9];
329
332
334 vtkInformationVector* outputVector) override;
335 virtual void ExecuteInformation();
337 virtual void ComputeDataIncrements();
338
339private:
340 vtkImageReader2(const vtkImageReader2&) = delete;
341 void operator=(const vtkImageReader2&) = delete;
342
344};
345
346VTK_ABI_NAMESPACE_END
347#endif
general representation of visualization data
unsigned long DataIncrements[4]
virtual void ComputeDataIncrements()
vtkSetFilePathMacro(FilePrefix)
Specify file prefix for the image file or files.
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.
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.
int GetFileDimensionality()
The number of dimensions stored in a file.
vtkTypeBool SwapBytes
virtual int CanReadFile(const char *fname)
Return non zero if the reader can read the given file name.
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 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.
vtkMTimeType GetMTime() override
Overridden to take into account mtime from the internal vtkResourceStream.
virtual void SetDataScalarTypeToInt()
virtual const char * GetFileExtensions()
Get the file extensions for this format.
vtkGetFilePathMacro(FilePattern)
The std::format or printf 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.
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 std::format or printf style format string used to build filename from FilePrefix and slice number...
virtual void SetDataScalarTypeToUnsignedChar()
virtual void SetDataByteOrder(int)
These methods should be used instead of the SwapBytes methods.
double DataDirection[9]
static vtkImageReader2 * New()
virtual void SetDataByteOrderToBigEndian()
These methods should be used instead of the SwapBytes methods.
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 int CanReadFile(vtkResourceStream *stream)
Return non zero if the reader can read the given file name.
virtual void SetDataScalarTypeToUnsignedShort()
vtkStringArray * FileNames
virtual void SetDataScalarTypeToUnsignedInt()
virtual void ExecuteInformation()
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:29
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Abstract class used for custom streams.
Hold a reference to a vtkObjectBase instance.
a vtkAbstractArray subclass for strings
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_SHORT
Definition vtkType.h:37
#define VTK_UNSIGNED_INT
Definition vtkType.h:40
#define VTK_DOUBLE
Definition vtkType.h:44
#define VTK_UNSIGNED_CHAR
Definition vtkType.h:36
#define VTK_UNSIGNED_SHORT
Definition vtkType.h:38
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:318
#define VTK_INT
Definition vtkType.h:39
#define VTK_SIGNED_CHAR
Definition vtkType.h:35
#define VTK_FLOAT
Definition vtkType.h:43
#define VTK_CHAR
Definition vtkType.h:34
#define VTK_FILEPATH