VTK  9.6.1
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 "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_5_0
39#include "vtkIOImageModule.h" // For export macro
40#include "vtkImageAlgorithm.h"
41#include "vtkResourceStream.h" // For stream
42#include "vtkSmartPointer.h" // For smart pointer
43
44VTK_ABI_NAMESPACE_BEGIN
45class vtkStringArray;
47
48#define VTK_FILE_BYTE_ORDER_BIG_ENDIAN 0
49#define VTK_FILE_BYTE_ORDER_LITTLE_ENDIAN 1
50
51class VTKIOIMAGE_EXPORT vtkImageReader2 : public vtkImageAlgorithm
52{
53public:
56 void PrintSelf(ostream& os, vtkIndent indent) override;
57
59
63 virtual void SetFileName(VTK_FILEPATH const char*);
66
68
76 vtkGetObjectMacro(FileNames, vtkStringArray);
78
80
90
92
96 virtual void SetFilePattern(VTK_FILEPATH const char*);
99
101
106 vtkSetSmartPointerMacro(Stream, vtkResourceStream);
107 vtkGetSmartPointerMacro(Stream, vtkResourceStream);
109
111
117 VTK_DEPRECATED_IN_9_6_0("Use SetStream instead")
118 virtual void SetMemoryBuffer(const void*);
119 VTK_DEPRECATED_IN_9_6_0("Use GetStream instead")
120 virtual const void* GetMemoryBuffer();
122
124
127 VTK_DEPRECATED_IN_9_6_0("Use SetStream instead")
128 virtual void SetMemoryBufferLength(vtkIdType buflen);
129 VTK_DEPRECATED_IN_9_6_0("Use GetStream instead")
132
138 virtual void SetDataScalarType(int type);
148
150
153 vtkGetMacro(DataScalarType, int);
155
157
160 vtkSetMacro(NumberOfScalarComponents, int);
161 vtkGetMacro(NumberOfScalarComponents, int);
163
165
168 vtkSetVector6Macro(DataExtent, int);
169 vtkGetVector6Macro(DataExtent, int);
171
173
176 vtkSetMacro(FileDimensionality, int);
179
181
184 vtkSetVector3Macro(DataSpacing, double);
185 vtkGetVector3Macro(DataSpacing, double);
187
189
192 vtkSetVector3Macro(DataOrigin, double);
193 vtkGetVector3Macro(DataOrigin, double);
195
197
200 vtkSetVectorMacro(DataDirection, double, 9);
201 vtkGetVectorMacro(DataDirection, double, 9);
203
205
208 unsigned long GetHeaderSize();
209 unsigned long GetHeaderSize(unsigned long slice);
211
216 virtual void SetHeaderSize(unsigned long size);
217
219
234 virtual int GetDataByteOrder();
235 virtual void SetDataByteOrder(int);
236 virtual const char* GetDataByteOrderAsString();
238
240
244 vtkSetMacro(FileNameSliceOffset, int);
245 vtkGetMacro(FileNameSliceOffset, int);
247
249
254 vtkSetMacro(FileNameSliceSpacing, int);
255 vtkGetMacro(FileNameSliceSpacing, int);
257
259
262 vtkSetMacro(SwapBytes, vtkTypeBool);
263 virtual vtkTypeBool GetSwapBytes() { return this->SwapBytes; }
264 vtkBooleanMacro(SwapBytes, vtkTypeBool);
266
267 istream* GetFile() { return this->File; }
268 vtkGetVectorMacro(DataIncrements, unsigned long, 4);
269
270 virtual int OpenFile();
271 void CloseFile();
272 virtual void SeekFile(int i, int j, int k);
273
275
279 vtkBooleanMacro(FileLowerLeft, vtkTypeBool);
283
285
288 virtual void ComputeInternalFileName(int slice);
291
301 virtual int CanReadFile(VTK_FILEPATH const char* vtkNotUsed(fname)) { return 0; }
302
308 virtual const char* GetFileExtensions() { return nullptr; }
309
311
314 virtual const char* GetDescriptiveName() { return nullptr; }
315
320
321protected:
325
327
329 char* FileName;
334
335 VTK_DEPRECATED_IN_9_6_0("Use GetStream instead")
336 const void* MemoryBuffer;
337
338 VTK_DEPRECATED_IN_9_6_0("Use GetStream instead")
340
341 istream* File;
342 unsigned long DataIncrements[4];
345
347 unsigned long HeaderSize;
349 unsigned long ManualHeaderSize;
350
351 double DataSpacing[3];
352 double DataOrigin[3];
353 double DataDirection[9];
354
357
359 vtkInformationVector* outputVector) override;
360 virtual void ExecuteInformation();
362 virtual void ComputeDataIncrements();
363
364private:
365 vtkImageReader2(const vtkImageReader2&) = delete;
366 void operator=(const vtkImageReader2&) = delete;
367
369};
370
371VTK_ABI_NAMESPACE_END
372#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.
virtual const void * GetMemoryBuffer()
Specify the in memory image buffer.
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 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.
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 std::format or printf style format string used to build filename from FilePrefix and slice number...
virtual void SetDataScalarTypeToUnsignedChar()
const void * MemoryBuffer
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 void SetDataScalarTypeToUnsignedShort()
vtkStringArray * FileNames
vtkIdType GetMemoryBufferLength()
Specify the in memory image buffer length.
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_DEPRECATED_IN_9_6_0(reason)
#define VTK_SHORT
Definition vtkType.h:37
int vtkIdType
Definition vtkType.h:368
#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:323
#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