15 #ifndef GDCMSEQUENCEOFITEMS_H
16 #define GDCMSEQUENCEOFITEMS_H
47 Iterator
Begin() {
return Items.begin(); }
48 Iterator
End() {
return Items.end(); }
49 ConstIterator
Begin()
const {
return Items.begin(); }
50 ConstIterator
End()
const {
return Items.end(); }
60 SequenceLengthField = length;
63 void SetLengthToUndefined();
66 return SequenceLengthField.IsUndefined();
69 template <
typename TDE>
70 VL ComputeLength()
const;
76 void AddItem(
Item const &item);
80 bool RemoveItemByIndex(
const SizeType index );
90 const Item &GetItem(SizeType position)
const;
91 Item &GetItem(SizeType position);
99 template <
typename TDE,
typename TSwap>
100 std::istream &
Read(std::istream &is,
bool readvalues =
true)
103 const Tag seqDelItem(0xfffe,0xe0dd);
104 if( SequenceLengthField.IsUndefined() )
107 while( item.
Read<TDE,TSwap>(is) && item.
GetTag() != seqDelItem )
110 assert( item.
GetTag() != seqDelItem );
111 Items.push_back( item );
121 while( l != SequenceLengthField )
125 item.
Read<TDE,TSwap>(is);
131 VL newlength = l + item.template GetLength<TDE>();
132 if( newlength > SequenceLengthField )
136 SequenceLengthField = newlength;
144 #ifdef GDCM_SUPPORT_BROKEN_IMPLEMENTATION
145 if( item.
GetTag() == seqDelItem )
147 gdcmWarningMacro(
"SegDelItem found in defined length Sequence. Skipping" );
148 assert( item.
GetVL() == 0 );
160 Items.push_back( item );
162 l += item.template GetLength<TDE>();
163 if( l > SequenceLengthField )
166 throw "Length of Item larger than expected";
168 assert( l <= SequenceLengthField );
170 #ifdef GDCM_SUPPORT_BROKEN_IMPLEMENTATION
173 if( SequenceLengthField == 778 && l == 774 )
176 SequenceLengthField = l;
183 else if ( SequenceLengthField == 444 && l == 3*71 )
187 l = SequenceLengthField;
191 assert( l == SequenceLengthField );
196 template <
typename TDE,
typename TSwap>
197 std::ostream
const &
Write(std::ostream &os)
const
199 typename ItemVector::const_iterator it = Items.begin();
200 for(;it != Items.end(); ++it)
202 it->Write<TDE,TSwap>(os);
204 if( SequenceLengthField.IsUndefined() )
207 const Tag seqDelItem(0xfffe,0xe0dd);
208 seqDelItem.
Write<TSwap>(os);
210 zero.
Write<TSwap>(os);
217 void Print(std::ostream &os)
const {
218 os <<
"\t(" << SequenceLengthField <<
")\n";
219 ItemVector::const_iterator it =
221 for(;it != Items.end(); ++it)
225 if( SequenceLengthField.IsUndefined() )
227 const Tag seqDelItem(0xfffe,0xe0dd);
238 bool FindDataElement(
const Tag &t)
const;
257 #include "gdcmSequenceOfItems.txx"
259 #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:217
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:31
ItemVector::const_iterator ConstIterator
Definition: gdcmSequenceOfItems.h:46
std::ostream const & Write(std::ostream &os) const
Definition: gdcmSequenceOfItems.h:197
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:93
ItemVector Items
Vector of Sequence Items.
Definition: gdcmSequenceOfItems.h:252
#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:234
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:83
Class for Smart Pointer.
Definition: gdcmObject.h:26
bool operator==(const Value &val) const
Definition: gdcmSequenceOfItems.h:240
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:250
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:100
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:82