VTK  9.7.1
vtkMetaImageReader.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
53 #ifndef vtkMetaImageReader_h
54 #define vtkMetaImageReader_h
55 
56 #include "vtkIOImageModule.h" // For export macro
57 #include "vtkImageReader2.h"
58 
59 namespace vtkmetaio
60 {
61 class MetaImage;
62 } // forward declaration
63 
64 VTK_ABI_NAMESPACE_BEGIN
65 
66 class VTKIOIMAGE_EXPORT vtkMetaImageReader : public vtkImageReader2
67 {
68 public:
70  void PrintSelf(ostream& os, vtkIndent indent) override;
71 
75  static vtkMetaImageReader* New();
76 
77  const char* GetFileExtensions() override { return ".mhd .mha"; }
78 
79  const char* GetDescriptiveName() override { return "MetaIO Library: MetaImage"; }
80 
81  // These duplicate functions in vtkImageReader2, vtkMedicalImageReader.
82  double* GetPixelSpacing() { return this->GetDataSpacing(); }
83  int GetWidth() { return (this->GetDataExtent()[1] - this->GetDataExtent()[0] + 1); }
84  int GetHeight() { return (this->GetDataExtent()[3] - this->GetDataExtent()[2] + 1); }
85  double* GetImagePositionPatient() { return this->GetDataOrigin(); }
87  int GetPixelRepresentation() { return this->GetDataScalarType(); }
88  int GetDataByteOrder() override;
89 
90  vtkGetMacro(RescaleSlope, double);
91  vtkGetMacro(RescaleOffset, double);
92  vtkGetMacro(BitsAllocated, int);
93  vtkGetStringMacro(DistanceUnits);
94  vtkGetStringMacro(AnatomicalOrientation);
95  vtkGetMacro(GantryAngle, double);
96  vtkGetStringMacro(PatientName);
97  vtkGetStringMacro(PatientID);
98  vtkGetStringMacro(Date);
99  vtkGetStringMacro(Series);
100  vtkGetStringMacro(ImageNumber);
101  vtkGetStringMacro(Modality);
102  vtkGetStringMacro(StudyID);
103  vtkGetStringMacro(StudyUID);
104  vtkGetStringMacro(TransferSyntaxUID);
105 
106  using Superclass::CanReadFile;
111  int CanReadFile(VTK_FILEPATH const char* name) override;
112 
113 protected:
115  ~vtkMetaImageReader() override;
116 
117  // These functions make no sense for this (or most) file readers
118  // and should be hidden from the user...but then the getsettest fails.
119  /*virtual void SetFilePrefix(const char * arg)
120  { vtkImageReader2::SetFilePrefix(arg); }
121  virtual void SetFilePattern(VTK_FILEPATH const char * arg)
122  { vtkImageReader2::SetFilePattern(arg); }
123  virtual void SetDataScalarType(int type)
124  { vtkImageReader2::SetDataScalarType(type); }
125  virtual void SetDataScalarTypeToFloat()
126  { this->SetDataScalarType(VTK_FLOAT); }
127  virtual void SetDataScalarTypeToDouble()
128  { this->SetDataScalarType(VTK_DOUBLE); }
129  virtual void SetDataScalarTypeToInt()
130  { this->SetDataScalarType(VTK_INT); }
131  virtual void SetDataScalarTypeToShort()
132  { this->SetDataScalarType(VTK_SHORT); }
133  virtual void SetDataScalarTypeToUnsignedShort()
134  {this->SetDataScalarType(VTK_UNSIGNED_SHORT);}
135  virtual void SetDataScalarTypeToUnsignedChar()
136  {this->SetDataScalarType(VTK_UNSIGNED_CHAR);}
137  vtkSetMacro(NumberOfScalarComponents, int);
138  vtkSetVector6Macro(DataExtent, int);
139  vtkSetMacro(FileDimensionality, int);
140  vtkSetVector3Macro(DataSpacing, double);
141  vtkSetVector3Macro(DataOrigin, double);
142  vtkSetMacro(HeaderSize, unsigned long);
143  unsigned long GetHeaderSize(unsigned long)
144  { return 0; }
145  virtual void SetDataByteOrderToBigEndian()
146  { this->SetDataByteOrderToBigEndian(); }
147  virtual void SetDataByteOrderToLittleEndian()
148  { this->SetDataByteOrderToBigEndian(); }
149  virtual void SetDataByteOrder(int order)
150  { this->SetDataByteOrder(order); }
151  vtkSetMacro(FileNameSliceOffset,int);
152  vtkSetMacro(FileNameSliceSpacing,int);
153  vtkSetMacro(SwapBytes, int);
154  virtual int OpenFile()
155  { return vtkImageReader2::OpenFile(); }
156  virtual void SeekFile(int i, int j, int k)
157  { vtkImageReader2::SeekFile(i, j, k); }
158  vtkSetMacro(FileLowerLeft, int);
159  virtual void ComputeInternalFileName(int slice)
160  { vtkImageReader2::ComputeInternalFileName(slice); }
161  vtkGetFilePathMacro(InternalFileName);
162  const char * GetDataByteOrderAsString()
163  { return vtkImageReader2::GetDataByteOrderAsString(); }
164  unsigned long GetHeaderSize()
165  { return vtkImageReader2::GetHeaderSize(); }*/
166 
167  void ExecuteInformation() override;
168  void ExecuteDataWithInformation(vtkDataObject* out, vtkInformation* outInfo) override;
169  int RequestInformation(vtkInformation* request, vtkInformationVector** inputVector,
170  vtkInformationVector* outputVector) override;
171 
172 private:
173  vtkMetaImageReader(const vtkMetaImageReader&) = delete;
174  void operator=(const vtkMetaImageReader&) = delete;
175 
176  vtkmetaio::MetaImage* MetaImagePtr;
177 
178  double GantryAngle;
179  char PatientName[255];
180  char PatientID[255];
181  char Date[255];
182  char Series[255];
183  char Study[255];
184  char ImageNumber[255];
185  char Modality[255];
186  char StudyID[255];
187  char StudyUID[255];
188  char TransferSyntaxUID[255];
189 
190  double RescaleSlope;
191  double RescaleOffset;
192  int BitsAllocated;
193  char DistanceUnits[255];
194  char AnatomicalOrientation[255];
195 };
196 
197 VTK_ABI_NAMESPACE_END
198 #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.
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:28
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...
virtual int CanReadFile(const char *fname)
Return non zero if the reader can read the given file name.
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:55