VTK  9.2.6
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
73 {
74 class MetaImage;
75 } // forward declaration
76 
77 class VTKIOIMAGE_EXPORT vtkMetaImageReader : public vtkImageReader2
78 {
79 public:
81  void PrintSelf(ostream& os, vtkIndent indent) override;
82 
86  static vtkMetaImageReader* New();
87 
88  const char* GetFileExtensions() override { return ".mhd .mha"; }
89 
90  const char* GetDescriptiveName() override { return "MetaIO Library: MetaImage"; }
91 
92  // These duplicate functions in vtkImageReader2, vtkMedicalImageReader.
93  double* GetPixelSpacing() { return this->GetDataSpacing(); }
94  int GetWidth() { return (this->GetDataExtent()[1] - this->GetDataExtent()[0] + 1); }
95  int GetHeight() { return (this->GetDataExtent()[3] - this->GetDataExtent()[2] + 1); }
96  double* GetImagePositionPatient() { return this->GetDataOrigin(); }
98  int GetPixelRepresentation() { return this->GetDataScalarType(); }
99  int GetDataByteOrder(void) override;
100 
101  vtkGetMacro(RescaleSlope, double);
102  vtkGetMacro(RescaleOffset, double);
103  vtkGetMacro(BitsAllocated, int);
104  vtkGetStringMacro(DistanceUnits);
105  vtkGetStringMacro(AnatomicalOrientation);
106  vtkGetMacro(GantryAngle, double);
107  vtkGetStringMacro(PatientName);
108  vtkGetStringMacro(PatientID);
109  vtkGetStringMacro(Date);
110  vtkGetStringMacro(Series);
111  vtkGetStringMacro(ImageNumber);
112  vtkGetStringMacro(Modality);
113  vtkGetStringMacro(StudyID);
114  vtkGetStringMacro(StudyUID);
115  vtkGetStringMacro(TransferSyntaxUID);
116 
121  int CanReadFile(VTK_FILEPATH const char* name) override;
122 
123 protected:
125  ~vtkMetaImageReader() override;
126 
127  // These functions make no sense for this (or most) file readers
128  // and should be hidden from the user...but then the getsettest fails.
129  /*virtual void SetFilePrefix(const char * arg)
130  { vtkImageReader2::SetFilePrefix(arg); }
131  virtual void SetFilePattern(VTK_FILEPATH const char * arg)
132  { vtkImageReader2::SetFilePattern(arg); }
133  virtual void SetDataScalarType(int type)
134  { vtkImageReader2::SetDataScalarType(type); }
135  virtual void SetDataScalarTypeToFloat()
136  { this->SetDataScalarType(VTK_FLOAT); }
137  virtual void SetDataScalarTypeToDouble()
138  { this->SetDataScalarType(VTK_DOUBLE); }
139  virtual void SetDataScalarTypeToInt()
140  { this->SetDataScalarType(VTK_INT); }
141  virtual void SetDataScalarTypeToShort()
142  { this->SetDataScalarType(VTK_SHORT); }
143  virtual void SetDataScalarTypeToUnsignedShort()
144  {this->SetDataScalarType(VTK_UNSIGNED_SHORT);}
145  virtual void SetDataScalarTypeToUnsignedChar()
146  {this->SetDataScalarType(VTK_UNSIGNED_CHAR);}
147  vtkSetMacro(NumberOfScalarComponents, int);
148  vtkSetVector6Macro(DataExtent, int);
149  vtkSetMacro(FileDimensionality, int);
150  vtkSetVector3Macro(DataSpacing, double);
151  vtkSetVector3Macro(DataOrigin, double);
152  vtkSetMacro(HeaderSize, unsigned long);
153  unsigned long GetHeaderSize(unsigned long)
154  { return 0; }
155  virtual void SetDataByteOrderToBigEndian()
156  { this->SetDataByteOrderToBigEndian(); }
157  virtual void SetDataByteOrderToLittleEndian()
158  { this->SetDataByteOrderToBigEndian(); }
159  virtual void SetDataByteOrder(int order)
160  { this->SetDataByteOrder(order); }
161  vtkSetMacro(FileNameSliceOffset,int);
162  vtkSetMacro(FileNameSliceSpacing,int);
163  vtkSetMacro(SwapBytes, int);
164  virtual int OpenFile()
165  { return vtkImageReader2::OpenFile(); }
166  virtual void SeekFile(int i, int j, int k)
167  { vtkImageReader2::SeekFile(i, j, k); }
168  vtkSetMacro(FileLowerLeft, int);
169  virtual void ComputeInternalFileName(int slice)
170  { vtkImageReader2::ComputeInternalFileName(slice); }
171  vtkGetFilePathMacro(InternalFileName);
172  const char * GetDataByteOrderAsString(void)
173  { return vtkImageReader2::GetDataByteOrderAsString(); }
174  unsigned long GetHeaderSize(void)
175  { return vtkImageReader2::GetHeaderSize(); }*/
176 
177  void ExecuteInformation() override;
178  void ExecuteDataWithInformation(vtkDataObject* out, vtkInformation* outInfo) override;
179  int RequestInformation(vtkInformation* request, 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
virtual int * GetDataExtent()
Get/Set the extent of the data on disk.
const char * GetFileExtensions() override
Get the file extensions for this format.
static vtkImageReader2 * New()
Store vtkAlgorithm input/output information.
double * GetImagePositionPatient()
virtual int GetNumberOfScalarComponents()
Set/Get the number of scalar components.
const char * GetDescriptiveName() override
Return a descriptive name for the file format that might be useful in a GUI.
virtual int CanReadFile(VTK_FILEPATH const char *vtkNotUsed(fname))
Return non zero if the reader can read the given file name.
void ExecuteDataWithInformation(vtkDataObject *data, vtkInformation *outInfo) override
This is a convenience method that is implemented in many subclasses instead of RequestData.
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 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
Superclass of binary file readers.
#define VTK_FILEPATH
int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
Subclasses can reimplement this method to collect information from their inputs and set information f...
Store zero or more vtkInformation instances.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
general representation of visualization data
Definition: vtkDataObject.h:65