VTK  9.7.1
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
33 #ifndef vtkDICOMImageReader_h
34 #define vtkDICOMImageReader_h
35 
36 #include "vtkIOImageModule.h" // For export macro
37 #include "vtkImageReader2.h"
38 
39 #include <istream> // for IStream
40 #include <streambuf> // for Streambuf
41 
42 VTK_ABI_NAMESPACE_BEGIN
43 class vtkDICOMImageReaderVector;
44 class DICOMParser;
45 class DICOMAppHelper;
46 
47 class VTKIOIMAGE_EXPORT vtkDICOMImageReader : public vtkImageReader2
48 {
49 public:
51 
54  static vtkDICOMImageReader* New();
57 
61  void PrintSelf(ostream& os, vtkIndent indent) override;
62 
64 
68  void SetFileName(VTK_FILEPATH const char* fn) override
69  {
70  delete[] this->DirectoryName;
71  delete[] this->FileName;
72  this->DirectoryName = nullptr;
73  this->FileName = nullptr;
75  }
77 
87  void SetDirectoryName(VTK_FILEPATH const char* dn);
88 
90 
93  vtkGetFilePathMacro(DirectoryName);
95 
102  double* GetPixelSpacing() VTK_SIZEHINT(3);
103 
107  int GetWidth();
108 
112  int GetHeight();
113 
119  float* GetImagePositionPatient() VTK_SIZEHINT(3);
120 
126  float* GetImageOrientationPatient() VTK_SIZEHINT(6);
127 
131  int GetBitsAllocated();
132 
138  int GetPixelRepresentation();
139 
144  int GetNumberOfComponents();
145 
149  const char* GetTransferSyntaxUID();
150 
154  float GetRescaleSlope();
155 
159  float GetRescaleOffset();
160 
164  const char* GetPatientName();
165 
169  const char* GetStudyUID();
170 
174  const char* GetStudyID();
175 
179  float GetGantryAngle();
180 
182 
187  int CanReadFile(VTK_FILEPATH const char* fname) override;
188  int CanReadFile(vtkResourceStream* stream) override;
190 
191  //
192  // What file extensions are supported?
193  //
194  const char* GetFileExtensions() override { return ".dcm"; }
195 
199  const char* GetDescriptiveName() override { return "DICOM"; }
200 
201 protected:
202  //
203  // Setup the volume size
204  //
205  void SetupOutputInformation(int num_slices);
206 
207  void ExecuteInformation() override;
208  void ExecuteDataWithInformation(vtkDataObject* out, vtkInformation* outInfo) override;
209 
210  //
211  // Constructor
212  //
214 
215  //
216  // Destructor
217  //
218  ~vtkDICOMImageReader() override;
219 
220  //
221  // Instance of the parser used to parse the file.
222  //
223  DICOMParser* Parser;
224 
225  //
226  // Instance of the callbacks that get the data from the file.
227  //
228  DICOMAppHelper* AppHelper;
229 
230  //
231  // vtkDICOMImageReaderVector wants to be a PIMPL and it will be, but not quite yet.
232  //
233  vtkDICOMImageReaderVector* DICOMFileNames;
235 
236  char* PatientName;
237  char* StudyUID;
238  char* StudyID;
240 
241  // DICOMFileNames accessor methods for subclasses:
242  int GetNumberOfDICOMFileNames();
243  VTK_FILEPATH const char* GetDICOMFileName(int index);
244 
245 private:
246  vtkDICOMImageReader(const vtkDICOMImageReader&) = delete;
247  void operator=(const vtkDICOMImageReader&) = delete;
248 
249  // Used when reading streams
250  std::unique_ptr<std::streambuf> Streambuf;
251 };
252 
253 VTK_ABI_NAMESPACE_END
254 #endif
const char * GetDescriptiveName() override
Return a descriptive name for the file format that might be useful in a GUI.
Abstract class used for custom streams.
void SetFileName(const char *fn) override
Set the filename for the file to read.
static vtkImageReader2 * New()
Store vtkAlgorithm input/output information.
vtkGetFilePathMacro(FileName)
Specify file name for the image file.
void ExecuteDataWithInformation(vtkDataObject *data, vtkInformation *outInfo) override
This is a convenience method that is implemented in many subclasses instead of RequestData.
a simple class to control print indentation
Definition: vtkIndent.h:28
virtual void ExecuteInformation()
#define VTK_SIZEHINT(...)
Superclass of binary file readers.
#define VTK_FILEPATH
DICOMAppHelper * AppHelper
virtual void SetFileName(const char *)
Specify file name for the image file.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
general representation of visualization data
Definition: vtkDataObject.h:55
vtkDICOMImageReaderVector * DICOMFileNames
Reads some DICOM images.