72 assert( DES.empty() );
79 void Print(std::ostream &os, std::string
const &indent =
"")
const {
86 for( ; it != DES.end(); ++it)
88 os << indent << *it <<
"\n";
92 template <
typename TDE>
99 for( ++it; it != DES.end()
100 && it->GetTag().GetGroup() == tag.
GetGroup(); ++it)
102 assert( it->GetTag().GetElement() != 0x0 );
103 assert( it->GetTag().GetGroup() == tag.
GetGroup() );
104 res += it->GetLength<TDE>();
109 template <
typename TDE>
111 if( DES.empty() )
return 0;
112 assert( !DES.empty() );
116 for( ; it != DES.end(); ++it)
118 assert( !(it->GetLength<TDE>().IsUndefined()) );
119 if ( it->GetTag() !=
Tag(0xfffe,0xe00d) )
141 InsertDataElement( de );
146 gdcmErrorMacro(
"Cannot add element with group < 0x0008 and != 0x4 in the dataset: " << de.
GetTag() );
152 if( it != DES.end() )
163 if( it != DES.end() && it->IsEmpty() )
173 DataElementSet::size_type count = DES.erase(tag);
174 assert( count == 0 || count == 1 );
191 if( it != DES.end() )
196 const DataElement& operator() (uint16_t group, uint16_t element)
const {
return GetDataElement(
Tag(group,element) ); }
212 const auto it = GetDataElement(t);
214 return it != GetDEEnd();
222 if( it != DES.end() )
233 template <
typename TDE,
typename TSwap>
236 template <
typename TDE,
typename TSwap>
237 std::istream &
Read(std::istream &is);
239 template <
typename TDE,
typename TSwap>
240 std::istream &
ReadUpToTag(std::istream &is,
const Tag &t, std::set<Tag>
const & skiptags);
242 template <
typename TDE,
typename TSwap>
245 template <
typename TDE,
typename TSwap>
246 std::istream &
ReadSelectedTags(std::istream &is,
const std::set<Tag> & tags,
bool readvalues =
true);
247 template <
typename TDE,
typename TSwap>
250 template <
typename TDE,
typename TSwap>
252 template <
typename TDE,
typename TSwap>
255 template <
typename TDE,
typename TSwap>
256 std::ostream
const &
Write(std::ostream &os)
const;
258 template <
typename TDE,
typename TSwap>
277 std::pair<Iterator,bool> pr = DES.insert(de);
278 if( pr.second ==
false )
280 gdcmWarningMacro(
"DataElement: " << de <<
" was already found, skipping duplicate entry.\n"
281 "Original entry kept is: " << *pr.first );
306#if defined(SWIGPYTHON) || defined(SWIGCSHARP) || defined(SWIGJAVA) || defined(SWIGPHP)
314 SWIGDataSet(
DataSet &des):Internal(des),it(des.Begin()) {}
315 const DataElement& GetCurrent()
const {
return *it; }
316 void Start() { it = Internal.Begin(); }
317 bool IsAtEnd()
const {
return it == Internal.End(); }
318 void Next() { ++it; }
321 DataSet::ConstIterator it;
332#include "gdcmDataSet.txx"
Definition gdcmDataSet.h:28
Class to represent a Data Element either Implicit or Explicit.
Definition gdcmDataElement.h:59
const VL & GetVL() const
Get VL.
Definition gdcmDataElement.h:74
const Tag & GetTag() const
Get Tag.
Definition gdcmDataElement.h:67
bool IsEmpty() const
Check if Data Element is empty.
Definition gdcmDataElement.h:106
Value const & GetValue() const
Set/Get Value (bytes array, SQ of items, SQ of fragments):
Definition gdcmDataElement.h:94
Class to represent a Data Set (which contains Data Elements)
Definition gdcmDataSet.h:56
DataElementSet::iterator Iterator
Definition gdcmDataSet.h:61
const DataElement & GetDataElement(const Tag &t) const
Definition gdcmDataSet.h:188
DataSet & operator=(DataSet const &)=default
void InsertDataElement(const DataElement &de)
Definition gdcmDataSet.h:273
Tag ComputeDataElement(const PrivateTag &t) const
std::istream & ReadSelectedTags(std::istream &is, const std::set< Tag > &tags, bool readvalues=true)
Iterator End()
Definition gdcmDataSet.h:67
PrivateTag GetPrivateTag(const Tag &t) const
Return the private tag of the private tag 't', private creator will be set to empty if not found.
void Clear()
Definition gdcmDataSet.h:70
const DataElement & FindNextDataElement(const Tag &t) const
Definition gdcmDataSet.h:219
void ReplaceEmpty(const DataElement &de)
Only replace a DICOM attribute when it is missing or empty.
Definition gdcmDataSet.h:161
bool FindDataElement(const PrivateTag &t) const
Look up if private tag 't' is present in the dataset:
MediaStorage GetMediaStorage() const
std::string GetPrivateCreator(const Tag &t) const
DataElementSet::const_iterator ConstIterator
Definition gdcmDataSet.h:60
const DataElementSet & GetDES() const
Definition gdcmDataSet.h:68
bool IsEmpty() const
Returns if the dataset is empty.
Definition gdcmDataSet.h:228
std::istream & Read(std::istream &is)
SizeType Remove(const Tag &tag)
Completely remove a dataelement from the dataset.
Definition gdcmDataSet.h:172
const DataElement & GetDataElement(const PrivateTag &t) const
Return the dataelement.
std::istream & ReadNested(std::istream &is)
DataElementSet::size_type SizeType
Definition gdcmDataSet.h:62
std::istream & ReadSelectedPrivateTags(std::istream &is, const std::set< PrivateTag > &tags, bool readvalues=true)
std::ostream const & Write(std::ostream &os) const
void Insert(const DataElement &de)
Definition gdcmDataSet.h:128
ConstIterator Begin() const
Definition gdcmDataSet.h:64
Iterator Begin()
Definition gdcmDataSet.h:65
std::istream & ReadSelectedTagsWithLength(std::istream &is, const std::set< Tag > &tags, VL &length, bool readvalues=true)
void Print(std::ostream &os, std::string const &indent="") const
Definition gdcmDataSet.h:79
std::set< DataElement > DataElementSet
Definition gdcmDataSet.h:59
VL GetLength() const
Definition gdcmDataSet.h:110
bool FindDataElement(const Tag &t) const
Definition gdcmDataSet.h:211
std::istream & ReadUpToTagWithLength(std::istream &is, const Tag &t, std::set< Tag > const &skiptags, VL &length)
SizeType Size() const
Definition gdcmDataSet.h:75
void Replace(const DataElement &de)
Replace a dataelement with another one.
Definition gdcmDataSet.h:150
unsigned int ComputeGroupLength(Tag const &tag) const
Definition gdcmDataSet.h:93
const DataElement & GetDEEnd() const
std::istream & ReadWithLength(std::istream &is, VL &length)
DataElementSet & GetDES()
Definition gdcmDataSet.h:69
std::istream & ReadUpToTag(std::istream &is, const Tag &t, std::set< Tag > const &skiptags)
std::istream & ReadSelectedPrivateTagsWithLength(std::istream &is, const std::set< PrivateTag > &tags, VL &length, bool readvalues=true)
ConstIterator End() const
Definition gdcmDataSet.h:66
Class to represent a Private DICOM Data Element (Attribute) Tag (Group, Element, Owner)
Definition gdcmPrivateTag.h:39
Class to represent a DICOM Data Element (Attribute) Tag (Group, Element).
Definition gdcmTag.h:39
uint16_t GetGroup() const
Returns the 'Group number' of the given Tag.
Definition gdcmTag.h:55
uint16_t GetElement() const
Returns the 'Element number' of the given Tag.
Definition gdcmTag.h:57
Value Length.
Definition gdcmVL.h:30
VL GetLength() const
Definition gdcmVL.h:68
virtual VL GetLength() const =0
#define gdcmAssertAlwaysMacro(arg)
AssertAlways.
Definition gdcmTrace.h:228
#define gdcmWarningMacro(msg)
Warning.
Definition gdcmTrace.h:142
#define gdcmErrorMacro(msg)
Error this is pretty bad, more than just warning It could mean lost of data, something not handle....
Definition gdcmTrace.h:165
#define GDCM_EXPORT
Definition gdcmWin32.h:34
std::ostream & operator<<(std::ostream &os, const Directory &d)
Definition gdcmDirectory.h:88