VTK  9.1.0
vtkMetaImageReader.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkMetaImageReader.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
69#ifndef vtkMetaImageReader_h
70#define vtkMetaImageReader_h
71
72#include "vtkIOImageModule.h" // For export macro
73#include "vtkImageReader2.h"
74
75namespace vtkmetaio
76{
77class MetaImage;
78} // forward declaration
79
80class VTKIOIMAGE_EXPORT vtkMetaImageReader : public vtkImageReader2
81{
82public:
84 void PrintSelf(ostream& os, vtkIndent indent) override;
85
90
91 const char* GetFileExtensions() override { return ".mhd .mha"; }
92
93 const char* GetDescriptiveName() override { return "MetaIO Library: MetaImage"; }
94
95 // These duplicate functions in vtkImageReader2, vtkMedicalImageReader.
96 double* GetPixelSpacing() { return this->GetDataSpacing(); }
97 int GetWidth() { return (this->GetDataExtent()[1] - this->GetDataExtent()[0] + 1); }
98 int GetHeight() { return (this->GetDataExtent()[3] - this->GetDataExtent()[2] + 1); }
99 double* GetImagePositionPatient() { return this->GetDataOrigin(); }
102 int GetDataByteOrder(void) override;
103
104 vtkGetMacro(RescaleSlope, double);
105 vtkGetMacro(RescaleOffset, double);
106 vtkGetMacro(BitsAllocated, int);
107 vtkGetStringMacro(DistanceUnits);
108 vtkGetStringMacro(AnatomicalOrientation);
109 vtkGetMacro(GantryAngle, double);
110 vtkGetStringMacro(PatientName);
111 vtkGetStringMacro(PatientID);
112 vtkGetStringMacro(Date);
113 vtkGetStringMacro(Series);
114 vtkGetStringMacro(ImageNumber);
115 vtkGetStringMacro(Modality);
116 vtkGetStringMacro(StudyID);
117 vtkGetStringMacro(StudyUID);
118 vtkGetStringMacro(TransferSyntaxUID);
119
124 int CanReadFile(VTK_FILEPATH const char* name) override;
125
126protected:
129
130 // These functions make no sense for this (or most) file readers
131 // and should be hidden from the user...but then the getsettest fails.
132 /*virtual void SetFilePrefix(const char * arg)
133 { vtkImageReader2::SetFilePrefix(arg); }
134 virtual void SetFilePattern(VTK_FILEPATH const char * arg)
135 { vtkImageReader2::SetFilePattern(arg); }
136 virtual void SetDataScalarType(int type)
137 { vtkImageReader2::SetDataScalarType(type); }
138 virtual void SetDataScalarTypeToFloat()
139 { this->SetDataScalarType(VTK_FLOAT); }
140 virtual void SetDataScalarTypeToDouble()
141 { this->SetDataScalarType(VTK_DOUBLE); }
142 virtual void SetDataScalarTypeToInt()
143 { this->SetDataScalarType(VTK_INT); }
144 virtual void SetDataScalarTypeToShort()
145 { this->SetDataScalarType(VTK_SHORT); }
146 virtual void SetDataScalarTypeToUnsignedShort()
147 {this->SetDataScalarType(VTK_UNSIGNED_SHORT);}
148 virtual void SetDataScalarTypeToUnsignedChar()
149 {this->SetDataScalarType(VTK_UNSIGNED_CHAR);}
150 vtkSetMacro(NumberOfScalarComponents, int);
151 vtkSetVector6Macro(DataExtent, int);
152 vtkSetMacro(FileDimensionality, int);
153 vtkSetVector3Macro(DataSpacing, double);
154 vtkSetVector3Macro(DataOrigin, double);
155 vtkSetMacro(HeaderSize, unsigned long);
156 unsigned long GetHeaderSize(unsigned long)
157 { return 0; }
158 virtual void SetDataByteOrderToBigEndian()
159 { this->SetDataByteOrderToBigEndian(); }
160 virtual void SetDataByteOrderToLittleEndian()
161 { this->SetDataByteOrderToBigEndian(); }
162 virtual void SetDataByteOrder(int order)
163 { this->SetDataByteOrder(order); }
164 vtkSetMacro(FileNameSliceOffset,int);
165 vtkSetMacro(FileNameSliceSpacing,int);
166 vtkSetMacro(SwapBytes, int);
167 virtual int OpenFile()
168 { return vtkImageReader2::OpenFile(); }
169 virtual void SeekFile(int i, int j, int k)
170 { vtkImageReader2::SeekFile(i, j, k); }
171 vtkSetMacro(FileLowerLeft, int);
172 virtual void ComputeInternalFileName(int slice)
173 { vtkImageReader2::ComputeInternalFileName(slice); }
174 vtkGetFilePathMacro(InternalFileName);
175 const char * GetDataByteOrderAsString(void)
176 { return vtkImageReader2::GetDataByteOrderAsString(); }
177 unsigned long GetHeaderSize(void)
178 { return vtkImageReader2::GetHeaderSize(); }*/
179
180 void ExecuteInformation() override;
183 vtkInformationVector* outputVector) override;
184
185private:
186 vtkMetaImageReader(const vtkMetaImageReader&) = delete;
187 void operator=(const vtkMetaImageReader&) = delete;
188
189 vtkmetaio::MetaImage* MetaImagePtr;
190
191 double GantryAngle;
192 char PatientName[255];
193 char PatientID[255];
194 char Date[255];
195 char Series[255];
196 char Study[255];
197 char ImageNumber[255];
198 char Modality[255];
199 char StudyID[255];
200 char StudyUID[255];
201 char TransferSyntaxUID[255];
202
203 double RescaleSlope;
204 double RescaleOffset;
205 int BitsAllocated;
206 char DistanceUnits[255];
207 char AnatomicalOrientation[255];
208};
209
210#endif
general representation of visualization data
Definition: vtkDataObject.h:69
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:43
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(void) 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.
@ name
Definition: vtkX3D.h:225
#define VTK_FILEPATH