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=========================================================================*/
60#ifndef vtkMetaImageReader_h
61#define vtkMetaImageReader_h
62
63#include "vtkIOImageModule.h" // For export macro
64#include "vtkImageReader2.h"
65
66namespace vtkmetaio
67{
68class MetaImage;
69} // forward declaration
70
71class VTKIOIMAGE_EXPORT vtkMetaImageReader : public vtkImageReader2
72{
73public:
75 void PrintSelf(ostream& os, vtkIndent indent) override;
76
81
82 const char* GetFileExtensions() override { return ".mhd .mha"; }
83
84 const char* GetDescriptiveName() override { return "MetaIO Library: MetaImage"; }
85
86 // These duplicate functions in vtkImageReader2, vtkMedicalImageReader.
87 double* GetPixelSpacing() { return this->GetDataSpacing(); }
88 int GetWidth() { return (this->GetDataExtent()[1] - this->GetDataExtent()[0] + 1); }
89 int GetHeight() { return (this->GetDataExtent()[3] - this->GetDataExtent()[2] + 1); }
90 double* GetImagePositionPatient() { return this->GetDataOrigin(); }
92 int GetPixelRepresentation() { return this->GetDataScalarType(); }
93 int GetDataByteOrder(void) override;
94
95 vtkGetMacro(RescaleSlope, double);
96 vtkGetMacro(RescaleOffset, double);
97 vtkGetMacro(BitsAllocated, int);
98 vtkGetStringMacro(DistanceUnits);
99 vtkGetStringMacro(AnatomicalOrientation);
100 vtkGetMacro(GantryAngle, double);
101 vtkGetStringMacro(PatientName);
102 vtkGetStringMacro(PatientID);
103 vtkGetStringMacro(Date);
104 vtkGetStringMacro(Series);
105 vtkGetStringMacro(ImageNumber);
106 vtkGetStringMacro(Modality);
107 vtkGetStringMacro(StudyID);
108 vtkGetStringMacro(StudyUID);
109 vtkGetStringMacro(TransferSyntaxUID);
110
115 int CanReadFile(VTK_FILEPATH const char* name) override;
116
117protected:
120
121 // These functions make no sense for this (or most) file readers
122 // and should be hidden from the user...but then the getsettest fails.
123 /*virtual void SetFilePrefix(const char * arg)
124 { vtkImageReader2::SetFilePrefix(arg); }
125 virtual void SetFilePattern(VTK_FILEPATH const char * arg)
126 { vtkImageReader2::SetFilePattern(arg); }
127 virtual void SetDataScalarType(int type)
128 { vtkImageReader2::SetDataScalarType(type); }
129 virtual void SetDataScalarTypeToFloat()
130 { this->SetDataScalarType(VTK_FLOAT); }
131 virtual void SetDataScalarTypeToDouble()
132 { this->SetDataScalarType(VTK_DOUBLE); }
133 virtual void SetDataScalarTypeToInt()
134 { this->SetDataScalarType(VTK_INT); }
135 virtual void SetDataScalarTypeToShort()
136 { this->SetDataScalarType(VTK_SHORT); }
137 virtual void SetDataScalarTypeToUnsignedShort()
138 {this->SetDataScalarType(VTK_UNSIGNED_SHORT);}
139 virtual void SetDataScalarTypeToUnsignedChar()
140 {this->SetDataScalarType(VTK_UNSIGNED_CHAR);}
141 vtkSetMacro(NumberOfScalarComponents, int);
142 vtkSetVector6Macro(DataExtent, int);
143 vtkSetMacro(FileDimensionality, int);
144 vtkSetVector3Macro(DataSpacing, double);
145 vtkSetVector3Macro(DataOrigin, double);
146 vtkSetMacro(HeaderSize, unsigned long);
147 unsigned long GetHeaderSize(unsigned long)
148 { return 0; }
149 virtual void SetDataByteOrderToBigEndian()
150 { this->SetDataByteOrderToBigEndian(); }
151 virtual void SetDataByteOrderToLittleEndian()
152 { this->SetDataByteOrderToBigEndian(); }
153 virtual void SetDataByteOrder(int order)
154 { this->SetDataByteOrder(order); }
155 vtkSetMacro(FileNameSliceOffset,int);
156 vtkSetMacro(FileNameSliceSpacing,int);
157 vtkSetMacro(SwapBytes, int);
158 virtual int OpenFile()
159 { return vtkImageReader2::OpenFile(); }
160 virtual void SeekFile(int i, int j, int k)
161 { vtkImageReader2::SeekFile(i, j, k); }
162 vtkSetMacro(FileLowerLeft, int);
163 virtual void ComputeInternalFileName(int slice)
164 { vtkImageReader2::ComputeInternalFileName(slice); }
165 vtkGetFilePathMacro(InternalFileName);
166 const char * GetDataByteOrderAsString(void)
167 { return vtkImageReader2::GetDataByteOrderAsString(); }
168 unsigned long GetHeaderSize(void)
169 { return vtkImageReader2::GetHeaderSize(); }*/
170
171 void ExecuteInformation() override;
174 vtkInformationVector* outputVector) override;
175
176private:
177 vtkMetaImageReader(const vtkMetaImageReader&) = delete;
178 void operator=(const vtkMetaImageReader&) = delete;
179
180 vtkmetaio::MetaImage* MetaImagePtr;
181
182 double GantryAngle;
183 char PatientName[255];
184 char PatientID[255];
185 char Date[255];
186 char Series[255];
187 char Study[255];
188 char ImageNumber[255];
189 char Modality[255];
190 char StudyID[255];
191 char StudyUID[255];
192 char TransferSyntaxUID[255];
193
194 double RescaleSlope;
195 double RescaleOffset;
196 int BitsAllocated;
197 char DistanceUnits[255];
198 char AnatomicalOrientation[255];
199};
200
201#endif
general representation of visualization data
Definition: vtkDataObject.h:60
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:34
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