vega
|
This class is used to contain the information in a single DataElement. More...
#include <vega/dicom/data_element.h>
Public Member Functions | |
DataElement (std::shared_ptr< DataSet > parent=nullptr) | |
DataElement (const std::string &name, std::shared_ptr< DataSet > parent=nullptr) | |
DataElement (const Tag &tag, std::shared_ptr< DataSet > parent=nullptr) | |
DataElement (const Tag &tag, const VR &vr, std::shared_ptr< DataSet > parent=nullptr) | |
const std::shared_ptr< const dictionary::Page > & | page () const |
void | set_page (std::shared_ptr< const dictionary::Page > page) |
Sets the dictionary::Page for blank DataElements. More... | |
const DataElementHeader & | header () const |
DataElementHeader & | header () |
const Tag & | tag () const |
Tag & | tag () |
const VR & | vr () const |
VR & | vr () |
const DataElementHeader::length_type & | length () const |
DataElementHeader::length_type & | length () |
const std::weak_ptr< DataSet > & | parent () const |
std::weak_ptr< DataSet > & | parent () |
const std::vector< std::shared_ptr< DataSet > > & | data_sets () const |
std::vector< std::shared_ptr< DataSet > > & | data_sets () |
template<typename T > | |
void | set_manipulator (std::shared_ptr< T > manipulator) |
template<typename T > | |
std::shared_ptr< T > | get_manipulator () |
std::string | str () const |
Builds a string representation of the content of this DataElement. More... | |
bool | is_sequence () const |
std::vector< std::shared_ptr< DataSet > >::iterator | begin () |
std::vector< std::shared_ptr< DataSet > >::const_iterator | begin () const |
std::vector< std::shared_ptr< DataSet > >::iterator | end () |
std::vector< std::shared_ptr< DataSet > >::const_iterator | end () const |
bool | operator== (const DataElement &other) const |
bool | operator!= (const DataElement &other) const |
void | log (Logger &logger) const |
This class is used to contain the information in a single DataElement.
This class corresponds to the part of a DICOM file called a "data element" (see DICOM documentation).
A DataElement has two main parts: a DataElementHeader and the data itself. The DataElementHeader is used to store the Tag which defines what type of data is stored, VR which defines the representation that the data is in, and a length which determines how much data is stored in the DataElement. The length never needs to be touched by the user of this library, because it is always dynamically determined when writing to file anyway. Furthermore, the user should also never need to concern themselves with modifying the tag or vr directly. This is because they are automatically filled when reading from a DICOM file, and they are automatically set for you when you instantiate a new DataElement yourself.
The data stored in the DataElement can take one of two forms: raw data, or sequence data. The details are explained in the DICOM documentation, but it is not necessary to understand these details to use this library. The main thing to know is that when the VR of a DataElement is vr::SQ (is_sequence() returns true
), the DataElement stores a vector of DataSets, and otherwise (is_sequence() returns false
) it stores raw data that is accessible through a manipulator.
When the DataElement is a sequence, you can access the DataSet vector through the data_sets() method. This class also provides iterators through the begin() and end() methods so the DataSets can be looped over easily.
In this case, the DataElement stores raw data accessible through a manipulator object. The difficulty with using manipulators comes from the fact that what data is stored and how it is stored varies depending on the VR. This means that this information cannot be known at compile-time, and so must be provided through the templates of get_manipulator() and set_manipulator(). The advantage of using these manipulators is that they are each designed to make dealing with the data for each type of VR. See vega/manipulator.h for a list of allowed manipulators and how to use them.
Note that it is usually easier to use the wrapper class Element<T> instead of DataElement when dealing with raw data.
vega::dicom::DataElement::DataElement | ( | std::shared_ptr< DataSet > | parent = nullptr | ) |
Creates a blank DataElement with the given parent
.
parent | is the parent DataSet of the DataElement |
vega::dicom::DataElement::DataElement | ( | const std::string & | name, |
std::shared_ptr< DataSet > | parent = nullptr |
||
) |
Creates a blank DataElement with tag given by the name
.
The Tag and VR is read from the Dictionary using the name
parameter. Can only use this constructor if the corresponding dictionary::Page has a single unique Tag. For example the dictionary entry "CurveDimensions"
is defined to have tag (50xx,0005)
where xx
can be any hexadecimal digits, and so this would not be permitted.
name | is the name of a Dictionary entry to read VR and Tag data from (e.g. "PatientName" ). |
parent | is the parent DataSet of the DataElement |
vega::dicom::DataElement::DataElement | ( | const Tag & | tag, |
std::shared_ptr< DataSet > | parent = nullptr |
||
) |
Creates a blank DataElement with tag given by the tag
.
Will raise an error if the given Tag is not present in the Dictionary, or if the Tag has a variable VR. For instance pixel data with tag (0x7FE0,0x0010)
can have VR of vr::OB or vr::OW, and so you should use the constructor which takes a VR also.
tag | is the Tag of this DataElement. |
parent | is the parent DataSet of the DataElement |
vega::dicom::DataElement::DataElement | ( | const Tag & | tag, |
const VR & | vr, | ||
std::shared_ptr< DataSet > | parent = nullptr |
||
) |
Creates a blank DataElement with tag given by the tag
and VR
.
Will raise an error if the given dictionary::Page corresponding to the Tag is not found or if the VR is incompatible with it.
tag | is the Tag of this DataElement. |
vr | is the VR of this DataElement. |
parent | is the parent DataSet of the DataElement (nullptr when at the root of the DICOM file) |
|
inline |
|
inline |
const std::vector<std::shared_ptr<DataSet> >& vega::dicom::DataElement::data_sets | ( | ) | const |
std::vector<std::shared_ptr<DataSet> >& vega::dicom::DataElement::data_sets | ( | ) |
This method is used when building a new DataElement sequence by giving the user a reference.
|
inline |
|
inline |
|
inline |
Returns a vega/manipulator.h manipulator object for the user to manipulate the content of this DataElement. If there is not yet a manipulator object, a new one is created and returned. If the received type T is compatible with the current existing manipulator, then a pointer to that is cast and returned. Otherwise if a new type is specified then a new manipulator is created from the existing raw data, so if it currently stores a list of 16 bit integers and you request a manipulator of 32 bit integers, then each 32 bit integer will be a pair of 16 bit integers.
const DataElementHeader& vega::dicom::DataElement::header | ( | ) | const |
DataElementHeader& vega::dicom::DataElement::header | ( | ) |
bool vega::dicom::DataElement::is_sequence | ( | ) | const |
true
when this DataElement is a sequence (has VR of vr::SQ). const DataElementHeader::length_type& vega::dicom::DataElement::length | ( | ) | const |
DataElementHeader::length_type& vega::dicom::DataElement::length | ( | ) |
void vega::dicom::DataElement::log | ( | Logger & | logger | ) | const |
bool vega::dicom::DataElement::operator!= | ( | const DataElement & | other | ) | const |
bool vega::dicom::DataElement::operator== | ( | const DataElement & | other | ) | const |
const std::shared_ptr<const dictionary::Page>& vega::dicom::DataElement::page | ( | ) | const |
const std::weak_ptr<DataSet>& vega::dicom::DataElement::parent | ( | ) | const |
std::weak_ptr<DataSet>& vega::dicom::DataElement::parent | ( | ) |
|
inline |
Given a user filled manipulator, this DataElement's internal manipulator will be set to this, and so any stored data is overwritten.
void vega::dicom::DataElement::set_page | ( | std::shared_ptr< const dictionary::Page > | page | ) |
Sets the dictionary::Page for blank DataElements.
std::string vega::dicom::DataElement::str | ( | ) | const |
Builds a string representation of the content of this DataElement.
const Tag& vega::dicom::DataElement::tag | ( | ) | const |
Tag& vega::dicom::DataElement::tag | ( | ) |
const VR& vega::dicom::DataElement::vr | ( | ) | const |
VR& vega::dicom::DataElement::vr | ( | ) |