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=========================================================================*/
169#ifndef vtkMetaImageReader_h
170#define vtkMetaImageReader_h
171
172#include "vtkIOImageModule.h" // For export macro
173#include "vtkImageReader2.h"
174
175namespace vtkmetaio
176{
177class MetaImage;
178} // forward declaration
179
180class VTKIOIMAGE_EXPORT vtkMetaImageReader : public vtkImageReader2
181{
182public:
184 void PrintSelf(ostream& os, vtkIndent indent) override;
185
190
191 const char* GetFileExtensions() override { return ".mhd .mha"; }
192
193 const char* GetDescriptiveName() override { return "MetaIO Library: MetaImage"; }
194
195 // These duplicate functions in vtkImageReader2, vtkMedicalImageReader.
196 double* GetPixelSpacing() { return this->GetDataSpacing(); }
197 int GetWidth() { return (this->GetDataExtent()[1] - this->GetDataExtent()[0] + 1); }
198 int GetHeight() { return (this->GetDataExtent()[3] - this->GetDataExtent()[2] + 1); }
199 double* GetImagePositionPatient() { return this->GetDataOrigin(); }
202 int GetDataByteOrder(void) override;
203
204 vtkGetMacro(RescaleSlope, double);
205 vtkGetMacro(RescaleOffset, double);
206 vtkGetMacro(BitsAllocated, int);
207 vtkGetStringMacro(DistanceUnits);
208 vtkGetStringMacro(AnatomicalOrientation);
209 vtkGetMacro(GantryAngle, double);
210 vtkGetStringMacro(PatientName);
211 vtkGetStringMacro(PatientID);
212 vtkGetStringMacro(Date);
213 vtkGetStringMacro(Series);
214 vtkGetStringMacro(ImageNumber);
215 vtkGetStringMacro(Modality);
216 vtkGetStringMacro(StudyID);
217 vtkGetStringMacro(StudyUID);
218 vtkGetStringMacro(TransferSyntaxUID);
219
224 int CanReadFile(VTK_FILEPATH const char* name) override;
225
226protected:
229
230 // These functions make no sense for this (or most) file readers
231 // and should be hidden from the user...but then the getsettest fails.
232 /*virtual void SetFilePrefix(const char * arg)
233 { vtkImageReader2::SetFilePrefix(arg); }
234 virtual void SetFilePattern(VTK_FILEPATH const char * arg)
235 { vtkImageReader2::SetFilePattern(arg); }
236 virtual void SetDataScalarType(int type)
237 { vtkImageReader2::SetDataScalarType(type); }
238 virtual void SetDataScalarTypeToFloat()
239 { this->SetDataScalarType(VTK_FLOAT); }
240 virtual void SetDataScalarTypeToDouble()
241 { this->SetDataScalarType(VTK_DOUBLE); }
242 virtual void SetDataScalarTypeToInt()
243 { this->SetDataScalarType(VTK_INT); }
244 virtual void SetDataScalarTypeToShort()
245 { this->SetDataScalarType(VTK_SHORT); }
246 virtual void SetDataScalarTypeToUnsignedShort()
247 {this->SetDataScalarType(VTK_UNSIGNED_SHORT);}
248 virtual void SetDataScalarTypeToUnsignedChar()
249 {this->SetDataScalarType(VTK_UNSIGNED_CHAR);}
250 vtkSetMacro(NumberOfScalarComponents, int);
251 vtkSetVector6Macro(DataExtent, int);
252 vtkSetMacro(FileDimensionality, int);
253 vtkSetVector3Macro(DataSpacing, double);
254 vtkSetVector3Macro(DataOrigin, double);
255 vtkSetMacro(HeaderSize, unsigned long);
256 unsigned long GetHeaderSize(unsigned long)
257 { return 0; }
258 virtual void SetDataByteOrderToBigEndian()
259 { this->SetDataByteOrderToBigEndian(); }
260 virtual void SetDataByteOrderToLittleEndian()
261 { this->SetDataByteOrderToBigEndian(); }
262 virtual void SetDataByteOrder(int order)
263 { this->SetDataByteOrder(order); }
264 vtkSetMacro(FileNameSliceOffset,int);
265 vtkSetMacro(FileNameSliceSpacing,int);
266 vtkSetMacro(SwapBytes, int);
267 virtual int OpenFile()
268 { return vtkImageReader2::OpenFile(); }
269 virtual void SeekFile(int i, int j, int k)
270 { vtkImageReader2::SeekFile(i, j, k); }
271 vtkSetMacro(FileLowerLeft, int);
272 virtual void ComputeInternalFileName(int slice)
273 { vtkImageReader2::ComputeInternalFileName(slice); }
274 vtkGetFilePathMacro(InternalFileName);
275 const char * GetDataByteOrderAsString(void)
276 { return vtkImageReader2::GetDataByteOrderAsString(); }
277 unsigned long GetHeaderSize(void)
278 { return vtkImageReader2::GetHeaderSize(); }*/
279
280 void ExecuteInformation() override;
283 vtkInformationVector* outputVector) override;
284
285private:
286 vtkMetaImageReader(const vtkMetaImageReader&) = delete;
287 void operator=(const vtkMetaImageReader&) = delete;
288
289 vtkmetaio::MetaImage* MetaImagePtr;
290
291 double GantryAngle;
292 char PatientName[255];
293 char PatientID[255];
294 char Date[255];
295 char Series[255];
296 char Study[255];
297 char ImageNumber[255];
298 char Modality[255];
299 char StudyID[255];
300 char StudyUID[255];
301 char TransferSyntaxUID[255];
302
303 double RescaleSlope;
304 double RescaleOffset;
305 int BitsAllocated;
306 char DistanceUnits[255];
307 char AnatomicalOrientation[255];
308};
309
310#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:113
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