diff OrthancStone/Sources/Toolbox/SortedFrames.cpp @ 1630:78509230f0d7

SortedFrames sharing code with CoordinateSystem3D
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 09 Nov 2020 18:01:32 +0100
parents b3c439d96d3e
children 960bb5fcc440
line wrap: on
line diff
--- a/OrthancStone/Sources/Toolbox/SortedFrames.cpp	Mon Nov 09 15:14:37 2020 +0100
+++ b/OrthancStone/Sources/Toolbox/SortedFrames.cpp	Mon Nov 09 18:01:32 2020 +0100
@@ -29,7 +29,8 @@
 
 namespace OrthancStone
 {
-  SortedFrames::Instance::Instance(const Orthanc::DicomMap& tags)
+  SortedFrames::Instance::Instance(const Orthanc::DicomMap& tags) :
+    geometry_(tags)
   {
     tags_.Assign(tags);
 
@@ -58,40 +59,9 @@
     {
       monochrome1_ = false;
     }
-
-    hasPosition_ = (
-      LinearAlgebra::ParseVector(position_, tags, Orthanc::DICOM_TAG_IMAGE_POSITION_PATIENT) &&
-      position_.size() == 3 &&
-      GeometryToolbox::ComputeNormal(normal_, tags));
   }
 
 
-  const Vector& SortedFrames::Instance::GetNormal() const
-  {
-    if (hasPosition_)
-    {
-      return normal_;
-    }
-    else
-    {
-      throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
-    }
-  }
-
-
-  const Vector& SortedFrames::Instance::GetPosition() const
-  {
-    if (hasPosition_)
-    {
-      return position_;
-    }
-    else
-    {
-      throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
-    }
-  }
-
-  
   SortedFrames::Frame::Frame(const Instance& instance,
                              unsigned int frameNumber) :
     instance_(&instance),
@@ -343,10 +313,10 @@
       assert(instances_[*it] != NULL);
       const Instance& instance = *instances_[*it];
 
-      if (instance.HasPosition())
+      if (instance.GetGeometry().IsValid())
       {
         n += 1;
-        meanNormal += (instance.GetNormal() - meanNormal) / static_cast<float>(n);
+        meanNormal += (instance.GetGeometry().GetNormal() - meanNormal) / static_cast<float>(n);
       }
     }
 
@@ -358,13 +328,13 @@
     {
       assert(instances_[*it] != NULL);
       const Instance& instance = *instances_[*it];
-        
+      
       std::string sopInstanceUid;
-      if (instance.HasPosition() &&
+      if (instance.GetGeometry().IsValid() &&
           instance.GetTags().LookupStringValue(
             sopInstanceUid, Orthanc::DICOM_TAG_SOP_INSTANCE_UID, false))
       {
-        double p = LinearAlgebra::DotProduct(meanNormal, instance.GetPosition());
+        double p = LinearAlgebra::DotProduct(meanNormal, instance.GetGeometry().GetOrigin());
         items.push_back(SortableItem<float>(static_cast<float>(p), *it, sopInstanceUid));
       }
     }