]> SALOME platform Git repositories - modules/med.git/commitdiff
Salome HOME
MEDReader -> debugging session
authorageay <ageay>
Tue, 30 Jul 2013 15:46:16 +0000 (15:46 +0000)
committerageay <ageay>
Tue, 30 Jul 2013 15:46:16 +0000 (15:46 +0000)
src/MEDCoupling/MEDCouplingMemArray.cxx
src/MEDCoupling_Swig/MEDCouplingBasicsTest.py

index 395bcb8bbfe8af2f821437a27b07856475cbc62e..03cf0c323ccc5d0b5d0e689e6b20a1743f0afa1d 100644 (file)
@@ -6149,7 +6149,16 @@ DataArrayInt *DataArrayInt::invertArrayN2O2O2N(int oldNbOfElem) const
   std::fill(pt,pt+oldNbOfElem,-1);
   int nbOfNewElems=getNumberOfTuples();
   for(int i=0;i<nbOfNewElems;i++)
-    pt[new2Old[i]]=i;
+    {
+      int v(new2Old[i]);
+      if(v>=0 && v<oldNbOfElem)
+         pt[v]=i;
+      else
+        {
+          std::ostringstream oss; oss << "DataArrayInt::invertArrayN2O2O2N : in new id #" << i << " old value is " << v << " expected to be in [0," << oldNbOfElem << ") !";
+          throw INTERP_KERNEL::Exception(oss.str().c_str());
+        }
+    }
   return ret.retn();
 }
 
index 0df84a8f3b0a076bc6c726c8a3e66087bc0968fe..68f4dcbc964c9b1a22a7eae99072c24daf2c8a51 100644 (file)
@@ -13498,6 +13498,15 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         self.assertEqual([8,9,14,13],m.getNodeIdsOfCell(7))
         pass
 
+    def testSwig2ThrowOnDAIInvertN2O2ON2(self):
+        p1=DataArrayInt([3,5,8])
+        p2=DataArrayInt([0,3,4,5,6,7,8,9,10])
+        p1.transformWithIndArr(p2.invertArrayN2O2O2N(11))
+        self.assertTrue(p1.isEqual(DataArrayInt([1,3,6])))
+        self.assertTrue(p2.invertArrayN2O2O2N(11).isEqual(DataArrayInt([0,-1,-1,1,2,3,4,5,6,7,8])))
+        self.assertRaises(InterpKernelException,p2.invertArrayN2O2O2N,10)
+        pass
+
     def setUp(self):
         pass
     pass