VTK  9.6.20260202
vtkDICOMImageReader.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
81
82#ifndef vtkDICOMImageReader_h
83#define vtkDICOMImageReader_h
84
85#include "vtkIOImageModule.h" // For export macro
86#include "vtkImageReader2.h"
87
88#include <istream> // for IStream
89#include <streambuf> // for Streambuf
90
91VTK_ABI_NAMESPACE_BEGIN
92class vtkDICOMImageReaderVector;
93class DICOMParser;
94class DICOMAppHelper;
95
96class VTKIOIMAGE_EXPORT vtkDICOMImageReader : public vtkImageReader2
97{
98public:
100
106
110 void PrintSelf(ostream& os, vtkIndent indent) override;
111
113
117 void SetFileName(VTK_FILEPATH const char* fn) override
118 {
119 delete[] this->DirectoryName;
120 delete[] this->FileName;
121 this->DirectoryName = nullptr;
122 this->FileName = nullptr;
124 }
125
126
136 void SetDirectoryName(VTK_FILEPATH const char* dn);
137
139
144
152
156 int GetWidth();
157
162
169
176
181
188
194
198 const char* GetTransferSyntaxUID();
199
204
209
213 const char* GetPatientName();
214
218 const char* GetStudyUID();
219
223 const char* GetStudyID();
224
229
231
236 int CanReadFile(VTK_FILEPATH const char* fname) override;
237 int CanReadFile(vtkResourceStream* stream) override;
239
240 //
241 // What file extensions are supported?
242 //
243 const char* GetFileExtensions() override { return ".dcm"; }
244
248 const char* GetDescriptiveName() override { return "DICOM"; }
249
250protected:
251 //
252 // Setup the volume size
253 //
254 void SetupOutputInformation(int num_slices);
255
256 void ExecuteInformation() override;
258
259 //
260 // Constructor
261 //
263
264 //
265 // Destructor
266 //
268
269 //
270 // Instance of the parser used to parse the file.
271 //
272 DICOMParser* Parser;
273
274 //
275 // Instance of the callbacks that get the data from the file.
276 //
277 DICOMAppHelper* AppHelper;
278
279 //
280 // vtkDICOMImageReaderVector wants to be a PIMPL and it will be, but not quite yet.
281 //
282 vtkDICOMImageReaderVector* DICOMFileNames;
284
286 char* StudyUID;
287 char* StudyID;
289
290 // DICOMFileNames accessor methods for subclasses:
292 VTK_FILEPATH const char* GetDICOMFileName(int index);
293
294private:
296 void operator=(const vtkDICOMImageReader&) = delete;
297
298 // Used when reading streams
299 std::unique_ptr<std::streambuf> Streambuf;
300};
301
302VTK_ABI_NAMESPACE_END
303#endif
const char * GetDescriptiveName() override
Return a descriptive name for the file format that might be useful in a GUI.
void ExecuteInformation() override
const char * GetStudyUID()
Get the study uid for the last image processed.
void SetupOutputInformation(int num_slices)
static vtkDICOMImageReader * New()
Static method for construction.
const char * GetStudyID()
Get the Study ID for the last image processed.
vtkDICOMImageReaderVector * DICOMFileNames
DICOMAppHelper * AppHelper
void SetDirectoryName(const char *dn)
Set the directory name for the reader to look in for DICOM files.
float GetGantryAngle()
Get the gantry angle for the last image processed.
int GetHeight()
Returns the image height.
int GetNumberOfComponents()
Get the number of components of the image data for the last image processed.
float * GetImagePositionPatient()
Get the (DICOM) x,y,z coordinates of the first pixel in the image (upper left hand corner) of the las...
int GetPixelRepresentation()
Get the pixel representation of the last image processed by the DICOMParser.
float GetRescaleOffset()
Get the rescale offset for the pixel data.
void SetFileName(const char *fn) override
Set the filename for the file to read.
int CanReadFile(const char *fname) override
Return 1 if, after a quick check of file header, it looks like the provided file or stream can be rea...
int GetBitsAllocated()
Get the number of bits allocated for each pixel in the file.
const char * GetFileExtensions() override
Get the file extensions for this format.
double * GetPixelSpacing()
Returns the pixel spacing (in X, Y, Z).
float GetRescaleSlope()
Get the rescale slope for the pixel data.
int GetWidth()
Returns the image width.
const char * GetDICOMFileName(int index)
float * GetImageOrientationPatient()
Get the (DICOM) directions cosines.
const char * GetTransferSyntaxUID()
Get the transfer syntax UID for the last image processed.
int GetNumberOfDICOMFileNames()
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
Prints the ivars.
~vtkDICOMImageReader() override
const char * GetPatientName()
Get the patient name for the last image processed.
vtkGetFilePathMacro(DirectoryName)
Returns the directory name.
general representation of visualization data
virtual void SetFileName(const char *)
Specify file name for the image 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 vtkAlgorithm input/output information.
Abstract class used for custom streams.
#define VTK_FILEPATH
#define VTK_SIZEHINT(...)