VTK  9.2.6
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=========================================================================*/
75#ifndef vtkMetaImageReader_h
76#define vtkMetaImageReader_h
77
78#include "vtkIOImageModule.h" // For export macro
79#include "vtkImageReader2.h"
80
81namespace vtkmetaio
82{
83class MetaImage;
84} // forward declaration
85
86class VTKIOIMAGE_EXPORT vtkMetaImageReader : public vtkImageReader2
87{
88public:
90 void PrintSelf(ostream& os, vtkIndent indent) override;
91
96
97 const char* GetFileExtensions() override { return ".mhd .mha"; }
98
99 const char* GetDescriptiveName() override { return "MetaIO Library: MetaImage"; }
100
101 // These duplicate functions in vtkImageReader2, vtkMedicalImageReader.
102 double* GetPixelSpacing() { return this->GetDataSpacing(); }
103 int GetWidth() { return (this->GetDataExtent()[1] - this->GetDataExtent()[0] + 1); }
104 int GetHeight() { return (this->GetDataExtent()[3] - this->GetDataExtent()[2] + 1); }
105 double* GetImagePositionPatient() { return this->GetDataOrigin(); }
108 int GetDataByteOrder(void) override;
109
110 vtkGetMacro(RescaleSlope, double);
111 vtkGetMacro(RescaleOffset, double);
112 vtkGetMacro(BitsAllocated, int);
113 vtkGetStringMacro(DistanceUnits);
114 vtkGetStringMacro(AnatomicalOrientation);
115 vtkGetMacro(GantryAngle, double);
116 vtkGetStringMacro(PatientName);
117 vtkGetStringMacro(PatientID);
118 vtkGetStringMacro(Date);
119 vtkGetStringMacro(Series);
120 vtkGetStringMacro(ImageNumber);
121 vtkGetStringMacro(Modality);
122 vtkGetStringMacro(StudyID);
123 vtkGetStringMacro(StudyUID);
124 vtkGetStringMacro(TransferSyntaxUID);
125
130 int CanReadFile(VTK_FILEPATH const char* name) override;
131
132protected:
135
136 // These functions make no sense for this (or most) file readers
137 // and should be hidden from the user...but then the getsettest fails.
138 /*virtual void SetFilePrefix(const char * arg)
139 { vtkImageReader2::SetFilePrefix(arg); }
140 virtual void SetFilePattern(VTK_FILEPATH const char * arg)
141 { vtkImageReader2::SetFilePattern(arg); }
142 virtual void SetDataScalarType(int type)
143 { vtkImageReader2::SetDataScalarType(type); }
144 virtual void SetDataScalarTypeToFloat()
145 { this->SetDataScalarType(VTK_FLOAT); }
146 virtual void SetDataScalarTypeToDouble()
147 { this->SetDataScalarType(VTK_DOUBLE); }
148 virtual void SetDataScalarTypeToInt()
149 { this->SetDataScalarType(VTK_INT); }
150 virtual void SetDataScalarTypeToShort()
151 { this->SetDataScalarType(VTK_SHORT); }
152 virtual void SetDataScalarTypeToUnsignedShort()
153 {this->SetDataScalarType(VTK_UNSIGNED_SHORT);}
154 virtual void SetDataScalarTypeToUnsignedChar()
155 {this->SetDataScalarType(VTK_UNSIGNED_CHAR);}
156 vtkSetMacro(NumberOfScalarComponents, int);
157 vtkSetVector6Macro(DataExtent, int);
158 vtkSetMacro(FileDimensionality, int);
159 vtkSetVector3Macro(DataSpacing, double);
160 vtkSetVector3Macro(DataOrigin, double);
161 vtkSetMacro(HeaderSize, unsigned long);
162 unsigned long GetHeaderSize(unsigned long)
163 { return 0; }
164 virtual void SetDataByteOrderToBigEndian()
165 { this->SetDataByteOrderToBigEndian(); }
166 virtual void SetDataByteOrderToLittleEndian()
167 { this->SetDataByteOrderToBigEndian(); }
168 virtual void SetDataByteOrder(int order)
169 { this->SetDataByteOrder(order); }
170 vtkSetMacro(FileNameSliceOffset,int);
171 vtkSetMacro(FileNameSliceSpacing,int);
172 vtkSetMacro(SwapBytes, int);
173 virtual int OpenFile()
174 { return vtkImageReader2::OpenFile(); }
175 virtual void SeekFile(int i, int j, int k)
176 { vtkImageReader2::SeekFile(i, j, k); }
177 vtkSetMacro(FileLowerLeft, int);
178 virtual void ComputeInternalFileName(int slice)
179 { vtkImageReader2::ComputeInternalFileName(slice); }
180 vtkGetFilePathMacro(InternalFileName);
181 const char * GetDataByteOrderAsString(void)
182 { return vtkImageReader2::GetDataByteOrderAsString(); }
183 unsigned long GetHeaderSize(void)
184 { return vtkImageReader2::GetHeaderSize(); }*/
185
186 void ExecuteInformation() override;
189 vtkInformationVector* outputVector) override;
190
191private:
192 vtkMetaImageReader(const vtkMetaImageReader&) = delete;
193 void operator=(const vtkMetaImageReader&) = delete;
194
195 vtkmetaio::MetaImage* MetaImagePtr;
196
197 double GantryAngle;
198 char PatientName[255];
199 char PatientID[255];
200 char Date[255];
201 char Series[255];
202 char Study[255];
203 char ImageNumber[255];
204 char Modality[255];
205 char StudyID[255];
206 char StudyUID[255];
207 char TransferSyntaxUID[255];
208
209 double RescaleSlope;
210 double RescaleOffset;
211 int BitsAllocated;
212 char DistanceUnits[255];
213 char AnatomicalOrientation[255];
214};
215
216#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:49
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.
#define VTK_FILEPATH