VTK  9.7.20261204
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
166
167#ifndef vtkMetaImageReader_h
168#define vtkMetaImageReader_h
169
170#include "vtkIOImageModule.h" // For export macro
171#include "vtkImageReader2.h"
172
173namespace vtkmetaio
174{
175class MetaImage;
176} // forward declaration
177
178VTK_ABI_NAMESPACE_BEGIN
179
180class VTKIOIMAGE_EXPORT vtkMetaImageReader : public vtkImageReader2
181{
182public:
184 void PrintSelf(ostream& os, vtkIndent indent) override;
185
190
191 const char* GetFileExtensions() override { return ".mhd .mha"; }
192
193 const char* GetDescriptiveName() override { return "MetaIO Library: MetaImage"; }
194
195 // These duplicate functions in vtkImageReader2, vtkMedicalImageReader.
196 double* GetPixelSpacing() { return this->GetDataSpacing(); }
197 int GetWidth() { return (this->GetDataExtent()[1] - this->GetDataExtent()[0] + 1); }
198 int GetHeight() { return (this->GetDataExtent()[3] - this->GetDataExtent()[2] + 1); }
199 double* GetImagePositionPatient() { return this->GetDataOrigin(); }
202 int GetDataByteOrder() override;
203
204 vtkGetMacro(RescaleSlope, double);
205 vtkGetMacro(RescaleOffset, double);
206 vtkGetMacro(BitsAllocated, int);
207 vtkGetStringMacro(DistanceUnits);
208 vtkGetStringMacro(AnatomicalOrientation);
209 vtkGetMacro(GantryAngle, double);
210 vtkGetStringMacro(PatientName);
211 vtkGetStringMacro(PatientID);
212 vtkGetStringMacro(Date);
213 vtkGetStringMacro(Series);
214 vtkGetStringMacro(ImageNumber);
215 vtkGetStringMacro(Modality);
216 vtkGetStringMacro(StudyID);
217 vtkGetStringMacro(StudyUID);
218 vtkGetStringMacro(TransferSyntaxUID);
219
221
225 vtkBooleanMacro(UseArrayNameInFile, bool);
226 vtkSetMacro(UseArrayNameInFile, bool);
227 vtkGetMacro(UseArrayNameInFile, bool);
228
230
236 int CanReadFile(VTK_FILEPATH const char* name) override;
237
238protected:
241
242 // These functions make no sense for this (or most) file readers
243 // and should be hidden from the user...but then the getsettest fails.
244 /*virtual void SetFilePrefix(const char * arg)
245 { vtkImageReader2::SetFilePrefix(arg); }
246 virtual void SetFilePattern(VTK_FILEPATH const char * arg)
247 { vtkImageReader2::SetFilePattern(arg); }
248 virtual void SetDataScalarType(int type)
249 { vtkImageReader2::SetDataScalarType(type); }
250 virtual void SetDataScalarTypeToFloat()
251 { this->SetDataScalarType(VTK_FLOAT); }
252 virtual void SetDataScalarTypeToDouble()
253 { this->SetDataScalarType(VTK_DOUBLE); }
254 virtual void SetDataScalarTypeToInt()
255 { this->SetDataScalarType(VTK_INT); }
256 virtual void SetDataScalarTypeToShort()
257 { this->SetDataScalarType(VTK_SHORT); }
258 virtual void SetDataScalarTypeToUnsignedShort()
259 {this->SetDataScalarType(VTK_UNSIGNED_SHORT);}
260 virtual void SetDataScalarTypeToUnsignedChar()
261 {this->SetDataScalarType(VTK_UNSIGNED_CHAR);}
262 vtkSetMacro(NumberOfScalarComponents, int);
263 vtkSetVector6Macro(DataExtent, int);
264 vtkSetMacro(FileDimensionality, int);
265 vtkSetVector3Macro(DataSpacing, double);
266 vtkSetVector3Macro(DataOrigin, double);
267 vtkSetMacro(HeaderSize, unsigned long);
268 unsigned long GetHeaderSize(unsigned long)
269 { return 0; }
270 virtual void SetDataByteOrderToBigEndian()
271 { this->SetDataByteOrderToBigEndian(); }
272 virtual void SetDataByteOrderToLittleEndian()
273 { this->SetDataByteOrderToBigEndian(); }
274 virtual void SetDataByteOrder(int order)
275 { this->SetDataByteOrder(order); }
276 vtkSetMacro(FileNameSliceOffset,int);
277 vtkSetMacro(FileNameSliceSpacing,int);
278 vtkSetMacro(SwapBytes, int);
279 virtual int OpenFile()
280 { return vtkImageReader2::OpenFile(); }
281 virtual void SeekFile(int i, int j, int k)
282 { vtkImageReader2::SeekFile(i, j, k); }
283 vtkSetMacro(FileLowerLeft, int);
284 virtual void ComputeInternalFileName(int slice)
285 { vtkImageReader2::ComputeInternalFileName(slice); }
286 vtkGetFilePathMacro(InternalFileName);
287 const char * GetDataByteOrderAsString()
288 { return vtkImageReader2::GetDataByteOrderAsString(); }
289 unsigned long GetHeaderSize()
290 { return vtkImageReader2::GetHeaderSize(); }*/
291
292 void ExecuteInformation() override;
295 vtkInformationVector* outputVector) override;
296
297private:
298 vtkMetaImageReader(const vtkMetaImageReader&) = delete;
299 void operator=(const vtkMetaImageReader&) = delete;
300
301 vtkmetaio::MetaImage* MetaImagePtr;
302
303 double GantryAngle;
304 char PatientName[255];
305 char PatientID[255];
306 char Date[255];
307 char Series[255];
308 char Study[255];
309 char ImageNumber[255];
310 char Modality[255];
311 char StudyID[255];
312 char StudyUID[255];
313 char TransferSyntaxUID[255];
314
315 double RescaleSlope;
316 double RescaleOffset;
317 int BitsAllocated;
318 char DistanceUnits[255];
319 char AnatomicalOrientation[255];
320
321 bool UseArrayNameInFile = false;
322};
323
324VTK_ABI_NAMESPACE_END
325#endif
general representation of visualization data
virtual int GetNumberOfScalarComponents()
Set/Get the number of scalar components.
virtual int CanReadFile(const char *fname)
Return non zero if the reader can read the given file name.
virtual int * GetDataExtent()
Get/Set the extent of the data on disk.
virtual int GetDataScalarType()
Get the file format.
virtual double * GetDataSpacing()
Set/Get the spacing of the data in the file.
virtual double * GetDataOrigin()
Set/Get the origin of the data (location of first pixel in the file).
vtkImageReader2()
Return a descriptive name for the file format that might be useful in a GUI.
a simple class to control print indentation
Definition vtkIndent.h:108
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
double * GetImagePositionPatient()
static vtkMetaImageReader * New()
Construct object with FlipNormals turned off and Normals set to true.
int GetDataByteOrder() override
These methods should be used instead of the SwapBytes methods.
void ExecuteInformation() override
~vtkMetaImageReader() override
const char * GetFileExtensions() override
Get the file extensions for this format.
int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
Subclasses can reimplement this method to collect information from their inputs and set information f...
void ExecuteDataWithInformation(vtkDataObject *out, vtkInformation *outInfo) override
This is a convenience method that is implemented in many subclasses instead of RequestData.
int CanReadFile(const char *name) override
Test whether the file with the given name can be read by this reader.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
const char * GetDescriptiveName() override
Return a descriptive name for the file format that might be useful in a GUI.
#define VTK_FILEPATH