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);
79 
83  static vtkMetaImageReader *New();
84 
85  virtual const char * GetFileExtensions()
86  { return ".mhd .mha"; }
87 
88  virtual const char * GetDescriptiveName()
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);
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  virtual int CanReadFile(const char* name);
127 
128 protected:
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();
184  virtual int RequestInformation(vtkInformation * request,
185  vtkInformationVector ** inputVector,
186  vtkInformationVector * outputVector);
187 
188 private:
189  vtkMetaImageReader(const vtkMetaImageReader&) VTK_DELETE_FUNCTION;
190  void operator=(const vtkMetaImageReader&) VTK_DELETE_FUNCTION;
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
virtual int * GetDataExtent()
Get/Set the extent of the data on disk.
static vtkImageReader2 * New()
Store vtkAlgorithm input/output information.
double * GetImagePositionPatient()
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
Subclasses can reimplement this method to collect information from their inputs and set information f...
virtual int GetNumberOfScalarComponents()
Set/Get the number of scalar components.
virtual const char * GetDescriptiveName()
Return a descriptive name for the file format that might be useful in a GUI.
virtual int GetDataByteOrder()
These methods should be used instead of the SwapBytes methods.
virtual double * GetDataOrigin()
Set/Get the origin of the data (location of first pixel in the file).
virtual int CanReadFile(const char *vtkNotUsed(fname))
Return non zero if the reader can read the given file name.
virtual double * GetDataSpacing()
Set/Get the spacing of the data in the file.
a simple class to control print indentation
Definition: vtkIndent.h:39
virtual int GetDataScalarType()
Get the file format.
virtual void ExecuteInformation()
read binary UNC meta image data
vtkGetStringMacro(ExtensionsString)
Returns a string listing all available extensions.
Superclass of binary file readers.
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
Store zero or more vtkInformation instances.
virtual const char * GetFileExtensions()
Get the file extensions for this format.
virtual void ExecuteDataWithInformation(vtkDataObject *data, vtkInformation *outInfo)
This is a convenience method that is implemented in many subclasses instead of RequestData.
general representation of visualization data
Definition: vtkDataObject.h:64