VTK  9.6.1
vtkMetaImageReader.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
52
53#ifndef vtkMetaImageReader_h
54#define vtkMetaImageReader_h
55
56#include "vtkIOImageModule.h" // For export macro
57#include "vtkImageReader2.h"
58
59namespace vtkmetaio
60{
61class MetaImage;
62} // forward declaration
63
64VTK_ABI_NAMESPACE_BEGIN
65
66class VTKIOIMAGE_EXPORT vtkMetaImageReader : public vtkImageReader2
67{
68public:
70 void PrintSelf(ostream& os, vtkIndent indent) override;
71
76
77 const char* GetFileExtensions() override { return ".mhd .mha"; }
78
79 const char* GetDescriptiveName() override { return "MetaIO Library: MetaImage"; }
80
81 // These duplicate functions in vtkImageReader2, vtkMedicalImageReader.
82 double* GetPixelSpacing() { return this->GetDataSpacing(); }
83 int GetWidth() { return (this->GetDataExtent()[1] - this->GetDataExtent()[0] + 1); }
84 int GetHeight() { return (this->GetDataExtent()[3] - this->GetDataExtent()[2] + 1); }
85 double* GetImagePositionPatient() { return this->GetDataOrigin(); }
87 int GetPixelRepresentation() { return this->GetDataScalarType(); }
88 int GetDataByteOrder() override;
89
90 vtkGetMacro(RescaleSlope, double);
91 vtkGetMacro(RescaleOffset, double);
92 vtkGetMacro(BitsAllocated, int);
93 vtkGetStringMacro(DistanceUnits);
94 vtkGetStringMacro(AnatomicalOrientation);
95 vtkGetMacro(GantryAngle, double);
96 vtkGetStringMacro(PatientName);
97 vtkGetStringMacro(PatientID);
98 vtkGetStringMacro(Date);
99 vtkGetStringMacro(Series);
100 vtkGetStringMacro(ImageNumber);
101 vtkGetStringMacro(Modality);
102 vtkGetStringMacro(StudyID);
103 vtkGetStringMacro(StudyUID);
104 vtkGetStringMacro(TransferSyntaxUID);
105
110 int CanReadFile(VTK_FILEPATH const char* name) override;
111
112protected:
115
116 // These functions make no sense for this (or most) file readers
117 // and should be hidden from the user...but then the getsettest fails.
118 /*virtual void SetFilePrefix(const char * arg)
119 { vtkImageReader2::SetFilePrefix(arg); }
120 virtual void SetFilePattern(VTK_FILEPATH const char * arg)
121 { vtkImageReader2::SetFilePattern(arg); }
122 virtual void SetDataScalarType(int type)
123 { vtkImageReader2::SetDataScalarType(type); }
124 virtual void SetDataScalarTypeToFloat()
125 { this->SetDataScalarType(VTK_FLOAT); }
126 virtual void SetDataScalarTypeToDouble()
127 { this->SetDataScalarType(VTK_DOUBLE); }
128 virtual void SetDataScalarTypeToInt()
129 { this->SetDataScalarType(VTK_INT); }
130 virtual void SetDataScalarTypeToShort()
131 { this->SetDataScalarType(VTK_SHORT); }
132 virtual void SetDataScalarTypeToUnsignedShort()
133 {this->SetDataScalarType(VTK_UNSIGNED_SHORT);}
134 virtual void SetDataScalarTypeToUnsignedChar()
135 {this->SetDataScalarType(VTK_UNSIGNED_CHAR);}
136 vtkSetMacro(NumberOfScalarComponents, int);
137 vtkSetVector6Macro(DataExtent, int);
138 vtkSetMacro(FileDimensionality, int);
139 vtkSetVector3Macro(DataSpacing, double);
140 vtkSetVector3Macro(DataOrigin, double);
141 vtkSetMacro(HeaderSize, unsigned long);
142 unsigned long GetHeaderSize(unsigned long)
143 { return 0; }
144 virtual void SetDataByteOrderToBigEndian()
145 { this->SetDataByteOrderToBigEndian(); }
146 virtual void SetDataByteOrderToLittleEndian()
147 { this->SetDataByteOrderToBigEndian(); }
148 virtual void SetDataByteOrder(int order)
149 { this->SetDataByteOrder(order); }
150 vtkSetMacro(FileNameSliceOffset,int);
151 vtkSetMacro(FileNameSliceSpacing,int);
152 vtkSetMacro(SwapBytes, int);
153 virtual int OpenFile()
154 { return vtkImageReader2::OpenFile(); }
155 virtual void SeekFile(int i, int j, int k)
156 { vtkImageReader2::SeekFile(i, j, k); }
157 vtkSetMacro(FileLowerLeft, int);
158 virtual void ComputeInternalFileName(int slice)
159 { vtkImageReader2::ComputeInternalFileName(slice); }
160 vtkGetFilePathMacro(InternalFileName);
161 const char * GetDataByteOrderAsString()
162 { return vtkImageReader2::GetDataByteOrderAsString(); }
163 unsigned long GetHeaderSize()
164 { return vtkImageReader2::GetHeaderSize(); }*/
165
166 void ExecuteInformation() override;
169 vtkInformationVector* outputVector) override;
170
171private:
172 vtkMetaImageReader(const vtkMetaImageReader&) = delete;
173 void operator=(const vtkMetaImageReader&) = delete;
174
175 vtkmetaio::MetaImage* MetaImagePtr;
176
177 double GantryAngle;
178 char PatientName[255];
179 char PatientID[255];
180 char Date[255];
181 char Series[255];
182 char Study[255];
183 char ImageNumber[255];
184 char Modality[255];
185 char StudyID[255];
186 char StudyUID[255];
187 char TransferSyntaxUID[255];
188
189 double RescaleSlope;
190 double RescaleOffset;
191 int BitsAllocated;
192 char DistanceUnits[255];
193 char AnatomicalOrientation[255];
194};
195
196VTK_ABI_NAMESPACE_END
197#endif
general representation of visualization data
virtual int GetNumberOfScalarComponents()
Set/Get the number of scalar components.
virtual int * GetDataExtent()
Get/Set the extent of the data on disk.
virtual int GetDataScalarType()
Get the file format.
virtual double * GetDataSpacing()
Set/Get the spacing of the data in the file.
virtual double * GetDataOrigin()
Set/Get the origin of the data (location of first pixel in the file).
vtkImageReader2()
Return a descriptive name for the file format that might be useful in a GUI.
a simple class to control print indentation
Definition vtkIndent.h:29
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
double * GetImagePositionPatient()
static vtkMetaImageReader * New()
Construct object with FlipNormals turned off and Normals set to true.
int GetDataByteOrder() override
These methods should be used instead of the SwapBytes methods.
void ExecuteInformation() override
~vtkMetaImageReader() override
const char * GetFileExtensions() override
Get the file extensions for this format.
int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
Subclasses can reimplement this method to collect information from their inputs and set information f...
void ExecuteDataWithInformation(vtkDataObject *out, vtkInformation *outInfo) override
This is a convenience method that is implemented in many subclasses instead of RequestData.
int CanReadFile(const char *name) override
Test whether the file with the given name can be read by this reader.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
const char * GetDescriptiveName() override
Return a descriptive name for the file format that might be useful in a GUI.
#define VTK_FILEPATH