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