![]() |
ImFusion SDK 4.3
|
#include <ImFusion/Dicom/DicomSequence.h>
Concrete sequence of items of type T, which must be derived from SequenceItem. More...
Concrete sequence of items of type T, which must be derived from SequenceItem.
A sequence is an Element by itself (i.e. it has a DICOM tag) but its value is usually meaningless. Instead, it provides a list of DcmItems that consist of one or multiple Elements again. These Elements are usually not directly accessed from the root DcmDataset (expect when searching recursively with searchIntoSubs). While in the root dataset each tag can only occur once, the same tag can occur in each item of the sequence, e.g. there can be multiple 'VOI LUT Descriptor' Elements. The template type defines which Elements make up a single item (all items must have those Elements).
When creating a sequence, the SequenceItems are initialized with the corresponding child DcmItem of the sequence.
Example for a imaginary Dicom file with following elements:
Rescale Intercept: 0.0 Modality Lut Sequence: 2 items
Rescale Intercept: 100.0 Rescale Intercept: 200.0
Public Member Functions | |
Sequence (ElementList &parent, DcmTag tag, ElementBase::Type type) | |
Creates a new Sequence instance. | |
Sequence (DcmItem &item, DcmTag tag, ElementBase::Type type) | |
void | reload () |
Reloads the list of items from the parent data set. | |
int | count () const |
Returns the number of items in this sequence. | |
T & | item (int i) |
Returns the sequence item at the given index. | |
const T & | item (int i) const |
T * | insertItem () |
Appends a new sequence item to the list. | |
void | checkErrors (bool ignoreMandatory=false) const override |
Checks the sequence for errors. | |
bool | isValid () const override |
Returns true if the element exists and is in a valid range. | |
![]() | |
SequenceBase (ElementList &parent, DcmTag tag, ElementBase::Type type) | |
SequenceBase (DcmItem &item, DcmTag tag, ElementBase::Type type) | |
![]() | |
ElementBase (ElementList &parent, DcmTag tag, Type type=Conditional, bool searchIntoSubs=false) | |
ElementBase (DcmItem &item, DcmTag tag, Type type=Conditional, bool searchIntoSubs=false) | |
void | setCondition (std::function< bool()> predicate) |
Sets a callback function that determines if a conditional element is mandatory. | |
virtual DcmTag | tag () const |
DICOM tag wrapped by this Element. | |
virtual bool | isMandatory () const |
Evaluates whether this element is mandatory (based on the specified type and optionally condition). | |
virtual bool | exists () const |
Returns true if the elements exists in the dataset. | |
void | remove () |
Removes the element from the dataset. | |
std::string | valueString () const |
Returns the value of the element as a string. | |
void | setTargetSequence (DcmItem *sequence) |
Sets an optional sequence item where this elements will write its value. | |
![]() | |
virtual void * | registerErrorHandler (ErrorCallback handler) |
Registers a new handler callback function. | |
virtual void | unregisterErrorHandler (void *handler) |
Removes a previously registered handler again. | |
void * | forwardErrors (const ErrorRecorder *otherRecorder) |
Convenient function to forward all errors registered to this recorder to another recorder. | |
virtual void | registerError (const Error &error) const |
Sends the given error to all error handler callbacks. | |
void | registerError (Error::Code code, Error::Type type, const std::string &details, TagProxy tag=TagProxy()) const |
Protected Attributes | |
std::vector< std::unique_ptr< T > > | m_items |
![]() | |
DcmItem & | m_dataset |
DICOM data set/base element to retrieve element data from. | |
DcmItem * | m_targetSeq |
Optional sequence to write element data to; only used for setValue(). | |
DcmTag | m_tag |
DICOM tag the Element refers to. | |
Type | m_type |
Conditionality of the Element. | |
bool | m_searchIntoSubs |
Flag whether to search into sub sequences or not. | |
std::function< bool()> | m_typeCondition |
Optional predicate function to evaluate conditionality. | |
Additional Inherited Members | |
![]() | |
enum | Type { Mandatory , Conditional } |
Conditionality of an Element. More... | |
![]() | |
using | ErrorCallback = std::function<void(const Error&)> |
Alias for a function to call for each error recorded. | |
T & item | ( | int | i | ) |
Returns the sequence item at the given index.
Throws an out-of-range exception if i is smaller than 0 and not smaller than count().
T * insertItem | ( | ) |
Appends a new sequence item to the list.
Returns the newly created item. Throws a value_error in case the item could not be created in the wrapped DICOM dataset.
|
overridevirtual |
Checks the sequence for errors.
This assures that all mandatory and conditional elements are present and that all existing elements have a valid value. If ignoreMandatory is true, missing mandatory elements are not counted as errors (e.g. useful when the sequence itself is optional).
Implements SequenceBase.
|
overridevirtual |
Returns true if the element exists and is in a valid range.
Implements ElementBase.