MeVisLabToolboxReference
|
Class to represent one dicom tag. More...
#include <DCMTree_Tag.h>
Public Member Functions | |
Tag () | |
ctor | |
Tag (const TagInfo &info) | |
ctor info defines the datatype, name etc. | |
Tag (const Tag &other) | |
copy ctor - uses operator= | |
Tag (const Tag &other, unsigned short slot) | |
copy ctor for private tags with a given private slot | |
virtual | ~Tag () |
dtor | |
Tag & | operator= (const Tag &other) |
deep copy all values from other to this handles self-assignment well | |
bool | operator== (const Tag &other) const |
compare the tag with all contained values for equality | |
bool | operator!= (const Tag &other) const |
bool | isEqual (const Tag &other, double tolerance=0) const |
compare the tag with all contained values for equality; use tolerance for float value comparison | |
TagPtr | copy () const |
make a deep-copy of this | |
const TagInfo & | info () const |
get the tag-info (type etc.) of this tag | |
const TreePtrVector & | sequenceItems () const |
access the probably embedded sequences of this tag throws if this tag is not of type SQ! | |
TreePtrVector & | sequenceItems () |
access the probably embedded sequences of this tag throws if this tag is not of type SQ! | |
boost::uint32_t | numberOfSequenceItems () const |
get the number of embedded sequence items of this tag does not check for SQ | |
void | dropSequenceItems () |
drop all sequences of this tag does not check for SQ (if not SQ you just drop nothing) | |
void | dropSequenceItem (unsigned idx) |
drop the idx sequences of this tag throws if this tag tag is not of type SQ or the index is out of range | |
virtual boost::uint32_t | numberOfValues () const |
get the number of values of this tag | |
void | dropValues () |
drop all values of this tag does not drop sequences! these are handled differently! | |
bool | isEmpty () const |
return true if this tag has no sequences and no values | |
bool | isSequence () const |
return true if the vr of this tag is SQ | |
bool | isNull (unsigned idx) const |
check if the values with index idx is null throws if the index is out of range | |
bool | isSequenceItemNull (unsigned idx) const |
checks if the sequence with index idx is null throws if the index is out of range | |
void | setInfo (const TagInfo &info) |
set the tag-info for this tag be careful if changing vr! | |
void | addSequenceItem (const TreePtr &sequence) |
add the given TreePtr as sequence to this tag the referenced Tree remains valid tag stores only the reference, if the referenced data is changed externally this tag references the changes too if you need a dedicated copy, make one with Tree::copy! shared-pointers are to used to make it easier to edit/process sequences and to avoid copies | |
TreePtr & | addSequenceItem () |
add a sequence to this tag and return a reference to it for further processing | |
void | setSequenceItem (const TreePtr &sequence, unsigned idx=0) |
set the sequence with index idx same as addSequenceItem throws if the index is out of range | |
std::string | toString (unsigned int idx) const |
get the value of tag-value idx as string throws if type-checking failed throws if the index is out of range | |
std::string | toString () const |
convert the complete tag to a string that means, all values are concatenated by a backslash and converted to a string throws if not convertible | |
void | setValue (std::string value, unsigned int idx=0) |
set the value of tag-value idx as string throws if type-checking failed throws if the index is out of range | |
void | addValue (std::string value) |
convert string to one or more values and add them to this tag throws if not convertible | |
Date | toDate (unsigned int idx=0) const |
get the value of tag-value idx as date throws if type-checking failed throws if the index is out of range | |
void | setValue (Date value, unsigned int idx=0) |
set the value of tag-value idx as date throws if type-checking failed throws if the index is out of range | |
void | addValue (Date value) |
add a value of this tag as date throws if type-checking failed | |
Time | toTime (unsigned int idx=0) const |
get the value of tag-value idx as time throws if type-checking failed throws if the index is out of range | |
void | setValue (Time value, unsigned int idx=0) |
set the value of tag-value idx as time throws if type-checking failed throws if the index is out of range | |
void | addValue (Time value) |
add a value of this tag as time throws if type-checking failed | |
DateTime | toDateTime (unsigned int idx=0) const |
get the value of tag-value idx as datetime throws if type-checking failed throws if the index is out of range | |
void | setValue (DateTime value, unsigned int idx=0) |
set the value of tag-value idx as datetime throws if type-checking failed throws if the index is out of range | |
void | addValue (DateTime value) |
add a value of this tag as datetime throws if type-checking failed | |
float | toFloat (unsigned int idx=0) const |
get the value of tag-value idx as float throws if type-checking failed throws if the index is out of range | |
void | setValue (float value, unsigned int idx=0) |
set the value of tag-value idx as float throws if type-checking failed throws if the index is out of range | |
void | addValue (float value) |
add a value of this tag as float throws if type-checking failed | |
double | toDouble (unsigned int idx=0) const |
get the value of tag-value idx as double throws if type-checking failed throws if the index is out of range | |
void | setValue (double value, unsigned int idx=0) |
set the value of tag-value idx as double throws if type-checking failed throws if the index is out of range | |
void | addValue (double value) |
add a value of this tag as double throws if type-checking failed | |
int | toInt (unsigned int idx=0) const |
get the value of tag-value idx as int throws if type-checking failed throws if the index is out of range | |
void | setValue (int value, unsigned int idx=0) |
set the value of tag-value idx as int throws if type-checking failed throws if the index is out of range | |
void | addValue (int value) |
add a value of this tag as int throws if type-checking failed | |
unsigned int | toUInt (unsigned int idx=0) const |
get the value of tag-value idx as unsigned int throws if type-checking failed throws if the index is out of range | |
void | setValue (unsigned int value, unsigned int idx=0) |
set the value of tag-value idx as unsigned int throws if type-checking failed throws if the index is out of range | |
void | addValue (unsigned int value) |
add a value of this tag as unsigned int throws if type-checking failed | |
short int | toShort (unsigned int idx=0) const |
get the value of tag-value idx as short throws if type-checking failed throws if the index is out of range | |
void | setValue (short int value, unsigned int idx=0) |
set the value of tag-value idx as short throws if type-checking failed throws if the index is out of range | |
void | addValue (short int value) |
add a value of this tag as short throws if type-checking failed | |
unsigned short | toUShort (unsigned int idx=0) const |
get the value of tag-value idx as unsigned short throws if type-checking failed throws if the index is out of range | |
void | setValue (unsigned short int value, unsigned int idx=0) |
set the value of tag-value idx as unsigned short throws if type-checking failed throws if the index is out of range | |
void | addValue (unsigned short int value) |
add a value of this tag as unsigned short throws if type-checking failed | |
const Value & | getValue (unsigned int idx=0) const |
get the value-object with index idx throws if the index is out of range be careful - no type checking ! | |
void | setValue (const Value &value, unsigned int idx=0) |
set the value-object with index idx throws if the index is out of range be careful - no type checking ! | |
virtual Value & | addValue () |
add a value and return a reference for further processing be careful - no type checking ! | |
virtual boost::uint32_t | getValueSize (unsigned int idx) const |
get the size in bytes of the data of the value-object with index idx throws if the index is out of range | |
virtual boost::uint32_t | getValueSize () const |
get the total size in bytes of the data of the values | |
virtual void | fromStream (std::istream &in, bool readName) |
extract this instance from the given stream readName = true reads tag name(s) from stream, false assumes that no name(s) is/are in stream. | |
virtual void | toStream (std::ostream &out, bool writeName) const |
copy this instance recursively into the given stream writeName = true writes tag name(s) to stream, false writes no name(s) into stream. | |
int | compare (const Tag &tag, double tolerance=0.0001) const |
Copied from DicomTags (Marcus Barann). | |
void | setVr (Vr vr) |
Set a new value representation if the VR is unknown. | |
virtual void | serializeX (DCMTree_Serialization::Sink &sink) const |
Writes data of this object to Sink. | |
virtual void | deserializeX (DCMTree_Serialization::Source &source) |
Overwrites data of this object with data from Source. | |
Protected Member Functions | |
TagInfo const & | tagInfo () const |
Class to represent one dicom tag.
Definition at line 38 of file DCMTree_Tag.h.
DCMTree::Tag::Tag | ( | ) |
ctor
DCMTree::Tag::Tag | ( | const TagInfo & | info | ) |
ctor info defines the datatype, name etc.
of this tag
DCMTree::Tag::Tag | ( | const Tag & | other | ) |
copy ctor - uses operator=
DCMTree::Tag::Tag | ( | const Tag & | other, |
unsigned short | slot | ||
) |
copy ctor for private tags with a given private slot
slot | A value between 0x10 and 0xFF that will be used as the upper byte in the tag element |
virtual DCMTree::Tag::~Tag | ( | ) | [virtual] |
dtor
void DCMTree::Tag::addSequenceItem | ( | const TreePtr & | sequence | ) |
add the given TreePtr as sequence to this tag the referenced Tree remains valid tag stores only the reference, if the referenced data is changed externally this tag references the changes too if you need a dedicated copy, make one with Tree::copy! shared-pointers are to used to make it easier to edit/process sequences and to avoid copies
TreePtr& DCMTree::Tag::addSequenceItem | ( | ) |
add a sequence to this tag and return a reference to it for further processing
void DCMTree::Tag::addValue | ( | DateTime | value | ) |
add a value of this tag as datetime throws if type-checking failed
void DCMTree::Tag::addValue | ( | float | value | ) |
add a value of this tag as float throws if type-checking failed
void DCMTree::Tag::addValue | ( | double | value | ) |
add a value of this tag as double throws if type-checking failed
void DCMTree::Tag::addValue | ( | int | value | ) |
add a value of this tag as int throws if type-checking failed
void DCMTree::Tag::addValue | ( | unsigned int | value | ) |
add a value of this tag as unsigned int throws if type-checking failed
void DCMTree::Tag::addValue | ( | std::string | value | ) |
convert string to one or more values and add them to this tag throws if not convertible
void DCMTree::Tag::addValue | ( | short int | value | ) |
add a value of this tag as short throws if type-checking failed
void DCMTree::Tag::addValue | ( | unsigned short int | value | ) |
add a value of this tag as unsigned short throws if type-checking failed
virtual Value& DCMTree::Tag::addValue | ( | ) | [virtual] |
add a value and return a reference for further processing be careful - no type checking !
Reimplemented in DCMTree::MFPixelTag.
void DCMTree::Tag::addValue | ( | Date | value | ) |
add a value of this tag as date throws if type-checking failed
void DCMTree::Tag::addValue | ( | Time | value | ) |
add a value of this tag as time throws if type-checking failed
int DCMTree::Tag::compare | ( | const Tag & | tag, |
double | tolerance = 0.0001 |
||
) | const |
Copied from DicomTags (Marcus Barann).
Compare this to tag and return -1 if this < tag, 0 if this == tag, and 1 if this > tag. Comparison is performed value by value if both tags are numeric, otherwise byte by byte. If one tag is numeric and the other is a string, this results in nonsense. tolerance specifies the relative difference that is still accepted for 'equal' result.
TagPtr DCMTree::Tag::copy | ( | ) | const |
make a deep-copy of this
virtual void DCMTree::Tag::deserializeX | ( | DCMTree_Serialization::Source & | source | ) | [virtual] |
Overwrites data of this object with data from Source.
All the rules stated for SCR::Serializable::serializeX apply correspondingly.
Implements DCMTree_Serialization::Deserializable.
void DCMTree::Tag::dropSequenceItem | ( | unsigned | idx | ) |
drop the idx sequences of this tag throws if this tag tag is not of type SQ or the index is out of range
void DCMTree::Tag::dropSequenceItems | ( | ) |
drop all sequences of this tag does not check for SQ (if not SQ you just drop nothing)
void DCMTree::Tag::dropValues | ( | ) |
drop all values of this tag does not drop sequences! these are handled differently!
virtual void DCMTree::Tag::fromStream | ( | std::istream & | in, |
bool | readName | ||
) | [virtual] |
extract this instance from the given stream readName = true reads tag name(s) from stream, false assumes that no name(s) is/are in stream.
IMPORTANT: This method is used for file format persistence; thus stream contents must be maintained compatible.
Referenced by DCMTree::operator>>().
const Value& DCMTree::Tag::getValue | ( | unsigned int | idx = 0 | ) | const |
get the value-object with index idx throws if the index is out of range be careful - no type checking !
virtual boost::uint32_t DCMTree::Tag::getValueSize | ( | ) | const [virtual] |
get the total size in bytes of the data of the values
Reimplemented in DCMTree::MFPixelTag.
virtual boost::uint32_t DCMTree::Tag::getValueSize | ( | unsigned int | idx | ) | const [virtual] |
get the size in bytes of the data of the value-object with index idx throws if the index is out of range
Reimplemented in DCMTree::MFPixelTag.
const TagInfo& DCMTree::Tag::info | ( | ) | const |
get the tag-info (type etc.) of this tag
bool DCMTree::Tag::isEmpty | ( | ) | const |
return true if this tag has no sequences and no values
bool DCMTree::Tag::isEqual | ( | const Tag & | other, |
double | tolerance = 0 |
||
) | const |
compare the tag with all contained values for equality; use tolerance for float value comparison
bool DCMTree::Tag::isNull | ( | unsigned | idx | ) | const |
check if the values with index idx is null throws if the index is out of range
bool DCMTree::Tag::isSequence | ( | ) | const |
return true if the vr of this tag is SQ
bool DCMTree::Tag::isSequenceItemNull | ( | unsigned | idx | ) | const |
checks if the sequence with index idx is null throws if the index is out of range
boost::uint32_t DCMTree::Tag::numberOfSequenceItems | ( | ) | const |
get the number of embedded sequence items of this tag does not check for SQ
virtual boost::uint32_t DCMTree::Tag::numberOfValues | ( | ) | const [virtual] |
get the number of values of this tag
Reimplemented in DCMTree::MFPixelTag.
bool DCMTree::Tag::operator!= | ( | const Tag & | other | ) | const |
deep copy all values from other to this handles self-assignment well
bool DCMTree::Tag::operator== | ( | const Tag & | other | ) | const |
compare the tag with all contained values for equality
TreePtrVector& DCMTree::Tag::sequenceItems | ( | ) |
access the probably embedded sequences of this tag throws if this tag is not of type SQ!
const TreePtrVector& DCMTree::Tag::sequenceItems | ( | ) | const |
access the probably embedded sequences of this tag throws if this tag is not of type SQ!
virtual void DCMTree::Tag::serializeX | ( | DCMTree_Serialization::Sink & | sink | ) | const [virtual] |
Writes data of this object to Sink.
Implementations of Serializable::serializeX should strictly follow this pattern:
class C: public SCR::Serializable { T1 _m1; T2 _m2; T3 _m3; public: void serializeX(SCR::Sink &sink) const { SCR::serializeX(sink, _m1); SCR::serializeX(sink, _m2); SCR::serializeX(sink, _m3); } };
That is you should call some overloading of SCR::serializeX for every member.
If some of the types T1, T2, T3 are not serializable, you should make them serializable.
Implements DCMTree_Serialization::Serializable.
void DCMTree::Tag::setInfo | ( | const TagInfo & | info | ) |
set the tag-info for this tag be careful if changing vr!
void DCMTree::Tag::setSequenceItem | ( | const TreePtr & | sequence, |
unsigned | idx = 0 |
||
) |
set the sequence with index idx same as addSequenceItem throws if the index is out of range
void DCMTree::Tag::setValue | ( | DateTime | value, |
unsigned int | idx = 0 |
||
) |
set the value of tag-value idx as datetime throws if type-checking failed throws if the index is out of range
void DCMTree::Tag::setValue | ( | double | value, |
unsigned int | idx = 0 |
||
) |
set the value of tag-value idx as double throws if type-checking failed throws if the index is out of range
void DCMTree::Tag::setValue | ( | float | value, |
unsigned int | idx = 0 |
||
) |
set the value of tag-value idx as float throws if type-checking failed throws if the index is out of range
void DCMTree::Tag::setValue | ( | unsigned short int | value, |
unsigned int | idx = 0 |
||
) |
set the value of tag-value idx as unsigned short throws if type-checking failed throws if the index is out of range
void DCMTree::Tag::setValue | ( | Time | value, |
unsigned int | idx = 0 |
||
) |
set the value of tag-value idx as time throws if type-checking failed throws if the index is out of range
void DCMTree::Tag::setValue | ( | std::string | value, |
unsigned int | idx = 0 |
||
) |
set the value of tag-value idx as string throws if type-checking failed throws if the index is out of range
void DCMTree::Tag::setValue | ( | unsigned int | value, |
unsigned int | idx = 0 |
||
) |
set the value of tag-value idx as unsigned int throws if type-checking failed throws if the index is out of range
void DCMTree::Tag::setValue | ( | int | value, |
unsigned int | idx = 0 |
||
) |
set the value of tag-value idx as int throws if type-checking failed throws if the index is out of range
void DCMTree::Tag::setValue | ( | short int | value, |
unsigned int | idx = 0 |
||
) |
set the value of tag-value idx as short throws if type-checking failed throws if the index is out of range
void DCMTree::Tag::setValue | ( | const Value & | value, |
unsigned int | idx = 0 |
||
) |
set the value-object with index idx throws if the index is out of range be careful - no type checking !
void DCMTree::Tag::setValue | ( | Date | value, |
unsigned int | idx = 0 |
||
) |
set the value of tag-value idx as date throws if type-checking failed throws if the index is out of range
void DCMTree::Tag::setVr | ( | Vr | vr | ) |
Set a new value representation if the VR is unknown.
This is needed mainly for private tags with unknown VR, or can be used for still unsupported tags. The new VR is set _only_ if the current VR is unknown, and the existing value is converted to the new VR. This may also mean that the number of values changes.
TagInfo const& DCMTree::Tag::tagInfo | ( | ) | const [inline, protected] |
Definition at line 459 of file DCMTree_Tag.h.
Date DCMTree::Tag::toDate | ( | unsigned int | idx = 0 | ) | const |
get the value of tag-value idx as date throws if type-checking failed throws if the index is out of range
DateTime DCMTree::Tag::toDateTime | ( | unsigned int | idx = 0 | ) | const |
get the value of tag-value idx as datetime throws if type-checking failed throws if the index is out of range
double DCMTree::Tag::toDouble | ( | unsigned int | idx = 0 | ) | const |
get the value of tag-value idx as double throws if type-checking failed throws if the index is out of range
float DCMTree::Tag::toFloat | ( | unsigned int | idx = 0 | ) | const |
get the value of tag-value idx as float throws if type-checking failed throws if the index is out of range
int DCMTree::Tag::toInt | ( | unsigned int | idx = 0 | ) | const |
get the value of tag-value idx as int throws if type-checking failed throws if the index is out of range
short int DCMTree::Tag::toShort | ( | unsigned int | idx = 0 | ) | const |
get the value of tag-value idx as short throws if type-checking failed throws if the index is out of range
virtual void DCMTree::Tag::toStream | ( | std::ostream & | out, |
bool | writeName | ||
) | const [virtual] |
copy this instance recursively into the given stream writeName = true writes tag name(s) to stream, false writes no name(s) into stream.
IMPORTANT: This method is used for file format persistence; thus stream contents must be maintained compatible.
Referenced by DCMTree::operator<<().
std::string DCMTree::Tag::toString | ( | unsigned int | idx | ) | const |
get the value of tag-value idx as string throws if type-checking failed throws if the index is out of range
std::string DCMTree::Tag::toString | ( | ) | const |
convert the complete tag to a string that means, all values are concatenated by a backslash and converted to a string throws if not convertible
Time DCMTree::Tag::toTime | ( | unsigned int | idx = 0 | ) | const |
get the value of tag-value idx as time throws if type-checking failed throws if the index is out of range
unsigned int DCMTree::Tag::toUInt | ( | unsigned int | idx = 0 | ) | const |
get the value of tag-value idx as unsigned int throws if type-checking failed throws if the index is out of range
unsigned short DCMTree::Tag::toUShort | ( | unsigned int | idx = 0 | ) | const |
get the value of tag-value idx as unsigned short throws if type-checking failed throws if the index is out of range