changeset 2217:ccafa8ffcc6a

added CoordinateSystem3D::Equals()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 22 Apr 2025 17:01:35 +0200
parents d0d8090ea64f
children c098f0f16eb1
files OrthancStone/Sources/Toolbox/CoordinateSystem3D.cpp OrthancStone/Sources/Toolbox/CoordinateSystem3D.h OrthancStone/Sources/Toolbox/DicomStructureSet.cpp
diffstat 3 files changed, 23 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancStone/Sources/Toolbox/CoordinateSystem3D.cpp	Tue Apr 22 16:49:12 2025 +0200
+++ b/OrthancStone/Sources/Toolbox/CoordinateSystem3D.cpp	Tue Apr 22 17:01:35 2025 +0200
@@ -486,4 +486,24 @@
       throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
     }
   }
+
+
+  bool CoordinateSystem3D::Equals(const CoordinateSystem3D& other) const
+  {
+    if (!IsValid() && !other.IsValid())
+    {
+      return true;
+    }
+    else if (IsValid() && other.IsValid())
+    {
+      // The normal is automatically computed by "CheckAndComputeNormal()" that is called in all the constructors
+      return (LinearAlgebra::IsCloseToZero(boost::numeric::ublas::norm_2(GetOrigin() - other.GetOrigin())) &&
+              LinearAlgebra::IsCloseToZero(boost::numeric::ublas::norm_2(GetAxisX() - other.GetAxisX())) &&
+              LinearAlgebra::IsCloseToZero(boost::numeric::ublas::norm_2(GetAxisY() - other.GetAxisY())));
+    }
+    else
+    {
+      return false;
+    }
+  }
 }
--- a/OrthancStone/Sources/Toolbox/CoordinateSystem3D.h	Tue Apr 22 16:49:12 2025 +0200
+++ b/OrthancStone/Sources/Toolbox/CoordinateSystem3D.h	Tue Apr 22 17:01:35 2025 +0200
@@ -165,5 +165,7 @@
                                std::string& bottom /* out */,
                                std::string& left /* out */,
                                std::string& right /* out */) const;
+
+    bool Equals(const CoordinateSystem3D& other) const;
   };
 }
--- a/OrthancStone/Sources/Toolbox/DicomStructureSet.cpp	Tue Apr 22 16:49:12 2025 +0200
+++ b/OrthancStone/Sources/Toolbox/DicomStructureSet.cpp	Tue Apr 22 17:01:35 2025 +0200
@@ -306,7 +306,7 @@
 
         bool isOpposite;  // Ignored
         if (boost::numeric::ublas::norm_2(axisX) > 10.0 * std::numeric_limits<double>::epsilon() &&
-            !GeometryToolbox::IsParallelOrOpposite(axisX, estimatedNormal))
+            !GeometryToolbox::IsParallelOrOpposite(isOpposite, axisX, estimatedNormal))
         {
           found = true;
           break;