VTK  9.4.20241218
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
163#ifndef vtkMetaImageReader_h
164#define vtkMetaImageReader_h
165
166#include "vtkIOImageModule.h" // For export macro
167#include "vtkImageReader2.h"
168
169namespace vtkmetaio
170{
171class MetaImage;
172} // forward declaration
173
174VTK_ABI_NAMESPACE_BEGIN
175
176class VTKIOIMAGE_EXPORT vtkMetaImageReader : public vtkImageReader2
177{
178public:
180 void PrintSelf(ostream& os, vtkIndent indent) override;
181
186
187 const char* GetFileExtensions() override { return ".mhd .mha"; }
188
189 const char* GetDescriptiveName() override { return "MetaIO Library: MetaImage"; }
190
191 // These duplicate functions in vtkImageReader2, vtkMedicalImageReader.
192 double* GetPixelSpacing() { return this->GetDataSpacing(); }
193 int GetWidth() { return (this->GetDataExtent()[1] - this->GetDataExtent()[0] + 1); }
194 int GetHeight() { return (this->GetDataExtent()[3] - this->GetDataExtent()[2] + 1); }
195 double* GetImagePositionPatient() { return this->GetDataOrigin(); }
198 int GetDataByteOrder() override;
199
200 vtkGetMacro(RescaleSlope, double);
201 vtkGetMacro(RescaleOffset, double);
202 vtkGetMacro(BitsAllocated, int);
203 vtkGetStringMacro(DistanceUnits);
204 vtkGetStringMacro(AnatomicalOrientation);
205 vtkGetMacro(GantryAngle, double);
206 vtkGetStringMacro(PatientName);
207 vtkGetStringMacro(PatientID);
208 vtkGetStringMacro(Date);
209 vtkGetStringMacro(Series);
210 vtkGetStringMacro(ImageNumber);
211 vtkGetStringMacro(Modality);
212 vtkGetStringMacro(StudyID);
213 vtkGetStringMacro(StudyUID);
214 vtkGetStringMacro(TransferSyntaxUID);
215
220 int CanReadFile(VTK_FILEPATH const char* name) override;
221
222protected:
225
226 // These functions make no sense for this (or most) file readers
227 // and should be hidden from the user...but then the getsettest fails.
228 /*virtual void SetFilePrefix(const char * arg)
229 { vtkImageReader2::SetFilePrefix(arg); }
230 virtual void SetFilePattern(VTK_FILEPATH const char * arg)
231 { vtkImageReader2::SetFilePattern(arg); }
232 virtual void SetDataScalarType(int type)
233 { vtkImageReader2::SetDataScalarType(type); }
234 virtual void SetDataScalarTypeToFloat()
235 { this->SetDataScalarType(VTK_FLOAT); }
236 virtual void SetDataScalarTypeToDouble()
237 { this->SetDataScalarType(VTK_DOUBLE); }
238 virtual void SetDataScalarTypeToInt()
239 { this->SetDataScalarType(VTK_INT); }
240 virtual void SetDataScalarTypeToShort()
241 { this->SetDataScalarType(VTK_SHORT); }
242 virtual void SetDataScalarTypeToUnsignedShort()
243 {this->SetDataScalarType(VTK_UNSIGNED_SHORT);}
244 virtual void SetDataScalarTypeToUnsignedChar()
245 {this->SetDataScalarType(VTK_UNSIGNED_CHAR);}
246 vtkSetMacro(NumberOfScalarComponents, int);
247 vtkSetVector6Macro(DataExtent, int);
248 vtkSetMacro(FileDimensionality, int);
249 vtkSetVector3Macro(DataSpacing, double);
250 vtkSetVector3Macro(DataOrigin, double);
251 vtkSetMacro(HeaderSize, unsigned long);
252 unsigned long GetHeaderSize(unsigned long)
253 { return 0; }
254 virtual void SetDataByteOrderToBigEndian()
255 { this->SetDataByteOrderToBigEndian(); }
256 virtual void SetDataByteOrderToLittleEndian()
257 { this->SetDataByteOrderToBigEndian(); }
258 virtual void SetDataByteOrder(int order)
259 { this->SetDataByteOrder(order); }
260 vtkSetMacro(FileNameSliceOffset,int);
261 vtkSetMacro(FileNameSliceSpacing,int);
262 vtkSetMacro(SwapBytes, int);
263 virtual int OpenFile()
264 { return vtkImageReader2::OpenFile(); }
265 virtual void SeekFile(int i, int j, int k)
266 { vtkImageReader2::SeekFile(i, j, k); }
267 vtkSetMacro(FileLowerLeft, int);
268 virtual void ComputeInternalFileName(int slice)
269 { vtkImageReader2::ComputeInternalFileName(slice); }
270 vtkGetFilePathMacro(InternalFileName);
271 const char * GetDataByteOrderAsString()
272 { return vtkImageReader2::GetDataByteOrderAsString(); }
273 unsigned long GetHeaderSize()
274 { return vtkImageReader2::GetHeaderSize(); }*/
275
276 void ExecuteInformation() override;
279 vtkInformationVector* outputVector) override;
280
281private:
282 vtkMetaImageReader(const vtkMetaImageReader&) = delete;
283 void operator=(const vtkMetaImageReader&) = delete;
284
285 vtkmetaio::MetaImage* MetaImagePtr;
286
287 double GantryAngle;
288 char PatientName[255];
289 char PatientID[255];
290 char Date[255];
291 char Series[255];
292 char Study[255];
293 char ImageNumber[255];
294 char Modality[255];
295 char StudyID[255];
296 char StudyUID[255];
297 char TransferSyntaxUID[255];
298
299 double RescaleSlope;
300 double RescaleOffset;
301 int BitsAllocated;
302 char DistanceUnits[255];
303 char AnatomicalOrientation[255];
304};
305
306VTK_ABI_NAMESPACE_END
307#endif
general representation of visualization data
Superclass of binary file readers.
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).
a simple class to control print indentation
Definition vtkIndent.h:108
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
read binary UNC meta image data
double * GetImagePositionPatient()
int CanReadFile(VTK_FILEPATH const char *name) override
Test whether the file with the given name can be read by this reader.
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.
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