15 #include "dcmtk/ofstd/ofstd.h" 52 if (
const auto* otherSelf = dynamic_cast<const DICOMSortByTag*>(&other))
54 if (!(this->m_Tag == otherSelf->m_Tag))
return false;
56 if (this->
m_SecondaryCriterion.IsNull() && otherSelf->m_SecondaryCriterion.IsNull())
return true;
58 if (this->
m_SecondaryCriterion.IsNull() || otherSelf->m_SecondaryCriterion.IsNull())
return false;
81 list.push_back(m_Tag);
105 return leftFinding.
value.compare(rightFinding.
value) < 0;
125 double leftDouble( 0 );
126 double rightDouble( 0 );
130 leftDouble = OFStandard::atof( leftFinding.
value.c_str() );
131 rightDouble = OFStandard::atof(rightFinding.
value.c_str());
133 catch (
const std::exception& )
139 if ( leftDouble != rightDouble )
141 return leftDouble < rightDouble;
161 double fromDouble(0);
166 fromDouble = OFStandard::atof(fromFinding.
value.c_str());
167 toDouble = OFStandard::atof(toFinding.
value.c_str());
169 catch (
const std::exception& )
171 MITK_WARN <<
"NO NUMERIC DISTANCE between '" << fromFinding.
value <<
"' and '" << toFinding.
value <<
"'";
175 return toDouble - fromDouble;
void Print(std::ostream &os) const
add "(group-id,element-id) name" to given stream
~DICOMSortByTag() override
std::vector< DICOMTag > DICOMTagList
Representation of a DICOM tag.
void Print(std::ostream &os) const override
brief describe this class in given stream.
DICOMSortCriterion::Pointer m_SecondaryCriterion
DICOMSortCriterion & operator=(const DICOMSortCriterion &other)
Interface to datasets that is presented to sorting classes such as DICOMDatasetSorter.
bool NextLevelIsLeftBeforeRight(const mitk::DICOMDatasetAccess *left, const mitk::DICOMDatasetAccess *right) const
double NumericDistance(const mitk::DICOMDatasetAccess *from, const mitk::DICOMDatasetAccess *to) const override
Calculate a distance between two datasets. This ansers the question of consecutive datasets...
virtual DICOMDatasetFinding GetTagValueAsString(const DICOMTag &tag) const =0
Return a DICOMDatasetFinding instance of the tag. The return containes (if valid) the raw value of th...
bool StringCompare(const mitk::DICOMDatasetAccess *left, const mitk::DICOMDatasetAccess *right, const DICOMTag &tag) const
DICOMSortByTag & operator=(const DICOMSortByTag &other)
bool operator==(const DICOMSortCriterion &other) const override
Compare two datasets by the value of a single tag (for use in DICOMTagBasedSorter).
A tag based sorting criterion for use in DICOMTagBasedSorter.
DICOMSortByTag(const DICOMTag &tag, DICOMSortCriterion::Pointer secondaryCriterion=nullptr)
bool IsLeftBeforeRight(const mitk::DICOMDatasetAccess *left, const mitk::DICOMDatasetAccess *right) const override
Answer the sorting question.
DICOMTagList GetTagsOfInterest() const override
Tags used for comparison.
bool NumericCompare(const mitk::DICOMDatasetAccess *left, const mitk::DICOMDatasetAccess *right, const DICOMTag &tag) const