vtk-dicom  0.8.17
vtkDICOMSequence.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 vtkDICOMSequence_h
15 #define vtkDICOMSequence_h
16 
17 #include "vtkDICOMModule.h" // For export macro
18 #include "vtkDICOMValue.h"
19 
20 class vtkDICOMItem;
21 class vtkDICOMTagPath;
22 
24 
31 class VTKDICOM_EXPORT vtkDICOMSequence
32 {
33 public:
37 
39  explicit vtkDICOMSequence(unsigned int n);
41 
43  void Clear();
46 
48  const vtkDICOMValue &Get(size_t i, vtkDICOMTag tag) const;
50  const vtkDICOMValue &Get(size_t i, const vtkDICOMTagPath &p) const;
51  const vtkDICOMValue &GetAttributeValue(
52  size_t i, vtkDICOMTag tag) const {
53  return this->Get(i, tag); }
54  const vtkDICOMValue &GetAttributeValue(
55  size_t i, const vtkDICOMTagPath &p) const {
56  return this->Get(i, p); }
58 
60 
67  void AddItem(const vtkDICOMItem& item);
68 
70  size_t GetNumberOfItems() const {
71  return this->V.GetNumberOfValues(); }
73 
75 
80  void SetItem(size_t i, const vtkDICOMItem& item);
81 
83  const vtkDICOMItem& GetItem(size_t i) const;
84 
86  const vtkDICOMItem *GetSequenceData() const {
87  return this->V.GetSequenceData(); }
89 
91  vtkDICOMSequence(const vtkDICOMSequence& o) : V(o.V) {}
93 
95  vtkDICOMSequence(const vtkDICOMValue& o) : V(o) {
96  if (o.GetVR() != vtkDICOMVR::SQ) { this->V.Clear(); } }
97 
99  bool IsValid() const {
100  return this->V.IsValid(); }
102 
104  vtkDICOMSequence& operator=(const vtkDICOMSequence& o) {
106  this->V = o.V; return *this; }
107 
110  if (o.GetVR() == vtkDICOMVR::SQ) { this->V = o; }
111  else { this->V.Clear(); } return *this; }
113 
114 private:
115  friend class vtkDICOMValue;
116 
117  vtkDICOMValue V;
118 
120  static const vtkDICOMValue InvalidValue;
122  static const vtkDICOMItem EmptyItem;
123 };
124 
125 VTKDICOM_EXPORT ostream& operator<<(ostream& os, const vtkDICOMSequence& v);
126 
127 #endif /* vtkDICOMSequence_h */
128 // VTK-HeaderTest-Exclude: vtkDICOMSequence.h
An item in a DICOM sequence (type SQ).
Definition: vtkDICOMItem.h:34
A sequence of items according to the SQ representation.
Definition: vtkDICOMSequence.h:32
void SetItem(size_t i, const vtkDICOMItem &item)
Set an item in the sequence.
vtkDICOMSequence(unsigned int n)
Construct a sequence of fixed size.
vtkDICOMSequence(const vtkDICOMValue &o)
Conversion from value to sequence is type checked.
Definition: vtkDICOMSequence.h:95
size_t GetNumberOfItems() const
Get the number of items in the sequence.
Definition: vtkDICOMSequence.h:70
const vtkDICOMItem * GetSequenceData() const
Get a pointer to the items in the sequence.
Definition: vtkDICOMSequence.h:86
const vtkDICOMItem & GetItem(size_t i) const
Get an item from the sequence.
vtkDICOMSequence & operator=(const vtkDICOMValue &o)
Assignment from value to sequence is type checked.
Definition: vtkDICOMSequence.h:109
bool IsValid() const
Check that the sequence was constructed from a valid value.
Definition: vtkDICOMSequence.h:99
void AddItem(const vtkDICOMItem &item)
Add an item to the sequence.
A tag path for digging values out of sequence items.
Definition: vtkDICOMTagPath.h:27
A (group,element) identifier tag for DICOM attributes.
Definition: vtkDICOMTag.h:23
@ SQ
Sequence of Items.
Definition: vtkDICOMVR.h:51
A class to store attribute values for DICOM metadata.
Definition: vtkDICOMValue.h:51
vtkDICOMVR GetVR() const
Get the VR, the representation of the data values.
Definition: vtkDICOMValue.h:177
void Clear()
Clear the value, the result is an invalid value.
Definition: vtkDICOMValue.h:166