59 os <<
"(0020,0032) Image Position (Patient) along normal of (0020,0037) Image Orientation (Patient)";
67 tags.push_back(
DICOMTag(0x0020, 0x0032) );
68 tags.push_back(
DICOMTag(0x0020, 0x0037) );
78 double distance = InternalNumericDistance(left, right, possible);
81 return distance > 0.0;
85 return this->NextLevelIsLeftBeforeRight(left, right);
97 Vector3D leftRight; leftRight.Fill(0.0);
99 bool leftHasOrientation(
false);
101 leftRight, leftUp, leftHasOrientation );
103 Vector3D rightRight; rightRight.Fill(0.0);
104 Vector3D rightUp; rightUp.Fill(0.0);
105 bool rightHasOrientation(
false);
107 rightRight, rightUp, rightHasOrientation );
109 Point3D leftOrigin; leftOrigin.Fill(0.0f);
110 bool leftHasOrigin(
false);
113 Point3D rightOrigin; rightOrigin.Fill(0.0f);
114 bool rightHasOrigin(
false);
121 for (
unsigned int dim = 0; dim < 3; ++dim)
123 if ( fabs(leftRight[dim] - rightRight[dim]) > 0.0001
124 || fabs(leftUp[dim] - rightUp[dim]) > 0.0001)
126 MITK_ERROR <<
"Dicom images have different orientations.";
127 throw std::logic_error(
"Dicom images have different orientations. Call GetSeries() first to separate images.");
132 normal[0] = leftRight[1] * leftUp[2] - leftRight[2] * leftUp[1];
133 normal[1] = leftRight[2] * leftUp[0] - leftRight[0] * leftUp[2];
134 normal[2] = leftRight[0] * leftUp[1] - leftRight[1] * leftUp[0];
136 double leftDistance = 0.0;
137 double rightDistance = 0.0;
140 for (
unsigned int dim = 0; dim < 3; ++dim)
142 leftDistance += normal[dim] * leftOrigin[dim];
143 rightDistance += normal[dim] * rightOrigin[dim];
147 if ( fabs(leftDistance - rightDistance) >=
mitk::eps)
151 return rightDistance - leftDistance;
166 double retVal = InternalNumericDistance(from, to, possible);
167 return possible ? retVal : 0.0;
virtual bool operator==(const DICOMSortCriterion &other) const override
itk::SmartPointer< Self > Pointer
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)
virtual ~SortByImagePositionPatient()
Interface to datasets that is presented to sorting classes such as DICOMDatasetSorter.
virtual void Print(std::ostream &os) const override
brief describe this class in given stream.
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...
virtual DICOMTagList GetTagsOfInterest() const override
Tags used for comparison.
virtual 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)
virtual bool IsLeftBeforeRight(const mitk::DICOMDatasetAccess *left, const mitk::DICOMDatasetAccess *right) const override
Answer the sorting question.