VTK  9.7.20260718
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">ResizeImage</div>
112 </div>
113 </div>
114 </a>
115
116
117 <a href="https://examples.vtk.org/site/Cxx/Images/ResizeImageDemo">
118 <div class="examplegrid_container">
119 <img src="https://raw.githubusercontent.com/Kitware/vtk-examples/gh-pages/src/Testing/Baseline//Cxx/Images/TestResizeImageDemo.png">
120 <div class="examplegrid_overlay">
121 <div class="examplegrid_text">ResizeImageDemo</div>
122 </div>
123 </div>
124 </a>
125
126
127 <a href="https://examples.vtk.org/site/Cxx/Images/StaticImage">
128 <div class="examplegrid_container">
129 <img src="https://raw.githubusercontent.com/Kitware/vtk-examples/gh-pages/src/Testing/Baseline//Cxx/Images/TestStaticImage.png">
130 <div class="examplegrid_overlay">
131 <div class="examplegrid_text">StaticImage</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 "vtkIOImageModule.h" // For export macro
148#include "vtkImageAlgorithm.h"
149#include "vtkResourceStream.h" // For stream
150#include "vtkSmartPointer.h" // For smart pointer
151
152VTK_ABI_NAMESPACE_BEGIN
153class vtkStringArray;
155
156#define VTK_FILE_BYTE_ORDER_BIG_ENDIAN 0
157#define VTK_FILE_BYTE_ORDER_LITTLE_ENDIAN 1
158
159class VTKIOIMAGE_EXPORT vtkImageReader2 : public vtkImageAlgorithm
160{
161public:
164 void PrintSelf(ostream& os, vtkIndent indent) override;
165
167
171 virtual void SetFileName(VTK_FILEPATH const char*);
174
176
184 vtkGetObjectMacro(FileNames, vtkStringArray);
186
188
198
200
204 virtual void SetFilePattern(VTK_FILEPATH const char*);
207
209
214 vtkSetSmartPointerMacro(Stream, vtkResourceStream);
215 vtkGetSmartPointerMacro(Stream, vtkResourceStream);
217
223 virtual void SetDataScalarType(int type);
233
235
238 vtkGetMacro(DataScalarType, int);
240
242
245 vtkSetMacro(NumberOfScalarComponents, int);
246 vtkGetMacro(NumberOfScalarComponents, int);
248
250
253 vtkSetVector6Macro(DataExtent, int);
254 vtkGetVector6Macro(DataExtent, int);
256
258
261 vtkSetMacro(FileDimensionality, int);
264
266
269 vtkSetVector3Macro(DataSpacing, double);
270 vtkGetVector3Macro(DataSpacing, double);
272
274
277 vtkSetVector3Macro(DataOrigin, double);
278 vtkGetVector3Macro(DataOrigin, double);
280
282
285 vtkSetVectorMacro(DataDirection, double, 9);
286 vtkGetVectorMacro(DataDirection, double, 9);
288
290
293 unsigned long GetHeaderSize();
294 unsigned long GetHeaderSize(unsigned long slice);
296
301 virtual void SetHeaderSize(unsigned long size);
302
304
319 virtual int GetDataByteOrder();
320 virtual void SetDataByteOrder(int);
321 virtual const char* GetDataByteOrderAsString();
323
325
329 vtkSetMacro(FileNameSliceOffset, int);
330 vtkGetMacro(FileNameSliceOffset, int);
332
334
339 vtkSetMacro(FileNameSliceSpacing, int);
340 vtkGetMacro(FileNameSliceSpacing, int);
342
344
347 vtkSetMacro(SwapBytes, vtkTypeBool);
348 virtual vtkTypeBool GetSwapBytes() { return this->SwapBytes; }
349 vtkBooleanMacro(SwapBytes, vtkTypeBool);
351
352 istream* GetFile() { return this->File; }
353 vtkGetVectorMacro(DataIncrements, unsigned long, 4);
354
355 virtual int OpenFile();
356 void CloseFile();
357 virtual void SeekFile(int i, int j, int k);
358
360
364 vtkBooleanMacro(FileLowerLeft, vtkTypeBool);
368
370
373 virtual void ComputeInternalFileName(int slice);
376
378
389 virtual int CanReadFile(VTK_FILEPATH const char* vtkNotUsed(fname)) { return 0; }
390 virtual int CanReadFile(vtkResourceStream* vtkNotUsed(stream)) { return 0; }
392
398 virtual const char* GetFileExtensions() { return nullptr; }
399
401
404 virtual const char* GetDescriptiveName() { return nullptr; }
405
410
411protected:
415
417
419 char* FileName;
424
425 istream* File;
426 unsigned long DataIncrements[4];
429
431 unsigned long HeaderSize;
433 unsigned long ManualHeaderSize;
434
435 double DataSpacing[3];
436 double DataOrigin[3];
437 double DataDirection[9];
438
441
443 vtkInformationVector* outputVector) override;
444 virtual void ExecuteInformation();
446 virtual void ComputeDataIncrements();
447
448private:
449 vtkImageReader2(const vtkImageReader2&) = delete;
450 void operator=(const vtkImageReader2&) = delete;
451
453};
454
455VTK_ABI_NAMESPACE_END
456#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: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_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