Salome HOME
[MEDCalc] : better slices + more error handling when invalid params
[modules/med.git] / src / MEDCalc / cmp / MEDPresentationContour.cxx
index d8b6b48d8a565280308ee5433930e21a9230f636..ee4628505aef623b148b0ff522c007eebc8cff3b 100644 (file)
@@ -66,6 +66,12 @@ MEDPresentationContour::internalGeneratePipeline()
       STDLOG(msg);
       throw KERNEL::createSalomeException(msg);
     }
+  if (_params.nbContours < 1)
+    {
+      const char * mes = "Invalid number of contours!";
+      STDLOG(mes);
+      throw KERNEL::createSalomeException(mes);
+    }
 
   setOrCreateRenderView(); // instanciate __viewXXX
 
@@ -103,7 +109,15 @@ MEDPresentationContour::updatePipeline(const MEDCALC::ContourParameters& params)
     updateColorMap<MEDPresentationContour, MEDCALC::ContourParameters>(params.colorMap);
 
   if (params.nbContours != _params.nbContours)
-    updateNbContours(params.nbContours);
+    {
+      if (params.nbContours < 1)
+        {
+          const char * mes = "Invalid number of contours!";
+          STDLOG(mes);
+          throw KERNEL::createSalomeException(mes);
+        }
+      updateNbContours(params.nbContours);
+    }
 }
 
 void