VTK  9.5.20251213
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
143
144#ifndef vtkImageReader2_h
145#define vtkImageReader2_h
146
147#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_5_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
410 virtual int CanReadFile(VTK_FILEPATH const char* vtkNotUsed(fname)) { return 0; }
411
417 virtual const char* GetFileExtensions() { return nullptr; }
418
420
423 virtual const char* GetDescriptiveName() { return nullptr; }
424
429
430protected:
434
436
438 char* FileName;
443
444 VTK_DEPRECATED_IN_9_6_0("Use GetStream instead")
445 const void* MemoryBuffer;
446
447 VTK_DEPRECATED_IN_9_6_0("Use GetStream instead")
449
450 istream* File;
451 unsigned long DataIncrements[4];
454
456 unsigned long HeaderSize;
458 unsigned long ManualHeaderSize;
459
460 double DataSpacing[3];
461 double DataOrigin[3];
462 double DataDirection[9];
463
466
468 vtkInformationVector* outputVector) override;
469 virtual void ExecuteInformation();
471 virtual void ComputeDataIncrements();
472
473private:
474 vtkImageReader2(const vtkImageReader2&) = delete;
475 void operator=(const vtkImageReader2&) = delete;
476
478};
479
480VTK_ABI_NAMESPACE_END
481#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: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:37
int vtkIdType
Definition vtkType.h:367
#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:322
#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