]> SALOME platform Git repositories - modules/med.git/commitdiff
Salome HOME
Py binding of static method DataArrayInt.CheckAndPreparePermutation. V7_4_0b1
authorgeay <anthony.geay@cea.fr>
Wed, 9 Apr 2014 14:09:21 +0000 (16:09 +0200)
committergeay <anthony.geay@cea.fr>
Wed, 9 Apr 2014 14:09:21 +0000 (16:09 +0200)
src/MEDCoupling_Swig/MEDCouplingBasicsTest.py
src/MEDCoupling_Swig/MEDCouplingMemArray.i

index 1f58aec188b11d5235783192f5522827bb61bc83..5ae3883ea5b63e67d2409ad83f26a855dd5fdb67 100644 (file)
@@ -14724,6 +14724,15 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         self.assertTrue(m.getNodalConnectivityIndex().isEqual(DataArrayInt([0,5])))
         pass
 
+    def testSwig2CheckAndPreparePermutation2(self):
+        a=DataArrayInt([10003,9999999,5,67])
+        self.assertTrue(DataArrayInt.CheckAndPreparePermutation(a).isEqual(DataArrayInt([2,3,0,1])))
+        a=DataArrayInt([10003,-9999999,5,67])
+        self.assertTrue(DataArrayInt.CheckAndPreparePermutation(a).isEqual(DataArrayInt([3,0,1,2])))
+        a=DataArrayInt([])
+        self.assertTrue(DataArrayInt.checkAndPreparePermutation(a).isEqual(DataArrayInt([])))
+        pass
+
     def setUp(self):
         pass
     pass
index c17ed322bbee0db8fb4732d034dbb5400646030c..a47188a900aa66526a91dd48aa924df121465d46 100644 (file)
 %newobject ParaMEDMEM::DataArrayInt::buildPermArrPerLevel;
 %newobject ParaMEDMEM::DataArrayInt::getDifferentValues;
 %newobject ParaMEDMEM::DataArrayInt::FindPermutationFromFirstToSecond;
+%newobject ParaMEDMEM::DataArrayInt::CheckAndPreparePermutation;
 %newobject ParaMEDMEM::DataArrayInt::__neg__;
 %newobject ParaMEDMEM::DataArrayInt::__add__;
 %newobject ParaMEDMEM::DataArrayInt::__radd__;
@@ -2787,6 +2788,17 @@ namespace ParaMEDMEM
         return ret;
       }
 
+      static DataArrayInt *CheckAndPreparePermutation(PyObject *arr) throw(INTERP_KERNEL::Exception)
+      {
+        MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret(DataArrayInt::New());
+        int szArr,sw,iTypppArr;
+        std::vector<int> stdvecTyyppArr;
+        const int *arrPtr(convertObjToPossibleCpp1_Safe(arr,sw,szArr,iTypppArr,stdvecTyyppArr));
+        int *pt(ParaMEDMEM::DataArrayInt::CheckAndPreparePermutation(arrPtr,arrPtr+szArr));
+        ret->useArray(pt,true,ParaMEDMEM::C_DEALLOC,szArr,1);
+        return ret.retn();
+      }
+
       void setValues(PyObject *li, PyObject *nbOfTuples=0, PyObject *nbOfComp=0) throw(INTERP_KERNEL::Exception)
       {
         const char *msg="ParaMEDMEM::DataArrayInt::setValues : Available API are : \n-DataArrayInt.setValues([1,3,4])\n-DataArrayInt.setValues([1,3,4],3)\n-DataArrayInt.setValues([1,3,4,5],2,2)\n-DataArrayInt.New(5)\n !";