55 os <<
"(0020,0032) Image Position (Patient) along normal of (0020,0037) Image Orientation (Patient)";
63 tags.push_back(
DICOMTag(0x0020, 0x0032) );
64 tags.push_back(
DICOMTag(0x0020, 0x0037) );
77 return distance > 0.0;
93 Vector3D leftRight; leftRight.Fill(0.0);
95 bool leftHasOrientation(
false);
97 leftRight, leftUp, leftHasOrientation );
99 Vector3D rightRight; rightRight.Fill(0.0);
100 Vector3D rightUp; rightUp.Fill(0.0);
101 bool rightHasOrientation(
false);
103 rightRight, rightUp, rightHasOrientation );
105 Point3D leftOrigin; leftOrigin.Fill(0.0f);
106 bool leftHasOrigin(
false);
109 Point3D rightOrigin; rightOrigin.Fill(0.0f);
110 bool rightHasOrigin(
false);
117 for (
unsigned int dim = 0; dim < 3; ++dim)
119 if ( fabs(leftRight[dim] - rightRight[dim]) > 0.0001
120 || fabs(leftUp[dim] - rightUp[dim]) > 0.0001)
122 MITK_ERROR <<
"Dicom images have different orientations.";
123 throw std::logic_error(
"Dicom images have different orientations. Call GetSeries() first to separate images.");
128 normal[0] = leftRight[1] * leftUp[2] - leftRight[2] * leftUp[1];
129 normal[1] = leftRight[2] * leftUp[0] - leftRight[0] * leftUp[2];
130 normal[2] = leftRight[0] * leftUp[1] - leftRight[1] * leftUp[0];
132 double leftDistance = 0.0;
133 double rightDistance = 0.0;
136 for (
unsigned int dim = 0; dim < 3; ++dim)
138 leftDistance += normal[dim] * leftOrigin[dim];
139 rightDistance += normal[dim] * rightOrigin[dim];
143 if ( fabs(leftDistance - rightDistance) >=
mitk::eps)
147 return rightDistance - leftDistance;
163 return possible ? retVal : 0.0;
bool operator==(const DICOMSortCriterion &other) const override
~SortByImagePositionPatient() override
std::vector< DICOMTag > DICOMTagList
void DICOMStringToOrientationVectors(const std::string &s, Vector3D &right, Vector3D &up, bool &successful)
Convert DICOM string describing a point two Vector3D.
Representation of a DICOM tag.
use the deprecated old MITK testing style If possible
Sort by distance of image origin along image normal (for use in DICOMTagBasedSorter).
DICOMSortCriterion & operator=(const DICOMSortCriterion &other)
SortByImagePositionPatient(DICOMSortCriterion::Pointer secondaryCriterion=nullptr)
Interface to datasets that is presented to sorting classes such as DICOMDatasetSorter.
void Print(std::ostream &os) const override
brief describe this class in given stream.
bool NextLevelIsLeftBeforeRight(const mitk::DICOMDatasetAccess *left, const mitk::DICOMDatasetAccess *right) const
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...
DICOMTagList GetTagsOfInterest() const override
Tags used for comparison.
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...
A tag based sorting criterion for use in DICOMTagBasedSorter.
MITKCORE_EXPORT const ScalarType eps
double InternalNumericDistance(const mitk::DICOMDatasetAccess *from, const mitk::DICOMDatasetAccess *to, bool &possible) const
Point3D DICOMStringToPoint3D(const std::string &s, bool &successful)
Convert DICOM string describing a point to Point3D.
SortByImagePositionPatient & operator=(const SortByImagePositionPatient &other)
bool IsLeftBeforeRight(const mitk::DICOMDatasetAccess *left, const mitk::DICOMDatasetAccess *right) const override
Answer the sorting question.