VTK  9.5.20251114
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 "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")
239 vtkIdType GetMemoryBufferLength();
241
247 virtual void SetDataScalarType(int type);
248 virtual void SetDataScalarTypeToFloat() { this->SetDataScalarType(VTK_FLOAT); }
249 virtual void SetDataScalarTypeToDouble() { this->SetDataScalarType(VTK_DOUBLE); }
250 virtual void SetDataScalarTypeToInt() { this->SetDataScalarType(VTK_INT); }
251 virtual void SetDataScalarTypeToUnsignedInt() { this->SetDataScalarType(VTK_UNSIGNED_INT); }
252 virtual void SetDataScalarTypeToShort() { this->SetDataScalarType(VTK_SHORT); }
253 virtual void SetDataScalarTypeToUnsignedShort() { this->SetDataScalarType(VTK_UNSIGNED_SHORT); }
254 virtual void SetDataScalarTypeToChar() { this->SetDataScalarType(VTK_CHAR); }
255 virtual void SetDataScalarTypeToSignedChar() { this->SetDataScalarType(VTK_SIGNED_CHAR); }
256 virtual void SetDataScalarTypeToUnsignedChar() { this->SetDataScalarType(VTK_UNSIGNED_CHAR); }
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);
286 int GetFileDimensionality() { return this->FileDimensionality; }
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);
389 vtkGetMacro(FileLowerLeft, vtkTypeBool);
390 vtkSetMacro(FileLowerLeft, vtkTypeBool);
392
394
397 virtual void ComputeInternalFileName(int slice);
398 vtkGetFilePathMacro(InternalFileName);
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")
448 vtkIdType MemoryBufferLength;
449
450 istream* File;
451 unsigned long DataIncrements[4];
452 int DataExtent[6];
453 vtkTypeBool SwapBytes;
454
455 int FileDimensionality;
456 unsigned long HeaderSize;
457 int DataScalarType;
458 unsigned long ManualHeaderSize;
459
460 double DataSpacing[3];
461 double DataOrigin[3];
462 double DataDirection[9];
463
464 int FileNameSliceOffset;
465 int FileNameSliceSpacing;
466
467 int RequestInformation(vtkInformation* request, vtkInformationVector** inputVector,
468 vtkInformationVector* outputVector) override;
469 virtual void ExecuteInformation();
470 void ExecuteDataWithInformation(vtkDataObject* data, vtkInformation* outInfo) override;
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
Generic algorithm superclass for image algs.
Superclass of binary file readers.
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()
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.
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.
virtual void ComputeInternalFileName(int slice)
Set/Get the internal file name.
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 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()
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 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.
static vtkImageReader2 * New()
virtual void SetDataByteOrderToBigEndian()
These methods should be used instead of the SwapBytes methods.
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
virtual void SetDataScalarTypeToUnsignedInt()
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