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
54 #ifndef vtkMetaImageReader_h
55 #define vtkMetaImageReader_h
56 
57 #include "vtkIOImageModule.h" // For export macro
58 #include "vtkImageReader2.h"
59 
60 namespace vtkmetaio
61 {
62 class MetaImage;
63 } // forward declaration
64 
65 VTK_ABI_NAMESPACE_BEGIN
66 
67 class VTKIOIMAGE_EXPORT vtkMetaImageReader : public vtkImageReader2
68 {
69 public:
71  void PrintSelf(ostream& os, vtkIndent indent) override;
72 
77 
78  const char* GetFileExtensions() override { return ".mhd .mha"; }
79 
80  const char* GetDescriptiveName() override { return "MetaIO Library: MetaImage"; }
81 
82  // These duplicate functions in vtkImageReader2, vtkMedicalImageReader.
83  double* GetPixelSpacing() { return this->GetDataSpacing(); }
84  int GetWidth() { return (this->GetDataExtent()[1] - this->GetDataExtent()[0] + 1); }
85  int GetHeight() { return (this->GetDataExtent()[3] - this->GetDataExtent()[2] + 1); }
86  double* GetImagePositionPatient() { return this->GetDataOrigin(); }
88  int GetPixelRepresentation() { return this->GetDataScalarType(); }
89  int GetDataByteOrder() override;
90 
91  vtkGetMacro(RescaleSlope, double);
92  vtkGetMacro(RescaleOffset, double);
93  vtkGetMacro(BitsAllocated, int);
94  vtkGetStringMacro(DistanceUnits);
95  vtkGetStringMacro(AnatomicalOrientation);
96  vtkGetMacro(GantryAngle, double);
97  vtkGetStringMacro(PatientName);
98  vtkGetStringMacro(PatientID);
99  vtkGetStringMacro(Date);
100  vtkGetStringMacro(Series);
101  vtkGetStringMacro(ImageNumber);
102  vtkGetStringMacro(Modality);
103  vtkGetStringMacro(StudyID);
104  vtkGetStringMacro(StudyUID);
105  vtkGetStringMacro(TransferSyntaxUID);
106 
111  int CanReadFile(VTK_FILEPATH const char* name) override;
112 
113 protected:
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;
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
general representation of visualization data
Definition: vtkDataObject.h:55
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:29
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