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 );
163 #ifdef GDCM_SUPPORT_BROKEN_IMPLEMENTATION
166 if( SequenceLengthField == 778 && l == 774 )
169 SequenceLengthField = l;
176 else if ( SequenceLengthField == 444 && l == 3*71 )
180 l = SequenceLengthField;
184 assert( l == SequenceLengthField );
189 template <
typename TDE,
typename TSwap>
190 std::ostream
const &
Write(std::ostream &os)
const
192 typename ItemVector::const_iterator it = Items.begin();
193 for(;it != Items.end(); ++it)
195 it->Write<TDE,TSwap>(os);
197 if( SequenceLengthField.IsUndefined() )
200 const Tag seqDelItem(0xfffe,0xe0dd);
201 seqDelItem.
Write<TSwap>(os);
203 zero.
Write<TSwap>(os);
210 void Print(std::ostream &os)
const {
211 os <<
"\t(" << SequenceLengthField <<
")\n";
212 ItemVector::const_iterator it =
214 for(;it != Items.end(); ++it)
218 if( SequenceLengthField.IsUndefined() )
220 const Tag seqDelItem(0xfffe,0xe0dd);
231 bool FindDataElement(
const Tag &t)
const;
250 #include "gdcmSequenceOfItems.txx"
252 #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:210
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:190
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:245
#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:227
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:233
void Clear()
Definition: gdcmSequenceOfItems.h:71
const char * GetDescription() const
Return the Description.
Definition: gdcmException.h:82
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:243
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:33
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