diff Framework/Radiography/RadiographyScene.cpp @ 571:a29f9628369e

fix build on visual studio 2008
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 18 Apr 2019 16:34:25 +0200
parents 92305ee35b1c
children 7a7e36c52d62
line wrap: on
line diff
--- a/Framework/Radiography/RadiographyScene.cpp	Thu Apr 18 14:54:33 2019 +0200
+++ b/Framework/Radiography/RadiographyScene.cpp	Thu Apr 18 16:34:25 2019 +0200
@@ -199,24 +199,37 @@
   {
     LOG(INFO) << "Removing layer: " << layerIndex;
 
-    if (layerIndex > countLayers_)
+    Layers::iterator found = layers_.find(layerIndex);
+
+    if (found == layers_.end())
     {
       throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
     }
-    delete layers_[layerIndex];
-    layers_.erase(layerIndex);
-    countLayers_--;
-    LOG(INFO) << "Removing layer, there are now : " << countLayers_ << " layers";
+    else
+    {
+      assert(found->second != NULL);
+      delete found->second;
+      
+      layers_.erase(found);
+      countLayers_--;
+      
+      LOG(INFO) << "Removing layer, there are now : " << countLayers_ << " layers";
+    }
   }
 
   const RadiographyLayer& RadiographyScene::GetLayer(size_t layerIndex) const
   {
-    if (layerIndex > countLayers_)
+    Layers::const_iterator found = layers_.find(layerIndex);
+    
+    if (found == layers_.end())
     {
       throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
     }
-
-    return *(layers_.at(layerIndex));
+    else
+    {
+      assert(found->second != NULL);
+      return *found->second;
+    }
   }
 
   bool RadiographyScene::GetWindowing(float& center,