VTK
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 =========================================================================*/
66 #ifndef vtkMetaImageReader_h
67 #define vtkMetaImageReader_h
68 
69 #include "vtkIOImageModule.h" // For export macro
70 #include "vtkImageReader2.h"
71 
72 namespace vtkmetaio { class MetaImage; } // forward declaration
73 
74 class VTKIOIMAGE_EXPORT vtkMetaImageReader : public vtkImageReader2
75 {
76 public:
78  void PrintSelf(ostream& os, vtkIndent indent) override;
79 
83  static vtkMetaImageReader *New();
84 
85  const char * GetFileExtensions() override
86  { return ".mhd .mha"; }
87 
88  const char * GetDescriptiveName() override
89  { return "MetaIO Library: MetaImage"; }
90 
91  // These duplicate functions in vtkImageReader2, vtkMedicalImageReader.
92  double * GetPixelSpacing()
93  { return this->GetDataSpacing(); }
94  int GetWidth()
95  { return (this->GetDataExtent()[1] - this->GetDataExtent()[0] + 1); }
96  int GetHeight()
97  { return (this->GetDataExtent()[3] - this->GetDataExtent()[2] + 1); }
99  { return this->GetDataOrigin(); }
101  { return this->GetNumberOfScalarComponents(); }
103  { return this->GetDataScalarType(); }
104  int GetDataByteOrder(void) override;
105 
106  vtkGetMacro(RescaleSlope, double);
107  vtkGetMacro(RescaleOffset, double);
108  vtkGetMacro(BitsAllocated, int);
109  vtkGetStringMacro(DistanceUnits);
110  vtkGetStringMacro(AnatomicalOrientation);
111  vtkGetMacro(GantryAngle, double);
112  vtkGetStringMacro(PatientName);
113  vtkGetStringMacro(PatientID);
114  vtkGetStringMacro(Date);
115  vtkGetStringMacro(Series);
116  vtkGetStringMacro(ImageNumber);
117  vtkGetStringMacro(Modality);
118  vtkGetStringMacro(StudyID);
119  vtkGetStringMacro(StudyUID);
120  vtkGetStringMacro(TransferSyntaxUID);
121 
126  int CanReadFile(const char* name) override;
127 
128 protected:
130  ~vtkMetaImageReader() override;
131 
132  // These functions make no sense for this (or most) file readers
133  // and should be hidden from the user...but then the getsettest fails.
134  /*virtual void SetFilePrefix(const char * arg)
135  { vtkImageReader2::SetFilePrefix(arg); }
136  virtual void SetFilePattern(const char * arg)
137  { vtkImageReader2::SetFilePattern(arg); }
138  virtual void SetDataScalarType(int type)
139  { vtkImageReader2::SetDataScalarType(type); }
140  virtual void SetDataScalarTypeToFloat()
141  { this->SetDataScalarType(VTK_FLOAT); }
142  virtual void SetDataScalarTypeToDouble()
143  { this->SetDataScalarType(VTK_DOUBLE); }
144  virtual void SetDataScalarTypeToInt()
145  { this->SetDataScalarType(VTK_INT); }
146  virtual void SetDataScalarTypeToShort()
147  { this->SetDataScalarType(VTK_SHORT); }
148  virtual void SetDataScalarTypeToUnsignedShort()
149  {this->SetDataScalarType(VTK_UNSIGNED_SHORT);}
150  virtual void SetDataScalarTypeToUnsignedChar()
151  {this->SetDataScalarType(VTK_UNSIGNED_CHAR);}
152  vtkSetMacro(NumberOfScalarComponents, int);
153  vtkSetVector6Macro(DataExtent, int);
154  vtkSetMacro(FileDimensionality, int);
155  vtkSetVector3Macro(DataSpacing, double);
156  vtkSetVector3Macro(DataOrigin, double);
157  vtkSetMacro(HeaderSize, unsigned long);
158  unsigned long GetHeaderSize(unsigned long)
159  { return 0; }
160  virtual void SetDataByteOrderToBigEndian()
161  { this->SetDataByteOrderToBigEndian(); }
162  virtual void SetDataByteOrderToLittleEndian()
163  { this->SetDataByteOrderToBigEndian(); }
164  virtual void SetDataByteOrder(int order)
165  { this->SetDataByteOrder(order); }
166  vtkSetMacro(FileNameSliceOffset,int);
167  vtkSetMacro(FileNameSliceSpacing,int);
168  vtkSetMacro(SwapBytes, int);
169  virtual int OpenFile()
170  { return vtkImageReader2::OpenFile(); }
171  virtual void SeekFile(int i, int j, int k)
172  { vtkImageReader2::SeekFile(i, j, k); }
173  vtkSetMacro(FileLowerLeft, int);
174  virtual void ComputeInternalFileName(int slice)
175  { vtkImageReader2::ComputeInternalFileName(slice); }
176  vtkGetStringMacro(InternalFileName)
177  const char * GetDataByteOrderAsString(void)
178  { return vtkImageReader2::GetDataByteOrderAsString(); }
179  unsigned long GetHeaderSize(void)
180  { return vtkImageReader2::GetHeaderSize(); }*/
181 
182  void ExecuteInformation() override;
183  void ExecuteDataWithInformation(vtkDataObject *out, vtkInformation *outInfo) override;
184  int RequestInformation(vtkInformation * request,
185  vtkInformationVector ** inputVector,
186  vtkInformationVector * outputVector) override;
187 
188 private:
189  vtkMetaImageReader(const vtkMetaImageReader&) = delete;
190  void operator=(const vtkMetaImageReader&) = delete;
191 
192  vtkmetaio::MetaImage *MetaImagePtr;
193 
194  double GantryAngle;
195  char PatientName[255];
196  char PatientID[255];
197  char Date[255];
198  char Series[255];
199  char Study[255];
200  char ImageNumber[255];
201  char Modality[255];
202  char StudyID[255];
203  char StudyUID[255];
204  char TransferSyntaxUID[255];
205 
206  double RescaleSlope;
207  double RescaleOffset;
208  int BitsAllocated;
209  char DistanceUnits[255];
210  char AnatomicalOrientation[255];
211 };
212 
213 #endif
const char * GetFileExtensions() override
Get the file extensions for this format.
Store vtkAlgorithm input/output information.
double * GetImagePositionPatient()
const char * GetDescriptiveName() override
Return a descriptive name for the file format that might be useful in a GUI.
a simple class to control print indentation
Definition: vtkIndent.h:39
read binary UNC meta image data
Superclass of binary file readers.
Store zero or more vtkInformation instances.
general representation of visualization data
Definition: vtkDataObject.h:64