15 #ifndef GDCMSEQUENCEOFITEMS_H
16 #define GDCMSEQUENCEOFITEMS_H
60 SequenceLengthField = length;
63 void SetLengthToUndefined();
66 return SequenceLengthField.IsUndefined();
69 template <
typename TDE>
70 VL ComputeLength()
const;
74 void AddItem(
Item const &item);
84 const Item &GetItem(SizeType position)
const;
85 Item &GetItem(SizeType position);
93 template <
typename TDE,
typename TSwap>
94 std::istream &
Read(std::istream &is,
bool readvalues =
true)
97 const Tag seqDelItem(0xfffe,0xe0dd);
98 if( SequenceLengthField.IsUndefined() )
101 while( item.
Read<TDE,TSwap>(is) && item.
GetTag() != seqDelItem )
104 assert( item.
GetTag() != seqDelItem );
105 Items.push_back( item );
115 while( l != SequenceLengthField )
119 item.
Read<TDE,TSwap>(is);
125 VL newlength = l + item.template GetLength<TDE>();
126 if( newlength > SequenceLengthField )
130 SequenceLengthField = newlength;
138 #ifdef GDCM_SUPPORT_BROKEN_IMPLEMENTATION
139 if( item.
GetTag() == seqDelItem )
141 gdcmWarningMacro(
"SegDelItem found in defined length Sequence. Skipping" );
142 assert( item.
GetVL() == 0 );
154 Items.push_back( item );
156 l += item.template GetLength<TDE>();
157 if( l > SequenceLengthField )
160 throw "Length of Item larger than expected";
162 assert( l <= SequenceLengthField );
164 #ifdef GDCM_SUPPORT_BROKEN_IMPLEMENTATION
167 if( SequenceLengthField == 778 && l == 774 )
170 SequenceLengthField = l;
177 else if ( SequenceLengthField == 444 && l == 3*71 )
181 l = SequenceLengthField;
185 assert( l == SequenceLengthField );
190 template <
typename TDE,
typename TSwap>
191 std::ostream
const &
Write(std::ostream &os)
const
193 typename ItemVector::const_iterator it = Items.begin();
194 for(;it != Items.end(); ++it)
196 it->Write<TDE,TSwap>(os);
198 if( SequenceLengthField.IsUndefined() )
201 const Tag seqDelItem(0xfffe,0xe0dd);
202 seqDelItem.
Write<TSwap>(os);
204 zero.
Write<TSwap>(os);
211 void Print(std::ostream &os)
const {
212 os <<
"\t(" << SequenceLengthField <<
")\n";
213 ItemVector::const_iterator it =
215 for(;it != Items.end(); ++it)
219 if( SequenceLengthField.IsUndefined() )
221 const Tag seqDelItem(0xfffe,0xe0dd);
232 bool FindDataElement(
const Tag &t)
const;
251 #include "gdcmSequenceOfItems.txx"
253 #endif //GDCMSEQUENCEOFITEMS_H
ItemVector::iterator Iterator
Definition: gdcmSequenceOfItems.h:45
Class to represent a Sequence Of Items (value representation : SQ)
Definition: gdcmSequenceOfItems.h:39
void Print(std::ostream &os) const
Definition: gdcmSequenceOfItems.h:211
void SetLength(VL length)
Sets the actual SQ length.
Definition: gdcmSequenceOfItems.h:59
std::istream & Read(std::istream &is)
Definition: gdcmItem.h:97
Class to represent the value of a Data Element.
Definition: gdcmValue.h:29
ItemVector::const_iterator ConstIterator
Definition: gdcmSequenceOfItems.h:46
std::ostream const & Write(std::ostream &os) const
Definition: gdcmSequenceOfItems.h:191
const VL & GetVL() const
Get VL.
Definition: gdcmDataElement.h:74
ConstIterator End() const
Definition: gdcmSequenceOfItems.h:50
#define GDCM_EXPORT
Definition: gdcmWin32.h:34
SequenceOfItems & operator=(const SequenceOfItems &val)
Definition: gdcmSequenceOfItems.h:87
ItemVector Items
Vector of Sequence Items.
Definition: gdcmSequenceOfItems.h:246
#define gdcmWarningMacro(msg)
Warning.
Definition: gdcmTrace.h:141
Value Length.
Definition: gdcmVL.h:29
#define gdcmDebugMacro(msg)
Debug.
Definition: gdcmTrace.h:119
static SmartPointer< SequenceOfItems > New()
Definition: gdcmSequenceOfItems.h:228
const std::ostream & Write(std::ostream &os) const
Write a tag in binary rep.
Definition: gdcmTag.h:169
Class to represent an Item A component of the value of a Data Element that is of Value Representation...
Definition: gdcmItem.h:45
VL GetLength() const
Returns the SQ length, as read from disk.
Definition: gdcmSequenceOfItems.h:57
Iterator Begin()
Definition: gdcmSequenceOfItems.h:47
ItemVector::size_type SizeType
Definition: gdcmSequenceOfItems.h:44
SizeType Size() const
Definition: gdcmDataSet.h:75
const std::ostream & Write(std::ostream &os) const
Definition: gdcmVL.h:99
void SetNumberOfItems(SizeType n)
Definition: gdcmSequenceOfItems.h:77
Class for Smart Pointer.
Definition: gdcmObject.h:26
bool operator==(const Value &val) const
Definition: gdcmSequenceOfItems.h:234
void Clear()
Definition: gdcmSequenceOfItems.h:71
const char * GetDescription() const
Return the Description.
Definition: gdcmException.h:92
const Tag & GetTag() const
Get Tag.
Definition: gdcmDataElement.h:67
ConstIterator Begin() const
Definition: gdcmSequenceOfItems.h:49
VL SequenceLengthField
Total length of the Sequence (or 0xffffffff) if undefined.
Definition: gdcmSequenceOfItems.h:244
bool IsUndefinedLength() const
return if Value Length if of undefined length
Definition: gdcmSequenceOfItems.h:65
std::istream & Read(std::istream &is, bool readvalues=true)
Definition: gdcmSequenceOfItems.h:94
const DataSet & GetNestedDataSet() const
Definition: gdcmItem.h:80
Class to represent a DICOM Data Element (Attribute) Tag (Group, Element). Basically an uint32_t which...
Definition: gdcmTag.h:38
void Clear()
Definition: gdcmItem.h:51
Exception.
Definition: gdcmException.h:43
std::vector< Item > ItemVector
Definition: gdcmSequenceOfItems.h:43
Iterator End()
Definition: gdcmSequenceOfItems.h:48
SequenceOfItems()
constructor (UndefinedLength by default)
Definition: gdcmSequenceOfItems.h:53
SizeType GetNumberOfItems() const
Definition: gdcmSequenceOfItems.h:76