vtk-dicom  0.8.17
vtkDICOMGenerator.h
1 /*=========================================================================
2 
3  Program: DICOM for VTK
4 
5  Copyright (c) 2012-2024 David Gobbi
6  All rights reserved.
7  See Copyright.txt or http://dgobbi.github.io/bsd3.txt for details.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without even
10  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  PURPOSE. See the above copyright notice for more information.
12 
13 =========================================================================*/
14 #ifndef vtkDICOMGenerator_h
15 #define vtkDICOMGenerator_h
16 
17 #include "vtkObject.h"
18 #include "vtkStdString.h" // For std::string
19 #include "vtkDICOMModule.h" // For export macro
20 #include "vtkDICOMConfig.h" // For configuration details
21 #include "vtkDICOMTag.h" // For method parameter
22 
23 // Declare VTK classes within VTK's optional namespace
24 #if defined(VTK_ABI_NAMESPACE_BEGIN)
25 VTK_ABI_NAMESPACE_BEGIN
26 #endif
27 
28 class vtkIntArray;
29 class vtkMatrix4x4;
30 class vtkInformation;
31 class vtkStringArray;
32 
33 #if defined(VTK_ABI_NAMESPACE_BEGIN)
34 VTK_ABI_NAMESPACE_END
35 #endif
36 
37 class vtkDICOMMetaData;
38 class vtkDICOMItem;
40 
42 
55 class VTKDICOM_EXPORT vtkDICOMGenerator : public vtkObject
56 {
57 public:
60  vtkTypeMacro(vtkDICOMGenerator, vtkObject);
61 
63  void PrintSelf(ostream& os, vtkIndent indent) VTK_DICOM_OVERRIDE;
64 
66 
72  virtual bool GenerateInstance(vtkInformation *);
74 
76 
83 
85 
92  vtkSetMacro(Extended, int);
93  vtkBooleanMacro(Extended, int);
94  vtkGetMacro(Extended, int);
96 
98 
104  vtkSetMacro(MultiFrame, int);
105  vtkBooleanMacro(MultiFrame, int);
106  vtkGetMacro(MultiFrame, int);
108 
110 
116  vtkSetMacro(TimeAsVector, int);
117  vtkBooleanMacro(TimeAsVector, int);
118  vtkGetMacro(TimeAsVector, int);
120 
122 
130  vtkSetMacro(TimeDimension, int);
131  vtkGetMacro(TimeDimension, int);
132  vtkSetMacro(TimeSpacing, double);
133  vtkGetMacro(TimeSpacing, double);
135 
137 
143  vtkSetMacro(RescaleIntercept, double);
144  vtkGetMacro(RescaleIntercept, double);
145  vtkSetMacro(RescaleSlope, double);
146  vtkGetMacro(RescaleSlope, double);
148 
150 
156  vtkSetMacro(NumberOfOverlays, int);
157  vtkGetMacro(NumberOfOverlays, int);
159 
161 
166  void SetPatientMatrix(vtkMatrix4x4 *);
167  vtkMatrix4x4 *GetPatientMatrix() { return this->PatientMatrix; }
169 
171 
180  vtkSetMacro(OriginAtBottom, int);
181  vtkGetMacro(OriginAtBottom, int);
183 
185 
192  vtkSetMacro(ReverseSliceOrder, int);
193  vtkGetMacro(ReverseSliceOrder, int);
195 
197 
205  vtkDICOMMetaData *GetSourceMetaData();
207 
209 
215  vtkDICOMUIDGenerator *GetUIDGenerator();
217 
219 
226  vtkIntArray *GetSliceIndexArray() { return this->SliceIndexArray; }
227 
229 
235  vtkIntArray *GetComponentIndexArray() { return this->ComponentIndexArray; }
237 
238 protected:
240  enum {
241  RepresentationUnsigned = 1u,
242  RepresentationSigned = 2u,
243  BitsStored1 = 1u,
244  BitsStored6 = (1u << 5),
245  BitsStored8 = (1u << 7),
246  BitsStored10 = (1u << 9),
247  BitsStored12 = (1u << 11),
248  BitsStored16 = (1u << 15),
249  BitsStored32 = (1u << 31)
250  };
251 
255  ~vtkDICOMGenerator() VTK_DICOM_OVERRIDE;
257 
259  /*
261  * The generator uses the tag as a hint when generating the UIDs,
262  * for example the SOPInstanceUID might have a different format from
263  * the FrameOfReferenceUID.
264  */
265  std::string GenerateUID(vtkDICOMTag tag);
266 
268 
275  void GenerateUIDs(vtkDICOMTag tag, vtkStringArray *uids);
277 
279  void SetPixelRestrictions(
281  unsigned int pixelRepresentation, unsigned int bitsStored,
282  int colorComponents);
284 
286  virtual bool GenerateSOPCommonModule(
288  vtkDICOMMetaData *meta, const char *SOPClass);
289 
291  virtual bool GeneratePatientModule(vtkDICOMMetaData *source);
292 
294  virtual bool GenerateClinicalTrialSubjectModule(vtkDICOMMetaData *source);
295 
297  virtual bool GenerateGeneralStudyModule(vtkDICOMMetaData *source);
298 
300  virtual bool GeneratePatientStudyModule(vtkDICOMMetaData *source);
301 
303  virtual bool GenerateClinicalTrialStudyModule(vtkDICOMMetaData *source);
304 
306  virtual bool GenerateGeneralSeriesModule(vtkDICOMMetaData *source);
307 
309  virtual bool GenerateClinicalTrialSeriesModule(vtkDICOMMetaData *source);
310 
312  virtual bool GenerateFrameOfReferenceModule(vtkDICOMMetaData *source);
313 
315  virtual bool GenerateGeneralEquipmentModule(vtkDICOMMetaData *source);
316 
318  virtual bool GenerateGeneralImageModule(vtkDICOMMetaData *source);
319 
321  virtual bool GenerateImagePlaneModule(vtkDICOMMetaData *source);
322 
324  virtual bool GenerateImagePixelModule(vtkDICOMMetaData *source);
325 
327  virtual bool GenerateContrastBolusModule(vtkDICOMMetaData *source);
328 
330  virtual bool GenerateMultiFrameModule(vtkDICOMMetaData *source);
331 
333  virtual bool GenerateDeviceModule(vtkDICOMMetaData *source);
334 
336  virtual bool GenerateSpecimenModule(vtkDICOMMetaData *source);
337 
339  virtual bool GenerateOverlayPlaneModule(vtkDICOMMetaData *source);
340 
342  virtual bool GenerateVOILUTModule(vtkDICOMMetaData *source);
344 
346 
352  virtual bool CopyRequiredAttributes(
353  const DC::EnumType *tags, vtkDICOMMetaData *source);
354 
356 
359  virtual bool CopyOptionalAttributes(
360  const DC::EnumType *tags, vtkDICOMMetaData *source);
362 
364 
368  virtual bool CopyAttributes(
369  const DC::EnumType *blacklist, vtkDICOMMetaData *source);
371 
373  static void ComputeAspectRatio(const double spacing[2], int aspect[2]);
374 
376  void ComputeAdjustedMatrix(
378  double matrix[16], double origin[3], double spacing[3]);
380 
382 
387  static void ComputePositionAndOrientation(
388  const double origin[3], const double matrix[16],
389  double position[3], double orientation[6]);
390 
392 
397  virtual void ComputeDimensions(
398  vtkInformation *info, int *nframes, int dims[5],
399  double spacing[5], double origin[5]);
400 
402 
406  virtual void ComputePixelValueRange(
407  vtkInformation *info, int seriesRange[2]);
409 
411  virtual void MatchInstances(vtkDICOMMetaData *source);
414 
416 
422  virtual void InitializeMetaData(vtkInformation *info);
424 
426  vtkDICOMMetaData *MetaData;
427 
429  vtkDICOMMetaData *SourceMetaData;
430 
432  vtkDICOMUIDGenerator *UIDGenerator;
433 
435  int Extended;
436 
438  int MultiFrame;
439 
441  int OriginAtBottom;
442 
444  int ReverseSliceOrder;
445 
447  int TimeAsVector;
448 
450  int TimeDimension;
451  double TimeSpacing;
452 
454  double RescaleIntercept;
455  double RescaleSlope;
456 
458  int NumberOfOverlays;
459 
461  int ScalarType;
462 
464 
474  int NumberOfColorComponents;
475 
477  unsigned int AllowedPixelRepresentation;
478  unsigned int AllowedBitsStored;
479 
481 
487  int NumberOfFrames;
488 
490 
496  int Dimensions[5];
497  double Spacing[5];
498  double Origin[5];
499 
501 
504  int PixelValueRange[2];
505 
507  vtkMatrix4x4 *PatientMatrix;
508 
510  vtkIntArray *SliceIndexArray;
511  vtkIntArray *ComponentIndexArray;
512 
514  vtkIntArray *SourceInstanceArray;
515 
517  vtkIntArray *RangeArray;
518 
519 private:
520 #ifdef VTK_DICOM_DELETE
521  vtkDICOMGenerator(const vtkDICOMGenerator&) VTK_DICOM_DELETE;
522  void operator=(const vtkDICOMGenerator&) VTK_DICOM_DELETE;
523 #else
524  vtkDICOMGenerator(const vtkDICOMGenerator&) = delete;
525  void operator=(const vtkDICOMGenerator&) = delete;
526 #endif
527 };
528 
529 #endif // vtkDICOMGenerator_h
Generate DICOM data series for specific IOD classes.
Definition: vtkDICOMGenerator.h:56
vtkIntArray * GetSliceIndexArray()
Get an array that maps file and frame to slice.
Definition: vtkDICOMGenerator.h:226
void SetUIDGenerator(vtkDICOMUIDGenerator *)
Set the UID generator, for generating unique IDs.
void SetPatientMatrix(vtkMatrix4x4 *)
Set the matrix that places the image in DICOM patient coords.
vtkDICOMMetaData * GetMetaData()
Get the generated meta data.
static vtkDICOMGenerator * New()
Static method for construction.
vtkIntArray * GetComponentIndexArray()
Get an array that maps file and frame to component.
Definition: vtkDICOMGenerator.h:235
void PrintSelf(ostream &os, vtkIndent indent) VTK_DICOM_OVERRIDE
Print information about this object.
void SetSourceMetaData(vtkDICOMMetaData *)
Set some meta data for the constructor to use as a source.
virtual bool GenerateInstance(vtkInformation *)
Generate an instance of one of the supported classes.
An item in a DICOM sequence (type SQ).
Definition: vtkDICOMItem.h:34
A container class for DICOM metadata.
Definition: vtkDICOMMetaData.h:44
A (group,element) identifier tag for DICOM attributes.
Definition: vtkDICOMTag.h:23
Generate UIDs for written DICOM files.
Definition: vtkDICOMUIDGenerator.h:46
abstract base class for most VTK objects
Definition: vtkObject.h:54
Tag values defined in the DICOM standard.
Definition: vtkDICOMDictHash.h:10