VTK  9.5.20251008
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
144#ifndef vtkImageReader2_h
145#define vtkImageReader2_h
146
147#include "vtkIOImageModule.h" // For export macro
148#include "vtkImageAlgorithm.h"
149
150VTK_ABI_NAMESPACE_BEGIN
151class vtkStringArray;
152
153#define VTK_FILE_BYTE_ORDER_BIG_ENDIAN 0
154#define VTK_FILE_BYTE_ORDER_LITTLE_ENDIAN 1
155
156class VTKIOIMAGE_EXPORT vtkImageReader2 : public vtkImageAlgorithm
157{
158public:
161 void PrintSelf(ostream& os, vtkIndent indent) override;
162
164
168 virtual void SetFileName(VTK_FILEPATH const char*);
171
173
181 vtkGetObjectMacro(FileNames, vtkStringArray);
183
185
195
197
201 virtual void SetFilePattern(VTK_FILEPATH const char*);
204
211 virtual void SetMemoryBuffer(const void*);
212 virtual const void* GetMemoryBuffer() { return this->MemoryBuffer; }
213
217 virtual void SetMemoryBufferLength(vtkIdType buflen);
218 vtkIdType GetMemoryBufferLength() { return this->MemoryBufferLength; }
219
225 virtual void SetDataScalarType(int type);
226 virtual void SetDataScalarTypeToFloat() { this->SetDataScalarType(VTK_FLOAT); }
227 virtual void SetDataScalarTypeToDouble() { this->SetDataScalarType(VTK_DOUBLE); }
228 virtual void SetDataScalarTypeToInt() { this->SetDataScalarType(VTK_INT); }
229 virtual void SetDataScalarTypeToUnsignedInt() { this->SetDataScalarType(VTK_UNSIGNED_INT); }
230 virtual void SetDataScalarTypeToShort() { this->SetDataScalarType(VTK_SHORT); }
231 virtual void SetDataScalarTypeToUnsignedShort() { this->SetDataScalarType(VTK_UNSIGNED_SHORT); }
232 virtual void SetDataScalarTypeToChar() { this->SetDataScalarType(VTK_CHAR); }
233 virtual void SetDataScalarTypeToSignedChar() { this->SetDataScalarType(VTK_SIGNED_CHAR); }
234 virtual void SetDataScalarTypeToUnsignedChar() { this->SetDataScalarType(VTK_UNSIGNED_CHAR); }
235
237
240 vtkGetMacro(DataScalarType, int);
242
244
247 vtkSetMacro(NumberOfScalarComponents, int);
248 vtkGetMacro(NumberOfScalarComponents, int);
250
252
255 vtkSetVector6Macro(DataExtent, int);
256 vtkGetVector6Macro(DataExtent, int);
258
260
263 vtkSetMacro(FileDimensionality, int);
264 int GetFileDimensionality() { return this->FileDimensionality; }
266
268
271 vtkSetVector3Macro(DataSpacing, double);
272 vtkGetVector3Macro(DataSpacing, double);
274
276
279 vtkSetVector3Macro(DataOrigin, double);
280 vtkGetVector3Macro(DataOrigin, double);
282
284
287 vtkSetVectorMacro(DataDirection, double, 9);
288 vtkGetVectorMacro(DataDirection, double, 9);
290
292
295 unsigned long GetHeaderSize();
296 unsigned long GetHeaderSize(unsigned long slice);
298
303 virtual void SetHeaderSize(unsigned long size);
304
306
321 virtual int GetDataByteOrder();
322 virtual void SetDataByteOrder(int);
323 virtual const char* GetDataByteOrderAsString();
325
327
331 vtkSetMacro(FileNameSliceOffset, int);
332 vtkGetMacro(FileNameSliceOffset, int);
334
336
341 vtkSetMacro(FileNameSliceSpacing, int);
342 vtkGetMacro(FileNameSliceSpacing, int);
344
346
349 vtkSetMacro(SwapBytes, vtkTypeBool);
350 virtual vtkTypeBool GetSwapBytes() { return this->SwapBytes; }
351 vtkBooleanMacro(SwapBytes, vtkTypeBool);
353
354 istream* GetFile() { return this->File; }
355 vtkGetVectorMacro(DataIncrements, unsigned long, 4);
356
357 virtual int OpenFile();
358 void CloseFile();
359 virtual void SeekFile(int i, int j, int k);
360
362
366 vtkBooleanMacro(FileLowerLeft, vtkTypeBool);
367 vtkGetMacro(FileLowerLeft, vtkTypeBool);
368 vtkSetMacro(FileLowerLeft, vtkTypeBool);
370
372
375 virtual void ComputeInternalFileName(int slice);
376 vtkGetFilePathMacro(InternalFileName);
378
388 virtual int CanReadFile(VTK_FILEPATH const char* vtkNotUsed(fname)) { return 0; }
389
395 virtual const char* GetFileExtensions() { return nullptr; }
396
398
401 virtual const char* GetDescriptiveName() { return nullptr; }
402
403protected:
407
409
411 char* FileName;
416
417 const void* MemoryBuffer;
419
420 istream* File;
421 unsigned long DataIncrements[4];
422 int DataExtent[6];
424
426 unsigned long HeaderSize;
428 unsigned long ManualHeaderSize;
429
430 double DataSpacing[3];
431 double DataOrigin[3];
432 double DataDirection[9];
433
436
438 vtkInformationVector* outputVector) override;
439 virtual void ExecuteInformation();
441 virtual void ComputeDataIncrements();
442
443private:
444 vtkImageReader2(const vtkImageReader2&) = delete;
445 void operator=(const vtkImageReader2&) = delete;
446};
447
448VTK_ABI_NAMESPACE_END
449#endif
general representation of visualization data
Generic algorithm superclass for image algs.
Superclass of binary file readers.
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()
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.
virtual void SetDataScalarTypeToInt()
virtual const char * GetFileExtensions()
Get the file extensions for this format.
vtkGetFilePathMacro(FilePattern)
The std::format 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 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.
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()
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.
a vtkAbstractArray subclass for strings
int vtkTypeBool
Definition vtkABI.h:64
#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
#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