VTK  9.6.20260202
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
111 <div class="examplegrid_text">TexturePlane</div>
112 </div>
113 </div>
114 </a>
115
116
117 <a href="https://examples.vtk.org/site/Cxx/Visualization/CurvedReformation">
118 <div class="examplegrid_container">
119 <img src="https://raw.githubusercontent.com/Kitware/vtk-examples/gh-pages/src/Testing/Baseline//Cxx/Visualization/TestCurvedReformation.png">
120 <div class="examplegrid_overlay">
121 <div class="examplegrid_text">CurvedReformation</div>
122 </div>
123 </div>
124 </a>
125
126
127 <a href="https://examples.vtk.org/site/Cxx/Widgets/RectilinearWipeWidget">
128 <div class="examplegrid_container">
129 <img src="https://raw.githubusercontent.com/Kitware/vtk-examples/gh-pages/src/Testing/Baseline//Cxx/Widgets/TestRectilinearWipeWidget.png">
130 <div class="examplegrid_overlay">
131 <div class="examplegrid_text">RectilinearWipeWidget</div>
132 </div>
133 </div>
134 </a>
135
136 </div>
137
138 @endhtmlonly
139
140 @par Tests:
141 @ref c2_vtk_t_vtkImageReader2 "vtkImageReader2 (Tests)"
142 */
143
144#ifndef vtkImageReader2_h
145#define vtkImageReader2_h
146
147#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_6_0
148#include "vtkIOImageModule.h" // For export macro
149#include "vtkImageAlgorithm.h"
150#include "vtkResourceStream.h" // For stream
151#include "vtkSmartPointer.h" // For smart pointer
152
153VTK_ABI_NAMESPACE_BEGIN
154class vtkStringArray;
156
157#define VTK_FILE_BYTE_ORDER_BIG_ENDIAN 0
158#define VTK_FILE_BYTE_ORDER_LITTLE_ENDIAN 1
159
160class VTKIOIMAGE_EXPORT vtkImageReader2 : public vtkImageAlgorithm
161{
162public:
165 void PrintSelf(ostream& os, vtkIndent indent) override;
166
168
172 virtual void SetFileName(VTK_FILEPATH const char*);
175
177
185 vtkGetObjectMacro(FileNames, vtkStringArray);
187
189
199
201
205 virtual void SetFilePattern(VTK_FILEPATH const char*);
208
210
215 vtkSetSmartPointerMacro(Stream, vtkResourceStream);
216 vtkGetSmartPointerMacro(Stream, vtkResourceStream);
218
220
226 VTK_DEPRECATED_IN_9_6_0("Use SetStream instead")
227 virtual void SetMemoryBuffer(const void*);
228 VTK_DEPRECATED_IN_9_6_0("Use GetStream instead")
229 virtual const void* GetMemoryBuffer();
231
233
236 VTK_DEPRECATED_IN_9_6_0("Use SetStream instead")
237 virtual void SetMemoryBufferLength(vtkIdType buflen);
238 VTK_DEPRECATED_IN_9_6_0("Use GetStream instead")
241
247 virtual void SetDataScalarType(int type);
257
259
262 vtkGetMacro(DataScalarType, int);
264
266
269 vtkSetMacro(NumberOfScalarComponents, int);
270 vtkGetMacro(NumberOfScalarComponents, int);
272
274
277 vtkSetVector6Macro(DataExtent, int);
278 vtkGetVector6Macro(DataExtent, int);
280
282
285 vtkSetMacro(FileDimensionality, int);
288
290
293 vtkSetVector3Macro(DataSpacing, double);
294 vtkGetVector3Macro(DataSpacing, double);
296
298
301 vtkSetVector3Macro(DataOrigin, double);
302 vtkGetVector3Macro(DataOrigin, double);
304
306
309 vtkSetVectorMacro(DataDirection, double, 9);
310 vtkGetVectorMacro(DataDirection, double, 9);
312
314
317 unsigned long GetHeaderSize();
318 unsigned long GetHeaderSize(unsigned long slice);
320
325 virtual void SetHeaderSize(unsigned long size);
326
328
343 virtual int GetDataByteOrder();
344 virtual void SetDataByteOrder(int);
345 virtual const char* GetDataByteOrderAsString();
347
349
353 vtkSetMacro(FileNameSliceOffset, int);
354 vtkGetMacro(FileNameSliceOffset, int);
356
358
363 vtkSetMacro(FileNameSliceSpacing, int);
364 vtkGetMacro(FileNameSliceSpacing, int);
366
368
371 vtkSetMacro(SwapBytes, vtkTypeBool);
372 virtual vtkTypeBool GetSwapBytes() { return this->SwapBytes; }
373 vtkBooleanMacro(SwapBytes, vtkTypeBool);
375
376 istream* GetFile() { return this->File; }
377 vtkGetVectorMacro(DataIncrements, unsigned long, 4);
378
379 virtual int OpenFile();
380 void CloseFile();
381 virtual void SeekFile(int i, int j, int k);
382
384
388 vtkBooleanMacro(FileLowerLeft, vtkTypeBool);
392
394
397 virtual void ComputeInternalFileName(int slice);
400
402
413 virtual int CanReadFile(VTK_FILEPATH const char* vtkNotUsed(fname)) { return 0; }
414 virtual int CanReadFile(vtkResourceStream* vtkNotUsed(stream)) { return 0; }
416
422 virtual const char* GetFileExtensions() { return nullptr; }
423
425
428 virtual const char* GetDescriptiveName() { return nullptr; }
429
434
435protected:
439
441
443 char* FileName;
448
449 VTK_DEPRECATED_IN_9_6_0("Use GetStream instead")
450 const void* MemoryBuffer;
451
452 VTK_DEPRECATED_IN_9_6_0("Use GetStream instead")
454
455 istream* File;
456 unsigned long DataIncrements[4];
459
461 unsigned long HeaderSize;
463 unsigned long ManualHeaderSize;
464
465 double DataSpacing[3];
466 double DataOrigin[3];
467 double DataDirection[9];
468
471
473 vtkInformationVector* outputVector) override;
474 virtual void ExecuteInformation();
476 virtual void ComputeDataIncrements();
477
478private:
479 vtkImageReader2(const vtkImageReader2&) = delete;
480 void operator=(const vtkImageReader2&) = delete;
481
483};
484
485VTK_ABI_NAMESPACE_END
486#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 int CanReadFile(vtkResourceStream *stream)
Return non zero if the reader can read the given file name.
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:108
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:36
int vtkIdType
Definition vtkType.h:354
#define VTK_UNSIGNED_INT
Definition vtkType.h:39
#define VTK_DOUBLE
Definition vtkType.h:43
#define VTK_UNSIGNED_CHAR
Definition vtkType.h:35
#define VTK_UNSIGNED_SHORT
Definition vtkType.h:37
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:309
#define VTK_INT
Definition vtkType.h:38
#define VTK_SIGNED_CHAR
Definition vtkType.h:34
#define VTK_FLOAT
Definition vtkType.h:42
#define VTK_CHAR
Definition vtkType.h:33
#define VTK_FILEPATH