Skip to content
Snippets Groups Projects
Commit f797b08f authored by Johannes Junggeburth's avatar Johannes Junggeburth :dog2:
Browse files

Add check for GeoTransforms

parent 882c9889
No related branches found
No related tags found
No related merge requests found
Pipeline #6746054 passed
......@@ -18,7 +18,9 @@
*/
struct GeoPhysVolSorter {
bool operator()(const PVConstLink& a, const PVConstLink& b) const{
template <class VolType>
bool operator()(const GeoIntrusivePtr<VolType>& a,
const GeoIntrusivePtr<VolType>& b) const{
return compare(a, b) < 0;
}
......
......@@ -5,6 +5,8 @@
#define GEOMODELFUNCSNIPPETS_TRANSFORMSORTER_H
#include "GeoModelKernel/GeoDefinitions.h"
#include "GeoModelKernel/GeoTransform.h"
#include "GeoModelKernel/GeoIntrusivePtr.h"
#include "GeoModelKernel/Units.h"
#include <memory>
......@@ -18,14 +20,22 @@ namespace GeoTrf {
/// coincide within 0.01 degrees.
struct TransformSorter {
/// @brief Compare smart pointers of GeoTransforms
bool operator()(const std::unique_ptr<Transform3D>& a,
const std::unique_ptr<Transform3D>& b) const {
return (*this) (*a, *b);
}
const std::unique_ptr<Transform3D>& b) const;
bool operator()(const std::shared_ptr<Transform3D>& a,
const std::shared_ptr<Transform3D>& b) const {
return (*this)(*a, *b);
const std::shared_ptr<Transform3D>& b) const;
template<class GeoObjType>
bool operator()(const GeoIntrusivePtr<GeoObjType>& a,
const GeoIntrusivePtr<GeoObjType>& b) const {
return (*this) (a.get(), b.get());
}
bool operator()(const ::GeoTransform* a,
const ::GeoTransform* b) const;
bool operator()(const Transform3D& a, const Transform3D& b) const;
bool operator()(const RotationMatrix3D&a, const RotationMatrix3D& b) const;
......
......@@ -2,9 +2,23 @@
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
*/
#include "GeoModelFuncSnippets/TransformSorter.h"
#include "GeoModelFuncSnippets/throwExcept.h"
namespace GeoTrf {
bool TransformSorter::operator()(const std::unique_ptr<Transform3D>& a,
const std::unique_ptr<Transform3D>& b) const {
if (!a || !b) {
THROW_EXCEPTION("Nullptr given to comparator");
}
return (*this)(*a, *b);
}
bool TransformSorter::operator()(const std::shared_ptr<Transform3D>& a,
const std::shared_ptr<Transform3D>& b) const {
if (!a || !b) {
THROW_EXCEPTION("Nullptr given to comparator");
}
return (*this)(*a, *b);
}
bool TransformSorter::operator()(const Transform3D& a, const Transform3D& b) const{
return compare(a, b) < 0;
}
......@@ -21,4 +35,12 @@ namespace GeoTrf {
int TransformSorter::compare(const RotationMatrix3D&a, const RotationMatrix3D& b) const{
return getGeoRotationAngles(a).compare(getGeoRotationAngles(b));
}
bool TransformSorter::operator()(const ::GeoTransform* a,
const ::GeoTransform* b) const {
if (!a || !b) {
THROW_EXCEPTION("Nullptr given to comparator");
}
return (*this)(a->getTransform(), b->getTransform());
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment