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=========================================================================*/
175#ifndef vtkMetaImageReader_h
176#define vtkMetaImageReader_h
177
178#include "vtkIOImageModule.h" // For export macro
179#include "vtkImageReader2.h"
180
181namespace vtkmetaio
182{
183class MetaImage;
184} // forward declaration
185
186class VTKIOIMAGE_EXPORT vtkMetaImageReader : public vtkImageReader2
187{
188public:
190 void PrintSelf(ostream& os, vtkIndent indent) override;
191
196
197 const char* GetFileExtensions() override { return ".mhd .mha"; }
198
199 const char* GetDescriptiveName() override { return "MetaIO Library: MetaImage"; }
200
201 // These duplicate functions in vtkImageReader2, vtkMedicalImageReader.
202 double* GetPixelSpacing() { return this->GetDataSpacing(); }
203 int GetWidth() { return (this->GetDataExtent()[1] - this->GetDataExtent()[0] + 1); }
204 int GetHeight() { return (this->GetDataExtent()[3] - this->GetDataExtent()[2] + 1); }
205 double* GetImagePositionPatient() { return this->GetDataOrigin(); }
208 int GetDataByteOrder(void) override;
209
210 vtkGetMacro(RescaleSlope, double);
211 vtkGetMacro(RescaleOffset, double);
212 vtkGetMacro(BitsAllocated, int);
213 vtkGetStringMacro(DistanceUnits);
214 vtkGetStringMacro(AnatomicalOrientation);
215 vtkGetMacro(GantryAngle, double);
216 vtkGetStringMacro(PatientName);
217 vtkGetStringMacro(PatientID);
218 vtkGetStringMacro(Date);
219 vtkGetStringMacro(Series);
220 vtkGetStringMacro(ImageNumber);
221 vtkGetStringMacro(Modality);
222 vtkGetStringMacro(StudyID);
223 vtkGetStringMacro(StudyUID);
224 vtkGetStringMacro(TransferSyntaxUID);
225
230 int CanReadFile(VTK_FILEPATH const char* name) override;
231
232protected:
235
236 // These functions make no sense for this (or most) file readers
237 // and should be hidden from the user...but then the getsettest fails.
238 /*virtual void SetFilePrefix(const char * arg)
239 { vtkImageReader2::SetFilePrefix(arg); }
240 virtual void SetFilePattern(VTK_FILEPATH const char * arg)
241 { vtkImageReader2::SetFilePattern(arg); }
242 virtual void SetDataScalarType(int type)
243 { vtkImageReader2::SetDataScalarType(type); }
244 virtual void SetDataScalarTypeToFloat()
245 { this->SetDataScalarType(VTK_FLOAT); }
246 virtual void SetDataScalarTypeToDouble()
247 { this->SetDataScalarType(VTK_DOUBLE); }
248 virtual void SetDataScalarTypeToInt()
249 { this->SetDataScalarType(VTK_INT); }
250 virtual void SetDataScalarTypeToShort()
251 { this->SetDataScalarType(VTK_SHORT); }
252 virtual void SetDataScalarTypeToUnsignedShort()
253 {this->SetDataScalarType(VTK_UNSIGNED_SHORT);}
254 virtual void SetDataScalarTypeToUnsignedChar()
255 {this->SetDataScalarType(VTK_UNSIGNED_CHAR);}
256 vtkSetMacro(NumberOfScalarComponents, int);
257 vtkSetVector6Macro(DataExtent, int);
258 vtkSetMacro(FileDimensionality, int);
259 vtkSetVector3Macro(DataSpacing, double);
260 vtkSetVector3Macro(DataOrigin, double);
261 vtkSetMacro(HeaderSize, unsigned long);
262 unsigned long GetHeaderSize(unsigned long)
263 { return 0; }
264 virtual void SetDataByteOrderToBigEndian()
265 { this->SetDataByteOrderToBigEndian(); }
266 virtual void SetDataByteOrderToLittleEndian()
267 { this->SetDataByteOrderToBigEndian(); }
268 virtual void SetDataByteOrder(int order)
269 { this->SetDataByteOrder(order); }
270 vtkSetMacro(FileNameSliceOffset,int);
271 vtkSetMacro(FileNameSliceSpacing,int);
272 vtkSetMacro(SwapBytes, int);
273 virtual int OpenFile()
274 { return vtkImageReader2::OpenFile(); }
275 virtual void SeekFile(int i, int j, int k)
276 { vtkImageReader2::SeekFile(i, j, k); }
277 vtkSetMacro(FileLowerLeft, int);
278 virtual void ComputeInternalFileName(int slice)
279 { vtkImageReader2::ComputeInternalFileName(slice); }
280 vtkGetFilePathMacro(InternalFileName);
281 const char * GetDataByteOrderAsString(void)
282 { return vtkImageReader2::GetDataByteOrderAsString(); }
283 unsigned long GetHeaderSize(void)
284 { return vtkImageReader2::GetHeaderSize(); }*/
285
286 void ExecuteInformation() override;
289 vtkInformationVector* outputVector) override;
290
291private:
292 vtkMetaImageReader(const vtkMetaImageReader&) = delete;
293 void operator=(const vtkMetaImageReader&) = delete;
294
295 vtkmetaio::MetaImage* MetaImagePtr;
296
297 double GantryAngle;
298 char PatientName[255];
299 char PatientID[255];
300 char Date[255];
301 char Series[255];
302 char Study[255];
303 char ImageNumber[255];
304 char Modality[255];
305 char StudyID[255];
306 char StudyUID[255];
307 char TransferSyntaxUID[255];
308
309 double RescaleSlope;
310 double RescaleOffset;
311 int BitsAllocated;
312 char DistanceUnits[255];
313 char AnatomicalOrientation[255];
314};
315
316#endif
general representation of visualization data
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 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).
a simple class to control print indentation
Definition: vtkIndent.h:119
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
read binary UNC meta image data
double * GetImagePositionPatient()
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.
int GetDataByteOrder(void) 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.
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.
@ name
Definition: vtkX3D.h:225
#define VTK_FILEPATH