diff Framework/Toolbox/SlicesSorter.cpp @ 119:ba83e38cf3ff wasm

rendering of rt-dose
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 02 Oct 2017 22:01:41 +0200
parents 2eca030792aa
children e2fe9352f240
line wrap: on
line diff
--- a/Framework/Toolbox/SlicesSorter.cpp	Mon Oct 02 14:31:26 2017 +0200
+++ b/Framework/Toolbox/SlicesSorter.cpp	Mon Oct 02 22:01:41 2017 +0200
@@ -28,20 +28,25 @@
   class SlicesSorter::SliceWithDepth : public boost::noncopyable
   {
   private:
-    Slice   slice_;
-    double  depth_;
+    std::auto_ptr<Slice>   slice_;
+    double                 depth_;
 
   public:
-    SliceWithDepth(const Slice& slice) :
+    SliceWithDepth(Slice* slice) :
       slice_(slice),
       depth_(0)
     {
+      if (slice == NULL)
+      {
+        throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
+      }
     }
 
     void SetNormal(const Vector& normal)
     {
+      assert(slice_.get() != NULL);
       depth_ = boost::numeric::ublas::inner_prod
-        (slice_.GetGeometry().GetOrigin(), normal);
+        (slice_->GetGeometry().GetOrigin(), normal);
     }
 
     double GetDepth() const
@@ -51,7 +56,8 @@
 
     const Slice& GetSlice() const
     {
-      return slice_;
+      assert(slice_.get() != NULL);
+      return *slice_;
     }
   };
 
@@ -76,7 +82,7 @@
   }
 
 
-  void SlicesSorter::AddSlice(const Slice& slice)
+  void SlicesSorter::AddSlice(Slice* slice)
   {
     slices_.push_back(new SliceWithDepth(slice));
   }