]> SALOME platform Git repositories - modules/med.git/commitdiff
Salome HOME
debugs
authorageay <ageay>
Wed, 19 Jun 2013 14:53:10 +0000 (14:53 +0000)
committerageay <ageay>
Wed, 19 Jun 2013 14:53:10 +0000 (14:53 +0000)
src/MEDCoupling/MEDCoupling1GTUMesh.cxx
src/MEDCoupling/MEDCoupling1GTUMesh.hxx
src/MEDCoupling/MEDCouplingMemArray.cxx
src/MEDCoupling/MEDCouplingPointSet.cxx
src/MEDCoupling/MEDCouplingPointSet.hxx
src/MEDCoupling/MEDCouplingRefCountObject.cxx
src/MEDCoupling/MEDCouplingRefCountObject.hxx
src/MEDCoupling/MEDCouplingUMesh.cxx
src/MEDCoupling_Swig/MEDCouplingBasicsTest.py
src/MEDCoupling_Swig/MEDCouplingCommon.i

index c2bde1a5443964ecdce0838566b15a584b332a8a..fb67f3a0e90dc5ea64b33419b9c8b5b71bd177ff 100644 (file)
@@ -162,13 +162,14 @@ void MEDCoupling1GTUMesh::splitProfilePerType(const DataArrayInt *profile, std::
   int nbTuples=profile->getNumberOfTuples();
   int nbOfCells=getNumberOfCells();
   code.resize(3); idsInPflPerType.resize(1);
-  code[0]=(int)getCellModelEnum(); code[1]=nbOfCells;
+  code[0]=(int)getCellModelEnum(); code[1]=nbTuples;
   idsInPflPerType.resize(1);
   if(profile->isIdentity() && nbTuples==nbOfCells)
     {
       code[2]=-1;
       idsInPflPerType[0]=const_cast<DataArrayInt *>(profile); idsInPflPerType[0]->incrRef();
-      idsPerType.clear(); 
+      idsPerType.clear();
+      return ;
     }
   code[2]=0;
   profile->checkAllIdsInRange(0,nbOfCells);
@@ -240,7 +241,7 @@ bool MEDCoupling1GTUMesh::isEqualIfNotWhy(const MEDCouplingMesh *other, double p
       reason="mesh given in input is not castable in MEDCouplingSGTUMesh !";
       return false;
     }
-  if(&_cm!=&otherC->_cm)
+  if(_cm!=otherC->_cm)
     {
       reason="mismatch in geometric type !";
       return false;
@@ -257,7 +258,7 @@ bool MEDCoupling1GTUMesh::isEqualWithoutConsideringStr(const MEDCouplingMesh *ot
   const MEDCoupling1GTUMesh *otherC=dynamic_cast<const MEDCoupling1GTUMesh *>(other);
   if(!otherC)
     return false;
-  if(&_cm!=&otherC->_cm)
+  if(_cm!=otherC->_cm)
     return false;
   return true;
 }
@@ -816,28 +817,6 @@ DataArrayInt *MEDCoupling1SGTUMesh::mergeNodes2(double precision, bool& areNodes
   return ret;
 }
 
-/*!
- * Removes unused nodes (the node coordinates array is shorten) and returns an array
- * mapping between new and old node ids in "Old to New" mode. -1 values in the returned
- * array mean that the corresponding old node is no more used. 
- *  \return DataArrayInt * - a new instance of DataArrayInt of length \a
- *           this->getNumberOfNodes() before call of this method. The caller is to
- *           delete this array using decrRef() as it is no more needed. 
- *  \throw If the coordinates array is not set.
- *  \throw If the nodal connectivity of cells is not defined.
- *  \throw If the nodal connectivity includes an invalid id.
- *
- *  \ref cpp_mcumesh_zipCoordsTraducer "Here is a C++ example".<br>
- *  \ref  py_mcumesh_zipCoordsTraducer "Here is a Python example".
- */
-DataArrayInt *MEDCoupling1SGTUMesh::zipCoordsTraducer() throw(INTERP_KERNEL::Exception)
-{
-  int newNbOfNodes=-1;
-  DataArrayInt *traducer=getNodeIdsInUse(newNbOfNodes);
-  renumberNodes(traducer->getConstPointer(),newNbOfNodes);
-  return traducer;
-}
-
 /// @cond INTERNAL
 
 struct MEDCouplingAccVisit
@@ -874,9 +853,9 @@ DataArrayInt *MEDCoupling1SGTUMesh::getNodeIdsInUse(int& nbrOfNodesInUse) const
   const int *conn=_conn->begin();
   int nbNodesPerCell=getNumberOfNodesPerCell();
   for(int i=0;i<nbOfCells;i++)
-    for(int j=0;j<nbNodesPerCell;j++)
-      if(conn[j]>=0 && conn[j]<nbOfNodes)
-        traducer[conn[j]]=1;
+    for(int j=0;j<nbNodesPerCell;j++,conn++)
+      if(*conn>=0 && *conn<nbOfNodes)
+        traducer[*conn]=1;
       else
         {
           std::ostringstream oss; oss << "MEDCoupling1SGTUMesh::getNodeIdsInUse : In cell #" << i  << " presence of node id " <<  conn[j] << " not in [0," << nbOfNodes << ") !";
@@ -900,7 +879,7 @@ DataArrayInt *MEDCoupling1SGTUMesh::getNodeIdsInUse(int& nbrOfNodesInUse) const
 void MEDCoupling1SGTUMesh::renumberNodesInConn(const int *newNodeNumbersO2N)
 {
   getNumberOfCells();//only to check that all is well defined.
-  _conn->renumberInPlace(newNodeNumbersO2N);
+  _conn->transformWithIndArr(newNodeNumbersO2N,newNodeNumbersO2N+getNumberOfNodes());
   updateTime();
 }
 
@@ -957,6 +936,7 @@ MEDCoupling1SGTUMesh *MEDCoupling1SGTUMesh::Merge1SGTUMeshesOnSameCoords(std::ve
   const DataArrayDouble *coords=(*it)->getCoords();
   const INTERP_KERNEL::CellModel *cm=&((*it)->getCellModel());
   int nbNodesPerCell=(*it)->getNumberOfNodesPerCell();
+  it++;
   for(;it!=a.end();it++)
     {
       if(cm!=&((*it)->getCellModel()))
@@ -990,6 +970,7 @@ MEDCoupling1SGTUMesh *MEDCoupling1SGTUMesh::Merge1SGTUMeshesLL(std::vector<const
   int nbOfCells=(*it)->getNumberOfCells();
   const INTERP_KERNEL::CellModel *cm=&((*it)->getCellModel());
   int nbNodesPerCell=(*it)->getNumberOfNodesPerCell();
+  it++;
   for(;it!=a.end();it++)
     {
       if(cm!=&((*it)->getCellModel()))
@@ -1013,7 +994,7 @@ MEDCoupling1SGTUMesh *MEDCoupling1SGTUMesh::Merge1SGTUMeshesLL(std::vector<const
       offset+=(*it)->getNumberOfNodes();
     }
   //
-  ret->_conn=c;
+  ret->setNodalConnectivity(c);
   return ret.retn();
 }
 
@@ -1078,10 +1059,7 @@ MEDCoupling1SGTUMesh *MEDCoupling1SGTUMesh::buildSetInstanceFromThis(int spaceDi
       tmp1=DataArrayInt::New(); tmp1->alloc(0,1);
     }
   else
-    {
-      tmp1=_conn;
-      tmp1->incrRef();
-    }
+    tmp1=_conn;
   ret->_conn=tmp1;
   if(!_coords)
     {
@@ -1165,7 +1143,7 @@ DataArrayInt *MEDCoupling1SGTUMesh::simplexizePlanarFace6() throw(INTERP_KERNEL:
   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New(); ret->alloc(6*nbOfCells,1);
   const int *c(_conn->begin());
   int *retPtr(ret->getPointer()),*newConnPtr(newConn->getPointer());
-  for(int i=0;i<nbOfCells;i++,c+=8,newConnPtr+=20,retPtr+=6)
+  for(int i=0;i<nbOfCells;i++,c+=8,newConnPtr+=24,retPtr+=6)
     {
       for(int j=0;j<24;j++)
         newConnPtr[j]=c[INTERP_KERNEL::SPLIT_NODES_6_WO[j]];
index 947f3e16a88931f9ca6f0097e6b5d38d215dfdd6..5b4eba07e345f7b7c916b7b6672406b1be3d8ed1 100644 (file)
@@ -104,7 +104,6 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT MEDCouplingPointSet *mergeMyselfWithOnSameCoords(const MEDCouplingPointSet *other) const;
     MEDCOUPLING_EXPORT DataArrayInt *mergeNodes(double precision, bool& areNodesMerged, int& newNbOfNodes);
     MEDCOUPLING_EXPORT DataArrayInt *mergeNodes2(double precision, bool& areNodesMerged, int& newNbOfNodes);
-    MEDCOUPLING_EXPORT DataArrayInt *zipCoordsTraducer() throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelfKeepCoords(const int *begin, const int *end) const;
     MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelfKeepCoords2(int start, int end, int step) const;
     MEDCOUPLING_EXPORT void getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const throw(INTERP_KERNEL::Exception);
@@ -128,6 +127,7 @@ namespace ParaMEDMEM
   private:
     MEDCOUPLING_EXPORT MEDCoupling1SGTUMesh(const char *name, const INTERP_KERNEL::CellModel& cm);
     MEDCOUPLING_EXPORT MEDCoupling1SGTUMesh(const MEDCoupling1SGTUMesh& other, bool recDeepCpy);
+    virtual ~MEDCoupling1SGTUMesh() { }
   private:
     void checkNonDynamicGeoType() const throw(INTERP_KERNEL::Exception);
     static MEDCoupling1SGTUMesh *Merge1SGTUMeshesLL(std::vector<const MEDCoupling1SGTUMesh *>& a) throw(INTERP_KERNEL::Exception);
index d8dee0b6a7f7552bfa07fd860474debac6ad252b..f6f5243bddd4998c2936e75b65434d85960559e9 100644 (file)
@@ -1291,7 +1291,16 @@ void DataArrayDouble::renumberInPlace(const int *old2New) throw(INTERP_KERNEL::E
   double *tmp=new double[nbTuples*nbOfCompo];
   const double *iptr=getConstPointer();
   for(int i=0;i<nbTuples;i++)
-    std::copy(iptr+nbOfCompo*i,iptr+nbOfCompo*(i+1),tmp+nbOfCompo*old2New[i]);
+    {
+      int v=old2New[i];
+      if(v>=0 && v<nbTuples)
+        std::copy(iptr+nbOfCompo*i,iptr+nbOfCompo*(i+1),tmp+nbOfCompo*v);
+      else
+        {
+          std::ostringstream oss; oss << "DataArrayDouble::renumberInPlace : At place #" << i << " value is " << v << " ! Should be in [0," << nbTuples << ") !";
+          throw INTERP_KERNEL::Exception(oss.str().c_str());
+        }
+    }
   std::copy(tmp,tmp+nbTuples*nbOfCompo,getPointer());
   delete [] tmp;
   declareAsNew();
@@ -1315,7 +1324,16 @@ void DataArrayDouble::renumberInPlaceR(const int *new2Old) throw(INTERP_KERNEL::
   double *tmp=new double[nbTuples*nbOfCompo];
   const double *iptr=getConstPointer();
   for(int i=0;i<nbTuples;i++)
-    std::copy(iptr+nbOfCompo*new2Old[i],iptr+nbOfCompo*(new2Old[i]+1),tmp+nbOfCompo*i);
+    {
+      int v=new2Old[i];
+      if(v>=0 && v<nbTuples)
+        std::copy(iptr+nbOfCompo*v,iptr+nbOfCompo*(v+1),tmp+nbOfCompo*i);
+      else
+        {
+          std::ostringstream oss; oss << "DataArrayDouble::renumberInPlaceR : At place #" << i << " value is " << v << " ! Should be in [0," << nbTuples << ") !";
+          throw INTERP_KERNEL::Exception(oss.str().c_str());
+        }
+    }
   std::copy(tmp,tmp+nbTuples*nbOfCompo,getPointer());
   delete [] tmp;
   declareAsNew();
@@ -5887,7 +5905,7 @@ void DataArrayInt::splitByValueRange(const int *arrBg, const int *arrEnd,
         }
       else
         {
-          std::ostringstream oss; oss << "DataArrayInt::splitByValueRange : At rank #" << i << " the value is " << work[i] << " whereas the last value is " << *bg;
+          std::ostringstream oss; oss << "DataArrayInt::splitByValueRange : At rank #" << i << " the value is " << work[i] << " should be in [0," << *bg << ") !";
           throw INTERP_KERNEL::Exception(oss.str().c_str());
         }
     }
@@ -6346,7 +6364,16 @@ void DataArrayInt::renumberInPlace(const int *old2New) throw(INTERP_KERNEL::Exce
   int *tmp=new int[nbTuples*nbOfCompo];
   const int *iptr=getConstPointer();
   for(int i=0;i<nbTuples;i++)
-    std::copy(iptr+nbOfCompo*i,iptr+nbOfCompo*(i+1),tmp+nbOfCompo*old2New[i]);
+    {
+      int v=old2New[i];
+      if(v>=0 && v<nbTuples)
+        std::copy(iptr+nbOfCompo*i,iptr+nbOfCompo*(i+1),tmp+nbOfCompo*v);
+      else
+        {
+          std::ostringstream oss; oss << "DataArrayInt::renumberInPlace : At place #" << i << " value is " << v << " ! Should be in [0," << nbTuples << ") !";
+          throw INTERP_KERNEL::Exception(oss.str().c_str());
+        }
+    }
   std::copy(tmp,tmp+nbTuples*nbOfCompo,getPointer());
   delete [] tmp;
   declareAsNew();
@@ -6370,7 +6397,16 @@ void DataArrayInt::renumberInPlaceR(const int *new2Old) throw(INTERP_KERNEL::Exc
   int *tmp=new int[nbTuples*nbOfCompo];
   const int *iptr=getConstPointer();
   for(int i=0;i<nbTuples;i++)
-    std::copy(iptr+nbOfCompo*new2Old[i],iptr+nbOfCompo*(new2Old[i]+1),tmp+nbOfCompo*i);
+    {
+      int v=new2Old[i];
+      if(v>=0 && v<nbTuples)
+        std::copy(iptr+nbOfCompo*v,iptr+nbOfCompo*(v+1),tmp+nbOfCompo*i);
+      else
+        {
+          std::ostringstream oss; oss << "DataArrayInt::renumberInPlaceR : At place #" << i << " value is " << v << " ! Should be in [0," << nbTuples << ") !";
+          throw INTERP_KERNEL::Exception(oss.str().c_str());
+        }
+    }
   std::copy(tmp,tmp+nbTuples*nbOfCompo,getPointer());
   delete [] tmp;
   declareAsNew();
index 70411f77b82982c29fa8ba84b55f2d0dcf0f2897..204111cb6f26e046168b937a7e15415e2c236bb2 100644 (file)
@@ -389,8 +389,8 @@ void MEDCouplingPointSet::renumberNodes(const int *newNodeNumbers, int newNbOfNo
   if(!_coords)
     throw INTERP_KERNEL::Exception("MEDCouplingPointSet::renumberNodes : no coords specified !");
   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> newCoords=_coords->renumberAndReduce(newNodeNumbers,newNbOfNodes);
-  setCoords(newCoords);
   renumberNodesInConn(newNodeNumbers);
+  setCoords(newCoords);//let it here not before renumberNodesInConn because old number of nodes is sometimes used...
 }
 
 /*!
@@ -1515,3 +1515,25 @@ DataArrayInt *MEDCouplingPointSet::getCellIdsFullyIncludedInNodeIds(const int *p
 {
   return getCellIdsLyingOnNodes(partBg,partEnd,true);
 }
+
+/*!
+ * Removes unused nodes (the node coordinates array is shorten) and returns an array
+ * mapping between new and old node ids in "Old to New" mode. -1 values in the returned
+ * array mean that the corresponding old node is no more used. 
+ *  \return DataArrayInt * - a new instance of DataArrayInt of length \a
+ *           this->getNumberOfNodes() before call of this method. The caller is to
+ *           delete this array using decrRef() as it is no more needed. 
+ *  \throw If the coordinates array is not set.
+ *  \throw If the nodal connectivity of cells is not defined.
+ *  \throw If the nodal connectivity includes an invalid id.
+ *
+ *  \ref cpp_mcumesh_zipCoordsTraducer "Here is a C++ example".<br>
+ *  \ref  py_mcumesh_zipCoordsTraducer "Here is a Python example".
+ */
+DataArrayInt *MEDCouplingPointSet::zipCoordsTraducer() throw(INTERP_KERNEL::Exception)
+{
+  int newNbOfNodes=-1;
+  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> traducer=getNodeIdsInUse(newNbOfNodes);
+  renumberNodes(traducer->getConstPointer(),newNbOfNodes);
+  return traducer.retn();
+}
index ed2b4505643e890a85bfc52a3f361c4868a2827f..a815d8508ef6499d3b47365b97e8cf014d5eeaca 100644 (file)
@@ -128,7 +128,7 @@ namespace ParaMEDMEM
                          const std::vector<std::string>& littleStrings);
     virtual DataArrayInt *getCellsInBoundingBox(const double *bbox, double eps) const = 0;
     virtual DataArrayInt *getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps) = 0;
-    virtual DataArrayInt *zipCoordsTraducer() throw(INTERP_KERNEL::Exception) = 0;
+    virtual DataArrayInt *zipCoordsTraducer() throw(INTERP_KERNEL::Exception);
     virtual DataArrayInt *zipConnectivityTraducer(int compType, int startCellId=0) throw(INTERP_KERNEL::Exception);
     virtual void getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const throw(INTERP_KERNEL::Exception) = 0;
     //tools
index b4ae45f67b3c2de1fa79f62c43e71545dec1ea0d..c8de20ea996aef5ae3d3f85be783a7c5c690a308 100644 (file)
@@ -67,6 +67,11 @@ void RefCountObject::incrRef() const
   _cnt++;
 }
 
+int RefCountObject::getRCValue() const
+{
+  return _cnt;
+}
+
 RefCountObject::~RefCountObject()
 {
 }
index 7d8c1904b20d7c3c4f9dac5366ab4f4d35008232..0eb1f4deab79b22645baefbc315f65b06b63abc6 100644 (file)
@@ -66,6 +66,7 @@ namespace ParaMEDMEM
     bool decrRef() const;
     void incrRef() const;
     virtual std::size_t getHeapMemorySize() const = 0;
+    int getRCValue() const;
   protected:
     virtual ~RefCountObject();
   private:
index 953b9f8f83deb60bd545ae8ad6e7dfe41a7462c2..d416da071175c38bf7cc63c6db03e4bd532d5909 100644 (file)
@@ -1434,10 +1434,7 @@ DataArrayInt *MEDCouplingUMesh::computeNbOfFacesPerCell() const throw(INTERP_KER
  */
 DataArrayInt *MEDCouplingUMesh::zipCoordsTraducer() throw(INTERP_KERNEL::Exception)
 {
-  int newNbOfNodes=-1;
-  DataArrayInt *traducer=getNodeIdsInUse(newNbOfNodes);
-  renumberNodes(traducer->getConstPointer(),newNbOfNodes);
-  return traducer;
+  return MEDCouplingPointSet::zipCoordsTraducer();
 }
 
 /*!
@@ -6717,7 +6714,7 @@ MEDCoupling1GTUMesh *MEDCouplingUMesh::convertIntoSingleGeoTypeMesh() const thro
   INTERP_KERNEL::NormalizedCellType typ=*_types.begin();
   int typi=(int)typ;
   MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> ret=MEDCoupling1GTUMesh::New(getName(),typ);
-  ret->setCoords(ret->getCoords());
+  ret->setCoords(getCoords());
   MEDCoupling1SGTUMesh *retC=dynamic_cast<MEDCoupling1SGTUMesh *>((MEDCoupling1GTUMesh*)ret);
   if(retC)
     {
index 35a8eb09af09e593444940a23fa94cd6866fbba4..22817182f751b12c1def584782d8f6e2577a7c7b 100644 (file)
@@ -1852,10 +1852,10 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         self.assertTrue(check.isEqual(ids));
         
         code, idsInPflPerType, pfls=mesh1.splitProfilePerType(ids);
-        self.assertEqual(3, len(code));
-        self.assertEqual(NORM_HEXA8, code[0]);
-        self.assertEqual(27, code[1]);
-        self.assertEqual(0, code[2]);
+        self.assertEqual(1, len(code));
+        self.assertEqual(NORM_HEXA8, code[0][0]);
+        self.assertEqual(27, code[0][1]);
+        self.assertEqual(0, code[0][2]);
         self.assertEqual(1, len(idsInPflPerType));
         self.assertEqual(1, len(pfls));
         self.assertTrue(idsInPflPerType[0].isEqual(DataArrayInt([0,1,2,3,4,5,6,7,8,9])));
@@ -7745,12 +7745,10 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         d.setValues(val1,3,1);
         d.setName("sup")
         code,idsInPflPerType,pfls=m.splitProfilePerType(d);
-        self.assertEqual(6,len(code));
+        self.assertEqual(2,len(code));
         self.assertEqual(2,len(idsInPflPerType));
-        expected1=[3,1,0, 4,2,1]
-        for i in xrange(6):
-            self.assertEqual(expected1[i],code[i]);
-            pass
+        expected1=[[3,1,0], [4,2,1]]
+        self.assertEqual(expected1,code)
         self.assertEqual(2,len(idsInPflPerType));
         self.assertEqual(1,idsInPflPerType[0].getNumberOfTuples());
         self.assertEqual(0,idsInPflPerType[0].getIJ(0,0));
@@ -7771,12 +7769,10 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         d=DataArrayInt.New();
         d.setValues(val2,4,1);
         code,idsInPflPerType,pfls=m.splitProfilePerType(d);
-        self.assertEqual(6,len(code));
+        self.assertEqual(2,len(code));
         self.assertEqual(2,len(idsInPflPerType));
-        expected2=[3,1,0, 4,3,-1]
-        for i in xrange(6):
-            self.assertEqual(expected2[i],code[i]);
-            pass
+        expected2=[[3,1,0], [4,3,-1]]
+        self.assertEqual(expected2,code);
         self.assertEqual(2,len(idsInPflPerType));
         self.assertEqual(1,idsInPflPerType[0].getNumberOfTuples());
         self.assertEqual(0,idsInPflPerType[0].getIJ(0,0));
@@ -7793,12 +7789,10 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         d=DataArrayInt.New();
         d.setValues(val3,3,1);
         code,idsInPflPerType,pfls=m.splitProfilePerType(d);
-        self.assertEqual(6,len(code));
+        self.assertEqual(2,len(code));
         self.assertEqual(2,len(idsInPflPerType));
-        expected3=[3,2,0, 4,1,1]
-        for i in xrange(6):
-            self.assertEqual(expected3[i],code[i]);
-            pass
+        expected3=[[3,2,0], [4,1,1]]
+        self.assertEqual(expected3,code);
         self.assertEqual(2,len(idsInPflPerType));
         self.assertEqual(2,idsInPflPerType[0].getNumberOfTuples());
         self.assertEqual(0,idsInPflPerType[0].getIJ(0,0));
@@ -7816,12 +7810,10 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         d=DataArrayInt.New();
         d.setValues(val4,2,1);
         code,idsInPflPerType,pfls=m.splitProfilePerType(d);
-        self.assertEqual(3,len(code));
+        self.assertEqual(1,len(code));
         self.assertEqual(1,len(idsInPflPerType));
-        expected4=[4,2,0]
-        for i in xrange(3):
-            self.assertEqual(expected4[i],code[i]);
-            pass
+        expected4=[[4,2,0]]
+        self.assertEqual(expected4,code);
         self.assertEqual(1,len(idsInPflPerType));
         self.assertEqual(2,idsInPflPerType[0].getNumberOfTuples());
         self.assertEqual(0,idsInPflPerType[0].getIJ(0,0));
index f393ee31c6cede15489ea3ae6daec5cbf4767901..1b9d202ea2ae96f9763d953b6df5f6baa3b90984 100644 (file)
@@ -338,12 +338,12 @@ using namespace INTERP_KERNEL;
 %newobject ParaMEDMEM::MEDCouplingPointSet::mergeMyselfWithOnSameCoords;
 %newobject ParaMEDMEM::MEDCouplingPointSet::fillCellIdsToKeepFromNodeIds;
 %newobject ParaMEDMEM::MEDCouplingPointSet::getCellIdsLyingOnNodes;
+%newobject ParaMEDMEM::MEDCouplingPointSet::__getitem__;
 %newobject ParaMEDMEM::MEDCouplingUMesh::New;
 %newobject ParaMEDMEM::MEDCouplingUMesh::getNodalConnectivity;
 %newobject ParaMEDMEM::MEDCouplingUMesh::getNodalConnectivityIndex;
 %newobject ParaMEDMEM::MEDCouplingUMesh::clone;
 %newobject ParaMEDMEM::MEDCouplingUMesh::__iter__;
-%newobject ParaMEDMEM::MEDCouplingUMesh::__getitem__;
 %newobject ParaMEDMEM::MEDCouplingUMesh::cellsByType;
 %newobject ParaMEDMEM::MEDCouplingUMesh::buildDescendingConnectivity;
 %newobject ParaMEDMEM::MEDCouplingUMesh::buildDescendingConnectivity2;
@@ -505,6 +505,7 @@ namespace ParaMEDMEM
   public:
     bool decrRef() const;
     void incrRef() const;
+    int getRCValue() const;
     virtual std::size_t getHeapMemorySize() const;
   };
 }
@@ -931,6 +932,8 @@ namespace ParaMEDMEM
         PyObject *getDistributionOfTypes() const throw(INTERP_KERNEL::Exception)
         {
           std::vector<int> vals=self->getDistributionOfTypes();
+          if(vals.size()%3!=0)
+            throw INTERP_KERNEL::Exception("Internal Error detected in wrap python ! code returned by MEDCouplingMesh::getDistributionOfTypes is not so that %3==0 !");
           PyObject *ret=PyList_New((int)vals.size()/3);
           for(int j=0;j<(int)vals.size()/3;j++)
              {
@@ -959,7 +962,20 @@ namespace ParaMEDMEM
           std::vector<DataArrayInt *> idsPerType;
           self->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
           PyObject *ret=PyTuple_New(3);
-          PyTuple_SetItem(ret,0,convertIntArrToPyList2(code));
+          //
+          if(code.size()%3!=0)
+            throw INTERP_KERNEL::Exception("Internal Error detected in wrap python ! code returned by MEDCouplingMesh::splitProfilePerType is not so that %3==0 !");
+          PyObject *ret0=PyList_New((int)code.size()/3);
+          for(int j=0;j<(int)code.size()/3;j++)
+             {
+               PyObject *ret00=PyList_New(3);
+               PyList_SetItem(ret00,0,SWIG_From_int(code[3*j]));
+               PyList_SetItem(ret00,1,SWIG_From_int(code[3*j+1]));
+               PyList_SetItem(ret00,2,SWIG_From_int(code[3*j+2]));
+               PyList_SetItem(ret0,j,ret00);
+             }
+          PyTuple_SetItem(ret,0,ret0);
+          //
           PyObject *ret1=PyList_New(idsInPflPerType.size());
           for(std::size_t j=0;j<idsInPflPerType.size();j++)
             PyList_SetItem(ret1,j,SWIG_NewPointerObj(SWIG_as_voidptr(idsInPflPerType[j]),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
@@ -1430,6 +1446,62 @@ namespace ParaMEDMEM
                  return self->getCellIdsLyingOnNodes(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems(),fullyIn);
                }
            }
+
+           MEDCouplingPointSet *__getitem__(PyObject *listOrDataArrI) throw(INTERP_KERNEL::Exception)
+           {
+             int sw;
+             int singleVal;
+             std::vector<int> multiVal;
+             std::pair<int, std::pair<int,int> > slic;
+             ParaMEDMEM::DataArrayInt *daIntTyypp=0;
+             int nbc=self->getNumberOfCells();
+             convertObjToPossibleCpp2(listOrDataArrI,nbc,sw,singleVal,multiVal,slic,daIntTyypp);
+             switch(sw)
+               {
+               case 1:
+                 {
+                   if(singleVal>=nbc)
+                     {
+                       std::ostringstream oss;
+                       oss << "Requesting for cell id " << singleVal << " having only " << nbc << " cells !";
+                       throw INTERP_KERNEL::Exception(oss.str().c_str());
+                     }
+                   if(singleVal>=0)
+                     return self->buildPartOfMySelf(&singleVal,&singleVal+1,true);
+                   else
+                     {
+                       if(nbc+singleVal>0)
+                         {
+                           int tmp=nbc+singleVal;
+                           return self->buildPartOfMySelf(&tmp,&tmp+1,true);
+                         }
+                       else
+                         {
+                           std::ostringstream oss;
+                           oss << "Requesting for cell id " << singleVal << " having only " << nbc << " cells !";
+                           throw INTERP_KERNEL::Exception(oss.str().c_str());
+                         }
+                     }
+                 }
+               case 2:
+                 {
+                   return static_cast<MEDCouplingPointSet *>(self->buildPartOfMySelf(&multiVal[0],&multiVal[0]+multiVal.size(),true));
+                 }
+               case 3:
+                 {
+                   return self->buildPartOfMySelf2(slic.first,slic.second.first,slic.second.second,true);
+                 }
+               case 4:
+                 {
+                   if(!daIntTyypp)
+                     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::__getitem__ : null instance has been given in input !");
+                   daIntTyypp->checkAllocated();
+                   return self->buildPartOfMySelf(daIntTyypp->begin(),daIntTyypp->end(),true);
+                 }
+               default:
+                 throw INTERP_KERNEL::Exception("MEDCouplingUMesh::__getitem__ : unrecognized type in input ! Possibilities are : int, list or tuple of int DataArrayInt instance !");
+               }
+           }
            
            static void Rotate2DAlg(PyObject *center, double angle, int nbNodes, PyObject *coords) throw(INTERP_KERNEL::Exception)
            {
@@ -1661,62 +1733,6 @@ namespace ParaMEDMEM
       {
         return self->cellIterator();
       }
-
-      MEDCouplingPointSet *__getitem__(PyObject *listOrDataArrI) throw(INTERP_KERNEL::Exception)
-      {
-        int sw;
-        int singleVal;
-        std::vector<int> multiVal;
-        std::pair<int, std::pair<int,int> > slic;
-        ParaMEDMEM::DataArrayInt *daIntTyypp=0;
-        int nbc=self->getNumberOfCells();
-        convertObjToPossibleCpp2(listOrDataArrI,nbc,sw,singleVal,multiVal,slic,daIntTyypp);
-        switch(sw)
-          {
-          case 1:
-            {
-              if(singleVal>=nbc)
-                {
-                  std::ostringstream oss;
-                  oss << "Requesting for cell id " << singleVal << " having only " << nbc << " cells !";
-                  throw INTERP_KERNEL::Exception(oss.str().c_str());
-                }
-              if(singleVal>=0)
-                return self->buildPartOfMySelf(&singleVal,&singleVal+1,true);
-              else
-                {
-                  if(nbc+singleVal>0)
-                    {
-                      int tmp=nbc+singleVal;
-                      return self->buildPartOfMySelf(&tmp,&tmp+1,true);
-                    }
-                  else
-                    {
-                      std::ostringstream oss;
-                      oss << "Requesting for cell id " << singleVal << " having only " << nbc << " cells !";
-                      throw INTERP_KERNEL::Exception(oss.str().c_str());
-                    }
-                }
-            }
-          case 2:
-            {
-              return static_cast<MEDCouplingUMesh *>(self->buildPartOfMySelf(&multiVal[0],&multiVal[0]+multiVal.size(),true));
-            }
-          case 3:
-            {
-              return self->buildPartOfMySelf2(slic.first,slic.second.first,slic.second.second,true);
-            }
-          case 4:
-            {
-              if(!daIntTyypp)
-                throw INTERP_KERNEL::Exception("MEDCouplingUMesh::__getitem__ : null instance has been given in input !");
-              daIntTyypp->checkAllocated();
-              return self->buildPartOfMySelf(daIntTyypp->begin(),daIntTyypp->end(),true);
-            }
-          default:
-            throw INTERP_KERNEL::Exception("MEDCouplingUMesh::__getitem__ : unrecognized type in input ! Possibilities are : int, list or tuple of int DataArrayInt instance !");
-          }
-      }
       
       void setPartOfMySelf(PyObject *li, const MEDCouplingUMesh& otherOnSameCoordsThanThis) throw(INTERP_KERNEL::Exception)
       {