VTK  9.3.0
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
63 #ifndef vtkMetaImageReader_h
64 #define vtkMetaImageReader_h
65 
66 #include "vtkIOImageModule.h" // For export macro
67 #include "vtkImageReader2.h"
68 
69 namespace vtkmetaio
70 {
71 class MetaImage;
72 } // forward declaration
73 
74 VTK_ABI_NAMESPACE_BEGIN
75 
76 class VTKIOIMAGE_EXPORT vtkMetaImageReader : public vtkImageReader2
77 {
78 public:
80  void PrintSelf(ostream& os, vtkIndent indent) override;
81 
86 
87  const char* GetFileExtensions() override { return ".mhd .mha"; }
88 
89  const char* GetDescriptiveName() override { return "MetaIO Library: MetaImage"; }
90 
91  // These duplicate functions in vtkImageReader2, vtkMedicalImageReader.
92  double* GetPixelSpacing() { return this->GetDataSpacing(); }
93  int GetWidth() { return (this->GetDataExtent()[1] - this->GetDataExtent()[0] + 1); }
94  int GetHeight() { return (this->GetDataExtent()[3] - this->GetDataExtent()[2] + 1); }
95  double* GetImagePositionPatient() { return this->GetDataOrigin(); }
97  int GetPixelRepresentation() { return this->GetDataScalarType(); }
98  int GetDataByteOrder() 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(VTK_FILEPATH const char* name) override;
121 
122 protected:
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(VTK_FILEPATH 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  vtkGetFilePathMacro(InternalFileName);
171  const char * GetDataByteOrderAsString()
172  { return vtkImageReader2::GetDataByteOrderAsString(); }
173  unsigned long GetHeaderSize()
174  { return vtkImageReader2::GetHeaderSize(); }*/
175 
176  void ExecuteInformation() override;
179  vtkInformationVector* outputVector) override;
180 
181 private:
182  vtkMetaImageReader(const vtkMetaImageReader&) = delete;
183  void operator=(const vtkMetaImageReader&) = delete;
184 
185  vtkmetaio::MetaImage* MetaImagePtr;
186 
187  double GantryAngle;
188  char PatientName[255];
189  char PatientID[255];
190  char Date[255];
191  char Series[255];
192  char Study[255];
193  char ImageNumber[255];
194  char Modality[255];
195  char StudyID[255];
196  char StudyUID[255];
197  char TransferSyntaxUID[255];
198 
199  double RescaleSlope;
200  double RescaleOffset;
201  int BitsAllocated;
202  char DistanceUnits[255];
203  char AnatomicalOrientation[255];
204 };
205 
206 VTK_ABI_NAMESPACE_END
207 #endif
general representation of visualization data
Definition: vtkDataObject.h:64
Superclass of binary file readers.
virtual int GetNumberOfScalarComponents()
Set/Get the number of scalar components.
virtual int * GetDataExtent()
Get/Set the extent of the data on disk.
virtual double * GetDataSpacing()
Set/Get the spacing of the data in the file.
virtual int GetDataScalarType()
Get the file format.
virtual double * GetDataOrigin()
Set/Get the origin of the data (location of first pixel in the file).
a simple class to control print indentation
Definition: vtkIndent.h:38
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
read binary UNC meta image data
int CanReadFile(VTK_FILEPATH const char *name) override
Test whether the file with the given name can be read by this reader.
static vtkMetaImageReader * New()
Construct object with FlipNormals turned off and Normals set to true.
double * GetImagePositionPatient()
int GetDataByteOrder() override
These methods should be used instead of the SwapBytes methods.
const char * GetDescriptiveName() override
Return a descriptive name for the file format that might be useful in a GUI.
void ExecuteInformation() override
~vtkMetaImageReader() override
int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
Subclasses can reimplement this method to collect information from their inputs and set information f...
const char * GetFileExtensions() override
Get the file extensions for this format.
void ExecuteDataWithInformation(vtkDataObject *out, vtkInformation *outInfo) override
This is a convenience method that is implemented in many subclasses instead of RequestData.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
@ name
Definition: vtkX3D.h:219
#define VTK_FILEPATH