15#ifndef GDCMSEQUENCEOFITEMS_H
16#define GDCMSEQUENCEOFITEMS_H
60 SequenceLengthField = length;
66 return SequenceLengthField.IsUndefined();
69 template <
typename TDE>
85 bool IsEmpty()
const {
return Items.empty(); }
103 template <
typename TDE,
typename TSwap>
104 std::istream &
Read(std::istream &is,
bool readvalues =
true)
107 const Tag seqDelItem(0xfffe,0xe0dd);
108 if( SequenceLengthField.IsUndefined() )
111 while( item.
Read<TDE,TSwap>(is) && item.
GetTag() != seqDelItem )
114 assert( item.
GetTag() != seqDelItem );
115 Items.push_back( item );
125 while( l != SequenceLengthField )
129 item.
Read<TDE,TSwap>(is);
135 VL newlength = l + item.template GetLength<TDE>();
136 if( newlength > SequenceLengthField )
140 SequenceLengthField = newlength;
148#ifdef GDCM_SUPPORT_BROKEN_IMPLEMENTATION
149 if( item.
GetTag() == seqDelItem )
151 gdcmWarningMacro(
"SeqDelItem found in defined length Sequence. Skipping" );
152 assert( item.
GetVL() == 0 );
164 Items.push_back( item );
166 l += item.template GetLength<TDE>();
167 if( l > SequenceLengthField )
170 throw "Length of Item larger than expected";
172 assert( l <= SequenceLengthField );
174#ifdef GDCM_SUPPORT_BROKEN_IMPLEMENTATION
177 if( SequenceLengthField == 778 && l == 774 )
180 SequenceLengthField = l;
187 else if ( SequenceLengthField == 444 && l == 3*71 )
191 l = SequenceLengthField;
195 assert( l == SequenceLengthField );
200 template <
typename TDE,
typename TSwap>
201 std::ostream
const &
Write(std::ostream &os)
const
203 typename ItemVector::const_iterator it = Items.begin();
204 for(;it != Items.end(); ++it)
206 it->Write<TDE,TSwap>(os);
208 if( SequenceLengthField.IsUndefined() )
211 const Tag seqDelItem(0xfffe,0xe0dd);
212 seqDelItem.
Write<TSwap>(os);
214 zero.
Write<TSwap>(os);
221 void Print(std::ostream &os)
const override {
222 os <<
"\t(" << SequenceLengthField <<
")\n";
223 ItemVector::const_iterator it =
225 for(;it != Items.end(); ++it)
229 if( SequenceLengthField.IsUndefined() )
231 const Tag seqDelItem(0xfffe,0xe0dd);
261#include "gdcmSequenceOfItems.txx"
const VL & GetVL() const
Get VL.
Definition gdcmDataElement.h:74
const Tag & GetTag() const
Get Tag.
Definition gdcmDataElement.h:67
SizeType Size() const
Definition gdcmDataSet.h:75
Exception.
Definition gdcmException.h:44
const char * GetDescription() const
Return the Description.
Definition gdcmException.h:92
Class to represent an Item.
Definition gdcmItem.h:46
void Clear()
Definition gdcmItem.h:51
std::istream & Read(std::istream &is)
Definition gdcmItem.h:97
const DataSet & GetNestedDataSet() const
Definition gdcmItem.h:80
Class to represent a Sequence Of Items.
Definition gdcmSequenceOfItems.h:40
ItemVector::const_iterator ConstIterator
Definition gdcmSequenceOfItems.h:46
VL SequenceLengthField
Total length of the Sequence (or 0xffffffff) if undefined.
Definition gdcmSequenceOfItems.h:254
std::vector< Item > ItemVector
Definition gdcmSequenceOfItems.h:43
SizeType GetNumberOfItems() const
Definition gdcmSequenceOfItems.h:86
void Print(std::ostream &os) const override
Definition gdcmSequenceOfItems.h:221
bool operator==(const Value &val) const override
Definition gdcmSequenceOfItems.h:244
std::istream & Read(std::istream &is, bool readvalues=true)
Definition gdcmSequenceOfItems.h:104
SequenceOfItems & operator=(const SequenceOfItems &val)
Definition gdcmSequenceOfItems.h:97
ConstIterator Begin() const
Definition gdcmSequenceOfItems.h:49
void SetLength(VL length) override
Sets the actual SQ length.
Definition gdcmSequenceOfItems.h:59
bool RemoveItemByIndex(const SizeType index)
void SetNumberOfItems(SizeType n)
Definition gdcmSequenceOfItems.h:87
std::ostream const & Write(std::ostream &os) const
Definition gdcmSequenceOfItems.h:201
void AddItem(Item const &item)
Appends an Item to the already added ones.
void Clear() override
remove all items within the sequence
VL GetLength() const override
Returns the SQ length, as read from disk.
Definition gdcmSequenceOfItems.h:57
bool IsUndefinedLength() const
return if Value Length if of undefined length
Definition gdcmSequenceOfItems.h:65
bool FindDataElement(const Tag &t) const
Item & GetItem(SizeType position)
ItemVector Items
Vector of Sequence Items.
Definition gdcmSequenceOfItems.h:256
static SmartPointer< SequenceOfItems > New()
Definition gdcmSequenceOfItems.h:238
ItemVector::iterator Iterator
Definition gdcmSequenceOfItems.h:45
ConstIterator End() const
Definition gdcmSequenceOfItems.h:50
Iterator End()
Definition gdcmSequenceOfItems.h:48
const Item & GetItem(SizeType position) const
void SetLengthToUndefined()
Properly set the Sequence of Item to be undefined length.
Item & AddNewUndefinedLengthItem()
Appends an Item to the already added ones.
Iterator Begin()
Definition gdcmSequenceOfItems.h:47
SequenceOfItems()
constructor (UndefinedLength by default)
Definition gdcmSequenceOfItems.h:53
bool IsEmpty() const
Definition gdcmSequenceOfItems.h:85
ItemVector::size_type SizeType
Definition gdcmSequenceOfItems.h:44
Class for Smart Pointer.
Definition gdcmSmartPointer.h:40
Class to represent a DICOM Data Element (Attribute) Tag (Group, Element).
Definition gdcmTag.h:39
const std::ostream & Write(std::ostream &os) const
Write a tag in binary rep.
Definition gdcmTag.h:169
Value Length.
Definition gdcmVL.h:30
const std::ostream & Write(std::ostream &os) const
Definition gdcmVL.h:99
Class to represent the value of a Data Element.
Definition gdcmValue.h:32
#define gdcmWarningMacro(msg)
Warning.
Definition gdcmTrace.h:142
#define gdcmDebugMacro(msg)
Debug.
Definition gdcmTrace.h:119
#define GDCM_EXPORT
Definition gdcmWin32.h:34