Salome HOME
Swig problem.
[tools/medcoupling.git] / src / MEDCoupling_Swig / MEDCouplingMemArray.i
index a47188a900aa66526a91dd48aa924df121465d46..27f0d46cf7b7e7e8934022e7f4d3a7bb605beef6 100644 (file)
@@ -242,6 +242,7 @@ namespace ParaMEDMEM
     static int GetPosOfItemGivenBESRelativeNoThrow(int value, int begin, int end, int step) throw(INTERP_KERNEL::Exception);
     static std::string GetVarNameFromInfo(const std::string& info) throw(INTERP_KERNEL::Exception);
     static std::string GetUnitFromInfo(const std::string& info) throw(INTERP_KERNEL::Exception);
+    static std::string BuildInfoFromVarAndUnit(const std::string& var, const std::string& unit) throw(INTERP_KERNEL::Exception);
     void updateTime() const;
     %extend
     {
@@ -2250,6 +2251,11 @@ namespace ParaMEDMEM
         return trueSelf;
       }
 
+      PyObject *__len__() throw(INTERP_KERNEL::Exception)
+      {
+        return PyInt_FromLong(self->getNumberOfCompo());
+      }
+
       PyObject *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception)
       {
         const char msg2[]="DataArrayDoubleTuple::__getitem__ : Mismatch of slice values in 2nd parameter (components) !";
@@ -2269,7 +2275,8 @@ namespace ParaMEDMEM
                 {
                   std::ostringstream oss;
                   oss << "Requesting for id " << singleVal << " having only " << nbc << " components !";
-                  throw INTERP_KERNEL::Exception(oss.str().c_str());
+                  PyErr_SetString(PyExc_StopIteration,oss.str().c_str());
+                  return 0;
                 }
               if(singleVal>=0)
                 return PyFloat_FromDouble(pt[singleVal]);
@@ -4522,6 +4529,11 @@ namespace ParaMEDMEM
         Py_XINCREF(trueSelf);
         return trueSelf;
       }
+
+      PyObject *__len__() throw(INTERP_KERNEL::Exception)
+      {
+        return PyInt_FromLong(self->getNumberOfCompo());
+      }
   
       PyObject *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception)
       {
@@ -4542,7 +4554,8 @@ namespace ParaMEDMEM
                 {
                   std::ostringstream oss;
                   oss << "Requesting for id " << singleVal << " having only " << nbc << " components !";
-                  throw INTERP_KERNEL::Exception(oss.str().c_str());
+                  PyErr_SetString(PyExc_StopIteration,oss.str().c_str());
+                  return 0;
                 }
               if(singleVal>=0)
                 return PyInt_FromLong(pt[singleVal]);
@@ -5181,6 +5194,223 @@ namespace ParaMEDMEM
             return ParaMEDMEM_DataArrayByte_presenceOfTuple(self,obj);
           }
       }
+
+      DataArrayByte *__setitem__(PyObject *obj, PyObject *value) throw(INTERP_KERNEL::Exception)
+      {
+        self->checkAllocated();
+        const char msg[]="Unexpected situation in __setitem__ !";
+        int nbOfTuples(self->getNumberOfTuples()),nbOfComponents(self->getNumberOfComponents());
+        int sw1,sw2;
+        int i1;
+        std::vector<int> v1;
+        DataArrayInt *d1=0;
+        DataArrayIntTuple *dd1=0;
+        convertObjToPossibleCpp1(value,sw1,i1,v1,d1,dd1);
+        int it1,ic1;
+        std::vector<int> vt1,vc1;
+        std::pair<int, std::pair<int,int> > pt1,pc1;
+        DataArrayInt *dt1=0,*dc1=0;
+        convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw2,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
+        MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp;
+        switch(sw2)
+          {
+          case 1:
+            {
+              switch(sw1)
+                {
+                case 1:
+                  self->setPartOfValuesSimple1(i1,it1,it1+1,1,0,nbOfComponents,1);
+                  return self;
+                default:
+                  throw INTERP_KERNEL::Exception(msg);
+                }
+              break;
+            }
+          case 2:
+            {
+              switch(sw1)
+                {
+                case 1:
+                  self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
+                  return self;
+                default:
+                  throw INTERP_KERNEL::Exception(msg);
+                }
+              break;
+            }
+          case 3:
+            {
+              switch(sw1)
+                {
+                case 1:
+                  self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
+                  return self;
+                default:
+                  throw INTERP_KERNEL::Exception(msg);
+                }
+              break;
+            }
+          case 4:
+            {
+              switch(sw1)
+                {
+                case 1:
+                  self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
+                  return self;
+                default:
+                  throw INTERP_KERNEL::Exception(msg);
+                }
+              break;
+            }
+          case 5:
+            {
+              switch(sw1)
+                {
+                case 1:
+                  self->setPartOfValuesSimple1(i1,it1,it1+1,1,ic1,ic1+1,1);
+                  return self;
+                default:
+                  throw INTERP_KERNEL::Exception(msg);
+                }
+              break;
+            }
+          case 6:
+            {
+              switch(sw1)
+                {
+                case 1:
+                  self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
+                  return self;
+                default:
+                  throw INTERP_KERNEL::Exception(msg);
+                }
+              break;
+            }
+          case 7:
+            {
+              switch(sw1)
+                {
+                case 1:
+                  self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
+                  return self;
+                default:
+                  throw INTERP_KERNEL::Exception(msg);
+                }
+              break;
+            }
+          case 8:
+            {
+              switch(sw1)
+                {
+                case 1:
+                  self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
+                  return self;
+                default:
+                  throw INTERP_KERNEL::Exception(msg);
+                }
+              break;
+            }
+          case 9:
+            {
+              switch(sw1)
+                {
+                case 1:
+                  self->setPartOfValuesSimple2(i1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
+                  return self;
+                default:
+                  throw INTERP_KERNEL::Exception(msg);
+                }
+              break;
+            }
+          case 10:
+            {
+              switch(sw1)
+                {
+                case 1:
+                  self->setPartOfValuesSimple2(i1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
+                  return self;
+                default:
+                  throw INTERP_KERNEL::Exception(msg);
+                }
+              break;
+            }
+          case 11:
+            {
+              switch(sw1)
+                {
+                case 1:
+                  self->setPartOfValuesSimple4(i1,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size());
+                  return self;
+                default:
+                  throw INTERP_KERNEL::Exception(msg);
+                }
+              break;
+            }
+          case 12:
+            {
+              switch(sw1)
+                {
+                case 1:
+                  self->setPartOfValuesSimple2(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
+                  return self;
+                default:
+                  throw INTERP_KERNEL::Exception(msg);
+                }
+              break;
+            }
+          case 13:
+            {
+              switch(sw1)
+                {
+                case 1:
+                  self->setPartOfValuesSimple1(i1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
+                  return self;
+                default:
+                  throw INTERP_KERNEL::Exception(msg);
+                }
+              break;
+            }
+          case 14:
+            {
+              switch(sw1)
+                {
+                case 1:
+                  self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
+                  return self;
+                default:
+                  throw INTERP_KERNEL::Exception(msg);
+                }
+              break;
+            }
+          case 15:
+            {
+              switch(sw1)
+                {
+                case 1:
+                  self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
+                  return self;
+                default:
+                  throw INTERP_KERNEL::Exception(msg);
+                }
+              break;
+            }
+          case 16:
+            {
+              switch(sw1)
+                {
+                case 1:
+                  self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
+                  return self;
+                default:
+                  throw INTERP_KERNEL::Exception(msg);
+                }
+              break;
+            }
+          default:
+            throw INTERP_KERNEL::Exception(msg);
+          }
+        return self;
+      }
     }
   };