Salome HOME
[EDF27860] : MEDCouplingUMesh.getCellsContainingPoints eps parameter specifies a...
[tools/medcoupling.git] / src / MEDCoupling / MEDCouplingUMesh.cxx
old mode 100644 (file)
new mode 100755 (executable)
index 40318b0..6d2ad7a
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2016  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2023  CEA, EDF
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 //
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
-// Author : Anthony Geay (CEA/DEN)
+// Author : Anthony Geay (EDF R&D)
 
-#include "MEDCouplingUMesh.hxx"
+#include "MEDCouplingUMesh.txx"
+#include "MEDCouplingCMesh.hxx"
 #include "MEDCoupling1GTUMesh.hxx"
 #include "MEDCouplingFieldDouble.hxx"
 #include "MEDCouplingSkyLineArray.hxx"
 #include "InterpKernelGeo2DEdgeLin.hxx"
 #include "InterpKernelGeo2DEdgeArcCircle.hxx"
 #include "InterpKernelGeo2DQuadraticPolygon.hxx"
+#include "OrientationInverter.hxx"
+#include "MEDCouplingUMesh_internal.hxx"
 
 #include <sstream>
 #include <fstream>
 #include <numeric>
+#include <memory>
 #include <cstring>
 #include <limits>
 #include <list>
@@ -53,8 +57,8 @@ using namespace MEDCoupling;
 double MEDCouplingUMesh::EPS_FOR_POLYH_ORIENTATION=1.e-14;
 
 /// @cond INTERNAL
-const INTERP_KERNEL::NormalizedCellType MEDCouplingUMesh::MEDMEM_ORDER[N_MEDMEM_ORDER] = { INTERP_KERNEL::NORM_POINT1, INTERP_KERNEL::NORM_SEG2, INTERP_KERNEL::NORM_SEG3, INTERP_KERNEL::NORM_SEG4, INTERP_KERNEL::NORM_POLYL, INTERP_KERNEL::NORM_TRI3, INTERP_KERNEL::NORM_QUAD4, INTERP_KERNEL::NORM_TRI6, INTERP_KERNEL::NORM_TRI7, INTERP_KERNEL::NORM_QUAD8, INTERP_KERNEL::NORM_QUAD9, INTERP_KERNEL::NORM_POLYGON, INTERP_KERNEL::NORM_QPOLYG, INTERP_KERNEL::NORM_TETRA4, INTERP_KERNEL::NORM_PYRA5, INTERP_KERNEL::NORM_PENTA6, INTERP_KERNEL::NORM_HEXA8, INTERP_KERNEL::NORM_HEXGP12, INTERP_KERNEL::NORM_TETRA10, INTERP_KERNEL::NORM_PYRA13, INTERP_KERNEL::NORM_PENTA15, INTERP_KERNEL::NORM_HEXA20, INTERP_KERNEL::NORM_HEXA27, INTERP_KERNEL::NORM_POLYHED };
-const int MEDCouplingUMesh::MEDCOUPLING2VTKTYPETRADUCER[INTERP_KERNEL::NORM_MAXTYPE+1]={1,3,21,5,9,7,22,34,23,28,-1,-1,-1,-1,10,14,13,-1,12,-1,24,-1,16,27,-1,26,-1,29,-1,-1,25,42,36,4};
+
+const INTERP_KERNEL::NormalizedCellType MEDCouplingUMesh::MEDMEM_ORDER[N_MEDMEM_ORDER] = { INTERP_KERNEL::NORM_POINT1, INTERP_KERNEL::NORM_SEG2, INTERP_KERNEL::NORM_SEG3, INTERP_KERNEL::NORM_SEG4, INTERP_KERNEL::NORM_POLYL, INTERP_KERNEL::NORM_TRI3, INTERP_KERNEL::NORM_QUAD4, INTERP_KERNEL::NORM_TRI6, INTERP_KERNEL::NORM_TRI7, INTERP_KERNEL::NORM_QUAD8, INTERP_KERNEL::NORM_QUAD9, INTERP_KERNEL::NORM_POLYGON, INTERP_KERNEL::NORM_QPOLYG, INTERP_KERNEL::NORM_TETRA4, INTERP_KERNEL::NORM_PYRA5, INTERP_KERNEL::NORM_PENTA6, INTERP_KERNEL::NORM_HEXA8, INTERP_KERNEL::NORM_HEXGP12, INTERP_KERNEL::NORM_TETRA10, INTERP_KERNEL::NORM_PYRA13, INTERP_KERNEL::NORM_PENTA15, INTERP_KERNEL::NORM_PENTA18, INTERP_KERNEL::NORM_HEXA20, INTERP_KERNEL::NORM_HEXA27, INTERP_KERNEL::NORM_POLYHED };
 /// @endcond
 
 MEDCouplingUMesh *MEDCouplingUMesh::New()
@@ -74,7 +78,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::New(const std::string& meshName, int meshDim
  * Returns a new MEDCouplingUMesh which is a full copy of \a this one. No data is shared
  * between \a this and the new mesh.
  *  \return MEDCouplingUMesh * - a new instance of MEDCouplingMesh. The caller is to
- *          delete this mesh using decrRef() as it is no more needed. 
+ *          delete this mesh using decrRef() as it is no more needed.
  */
 MEDCouplingUMesh *MEDCouplingUMesh::deepCopy() const
 {
@@ -87,7 +91,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::deepCopy() const
  *  \param [in] recDeepCpy - if \a true, the copy is deep, else all data arrays of \a
  * this mesh are shared by the new mesh.
  *  \return MEDCouplingUMesh * - a new instance of MEDCouplingMesh. The caller is to
- *          delete this mesh using decrRef() as it is no more needed. 
+ *          delete this mesh using decrRef() as it is no more needed.
  */
 MEDCouplingUMesh *MEDCouplingUMesh::clone(bool recDeepCpy) const
 {
@@ -97,7 +101,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::clone(bool recDeepCpy) const
 /*!
  * This method behaves mostly like MEDCouplingUMesh::deepCopy method, except that only nodal connectivity arrays are deeply copied.
  * The coordinates are shared between \a this and the returned instance.
- * 
+ *
  * \return MEDCouplingUMesh * - A new object instance holding the copy of \a this (deep for connectivity, shallow for coordiantes)
  * \sa MEDCouplingUMesh::deepCopy
  */
@@ -105,7 +109,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::deepCopyConnectivityOnly() const
 {
   checkConnectivityFullyDefined();
   MCAuto<MEDCouplingUMesh> ret=clone(false);
-  MCAuto<DataArrayInt> c(getNodalConnectivity()->deepCopy()),ci(getNodalConnectivityIndex()->deepCopy());
+  MCAuto<DataArrayIdType> c(getNodalConnectivity()->deepCopy()),ci(getNodalConnectivityIndex()->deepCopy());
   ret->setConnectivity(c,ci);
   return ret.retn();
 }
@@ -173,7 +177,7 @@ void MEDCouplingUMesh::checkConsistencyLight() const
     MEDCouplingPointSet::checkConsistencyLight();
   for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator iter=_types.begin();iter!=_types.end();iter++)
     {
-      if((int)INTERP_KERNEL::CellModel::GetCellModel(*iter).getDimension()!=_mesh_dim)
+      if(ToIdType(INTERP_KERNEL::CellModel::GetCellModel(*iter).getDimension())!=_mesh_dim)
         {
           std::ostringstream message;
           message << "Mesh invalid because dimension is " << _mesh_dim << " and there is presence of cell(s) with type " << (*iter);
@@ -204,9 +208,13 @@ void MEDCouplingUMesh::checkConsistencyLight() const
 
 /*!
  * Checks if \a this mesh is well defined. If no exception is thrown by this method,
- * then \a this mesh is most probably is writable, exchangeable and available for all
+ * then \a this mesh is informatically clean, most probably is writable, exchangeable and available for all
  * algorithms. <br> In addition to the checks performed by checkConsistencyLight(), this
- * method thoroughly checks the nodal connectivity.
+ * method thoroughly checks the nodal connectivity. For more geometrical checking
+ * checkGeomConsistency method is better than this.
+ * 
+ * \sa MEDCouplingUMesh::checkGeomConsistency
+ * 
  *  \param [in] eps - a not used parameter.
  *  \throw If the mesh dimension is not set.
  *  \throw If the coordinates array is not set (if mesh dimension != -1 ).
@@ -224,22 +232,22 @@ void MEDCouplingUMesh::checkConsistency(double eps) const
   if(_mesh_dim==-1)
     return ;
   int meshDim=getMeshDimension();
-  int nbOfNodes=getNumberOfNodes();
-  int nbOfCells=getNumberOfCells();
-  const int *ptr=_nodal_connec->getConstPointer();
-  const int *ptrI=_nodal_connec_index->getConstPointer();
-  for(int i=0;i<nbOfCells;i++)
+  mcIdType nbOfNodes=getNumberOfNodes();
+  mcIdType nbOfCells=getNumberOfCells();
+  const mcIdType *ptr=_nodal_connec->getConstPointer();
+  const mcIdType *ptrI=_nodal_connec_index->getConstPointer();
+  for(mcIdType i=0;i<nbOfCells;i++)
     {
       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)ptr[ptrI[i]]);
-      if((int)cm.getDimension()!=meshDim)
+      if(ToIdType(cm.getDimension())!=meshDim)
         {
           std::ostringstream oss;
           oss << "MEDCouplingUMesh::checkConsistency : cell << #" << i<< " with type Type " << cm.getRepr() << " in 'this' whereas meshdim == " << meshDim << " !";
           throw INTERP_KERNEL::Exception(oss.str());
         }
-      int nbOfNodesInCell=ptrI[i+1]-ptrI[i]-1;
+      mcIdType nbOfNodesInCell=ptrI[i+1]-ptrI[i]-1;
       if(!cm.isDynamic())
-        if(nbOfNodesInCell!=(int)cm.getNumberOfNodes())
+        if(nbOfNodesInCell!=ToIdType(cm.getNumberOfNodes()))
           {
             std::ostringstream oss;
             oss << "MEDCouplingUMesh::checkConsistency : cell #" << i << " with static Type '" << cm.getRepr() << "' has " <<  cm.getNumberOfNodes();
@@ -254,9 +262,9 @@ void MEDCouplingUMesh::checkConsistency(double eps) const
             oss << " nodes. This should be even, and greater or equal than 4!! Looks very bad!";
             throw INTERP_KERNEL::Exception(oss.str());
           }
-      for(const int *w=ptr+ptrI[i]+1;w!=ptr+ptrI[i+1];w++)
+      for(const mcIdType *w=ptr+ptrI[i]+1;w!=ptr+ptrI[i+1];w++)
         {
-          int nodeId=*w;
+          mcIdType nodeId=*w;
           if(nodeId>=0)
             {
               if(nodeId>=nbOfNodes)
@@ -282,6 +290,28 @@ void MEDCouplingUMesh::checkConsistency(double eps) const
     }
 }
 
+/*!
+ * This method adds some geometrical checks in addition to the informatical check of checkConsistency method.
+ * This method in particular checks that a same node is not repeated several times in a cell.
+ * 
+ *  \throw If there is a presence a multiple same node ID in nodal connectivity of cell.
+ */
+void MEDCouplingUMesh::checkGeomConsistency(double eps) const
+{
+  this->checkConsistency(eps);
+  auto nbOfCells(getNumberOfCells());
+  const mcIdType *ptr(_nodal_connec->begin()),*ptrI(_nodal_connec_index->begin());
+  for(auto icell = 0 ; icell < nbOfCells ; ++icell)
+  {
+    std::set<mcIdType> s(ptr+ptrI[icell]+1,ptr+ptrI[icell+1]);
+    if(ToIdType(s.size())==ptrI[icell+1]-ptrI[icell]-1)
+      continue;
+    std::ostringstream oss; oss << "MEDCouplingUMesh::checkGeomConsistency : for cell #" << icell << " presence of multiple same nodeID !";
+    throw INTERP_KERNEL::Exception(oss.str());
+  }
+}
+
+
 /*!
  * Sets dimension of \a this mesh. The mesh dimension in general depends on types of
  * elements contained in the mesh. For more info on the mesh dimension see
@@ -298,9 +328,10 @@ void MEDCouplingUMesh::setMeshDimension(int meshDim)
 }
 
 /*!
- * Allocates memory to store an estimation of the given number of cells. The closer is the estimation to the number of cells effectively inserted,
- * the less will the library need to reallocate memory. If the number of cells to be inserted is not known simply put 0 to this parameter.
- * If a nodal connectivity previouly existed before the call of this method, it will be reset.
+ * Allocates memory to store an estimation of the given number of cells.
+ * The closer the estimation to the number of cells effectively inserted, the less need the library requires
+ * to reallocate memory. If the number of cells to be inserted is not known simply assign 0 to this parameter.
+ * If a nodal connectivity previously existed before the call of this method, it will be reset.
  *
  *  \param [in] nbOfCells - estimation of the number of cell \a this mesh will contain.
  *
@@ -309,7 +340,7 @@ void MEDCouplingUMesh::setMeshDimension(int meshDim)
  *  \ref medcouplingpyexamplesUmeshStdBuild1 "Here is a Python example".
  *  \endif
  */
-void MEDCouplingUMesh::allocateCells(int nbOfCells)
+void MEDCouplingUMesh::allocateCells(mcIdType nbOfCells)
 {
   if(nbOfCells<0)
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::allocateCells : the input number of cells should be >= 0 !");
@@ -321,10 +352,10 @@ void MEDCouplingUMesh::allocateCells(int nbOfCells)
     {
       _nodal_connec->decrRef();
     }
-  _nodal_connec_index=DataArrayInt::New();
+  _nodal_connec_index=DataArrayIdType::New();
   _nodal_connec_index->reserve(nbOfCells+1);
   _nodal_connec_index->pushBackSilent(0);
-  _nodal_connec=DataArrayInt::New();
+  _nodal_connec=DataArrayIdType::New();
   _nodal_connec->reserve(2*nbOfCells);
   _types.clear();
   declareAsNew();
@@ -336,28 +367,28 @@ void MEDCouplingUMesh::allocateCells(int nbOfCells)
  *  \param [in] type - type of cell to add.
  *  \param [in] size - number of nodes constituting this cell.
  *  \param [in] nodalConnOfCell - the connectivity of the cell to add.
- * 
+ *
  *  \if ENABLE_EXAMPLES
  *  \ref medcouplingcppexamplesUmeshStdBuild1 "Here is a C++ example".<br>
  *  \ref medcouplingpyexamplesUmeshStdBuild1 "Here is a Python example".
  *  \endif
  */
-void MEDCouplingUMesh::insertNextCell(INTERP_KERNEL::NormalizedCellType type, int size, const int *nodalConnOfCell)
+void MEDCouplingUMesh::insertNextCell(INTERP_KERNEL::NormalizedCellType type, mcIdType size, const mcIdType *nodalConnOfCell)
 {
   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type);
   if(_nodal_connec_index==0)
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::insertNextCell : nodal connectivity not set ! invoke allocateCells before calling insertNextCell !");
-  if((int)cm.getDimension()==_mesh_dim)
+  if(ToIdType(cm.getDimension())==_mesh_dim)
     {
       if(!cm.isDynamic())
-        if(size!=(int)cm.getNumberOfNodes())
+        if(size!=ToIdType(cm.getNumberOfNodes()))
           {
             std::ostringstream oss; oss << "MEDCouplingUMesh::insertNextCell : Trying to push a " << cm.getRepr() << " cell with a size of " << size;
             oss << " ! Expecting " << cm.getNumberOfNodes() << " !";
             throw INTERP_KERNEL::Exception(oss.str());
           }
-      int idx=_nodal_connec_index->back();
-      int val=idx+size+1;
+      mcIdType idx=_nodal_connec_index->back();
+      mcIdType val=idx+size+1;
       _nodal_connec_index->pushBackSilent(val);
       _nodal_connec->writeOnPlace(idx,type,nodalConnOfCell,size);
       _types.insert(type);
@@ -374,7 +405,7 @@ void MEDCouplingUMesh::insertNextCell(INTERP_KERNEL::NormalizedCellType type, in
 /*!
  * Compacts data arrays to release unused memory. This method is to be called after
  * finishing cell insertion using \a this->insertNextCell().
- * 
+ *
  *  \if ENABLE_EXAMPLES
  *  \ref medcouplingcppexamplesUmeshStdBuild1 "Here is a C++ example".<br>
  *  \ref medcouplingpyexamplesUmeshStdBuild1 "Here is a Python example".
@@ -400,7 +431,7 @@ MEDCouplingUMeshCellIterator *MEDCouplingUMesh::cellIterator()
 
 /*!
  * Entry point for iteration over cells groups geo types per geotypes. Warning the returned cell iterator should be deallocated.
- * If \a this is not so that that cells are grouped by geo types this method will throw an exception.
+ * If \a this is not so that the cells are grouped by geo types, this method will throw an exception.
  * In this case MEDCouplingUMesh::sortCellsInMEDFileFrmt or MEDCouplingUMesh::rearrange2ConsecutiveCellTypes methods for example can be called before invoking this method.
  * Useful for python users.
  */
@@ -428,21 +459,21 @@ std::set<INTERP_KERNEL::NormalizedCellType> MEDCouplingUMesh::getAllGeoTypes() c
  * having the same geometric type. So a same geometric type can appear more than once if the cells are not sorted per geometric type.
  *
  * \throw if connectivity in \a this is not correctly defined.
- *  
+ *
  * \sa MEDCouplingMesh::getAllGeoTypes
  */
 std::vector<INTERP_KERNEL::NormalizedCellType> MEDCouplingUMesh::getAllGeoTypesSorted() const
 {
   std::vector<INTERP_KERNEL::NormalizedCellType> ret;
   checkConnectivityFullyDefined();
-  int nbOfCells(getNumberOfCells());
+  mcIdType nbOfCells=getNumberOfCells();
   if(nbOfCells==0)
     return ret;
   if(getNodalConnectivityArrayLen()<1)
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getAllGeoTypesSorted : the connectivity in this seems invalid !");
-  const int *c(_nodal_connec->begin()),*ci(_nodal_connec_index->begin());
+  const mcIdType *c(_nodal_connec->begin()),*ci(_nodal_connec_index->begin());
   ret.push_back((INTERP_KERNEL::NormalizedCellType)c[*ci++]);
-  for(int i=1;i<nbOfCells;i++,ci++)
+  for(mcIdType i=1;i<nbOfCells;i++,ci++)
     if(ret.back()!=((INTERP_KERNEL::NormalizedCellType)c[*ci]))
       ret.push_back((INTERP_KERNEL::NormalizedCellType)c[*ci]);
   return ret;
@@ -558,7 +589,7 @@ void MEDCouplingUMesh::checkFastEquivalWith(const MEDCouplingMesh *other, double
   MEDCouplingPointSet::checkFastEquivalWith(other,prec);
   const MEDCouplingUMesh *otherC=dynamic_cast<const MEDCouplingUMesh *>(other);
   if(!otherC)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::checkFastEquivalWith : Two meshes are not not unstructured !"); 
+    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::checkFastEquivalWith : Two meshes are not not unstructured !");
 }
 
 /*!
@@ -570,133 +601,53 @@ void MEDCouplingUMesh::checkFastEquivalWith(const MEDCouplingMesh *other, double
  * \param [in,out] revNodalIndx - an array, of length \a this->getNumberOfNodes() + 1,
  *        dividing cell ids in \a revNodal into groups each referring to one
  *        node. Its every element (except the last one) is an index pointing to the
- *         first id of a group of cells. For example cells sharing the node #1 are 
- *        described by following range of indices: 
+ *         first id of a group of cells. For example cells sharing the node #1 are
+ *        described by following range of indices:
  *        [ \a revNodalIndx[1], \a revNodalIndx[2] ) and the cell ids are
  *        \a revNodal[ \a revNodalIndx[1] ], \a revNodal[ \a revNodalIndx[1] + 1], ...
  *        Number of cells sharing the *i*-th node is
  *        \a revNodalIndx[ *i*+1 ] - \a revNodalIndx[ *i* ].
  * \throw If the coordinates array is not set.
  * \throw If the nodal connectivity of cells is not defined.
- * 
+ *
  * \if ENABLE_EXAMPLES
  * \ref cpp_mcumesh_getReverseNodalConnectivity "Here is a C++ example".<br>
  * \ref  py_mcumesh_getReverseNodalConnectivity "Here is a Python example".
  * \endif
  */
-void MEDCouplingUMesh::getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const
+void MEDCouplingUMesh::getReverseNodalConnectivity(DataArrayIdType *revNodal, DataArrayIdType *revNodalIndx) const
 {
   checkFullyDefined();
-  int nbOfNodes=getNumberOfNodes();
-  int *revNodalIndxPtr=(int *)malloc((nbOfNodes+1)*sizeof(int));
-  revNodalIndx->useArray(revNodalIndxPtr,true,C_DEALLOC,nbOfNodes+1,1);
+  mcIdType nbOfNodes(getNumberOfNodes());
+  mcIdType *revNodalIndxPtr=(mcIdType *)malloc((nbOfNodes+1)*sizeof(mcIdType));
+  revNodalIndx->useArray(revNodalIndxPtr,true,DeallocType::C_DEALLOC,nbOfNodes+1,1);
   std::fill(revNodalIndxPtr,revNodalIndxPtr+nbOfNodes+1,0);
-  const int *conn=_nodal_connec->getConstPointer();
-  const int *connIndex=_nodal_connec_index->getConstPointer();
-  int nbOfCells=getNumberOfCells();
-  int nbOfEltsInRevNodal=0;
-  for(int eltId=0;eltId<nbOfCells;eltId++)
-    {
-      const int *strtNdlConnOfCurCell=conn+connIndex[eltId]+1;
-      const int *endNdlConnOfCurCell=conn+connIndex[eltId+1];
-      for(const int *iter=strtNdlConnOfCurCell;iter!=endNdlConnOfCurCell;iter++)
+  const mcIdType *conn(_nodal_connec->begin()),*connIndex(_nodal_connec_index->begin());
+  mcIdType nbOfCells(getNumberOfCells()),nbOfEltsInRevNodal(0);
+  for(mcIdType eltId=0;eltId<nbOfCells;eltId++)
+    {
+      const mcIdType *strtNdlConnOfCurCell(conn+connIndex[eltId]+1),*endNdlConnOfCurCell(conn+connIndex[eltId+1]);
+      for(const mcIdType *iter=strtNdlConnOfCurCell;iter!=endNdlConnOfCurCell;iter++)
         if(*iter>=0)//for polyhedrons
           {
             nbOfEltsInRevNodal++;
             revNodalIndxPtr[(*iter)+1]++;
           }
     }
-  std::transform(revNodalIndxPtr+1,revNodalIndxPtr+nbOfNodes+1,revNodalIndxPtr,revNodalIndxPtr+1,std::plus<int>());
-  int *revNodalPtr=(int *)malloc((nbOfEltsInRevNodal)*sizeof(int));
-  revNodal->useArray(revNodalPtr,true,C_DEALLOC,nbOfEltsInRevNodal,1);
+  std::transform(revNodalIndxPtr+1,revNodalIndxPtr+nbOfNodes+1,revNodalIndxPtr,revNodalIndxPtr+1,std::plus<mcIdType>());
+  mcIdType *revNodalPtr=(mcIdType *)malloc(nbOfEltsInRevNodal*sizeof(mcIdType));
+  revNodal->useArray(revNodalPtr,true,DeallocType::C_DEALLOC,nbOfEltsInRevNodal,1);
   std::fill(revNodalPtr,revNodalPtr+nbOfEltsInRevNodal,-1);
-  for(int eltId=0;eltId<nbOfCells;eltId++)
+  for(mcIdType eltId=0;eltId<nbOfCells;eltId++)
     {
-      const int *strtNdlConnOfCurCell=conn+connIndex[eltId]+1;
-      const int *endNdlConnOfCurCell=conn+connIndex[eltId+1];
-      for(const int *iter=strtNdlConnOfCurCell;iter!=endNdlConnOfCurCell;iter++)
+      const mcIdType *strtNdlConnOfCurCell=conn+connIndex[eltId]+1;
+      const mcIdType *endNdlConnOfCurCell=conn+connIndex[eltId+1];
+      for(const mcIdType *iter=strtNdlConnOfCurCell;iter!=endNdlConnOfCurCell;iter++)
         if(*iter>=0)//for polyhedrons
-          *std::find_if(revNodalPtr+revNodalIndxPtr[*iter],revNodalPtr+revNodalIndxPtr[*iter+1],std::bind2nd(std::equal_to<int>(),-1))=eltId;
-    }
-}
-
-/// @cond INTERNAL
-
-int MEDCouplingFastNbrer(int id, unsigned nb, const INTERP_KERNEL::CellModel& cm, bool compute, const int *conn1, const int *conn2)
-{
-  return id;
-}
-
-int MEDCouplingOrientationSensitiveNbrer(int id, unsigned nb, const INTERP_KERNEL::CellModel& cm, bool compute, const int *conn1, const int *conn2)
-{
-  if(!compute)
-    return id+1;
-  else
-    {
-      if(cm.getOrientationStatus(nb,conn1,conn2))
-        return id+1;
-      else
-        return -(id+1);
+          *std::find_if(revNodalPtr+revNodalIndxPtr[*iter],revNodalPtr+revNodalIndxPtr[*iter+1],std::bind(std::equal_to<mcIdType>(),std::placeholders::_1,-1))=eltId;
     }
 }
 
-class MinusOneSonsGenerator
-{
-public:
-  MinusOneSonsGenerator(const INTERP_KERNEL::CellModel& cm):_cm(cm) { }
-  unsigned getNumberOfSons2(const int *conn, int lgth) const { return _cm.getNumberOfSons2(conn,lgth); }
-  unsigned fillSonCellNodalConnectivity2(int sonId, const int *nodalConn, int lgth, int *sonNodalConn, INTERP_KERNEL::NormalizedCellType& typeOfSon) const { return _cm.fillSonCellNodalConnectivity2(sonId,nodalConn,lgth,sonNodalConn,typeOfSon); }
-  static const int DELTA=1;
-private:
-  const INTERP_KERNEL::CellModel& _cm;
-};
-
-class MinusOneSonsGeneratorBiQuadratic
-{
-public:
-  MinusOneSonsGeneratorBiQuadratic(const INTERP_KERNEL::CellModel& cm):_cm(cm) { }
-  unsigned getNumberOfSons2(const int *conn, int lgth) const { return _cm.getNumberOfSons2(conn,lgth); }
-  unsigned fillSonCellNodalConnectivity2(int sonId, const int *nodalConn, int lgth, int *sonNodalConn, INTERP_KERNEL::NormalizedCellType& typeOfSon) const { return _cm.fillSonCellNodalConnectivity4(sonId,nodalConn,lgth,sonNodalConn,typeOfSon); }
-  static const int DELTA=1;
-private:
-  const INTERP_KERNEL::CellModel& _cm;
-};
-
-class MinusTwoSonsGenerator
-{
-public:
-  MinusTwoSonsGenerator(const INTERP_KERNEL::CellModel& cm):_cm(cm) { }
-  unsigned getNumberOfSons2(const int *conn, int lgth) const { return _cm.getNumberOfEdgesIn3D(conn,lgth); }
-  unsigned fillSonCellNodalConnectivity2(int sonId, const int *nodalConn, int lgth, int *sonNodalConn, INTERP_KERNEL::NormalizedCellType& typeOfSon) const { return _cm.fillSonEdgesNodalConnectivity3D(sonId,nodalConn,lgth,sonNodalConn,typeOfSon); }
-  static const int DELTA=2;
-private:
-  const INTERP_KERNEL::CellModel& _cm;
-};
-
-class MicroEdgesGenerator2D
-{
-public:
-  MicroEdgesGenerator2D(const INTERP_KERNEL::CellModel& cm):_cm(cm) { }
-  unsigned getNumberOfSons2(const int *conn, int lgth) const { return _cm.getNumberOfMicroEdges(); }
-  unsigned fillSonCellNodalConnectivity2(int sonId, const int *nodalConn, int lgth, int *sonNodalConn, INTERP_KERNEL::NormalizedCellType& typeOfSon) const { return _cm.fillMicroEdgeNodalConnectivity(sonId,nodalConn,sonNodalConn,typeOfSon); }
-  static const int DELTA=1;
-private:
-  const INTERP_KERNEL::CellModel& _cm;
-};
-
-class MicroEdgesGenerator3D
-{
-public:
-  MicroEdgesGenerator3D(const INTERP_KERNEL::CellModel& cm):_cm(cm) { }
-  unsigned getNumberOfSons2(const int *conn, int lgth) const { return _cm.getNumberOfMicroEdges(); }
-  unsigned fillSonCellNodalConnectivity2(int sonId, const int *nodalConn, int lgth, int *sonNodalConn, INTERP_KERNEL::NormalizedCellType& typeOfSon) const { return _cm.fillMicroEdgeNodalConnectivity(sonId,nodalConn,sonNodalConn,typeOfSon); }
-  static const int DELTA=2;
-private:
-  const INTERP_KERNEL::CellModel& _cm;
-};
-
-/// @endcond
-
 /*!
  * Creates a new MEDCouplingUMesh containing cells, of dimension one less than \a
  * this->getMeshDimension(), that bound cells of \a this mesh. In addition arrays
@@ -704,7 +655,7 @@ private:
  * returned. The arrays \a desc and \a descIndx (\ref numbering-indirect) describe the descending connectivity,
  * i.e. enumerate cells of the result mesh bounding each cell of \a this mesh. The
  * arrays \a revDesc and \a revDescIndx (\ref numbering-indirect) describe the reverse descending connectivity,
- * i.e. enumerate cells of  \a this mesh bounded by each cell of the result mesh. 
+ * i.e. enumerate cells of  \a this mesh bounded by each cell of the result mesh.
  * \warning For speed reasons, this method does not check if node ids in the nodal
  *          connectivity correspond to the size of node coordinates array.
  * \warning Cells of the result mesh are \b not sorted by geometric type, hence,
@@ -734,18 +685,56 @@ private:
  *  \throw If the nodal connectivity of cells is node defined.
  *  \throw If \a desc == NULL || \a descIndx == NULL || \a revDesc == NULL || \a
  *         revDescIndx == NULL.
- * 
+ *
  *  \if ENABLE_EXAMPLES
  *  \ref cpp_mcumesh_buildDescendingConnectivity "Here is a C++ example".<br>
  *  \ref  py_mcumesh_buildDescendingConnectivity "Here is a Python example".
  *  \endif
  * \sa buildDescendingConnectivity2()
  */
-MEDCouplingUMesh *MEDCouplingUMesh::buildDescendingConnectivity(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const
+MEDCouplingUMesh *MEDCouplingUMesh::buildDescendingConnectivity(DataArrayIdType *desc, DataArrayIdType *descIndx, DataArrayIdType *revDesc, DataArrayIdType *revDescIndx) const
 {
   return buildDescendingConnectivityGen<MinusOneSonsGenerator>(desc,descIndx,revDesc,revDescIndx,MEDCouplingFastNbrer);
 }
 
+/*!
+ * This method is a generalization of buildDescendingConnectivity method. This method return mesh containing subcells of this at level specified by \a targetDeltaLevel
+ * and return descending and reverse descending correspondances to this.
+ *
+ * \param [in] targetDeltaLevel target delta level compared to \a this mesh dimension. This parameter is expected to be lower than zero.
+ * 
+ * \throw If targetDeltaLevel is greater or equal to zero
+ * \throw If targetDeltaLevel is lower than -meshDim
+ * \sa MEDCouplingUMesh::buildDescendingConnectivity, MEDCouplingUMesh::explode3DMeshTo1D
+ */
+MCAuto<MEDCouplingUMesh> MEDCouplingUMesh::explodeMeshTo(int targetDeltaLevel, MCAuto<DataArrayIdType>& desc, MCAuto<DataArrayIdType>& descIndx, MCAuto<DataArrayIdType>& revDesc, MCAuto<DataArrayIdType>& revDescIndx) const
+{
+  this->checkConsistencyLight();
+  if( targetDeltaLevel >= 0 )
+    THROW_IK_EXCEPTION("Input parameter targetDeltaLevel is expected to be lower than zero !");
+  if( targetDeltaLevel == -1 )
+  {
+    desc = DataArrayIdType::New(); descIndx = DataArrayIdType::New(); revDesc = DataArrayIdType::New(); revDescIndx = DataArrayIdType::New();
+    MCAuto<MEDCouplingUMesh> ret( this->buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx) );
+    return ret;
+  }
+  if( targetDeltaLevel == -2 && this->getMeshDimension() == 3 )
+  {
+    desc = DataArrayIdType::New(); descIndx = DataArrayIdType::New(); revDesc = DataArrayIdType::New(); revDescIndx = DataArrayIdType::New();
+    MCAuto<MEDCouplingUMesh> ret( this->explode3DMeshTo1D(desc,descIndx,revDesc,revDescIndx) );
+    return ret;
+  }
+  if( targetDeltaLevel == -this->getMeshDimension() )
+  {
+    MCAuto<MEDCouplingUMesh> ret = MEDCouplingUMesh::Build0DMeshFromCoords( const_cast<DataArrayDouble *>( this->getCoords() ) );
+    MEDCouplingUMesh::DeleteCellTypeInIndexedArray(getNodalConnectivity(),getNodalConnectivityIndex(),desc,descIndx);
+    revDesc = DataArrayIdType::New(); revDescIndx = DataArrayIdType::New();
+    this->getReverseNodalConnectivity(revDesc,revDescIndx);
+    return ret;
+  }
+  THROW_IK_EXCEPTION("Not valid input targetDeltaLevel regarding mesh dimension");
+}
+
 /*!
  * \a this has to have a mesh dimension equal to 3. If it is not the case an INTERP_KERNEL::Exception will be thrown.
  * This behaves exactly as MEDCouplingUMesh::buildDescendingConnectivity does except that this method compute directly the transition from mesh dimension 3 to sub edges (dimension 1)
@@ -753,7 +742,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildDescendingConnectivity(DataArrayInt *de
  * This method returns 4 arrays and a mesh as MEDCouplingUMesh::buildDescendingConnectivity does.
  * \sa MEDCouplingUMesh::buildDescendingConnectivity
  */
-MEDCouplingUMesh *MEDCouplingUMesh::explode3DMeshTo1D(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const
+MEDCouplingUMesh *MEDCouplingUMesh::explode3DMeshTo1D(DataArrayIdType *desc, DataArrayIdType *descIndx, DataArrayIdType *revDesc, DataArrayIdType *revDescIndx) const
 {
   checkFullyDefined();
   if(getMeshDimension()!=3)
@@ -763,11 +752,11 @@ MEDCouplingUMesh *MEDCouplingUMesh::explode3DMeshTo1D(DataArrayInt *desc, DataAr
 
 /*!
  * This method computes the micro edges constituting each cell in \a this. Micro edge is an edge for non quadratic cells. Micro edge is an half edge for quadratic cells.
- * This method works for both meshes with mesh dimenstion equal to 2 or 3. Dynamical cells are not supported (polygons, polyhedrons...)
+ * This method works for both meshes with mesh dimension equal to 2 or 3. Dynamical cells are not supported (polygons, polyhedrons...)
  * 
  * \sa explode3DMeshTo1D, buildDescendingConnectiviy
  */
-MEDCouplingUMesh *MEDCouplingUMesh::explodeMeshIntoMicroEdges(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const
+MEDCouplingUMesh *MEDCouplingUMesh::explodeMeshIntoMicroEdges(DataArrayIdType *desc, DataArrayIdType *descIndx, DataArrayIdType *revDesc, DataArrayIdType *revDescIndx) const
 {
    checkFullyDefined();
    switch(getMeshDimension())
@@ -794,7 +783,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::explodeMeshIntoMicroEdges(DataArrayInt *desc
  * cell with id #0 can't be negative, the array \a desc returns ids in FORTRAN mode,
  * i.e. cell ids are one-based.
  * Arrays \a revDesc and \a revDescIndx (\ref numbering-indirect) describe the reverse descending connectivity,
- * i.e. enumerate cells of  \a this mesh bounded by each cell of the result mesh. 
+ * i.e. enumerate cells of  \a this mesh bounded by each cell of the result mesh.
  * \warning For speed reasons, this method does not check if node ids in the nodal
  *          connectivity correspond to the size of node coordinates array.
  * \warning Cells of the result mesh are \b not sorted by geometric type, hence,
@@ -825,14 +814,14 @@ MEDCouplingUMesh *MEDCouplingUMesh::explodeMeshIntoMicroEdges(DataArrayInt *desc
  *  \throw If the nodal connectivity of cells is node defined.
  *  \throw If \a desc == NULL || \a descIndx == NULL || \a revDesc == NULL || \a
  *         revDescIndx == NULL.
- * 
+ *
  *  \if ENABLE_EXAMPLES
  *  \ref cpp_mcumesh_buildDescendingConnectivity2 "Here is a C++ example".<br>
  *  \ref  py_mcumesh_buildDescendingConnectivity2 "Here is a Python example".
  *  \endif
  * \sa buildDescendingConnectivity()
  */
-MEDCouplingUMesh *MEDCouplingUMesh::buildDescendingConnectivity2(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const
+MEDCouplingUMesh *MEDCouplingUMesh::buildDescendingConnectivity2(DataArrayIdType *desc, DataArrayIdType *descIndx, DataArrayIdType *revDesc, DataArrayIdType *revDescIndx) const
 {
   return buildDescendingConnectivityGen<MinusOneSonsGenerator>(desc,descIndx,revDesc,revDescIndx,MEDCouplingOrientationSensitiveNbrer);
 }
@@ -841,9 +830,9 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildDescendingConnectivity2(DataArrayInt *d
  * \b WARNING this method do the assumption that connectivity lies on the coordinates set.
  * For speed reasons no check of this will be done. This method calls
  * MEDCouplingUMesh::buildDescendingConnectivity to compute the result.
- * This method lists cell by cell in \b this which are its neighbors. To compute the result
+ * This method lists for every cell in \b this its neighbor \b cells. To compute the result
  * only connectivities are considered.
- * The neighbor cells of cell having id 'cellId' are neighbors[neighborsIndx[cellId]:neighborsIndx[cellId+1]].
+ * The neighbor cells of a given cell having id 'cellId' are neighbors[neighborsIndx[cellId]:neighborsIndx[cellId+1]].
  * The format of return is hence \ref numbering-indirect.
  *
  * \param [out] neighbors is an array storing all the neighbors of all cells in \b this. This array is newly
@@ -853,17 +842,57 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildDescendingConnectivity2(DataArrayInt *d
  * \param [out] neighborsIndx is an array of size this->getNumberOfCells()+1 newly allocated and should be
  * dealt by the caller. This arrays allow to use the first output parameter \b neighbors (\ref numbering-indirect).
  */
-void MEDCouplingUMesh::computeNeighborsOfCells(DataArrayInt *&neighbors, DataArrayInt *&neighborsIndx) const
+void MEDCouplingUMesh::computeNeighborsOfCells(DataArrayIdType *&neighbors, DataArrayIdType *&neighborsIndx) const
 {
-  MCAuto<DataArrayInt> desc=DataArrayInt::New();
-  MCAuto<DataArrayInt> descIndx=DataArrayInt::New();
-  MCAuto<DataArrayInt> revDesc=DataArrayInt::New();
-  MCAuto<DataArrayInt> revDescIndx=DataArrayInt::New();
+  MCAuto<DataArrayIdType> desc=DataArrayIdType::New();
+  MCAuto<DataArrayIdType> descIndx=DataArrayIdType::New();
+  MCAuto<DataArrayIdType> revDesc=DataArrayIdType::New();
+  MCAuto<DataArrayIdType> revDescIndx=DataArrayIdType::New();
   MCAuto<MEDCouplingUMesh> meshDM1=buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx);
   meshDM1=0;
   ComputeNeighborsOfCellsAdv(desc,descIndx,revDesc,revDescIndx,neighbors,neighborsIndx);
 }
 
+/**
+ * Given a set of identifiers indexed by the node IDs of the mesh (and given in the (\ref numbering-indirect format) ,
+ * re-arrange the data to produce a set indexed by cell IDs. The mapping between a node ID and a cell ID is done using the connectivity
+ * of the mesh (e.g. a triangular element will receive the information from its three vertices).
+ * Doublons are eliminated. If present in the inital dataset, the ID of the cell itself is also remooved.
+ *
+ * \param [in] nodeNeigh a set of identifiers (mcIdType) stored by node index (\ref numbering-indirect format)
+ * \param [in] nodeNeighI a set of identifiers (mcIdType) stored by node index (\ref numbering-indirect format)
+ * \param [out] cellNeigh This array is newly allocated and should be dealt by the caller. It contains the initial identifiers
+ * provided in the input parameters but stored now by cell index (See 2nd output parameter and \ref numbering-indirect).
+ * \param [out] cellNeighI is an array of size this->getNumberOfCells()+1 newly allocated and should be
+ * dealt by the caller. This arrays allow to use the first output parameter \b neighbors (\ref numbering-indirect).
+ *
+ * \raise if the number of tuples in nodeNeighI is not equal to the number of nodes in the mesh.
+ */
+void MEDCouplingUMesh::computeCellNeighborhoodFromNodesOne(const DataArrayIdType *nodeNeigh, const DataArrayIdType *nodeNeighI,
+                                                           MCAuto<DataArrayIdType>& cellNeigh, MCAuto<DataArrayIdType>& cellNeighIndex) const
+{
+  if(!nodeNeigh || !nodeNeighI)
+    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::computeCellNeighborhoodFromNodesOne : null pointer !");
+  checkConsistencyLight();
+  nodeNeigh->checkAllocated(); nodeNeighI->checkAllocated();
+  nodeNeigh->checkNbOfComps(1,"MEDCouplingUMesh::computeCellNeighborhoodFromNodesOne : node neigh");
+  nodeNeighI->checkNbOfComps(1,"MEDCouplingUMesh::computeCellNeighborhoodFromNodesOne : node neigh index");
+  nodeNeighI->checkNbOfTuples(1+getNumberOfNodes(),"MEDCouplingUMesh::computeCellNeighborhoodFromNodesOne : invalid length");
+  mcIdType nbCells=getNumberOfCells();
+  const mcIdType *c(_nodal_connec->begin()),*ci(_nodal_connec_index->begin()),*ne(nodeNeigh->begin()),*nei(nodeNeighI->begin());
+  cellNeigh=DataArrayIdType::New(); cellNeigh->alloc(0,1); cellNeighIndex=DataArrayIdType::New(); cellNeighIndex->alloc(1,1); cellNeighIndex->setIJ(0,0,0);
+  for(mcIdType i=0;i<nbCells;i++)
+    {
+      std::set<mcIdType> s;
+      for(const mcIdType *it=c+ci[i]+1;it!=c+ci[i+1];it++)
+        if(*it>=0)  // avoid -1 in polygons or polyedrons
+          s.insert(ne+nei[*it],ne+nei[*it+1]);
+      s.erase(i);
+      cellNeigh->insertAtTheEnd(s.begin(),s.end());
+      cellNeighIndex->pushBackSilent(cellNeigh->getNumberOfTuples());
+    }
+}
+
 /*!
  * This method is called by MEDCouplingUMesh::computeNeighborsOfCells. This methods performs the algorithm
  * of MEDCouplingUMesh::computeNeighborsOfCells.
@@ -884,27 +913,27 @@ void MEDCouplingUMesh::computeNeighborsOfCells(DataArrayInt *&neighbors, DataArr
  *                        parameter allows to select the right part in this array. The number of tuples is equal to the last values in \b neighborsIndx.
  * \param [out] neighborsIndx is an array of size this->getNumberOfCells()+1 newly allocated and should be dealt by the caller. This arrays allow to use the first output parameter \b neighbors.
  */
-void MEDCouplingUMesh::ComputeNeighborsOfCellsAdv(const DataArrayInt *desc, const DataArrayInt *descIndx, const DataArrayInt *revDesc, const DataArrayInt *revDescIndx,
-                                                  DataArrayInt *&neighbors, DataArrayInt *&neighborsIndx)
+void MEDCouplingUMesh::ComputeNeighborsOfCellsAdv(const DataArrayIdType *desc, const DataArrayIdType *descIndx, const DataArrayIdType *revDesc, const DataArrayIdType *revDescIndx,
+                                                  DataArrayIdType *&neighbors, DataArrayIdType *&neighborsIndx)
 {
   if(!desc || !descIndx || !revDesc || !revDescIndx)
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ComputeNeighborsOfCellsAdv some input array is empty !");
-  const int *descPtr=desc->getConstPointer();
-  const int *descIPtr=descIndx->getConstPointer();
-  const int *revDescPtr=revDesc->getConstPointer();
-  const int *revDescIPtr=revDescIndx->getConstPointer();
+  const mcIdType *descPtr=desc->begin();
+  const mcIdType *descIPtr=descIndx->begin();
+  const mcIdType *revDescPtr=revDesc->begin();
+  const mcIdType *revDescIPtr=revDescIndx->begin();
   //
-  int nbCells=descIndx->getNumberOfTuples()-1;
-  MCAuto<DataArrayInt> out0=DataArrayInt::New();
-  MCAuto<DataArrayInt> out1=DataArrayInt::New(); out1->alloc(nbCells+1,1);
-  int *out1Ptr=out1->getPointer();
+  mcIdType nbCells=descIndx->getNumberOfTuples()-1;
+  MCAuto<DataArrayIdType> out0=DataArrayIdType::New();
+  MCAuto<DataArrayIdType> out1=DataArrayIdType::New(); out1->alloc(nbCells+1,1);
+  mcIdType *out1Ptr=out1->getPointer();
   *out1Ptr++=0;
   out0->reserve(desc->getNumberOfTuples());
-  for(int i=0;i<nbCells;i++,descIPtr++,out1Ptr++)
+  for(mcIdType i=0;i<nbCells;i++,descIPtr++,out1Ptr++)
     {
-      for(const int *w1=descPtr+descIPtr[0];w1!=descPtr+descIPtr[1];w1++)
+      for(const mcIdType *w1=descPtr+descIPtr[0];w1!=descPtr+descIPtr[1];w1++)
         {
-          std::set<int> s(revDescPtr+revDescIPtr[*w1],revDescPtr+revDescIPtr[(*w1)+1]);
+          std::set<mcIdType> s(revDescPtr+revDescIPtr[*w1],revDescPtr+revDescIPtr[(*w1)+1]);
           s.erase(i);
           out0->insertAtTheEnd(s.begin(),s.end());
         }
@@ -914,11 +943,40 @@ void MEDCouplingUMesh::ComputeNeighborsOfCellsAdv(const DataArrayInt *desc, cons
   neighborsIndx=out1.retn();
 }
 
+/*!
+ * Explodes \a this into edges whatever its dimension.
+ */
+MCAuto<MEDCouplingUMesh> MEDCouplingUMesh::explodeIntoEdges(MCAuto<DataArrayIdType>& desc, MCAuto<DataArrayIdType>& descIndex, MCAuto<DataArrayIdType>& revDesc, MCAuto<DataArrayIdType>& revDescIndx) const
+{
+  checkFullyDefined();
+  int mdim(getMeshDimension());
+  desc=DataArrayIdType::New(); descIndex=DataArrayIdType::New(); revDesc=DataArrayIdType::New(); revDescIndx=DataArrayIdType::New();
+  MCAuto<MEDCouplingUMesh> mesh1D;
+  switch(mdim)
+  {
+    case 3:
+      {
+        mesh1D=explode3DMeshTo1D(desc,descIndex,revDesc,revDescIndx);
+        break;
+      }
+    case 2:
+      {
+        mesh1D=buildDescendingConnectivity(desc,descIndex,revDesc,revDescIndx);
+        break;
+      }
+    default:
+      {
+        throw INTERP_KERNEL::Exception("MEDCouplingUMesh::computeNeighborsOfNodes : Mesh dimension supported are [3,2] !");
+      }
+  }
+  return mesh1D;
+}
+
 /*!
  * \b WARNING this method do the assumption that connectivity lies on the coordinates set.
  * For speed reasons no check of this will be done. This method calls
  * MEDCouplingUMesh::buildDescendingConnectivity to compute the result.
- * This method lists node by node in \b this which are its neighbors. To compute the result
+ * This method lists for every node in \b this its neighbor \b nodes. To compute the result
  * only connectivities are considered.
  * The neighbor nodes of node having id 'nodeId' are neighbors[neighborsIndx[cellId]:neighborsIndx[cellId+1]].
  *
@@ -928,13 +986,15 @@ void MEDCouplingUMesh::ComputeNeighborsOfCellsAdv(const DataArrayInt *desc, cons
  * The number of tuples is equal to the last values in \b neighborsIndx.
  * \param [out] neighborsIdx is an array of size this->getNumberOfCells()+1 newly allocated and should
  * be dealt by the caller. This arrays allow to use the first output parameter \b neighbors.
+ *
+ * \sa MEDCouplingUMesh::computeEnlargedNeighborsOfNodes
  */
-void MEDCouplingUMesh::computeNeighborsOfNodes(DataArrayInt *&neighbors, DataArrayInt *&neighborsIdx) const
+void MEDCouplingUMesh::computeNeighborsOfNodes(DataArrayIdType *&neighbors, DataArrayIdType *&neighborsIdx) const
 {
   checkFullyDefined();
-  int mdim(getMeshDimension()),nbNodes(getNumberOfNodes());
-  MCAuto<DataArrayInt> desc(DataArrayInt::New()),descIndx(DataArrayInt::New()),revDesc(DataArrayInt::New()),revDescIndx(DataArrayInt::New());
-  MCAuto<MEDCouplingUMesh> mesh1D;
+  mcIdType mdim(getMeshDimension()),nbNodes(getNumberOfNodes());
+  MCAuto<DataArrayIdType> desc(DataArrayIdType::New()),descIndx(DataArrayIdType::New()),revDesc(DataArrayIdType::New()),revDescIndx(DataArrayIdType::New());
+  MCConstAuto<MEDCouplingUMesh> mesh1D;
   switch(mdim)
   {
     case 3:
@@ -949,8 +1009,7 @@ void MEDCouplingUMesh::computeNeighborsOfNodes(DataArrayInt *&neighbors, DataArr
       }
     case 1:
       {
-        mesh1D=const_cast<MEDCouplingUMesh *>(this);
-        mesh1D->incrRef();
+        mesh1D.takeRef(this);
         break;
       }
     default:
@@ -958,149 +1017,65 @@ void MEDCouplingUMesh::computeNeighborsOfNodes(DataArrayInt *&neighbors, DataArr
         throw INTERP_KERNEL::Exception("MEDCouplingUMesh::computeNeighborsOfNodes : Mesh dimension supported are [3,2,1] !");
       }
   }
-  desc=DataArrayInt::New(); descIndx=DataArrayInt::New(); revDesc=0; revDescIndx=0;
+  desc=DataArrayIdType::New(); descIndx=DataArrayIdType::New(); revDesc=0; revDescIndx=0;
   mesh1D->getReverseNodalConnectivity(desc,descIndx);
-  MCAuto<DataArrayInt> ret0(DataArrayInt::New());
+  MCAuto<DataArrayIdType> ret0(DataArrayIdType::New());
   ret0->alloc(desc->getNumberOfTuples(),1);
-  int *r0Pt(ret0->getPointer());
-  const int *c1DPtr(mesh1D->getNodalConnectivity()->begin()),*rn(desc->begin()),*rni(descIndx->begin());
-  for(int i=0;i<nbNodes;i++,rni++)
+  mcIdType *r0Pt(ret0->getPointer());
+  const mcIdType *c1DPtr(mesh1D->getNodalConnectivity()->begin()),*rn(desc->begin()),*rni(descIndx->begin());
+  for(mcIdType i=0;i<nbNodes;i++,rni++)
     {
-      for(const int *oneDCellIt=rn+rni[0];oneDCellIt!=rn+rni[1];oneDCellIt++)
+      for(const mcIdType *oneDCellIt=rn+rni[0];oneDCellIt!=rn+rni[1];oneDCellIt++)
         *r0Pt++=c1DPtr[3*(*oneDCellIt)+1]==i?c1DPtr[3*(*oneDCellIt)+2]:c1DPtr[3*(*oneDCellIt)+1];
     }
   neighbors=ret0.retn();
   neighborsIdx=descIndx.retn();
 }
 
-/// @cond INTERNAL
-
 /*!
- * \b WARNING this method do the assumption that connectivity lies on the coordinates set.
- * For speed reasons no check of this will be done.
+ * Computes enlarged neighbors for each nodes in \a this. The behavior of this method is close to MEDCouplingUMesh::computeNeighborsOfNodes except that the neighborhood of each node is wider here.
+ * A node j is considered to be in the neighborhood of i if and only if there is a cell in \a this containing in its nodal connectivity both i and j.
+ * This method is useful to find ghost cells of a part of a mesh with a code based on fields on nodes.
+ *
+ * \sa MEDCouplingUMesh::computeNeighborsOfNodes
  */
-template<class SonsGenerator>
-MEDCouplingUMesh *MEDCouplingUMesh::buildDescendingConnectivityGen(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx, DimM1DescNbrer nbrer) const
+void MEDCouplingUMesh::computeEnlargedNeighborsOfNodes(MCAuto<DataArrayIdType> &neighbors, MCAuto<DataArrayIdType>& neighborsIdx) const
 {
-  if(!desc || !descIndx || !revDesc || !revDescIndx)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildDescendingConnectivityGen : present of a null pointer in input !");
-  checkConnectivityFullyDefined();
-  int nbOfCells=getNumberOfCells();
-  int nbOfNodes=getNumberOfNodes();
-  MCAuto<DataArrayInt> revNodalIndx=DataArrayInt::New(); revNodalIndx->alloc(nbOfNodes+1,1); revNodalIndx->fillWithZero();
-  int *revNodalIndxPtr=revNodalIndx->getPointer();
-  const int *conn=_nodal_connec->getConstPointer();
-  const int *connIndex=_nodal_connec_index->getConstPointer();
-  std::string name="Mesh constituent of "; name+=getName();
-  MCAuto<MEDCouplingUMesh> ret=MEDCouplingUMesh::New(name,getMeshDimension()-SonsGenerator::DELTA);
-  ret->setCoords(getCoords());
-  ret->allocateCells(2*nbOfCells);
-  descIndx->alloc(nbOfCells+1,1);
-  MCAuto<DataArrayInt> revDesc2(DataArrayInt::New()); revDesc2->reserve(2*nbOfCells);
-  int *descIndxPtr=descIndx->getPointer(); *descIndxPtr++=0;
-  for(int eltId=0;eltId<nbOfCells;eltId++,descIndxPtr++)
-    {
-      int pos=connIndex[eltId];
-      int posP1=connIndex[eltId+1];
-      const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)conn[pos]);
-      SonsGenerator sg(cm);
-      unsigned nbOfSons=sg.getNumberOfSons2(conn+pos+1,posP1-pos-1);
-      INTERP_KERNEL::AutoPtr<int> tmp=new int[posP1-pos];
-      for(unsigned i=0;i<nbOfSons;i++)
-        {
-          INTERP_KERNEL::NormalizedCellType cmsId;
-          unsigned nbOfNodesSon=sg.fillSonCellNodalConnectivity2(i,conn+pos+1,posP1-pos-1,tmp,cmsId);
-          for(unsigned k=0;k<nbOfNodesSon;k++)
-            if(tmp[k]>=0)
-              revNodalIndxPtr[tmp[k]+1]++;
-          ret->insertNextCell(cmsId,nbOfNodesSon,tmp);
-          revDesc2->pushBackSilent(eltId);
-        }
-      descIndxPtr[0]=descIndxPtr[-1]+(int)nbOfSons;
-    }
-  int nbOfCellsM1=ret->getNumberOfCells();
-  std::transform(revNodalIndxPtr+1,revNodalIndxPtr+nbOfNodes+1,revNodalIndxPtr,revNodalIndxPtr+1,std::plus<int>());
-  MCAuto<DataArrayInt> revNodal=DataArrayInt::New(); revNodal->alloc(revNodalIndx->back(),1);
-  std::fill(revNodal->getPointer(),revNodal->getPointer()+revNodalIndx->back(),-1);
-  int *revNodalPtr=revNodal->getPointer();
-  const int *connM1=ret->getNodalConnectivity()->getConstPointer();
-  const int *connIndexM1=ret->getNodalConnectivityIndex()->getConstPointer();
-  for(int eltId=0;eltId<nbOfCellsM1;eltId++)
-    {
-      const int *strtNdlConnOfCurCell=connM1+connIndexM1[eltId]+1;
-      const int *endNdlConnOfCurCell=connM1+connIndexM1[eltId+1];
-      for(const int *iter=strtNdlConnOfCurCell;iter!=endNdlConnOfCurCell;iter++)
-        if(*iter>=0)//for polyhedrons
-          *std::find_if(revNodalPtr+revNodalIndxPtr[*iter],revNodalPtr+revNodalIndxPtr[*iter+1],std::bind2nd(std::equal_to<int>(),-1))=eltId;
-    }
-  //
-  DataArrayInt *commonCells=0,*commonCellsI=0;
-  FindCommonCellsAlg(3,0,ret->getNodalConnectivity(),ret->getNodalConnectivityIndex(),revNodal,revNodalIndx,commonCells,commonCellsI);
-  MCAuto<DataArrayInt> commonCellsTmp(commonCells),commonCellsITmp(commonCellsI);
-  const int *commonCellsPtr(commonCells->getConstPointer()),*commonCellsIPtr(commonCellsI->getConstPointer());
-  int newNbOfCellsM1=-1;
-  MCAuto<DataArrayInt> o2nM1=DataArrayInt::ConvertIndexArrayToO2N(nbOfCellsM1,commonCells->begin(),
-                                                                                                            commonCellsI->begin(),commonCellsI->end(),newNbOfCellsM1);
-  std::vector<bool> isImpacted(nbOfCellsM1,false);
-  for(const int *work=commonCellsI->begin();work!=commonCellsI->end()-1;work++)
-    for(int work2=work[0];work2!=work[1];work2++)
-      isImpacted[commonCellsPtr[work2]]=true;
-  const int *o2nM1Ptr=o2nM1->getConstPointer();
-  MCAuto<DataArrayInt> n2oM1=o2nM1->invertArrayO2N2N2OBis(newNbOfCellsM1);
-  const int *n2oM1Ptr=n2oM1->getConstPointer();
-  MCAuto<MEDCouplingUMesh> ret2=static_cast<MEDCouplingUMesh *>(ret->buildPartOfMySelf(n2oM1->begin(),n2oM1->end(),true));
-  ret2->copyTinyInfoFrom(this);
-  desc->alloc(descIndx->back(),1);
-  int *descPtr=desc->getPointer();
-  const INTERP_KERNEL::CellModel& cmsDft=INTERP_KERNEL::CellModel::GetCellModel(INTERP_KERNEL::NORM_POINT1);
-  for(int i=0;i<nbOfCellsM1;i++,descPtr++)
-    {
-      if(!isImpacted[i])
-        *descPtr=nbrer(o2nM1Ptr[i],0,cmsDft,false,0,0);
-      else
-        {
-          if(i!=n2oM1Ptr[o2nM1Ptr[i]])
-            {
-              const INTERP_KERNEL::CellModel& cms=INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)connM1[connIndexM1[i]]);
-              *descPtr=nbrer(o2nM1Ptr[i],connIndexM1[i+1]-connIndexM1[i]-1,cms,true,connM1+connIndexM1[n2oM1Ptr[o2nM1Ptr[i]]]+1,connM1+connIndexM1[i]+1);
-            }
-          else
-            *descPtr=nbrer(o2nM1Ptr[i],0,cmsDft,false,0,0);
-        }
-    }
-  revDesc->reserve(newNbOfCellsM1);
-  revDescIndx->alloc(newNbOfCellsM1+1,1);
-  int *revDescIndxPtr=revDescIndx->getPointer(); *revDescIndxPtr++=0;
-  const int *revDesc2Ptr=revDesc2->getConstPointer();
-  for(int i=0;i<newNbOfCellsM1;i++,revDescIndxPtr++)
-    {
-      int oldCellIdM1=n2oM1Ptr[i];
-      if(!isImpacted[oldCellIdM1])
-        {
-          revDesc->pushBackSilent(revDesc2Ptr[oldCellIdM1]);
-          revDescIndxPtr[0]=revDescIndxPtr[-1]+1;
-        }
-      else
-        {
-          for(int j=commonCellsIPtr[0];j<commonCellsIPtr[1];j++)
-            revDesc->pushBackSilent(revDesc2Ptr[commonCellsPtr[j]]);
-          revDescIndxPtr[0]=revDescIndxPtr[-1]+commonCellsIPtr[1]-commonCellsIPtr[0];
-          commonCellsIPtr++;
-        }
-    }
-  //
-  return ret2.retn();
+  checkFullyDefined();
+  mcIdType nbOfNodes(getNumberOfNodes());
+  const mcIdType *conn(_nodal_connec->begin()),*connIndex(_nodal_connec_index->begin());
+  mcIdType nbOfCells=getNumberOfCells();
+  std::vector< std::set<mcIdType> > st0(nbOfNodes);
+  for(mcIdType eltId=0;eltId<nbOfCells;eltId++)
+    {
+      const mcIdType *strtNdlConnOfCurCell(conn+connIndex[eltId]+1),*endNdlConnOfCurCell(conn+connIndex[eltId+1]);
+      std::set<mcIdType> s(strtNdlConnOfCurCell,endNdlConnOfCurCell); s.erase(-1); //for polyhedrons
+      for(std::set<mcIdType>::const_iterator iter2=s.begin();iter2!=s.end();iter2++)
+        st0[*iter2].insert(s.begin(),s.end());
+    }
+  neighborsIdx=DataArrayIdType::New(); neighborsIdx->alloc(nbOfNodes+1,1); neighborsIdx->setIJ(0,0,0);
+  {
+    mcIdType *neighIdx(neighborsIdx->getPointer());
+    for(std::vector< std::set<mcIdType> >::const_iterator it=st0.begin();it!=st0.end();it++,neighIdx++)
+      {
+        if ((*it).empty())
+          neighIdx[1]=neighIdx[0];
+        else
+          neighIdx[1]=neighIdx[0]+ToIdType((*it).size())-1;
+      }
+  }
+  neighbors=DataArrayIdType::New(); neighbors->alloc(neighborsIdx->back(),1);
+  {
+    const mcIdType *neighIdx(neighborsIdx->begin());
+    mcIdType *neigh(neighbors->getPointer()),nodeId(0);
+    for(std::vector< std::set<mcIdType> >::const_iterator it=st0.begin();it!=st0.end();it++,neighIdx++,nodeId++)
+      {
+        std::set<mcIdType> s(*it); s.erase(nodeId);
+        std::copy(s.begin(),s.end(),neigh+*neighIdx);
+      }
+  }
 }
 
-struct MEDCouplingAccVisit
-{
-  MEDCouplingAccVisit():_new_nb_of_nodes(0) { }
-  int operator()(int val) { if(val!=-1) return _new_nb_of_nodes++; else return -1; }
-  int _new_nb_of_nodes;
-};
-
-/// @endcond
-
 /*!
  * Converts specified cells to either polygons (if \a this is a 2D mesh) or
  * polyhedrons (if \a this is a 3D mesh). The cells to convert are specified by an
@@ -1124,18 +1099,18 @@ struct MEDCouplingAccVisit
  *  \ref  py_mcumesh_convertToPolyTypes "Here is a Python example".
  *  \endif
  */
-void MEDCouplingUMesh::convertToPolyTypes(const int *cellIdsToConvertBg, const int *cellIdsToConvertEnd)
+void MEDCouplingUMesh::convertToPolyTypes(const mcIdType *cellIdsToConvertBg, const mcIdType *cellIdsToConvertEnd)
 {
   checkFullyDefined();
   int dim=getMeshDimension();
   if(dim<2 || dim>3)
     throw INTERP_KERNEL::Exception("Invalid mesh dimension : must be 2 or 3 !");
-  int nbOfCells(getNumberOfCells());
+  mcIdType nbOfCells=getNumberOfCells();
   if(dim==2)
     {
-      const int *connIndex=_nodal_connec_index->getConstPointer();
-      int *conn=_nodal_connec->getPointer();
-      for(const int *iter=cellIdsToConvertBg;iter!=cellIdsToConvertEnd;iter++)
+      const mcIdType *connIndex=_nodal_connec_index->begin();
+      mcIdType *conn=_nodal_connec->getPointer();
+      for(const mcIdType *iter=cellIdsToConvertBg;iter!=cellIdsToConvertEnd;iter++)
         {
           if(*iter>=0 && *iter<nbOfCells)
             {
@@ -1155,11 +1130,11 @@ void MEDCouplingUMesh::convertToPolyTypes(const int *cellIdsToConvertBg, const i
     }
   else
     {
-      int *connIndex(_nodal_connec_index->getPointer());
-      const int *connOld(_nodal_connec->getConstPointer());
-      MCAuto<DataArrayInt> connNew(DataArrayInt::New()),connNewI(DataArrayInt::New()); connNew->alloc(0,1); connNewI->alloc(1,1); connNewI->setIJ(0,0,0);
+      mcIdType *connIndex(_nodal_connec_index->getPointer());
+      const mcIdType *connOld(_nodal_connec->getConstPointer());
+      MCAuto<DataArrayIdType> connNew(DataArrayIdType::New()),connNewI(DataArrayIdType::New()); connNew->alloc(0,1); connNewI->alloc(1,1); connNewI->setIJ(0,0,0);
       std::vector<bool> toBeDone(nbOfCells,false);
-      for(const int *iter=cellIdsToConvertBg;iter!=cellIdsToConvertEnd;iter++)
+      for(const mcIdType *iter=cellIdsToConvertBg;iter!=cellIdsToConvertEnd;iter++)
         {
           if(*iter>=0 && *iter<nbOfCells)
             toBeDone[*iter]=true;
@@ -1170,16 +1145,16 @@ void MEDCouplingUMesh::convertToPolyTypes(const int *cellIdsToConvertBg, const i
               throw INTERP_KERNEL::Exception(oss.str());
             }
         }
-      for(int cellId=0;cellId<nbOfCells;cellId++)
+      for(mcIdType cellId=0;cellId<nbOfCells;cellId++)
         {
-          int pos(connIndex[cellId]),posP1(connIndex[cellId+1]);
-          int lgthOld(posP1-pos-1);
+          mcIdType pos(connIndex[cellId]),posP1(connIndex[cellId+1]);
+          mcIdType lgthOld(posP1-pos-1);
           if(toBeDone[cellId])
             {
               const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)connOld[pos]);
               unsigned nbOfFaces(cm.getNumberOfSons2(connOld+pos+1,lgthOld));
-              int *tmp(new int[nbOfFaces*lgthOld+1]);
-              int *work=tmp; *work++=INTERP_KERNEL::NORM_POLYHED;
+              mcIdType *tmp(new mcIdType[nbOfFaces*lgthOld+1]);
+              mcIdType *work=tmp; *work++=INTERP_KERNEL::NORM_POLYHED;
               for(unsigned j=0;j<nbOfFaces;j++)
                 {
                   INTERP_KERNEL::NormalizedCellType type;
@@ -1189,7 +1164,7 @@ void MEDCouplingUMesh::convertToPolyTypes(const int *cellIdsToConvertBg, const i
                 }
               std::size_t newLgth(std::distance(tmp,work)-1);//-1 for last -1
               connNew->pushBackValsSilent(tmp,tmp+newLgth);
-              connNewI->pushBackSilent(connNewI->back()+(int)newLgth);
+              connNewI->pushBackSilent(connNewI->back()+ToIdType(newLgth));
               delete [] tmp;
             }
           else
@@ -1215,11 +1190,11 @@ void MEDCouplingUMesh::convertToPolyTypes(const int *cellIdsToConvertBg, const i
  */
 void MEDCouplingUMesh::convertAllToPoly()
 {
-  int nbOfCells=getNumberOfCells();
-  std::vector<int> cellIds(nbOfCells);
-  for(int i=0;i<nbOfCells;i++)
+  mcIdType nbOfCells=getNumberOfCells();
+  std::vector<mcIdType> cellIds(nbOfCells);
+  for(mcIdType i=0;i<nbOfCells;i++)
     cellIds[i]=i;
-  convertToPolyTypes(&cellIds[0],&cellIds[0]+cellIds.size());
+  convertToPolyTypes(&cellIds[0],&cellIds[0]+ToIdType(cellIds.size()));
 }
 
 /*!
@@ -1254,14 +1229,14 @@ void MEDCouplingUMesh::convertExtrudedPolyhedra()
   checkFullyDefined();
   if(getMeshDimension()!=3 || getSpaceDimension()!=3)
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::convertExtrudedPolyhedra works on umeshes with meshdim equal to 3 and spaceDim equal to 3 too!");
-  int nbOfCells=getNumberOfCells();
-  MCAuto<DataArrayInt> newCi=DataArrayInt::New();
+  mcIdType nbOfCells=getNumberOfCells();
+  MCAuto<DataArrayIdType> newCi=DataArrayIdType::New();
   newCi->alloc(nbOfCells+1,1);
-  int *newci=newCi->getPointer();
-  const int *ci=_nodal_connec_index->getConstPointer();
-  const int *c=_nodal_connec->getConstPointer();
+  mcIdType *newci=newCi->getPointer();
+  const mcIdType *ci=_nodal_connec_index->getConstPointer();
+  const mcIdType *c=_nodal_connec->getConstPointer();
   newci[0]=0;
-  for(int i=0;i<nbOfCells;i++)
+  for(mcIdType i=0;i<nbOfCells;i++)
     {
       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)c[ci[i]];
       if(type==INTERP_KERNEL::NORM_POLYHED)
@@ -1277,16 +1252,16 @@ void MEDCouplingUMesh::convertExtrudedPolyhedra()
               std::ostringstream oss; oss << "MEDCouplingUMesh::convertExtrudedPolyhedra : cell # " << i << " is a polhedron with 1 face but there is a mismatch of number of nodes in face should be even !";
               throw INTERP_KERNEL::Exception(oss.str());
             }
-          int n1=(int)(n2/2);
+          mcIdType n1=ToIdType(n2/2);
           newci[i+1]=7*n1+2+newci[i];//6*n1 (nodal length) + n1+2 (number of faces) - 1 (number of '-1' separator is equal to number of faces -1) + 1 (for cell type)
         }
       else
         newci[i+1]=(ci[i+1]-ci[i])+newci[i];
     }
-  MCAuto<DataArrayInt> newC=DataArrayInt::New();
+  MCAuto<DataArrayIdType> newC=DataArrayIdType::New();
   newC->alloc(newci[nbOfCells],1);
-  int *newc=newC->getPointer();
-  for(int i=0;i<nbOfCells;i++)
+  mcIdType *newc=newC->getPointer();
+  for(mcIdType i=0;i<nbOfCells;i++)
     {
       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)c[ci[i]];
       if(type==INTERP_KERNEL::NORM_POLYHED)
@@ -1335,46 +1310,47 @@ bool MEDCouplingUMesh::unPolyze()
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::unPolyze works on umeshes with meshdim equals to 0, 1 2 or 3 !");
   if(mdim<=1)
     return false;
-  int nbOfCells=getNumberOfCells();
+  mcIdType nbOfCells=getNumberOfCells();
   if(nbOfCells<1)
     return false;
-  int initMeshLgth=getNodalConnectivityArrayLen();
-  int *conn=_nodal_connec->getPointer();
-  int *index=_nodal_connec_index->getPointer();
-  int posOfCurCell=0;
-  int newPos=0;
-  int lgthOfCurCell;
+  mcIdType initMeshLgth=getNodalConnectivityArrayLen();
+  mcIdType *conn=_nodal_connec->getPointer();
+  mcIdType *index=_nodal_connec_index->getPointer();
+  mcIdType posOfCurCell=0;
+  mcIdType newPos=0;
+  mcIdType lgthOfCurCell;
   bool ret=false;
-  for(int i=0;i<nbOfCells;i++)
+  for(mcIdType i=0;i<nbOfCells;i++)
     {
       lgthOfCurCell=index[i+1]-posOfCurCell;
       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)conn[posOfCurCell];
       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type);
       INTERP_KERNEL::NormalizedCellType newType=INTERP_KERNEL::NORM_ERROR;
-      int newLgth;
+      mcIdType newLgth=0;
       if(cm.isDynamic())
         {
           switch(cm.getDimension())
           {
             case 2:
               {
-                INTERP_KERNEL::AutoPtr<int> tmp=new int[lgthOfCurCell-1];
-                std::copy(conn+posOfCurCell+1,conn+posOfCurCell+lgthOfCurCell,(int *)tmp);
+                INTERP_KERNEL::AutoPtr<mcIdType> tmp=new mcIdType[lgthOfCurCell-1];
+                std::copy(conn+posOfCurCell+1,conn+posOfCurCell+lgthOfCurCell,(mcIdType *)tmp);
                 newType=INTERP_KERNEL::CellSimplify::tryToUnPoly2D(cm.isQuadratic(),tmp,lgthOfCurCell-1,conn+newPos+1,newLgth);
                 break;
               }
             case 3:
               {
-                int nbOfFaces,lgthOfPolyhConn;
-                INTERP_KERNEL::AutoPtr<int> zipFullReprOfPolyh=INTERP_KERNEL::CellSimplify::getFullPolyh3DCell(type,conn+posOfCurCell+1,lgthOfCurCell-1,nbOfFaces,lgthOfPolyhConn);
+                mcIdType nbOfFaces,lgthOfPolyhConn;
+                INTERP_KERNEL::AutoPtr<mcIdType> zipFullReprOfPolyh=INTERP_KERNEL::CellSimplify::getFullPolyh3DCell(type,conn+posOfCurCell+1,lgthOfCurCell-1,nbOfFaces,lgthOfPolyhConn);
                 newType=INTERP_KERNEL::CellSimplify::tryToUnPoly3D(zipFullReprOfPolyh,nbOfFaces,lgthOfPolyhConn,conn+newPos+1,newLgth);
                 break;
               }
-            case 1:
+         /*   case 1:  // Not supported yet
               {
                 newType=(lgthOfCurCell==3)?INTERP_KERNEL::NORM_SEG2:INTERP_KERNEL::NORM_POLYL;
                 break;
               }
+         */
           }
           ret=ret || (newType!=type);
           conn[newPos]=newType;
@@ -1400,9 +1376,11 @@ bool MEDCouplingUMesh::unPolyze()
 /*!
  * This method expects that spaceDimension is equal to 3 and meshDimension equal to 3.
  * This method performs operation only on polyhedrons in \b this. If no polyhedrons exists in \b this, \b this remains unchanged.
- * This method allows to merge if any coplanar 3DSurf cells that may appear in some polyhedrons cells. 
+ * This method allows to merge if any coplanar 3DSurf cells that may appear in some polyhedrons cells.
+ *
+ * \b WARNING: this method will not modify edges connectivity! Take a look at colinearizeEdges for that.
  *
- * \param [in] eps is a relative precision that allows to establish if some 3D plane are coplanar or not. This epsilon is used to recenter around origin to have maximal 
+ * \param [in] eps is a relative precision that allows to establish if some 3D plane are coplanar or not. This epsilon is used to recenter around origin to have maximal
  *             precision.
  */
 void MEDCouplingUMesh::simplifyPolyhedra(double eps)
@@ -1413,19 +1391,21 @@ void MEDCouplingUMesh::simplifyPolyhedra(double eps)
   MCAuto<DataArrayDouble> coords=getCoords()->deepCopy();
   coords->recenterForMaxPrecision(eps);
   //
-  int nbOfCells=getNumberOfCells();
-  const int *conn=_nodal_connec->getConstPointer();
-  const int *index=_nodal_connec_index->getConstPointer();
-  MCAuto<DataArrayInt> connINew=DataArrayInt::New();
+  mcIdType nbOfCells=getNumberOfCells();
+  const mcIdType *conn=_nodal_connec->getConstPointer();
+  const mcIdType *index=_nodal_connec_index->getConstPointer();
+  MCAuto<DataArrayIdType> connINew=DataArrayIdType::New();
   connINew->alloc(nbOfCells+1,1);
-  int *connINewPtr=connINew->getPointer(); *connINewPtr++=0;
-  MCAuto<DataArrayInt> connNew=DataArrayInt::New(); connNew->alloc(0,1);
+  mcIdType *connINewPtr=connINew->getPointer(); *connINewPtr++=0;
+  MCAuto<DataArrayIdType> connNew=DataArrayIdType::New(); connNew->alloc(0,1);
+  MCAuto<DataArrayIdType> E_Fi(DataArrayIdType::New()), E_F(DataArrayIdType::New()), F_Ei(DataArrayIdType::New()), F_E(DataArrayIdType::New());
+  MCAuto<MEDCouplingUMesh> m_faces(buildDescendingConnectivity(E_F, E_Fi, F_E, F_Ei));
   bool changed=false;
-  for(int i=0;i<nbOfCells;i++,connINewPtr++)
+  for(mcIdType i=0;i<nbOfCells;i++,connINewPtr++)
     {
-      if(conn[index[i]]==(int)INTERP_KERNEL::NORM_POLYHED)
+      if(conn[index[i]]==ToIdType(INTERP_KERNEL::NORM_POLYHED))
         {
-          SimplifyPolyhedronCell(eps,coords,conn+index[i],conn+index[i+1],connNew);
+          SimplifyPolyhedronCell(eps,coords, i,connNew, m_faces, E_Fi, E_F, F_Ei, F_E);
           changed=true;
         }
       else
@@ -1436,22 +1416,100 @@ void MEDCouplingUMesh::simplifyPolyhedra(double eps)
     setConnectivity(connNew,connINew,false);
 }
 
+/*!
+ * This method expects that spaceDimension is equal to 3 and meshDimension equal to 3.
+ * This method performs operation only on polyhedrons in \b this. If no polyhedrons exists in \b this, \b this remains unchanged.
+ * This method allows to simplify edges of polyhedron cells so that consecutive colinear segments (with intermediate points
+ * not used by any other cell) are merged together.
+ *
+ * \param [in] eps is a relative precision that allows to establish if two consecutive 3D segments are colinear or not.
+ *
+ * \sa simplifyPolyhedra
+ */
+void MEDCouplingUMesh::colinearizeEdges(double eps)
+{
+  //
+  // Thanks to Antoine Gerschenfeld (CEA) for contributing this method!
+  //
+  using DAI = MCAuto<DataArrayIdType>;
+  checkFullyDefined();
+  if(getMeshDimension()!=3 || getSpaceDimension()!=3)
+    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::colinearizeEdges() : works with meshdim=3 and spaceDim=3!");
+  double seps = sqrt(1-eps);
+  // Computing connectivities and correspondances : elements -> segments -> points
+  DAI E_Fi(DataArrayIdType::New()), E_F(DataArrayIdType::New()), F_Ei(DataArrayIdType::New()), F_E(DataArrayIdType::New()),
+         F_Si(DataArrayIdType::New()), F_S(DataArrayIdType::New()), S_Fi(DataArrayIdType::New()), S_F(DataArrayIdType::New()),
+         S_Pi(DataArrayIdType::New()), S_P(DataArrayIdType::New()), P_Si(DataArrayIdType::New()), P_S(DataArrayIdType::New());
+  MCAuto<MEDCouplingUMesh> m_f(buildDescendingConnectivity(E_F, E_Fi, F_E, F_Ei)),
+         m_s(m_f->buildDescendingConnectivity(F_S, F_Si, S_F, S_Fi)),
+         m_p(m_s->buildDescendingConnectivity(S_P, S_Pi, P_S, P_Si)); // E: elem, F: faces, S: segments (edges), P: points (vertices)
+  const mcIdType *S_Pp(S_P->begin()), *S_Pip(S_Pi->begin()), *P_Sp(P_S->begin()), *P_Sip(P_Si->begin());
+  std::set<mcIdType> pt_rem;
+  const mcIdType *m_pi = m_p->getNodalConnectivityIndex()->begin(),
+                 *m_pc = m_p->getNodalConnectivity()->begin();
+  double (*coord)[3] = (double (*)[3]) getCoords()->begin();
+  // Find all points only connected to exaclty 2 segments - they are the candidates for elimination
+  // Note that in 3D this can only happen for polyhedrons (when this happens at all)
+  DAI dsi = P_Si->deltaShiftIndex();
+  DAI cand = dsi->findIdsEqual(2);
+  for (const mcIdType& i: *cand)  // i is a point to be potentially eliminated, shared by 2 segs only
+    {
+      double n2[2] = {0., 0.}, scal = 0.; // n2 is a squared norm, scal is a scalar product
+      mcIdType p[2][2];                   // p[j][k] is the ID (in the coord array) of the k-th point of the j-th segment
+      for (mcIdType j = 0; j < 2; j++)
+        for (mcIdType k = 0; k < 2; k++)
+          {
+            mcIdType off1 = P_Sip[i] + j;   // offset to get ID of the j-th seg (around the i-th point) in the point->seg correspondance
+            mcIdType pt_id = P_Sp[off1] + k; // ID of the k-th point of the j-th seg in the point->seg correspondance
+            mcIdType pt_id2 = S_Pp[S_Pip[pt_id]]; // ID of the point in the point mesh
+            p[j][k] = m_pc[m_pi[pt_id2] + 1];  // Absolute ID, as read from the connectvity (+1 to skip type: NORM_POINT1)
+            // Just for fun, as initially written by Antoine :-)
+            // p[j][k] = m_pc[m_pi[S_P->getIJ(S_Pi->getIJ(P_S->getIJ(P_Si->getIJ(i, 0) + j, 0), 0) + k, 0)] + 1];
+          }
+      // Geometric test on scalar product
+      for (int d = 0; d < 3; d++) // dimension
+        {
+          for (int j = 0; j < 2; j++)
+            n2[j] += std::pow(coord[p[j][1]][d] - coord[p[j][0]][d], 2);
+          scal += (coord[p[1][1]][d] - coord[p[1][0]][d]) * (coord[p[0][1]][d] - coord[p[0][0]][d]);
+        }
+      if (scal * scal > seps * n2[0] * n2[1]) // seps is a sqrt for homogeneity
+        pt_rem.insert(m_pc[m_pi[i] + 1]);  // point should be removed
+    }
+  // Clean connectivity by filtering points to be removed:
+  DataArrayIdType *old_index = getNodalConnectivityIndex(), *old_conn = getNodalConnectivity();
+  DAI new_index(DataArrayIdType::New()), new_conn(DataArrayIdType::New());
+  const mcIdType *old_index_p(old_index->begin()), *old_conn_p(old_conn->begin());
+  for (mcIdType i = 0; i < getNumberOfCells(); i++)
+    {
+      new_index->pushBackSilent(new_conn->getNbOfElems());
+      for (mcIdType j = old_index_p[i]; j < old_index_p[i + 1]; j++)
+        {
+          // Keep point if it is not to be removed, or if is first in connectivity (TODO this last check could be removed?)
+          if (std::find(pt_rem.begin(), pt_rem.end(), old_conn_p[j]) == pt_rem.end() || j == old_index_p[i])
+            new_conn->pushBackSilent(old_conn_p[j]);
+        }
+    }
+  new_index->pushBackSilent(new_conn->getNbOfElems());
+  setConnectivity(new_conn, new_index);
+}
+
 /*!
  * This method returns all node ids used in the connectivity of \b this. The data array returned has to be dealt by the caller.
  * The returned node ids are sorted ascendingly. This method is close to MEDCouplingUMesh::getNodeIdsInUse except
- * the format of the returned DataArrayInt instance.
- * 
- * \return a newly allocated DataArrayInt sorted ascendingly of fetched node ids.
+ * the format of the returned DataArrayIdType instance.
+ *
+ * \return a newly allocated DataArrayIdType sorted ascendingly of fetched node ids.
  * \sa MEDCouplingUMesh::getNodeIdsInUse, areAllNodesFetched
  */
-DataArrayInt *MEDCouplingUMesh::computeFetchedNodeIds() const
+DataArrayIdType *MEDCouplingUMesh::computeFetchedNodeIds() const
 {
   checkConnectivityFullyDefined();
-  const int *maxEltPt(std::max_element(_nodal_connec->begin(),_nodal_connec->end()));
-  int maxElt(maxEltPt==_nodal_connec->end()?0:std::abs(*maxEltPt)+1);
+  const mcIdType *maxEltPt(std::max_element(_nodal_connec->begin(),_nodal_connec->end()));
+  mcIdType maxElt(maxEltPt==_nodal_connec->end()?0:std::abs(*maxEltPt)+1);
   std::vector<bool> retS(maxElt,false);
   computeNodeIdsAlg(retS);
-  return DataArrayInt::BuildListOfSwitchedOn(retS);
+  return DataArrayIdType::BuildListOfSwitchedOn(retS);
 }
 
 /*!
@@ -1460,10 +1518,11 @@ DataArrayInt *MEDCouplingUMesh::computeFetchedNodeIds() const
  */
 void MEDCouplingUMesh::computeNodeIdsAlg(std::vector<bool>& nodeIdsInUse) const
 {
-  int nbOfNodes((int)nodeIdsInUse.size()),nbOfCells(getNumberOfCells());
-  const int *connIndex(_nodal_connec_index->getConstPointer()),*conn(_nodal_connec->getConstPointer());
-  for(int i=0;i<nbOfCells;i++)
-    for(int j=connIndex[i]+1;j<connIndex[i+1];j++)
+  mcIdType nbOfNodes=ToIdType(nodeIdsInUse.size()),
+           nbOfCells=getNumberOfCells();
+  const mcIdType *connIndex(_nodal_connec_index->getConstPointer()),*conn(_nodal_connec->getConstPointer());
+  for(mcIdType i=0;i<nbOfCells;i++)
+    for(mcIdType j=connIndex[i]+1;j<connIndex[i+1];j++)
       if(conn[j]>=0)
         {
           if(conn[j]<nbOfNodes)
@@ -1476,15 +1535,26 @@ void MEDCouplingUMesh::computeNodeIdsAlg(std::vector<bool>& nodeIdsInUse) const
         }
 }
 
+/// @cond INTERNAL
+
+struct MEDCouplingAccVisit
+{
+  MEDCouplingAccVisit():_new_nb_of_nodes(0) { }
+  mcIdType operator()(mcIdType val) { if(val!=-1) return _new_nb_of_nodes++; else return -1; }
+  mcIdType _new_nb_of_nodes;
+};
+
+/// @endcond
+
 /*!
  * Finds nodes not used in any cell and returns an array giving a new id to every node
  * by excluding the unused nodes, for which the array holds -1. The result array is
- * a mapping in "Old to New" mode. 
+ * a mapping in "Old to New" mode.
  *  \param [out] nbrOfNodesInUse - number of node ids present in the nodal connectivity.
- *  \return DataArrayInt * - a new instance of DataArrayInt. Its length is \a
+ *  \return DataArrayIdType * - a new instance of DataArrayIdType. Its length is \a
  *          this->getNumberOfNodes(). It holds for each node of \a this mesh either -1
  *          if the node is unused or a new id else. The caller is to delete this
- *          array using decrRef() as it is no more needed.  
+ *          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.
@@ -1495,19 +1565,19 @@ void MEDCouplingUMesh::computeNodeIdsAlg(std::vector<bool>& nodeIdsInUse) const
  *  \endif
  * \sa computeFetchedNodeIds, computeNodeIdsAlg()
  */
-DataArrayInt *MEDCouplingUMesh::getNodeIdsInUse(int& nbrOfNodesInUse) const
+DataArrayIdType *MEDCouplingUMesh::getNodeIdsInUse(mcIdType& nbrOfNodesInUse) const
 {
   nbrOfNodesInUse=-1;
-  int nbOfNodes(getNumberOfNodes());
-  MCAuto<DataArrayInt> ret=DataArrayInt::New();
+  mcIdType nbOfNodes(getNumberOfNodes());
+  MCAuto<DataArrayIdType> ret=DataArrayIdType::New();
   ret->alloc(nbOfNodes,1);
-  int *traducer=ret->getPointer();
+  mcIdType *traducer=ret->getPointer();
   std::fill(traducer,traducer+nbOfNodes,-1);
-  int nbOfCells=getNumberOfCells();
-  const int *connIndex=_nodal_connec_index->getConstPointer();
-  const int *conn=_nodal_connec->getConstPointer();
-  for(int i=0;i<nbOfCells;i++)
-    for(int j=connIndex[i]+1;j<connIndex[i+1];j++)
+  mcIdType nbOfCells=getNumberOfCells();
+  const mcIdType *connIndex=_nodal_connec_index->getConstPointer();
+  const mcIdType *conn=_nodal_connec->getConstPointer();
+  for(mcIdType i=0;i<nbOfCells;i++)
+    for(mcIdType j=connIndex[i]+1;j<connIndex[i+1];j++)
       if(conn[j]>=0)
         {
           if(conn[j]<nbOfNodes)
@@ -1518,7 +1588,7 @@ DataArrayInt *MEDCouplingUMesh::getNodeIdsInUse(int& nbrOfNodesInUse) const
               throw INTERP_KERNEL::Exception(oss.str());
             }
         }
-  nbrOfNodesInUse=(int)std::count(traducer,traducer+nbOfNodes,1);
+  nbrOfNodesInUse=ToIdType(std::count(traducer,traducer+nbOfNodes,1));
   std::transform(traducer,traducer+nbOfNodes,traducer,MEDCouplingAccVisit());
   return ret.retn();
 }
@@ -1528,25 +1598,25 @@ DataArrayInt *MEDCouplingUMesh::getNodeIdsInUse(int& nbrOfNodesInUse) const
  * For each cell in \b this the number of nodes constituting cell is computed.
  * For each polyhedron cell, the sum of the number of nodes of each face constituting polyhedron cell is returned.
  * So for pohyhedrons some nodes can be counted several times in the returned result.
- * 
+ *
  * \return a newly allocated array
  * \sa MEDCouplingUMesh::computeEffectiveNbOfNodesPerCell
  */
-DataArrayInt *MEDCouplingUMesh::computeNbOfNodesPerCell() const
+DataArrayIdType *MEDCouplingUMesh::computeNbOfNodesPerCell() const
 {
   checkConnectivityFullyDefined();
-  int nbOfCells=getNumberOfCells();
-  MCAuto<DataArrayInt> ret=DataArrayInt::New();
+  mcIdType nbOfCells=getNumberOfCells();
+  MCAuto<DataArrayIdType> ret=DataArrayIdType::New();
   ret->alloc(nbOfCells,1);
-  int *retPtr=ret->getPointer();
-  const int *conn=getNodalConnectivity()->getConstPointer();
-  const int *connI=getNodalConnectivityIndex()->getConstPointer();
-  for(int i=0;i<nbOfCells;i++,retPtr++)
+  mcIdType *retPtr=ret->getPointer();
+  const mcIdType *conn=getNodalConnectivity()->getConstPointer();
+  const mcIdType *connI=getNodalConnectivityIndex()->getConstPointer();
+  for(mcIdType i=0;i<nbOfCells;i++,retPtr++)
     {
-      if(conn[connI[i]]!=(int)INTERP_KERNEL::NORM_POLYHED)
+      if(conn[connI[i]]!=ToIdType(INTERP_KERNEL::NORM_POLYHED))
         *retPtr=connI[i+1]-connI[i]-1;
       else
-        *retPtr=connI[i+1]-connI[i]-1-std::count(conn+connI[i]+1,conn+connI[i+1],-1);
+        *retPtr=connI[i+1]-connI[i]-1-ToIdType(std::count(conn+connI[i]+1,conn+connI[i+1],-1));
     }
   return ret.retn();
 }
@@ -1555,27 +1625,27 @@ DataArrayInt *MEDCouplingUMesh::computeNbOfNodesPerCell() const
  * This method computes effective number of nodes per cell. That is to say nodes appearing several times in nodal connectivity of a cell,
  * will be counted only once here whereas it will be counted several times in MEDCouplingUMesh::computeNbOfNodesPerCell method.
  *
- * \return DataArrayInt * - new object to be deallocated by the caller.
+ * \return DataArrayIdType * - new object to be deallocated by the caller.
  * \sa MEDCouplingUMesh::computeNbOfNodesPerCell
  */
-DataArrayInt *MEDCouplingUMesh::computeEffectiveNbOfNodesPerCell() const
+DataArrayIdType *MEDCouplingUMesh::computeEffectiveNbOfNodesPerCell() const
 {
   checkConnectivityFullyDefined();
-  int nbOfCells=getNumberOfCells();
-  MCAuto<DataArrayInt> ret=DataArrayInt::New();
+  mcIdType nbOfCells=getNumberOfCells();
+  MCAuto<DataArrayIdType> ret=DataArrayIdType::New();
   ret->alloc(nbOfCells,1);
-  int *retPtr=ret->getPointer();
-  const int *conn=getNodalConnectivity()->getConstPointer();
-  const int *connI=getNodalConnectivityIndex()->getConstPointer();
-  for(int i=0;i<nbOfCells;i++,retPtr++)
-    {
-      std::set<int> s(conn+connI[i]+1,conn+connI[i+1]);
-      if(conn[connI[i]]!=(int)INTERP_KERNEL::NORM_POLYHED)
-        *retPtr=(int)s.size();
+  mcIdType *retPtr=ret->getPointer();
+  const mcIdType *conn=getNodalConnectivity()->getConstPointer();
+  const mcIdType *connI=getNodalConnectivityIndex()->getConstPointer();
+  for(mcIdType i=0;i<nbOfCells;i++,retPtr++)
+    {
+      std::set<mcIdType> s(conn+connI[i]+1,conn+connI[i+1]);
+      if(conn[connI[i]]!=ToIdType(INTERP_KERNEL::NORM_POLYHED))
+        *retPtr=ToIdType(s.size());
       else
         {
           s.erase(-1);
-          *retPtr=(int)s.size();
+          *retPtr=ToIdType(s.size());
         }
     }
   return ret.retn();
@@ -1584,19 +1654,19 @@ DataArrayInt *MEDCouplingUMesh::computeEffectiveNbOfNodesPerCell() const
 /*!
  * This method returns a newly allocated array containing this->getNumberOfCells() tuples and 1 component.
  * For each cell in \b this the number of faces constituting (entity of dimension this->getMeshDimension()-1) cell is computed.
- * 
+ *
  * \return a newly allocated array
  */
-DataArrayInt *MEDCouplingUMesh::computeNbOfFacesPerCell() const
+DataArrayIdType *MEDCouplingUMesh::computeNbOfFacesPerCell() const
 {
   checkConnectivityFullyDefined();
-  int nbOfCells=getNumberOfCells();
-  MCAuto<DataArrayInt> ret=DataArrayInt::New();
+  mcIdType nbOfCells=getNumberOfCells();
+  MCAuto<DataArrayIdType> ret=DataArrayIdType::New();
   ret->alloc(nbOfCells,1);
-  int *retPtr=ret->getPointer();
-  const int *conn=getNodalConnectivity()->getConstPointer();
-  const int *connI=getNodalConnectivityIndex()->getConstPointer();
-  for(int i=0;i<nbOfCells;i++,retPtr++,connI++)
+  mcIdType *retPtr=ret->getPointer();
+  const mcIdType *conn=getNodalConnectivity()->getConstPointer();
+  const mcIdType *connI=getNodalConnectivityIndex()->getConstPointer();
+  for(mcIdType i=0;i<nbOfCells;i++,retPtr++,connI++)
     {
       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)conn[*connI]);
       *retPtr=cm.getNumberOfSons2(conn+connI[0]+1,connI[1]-connI[0]-1);
@@ -1607,10 +1677,10 @@ DataArrayInt *MEDCouplingUMesh::computeNbOfFacesPerCell() const
 /*!
  * 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
+ * array mean that the corresponding old node is no more used.
+ *  \return DataArrayIdType * - a new instance of DataArrayIdType 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. 
+ *           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.
@@ -1621,7 +1691,7 @@ DataArrayInt *MEDCouplingUMesh::computeNbOfFacesPerCell() const
  *  \ref  py_mcumesh_zipCoordsTraducer "Here is a Python example".
  *  \endif
  */
-DataArrayInt *MEDCouplingUMesh::zipCoordsTraducer()
+DataArrayIdType *MEDCouplingUMesh::zipCoordsTraducer()
 {
   return MEDCouplingPointSet::zipCoordsTraducer();
 }
@@ -1630,7 +1700,7 @@ DataArrayInt *MEDCouplingUMesh::zipCoordsTraducer()
  * This method stands if 'cell1' and 'cell2' are equals regarding 'compType' policy.
  * The semantic of 'compType' is specified in MEDCouplingPointSet::zipConnectivityTraducer method.
  */
-int MEDCouplingUMesh::AreCellsEqual(const int *conn, const int *connI, int cell1, int cell2, int compType)
+int MEDCouplingUMesh::AreCellsEqual(const mcIdType *conn, const mcIdType *connI, mcIdType cell1, mcIdType cell2, int compType)
 {
   switch(compType)
   {
@@ -1651,7 +1721,7 @@ int MEDCouplingUMesh::AreCellsEqual(const int *conn, const int *connI, int cell1
 /*!
  * This method is the last step of the MEDCouplingPointSet::zipConnectivityTraducer with policy 0.
  */
-int MEDCouplingUMesh::AreCellsEqualPolicy0(const int *conn, const int *connI, int cell1, int cell2)
+int MEDCouplingUMesh::AreCellsEqualPolicy0(const mcIdType *conn, const mcIdType *connI, mcIdType cell1, mcIdType cell2)
 {
   if(connI[cell1+1]-connI[cell1]==connI[cell2+1]-connI[cell2])
     return std::equal(conn+connI[cell1]+1,conn+connI[cell1+1],conn+connI[cell2]+1)?1:0;
@@ -1661,9 +1731,9 @@ int MEDCouplingUMesh::AreCellsEqualPolicy0(const int *conn, const int *connI, in
 /*!
  * This method is the last step of the MEDCouplingPointSet::zipConnectivityTraducer with policy 1.
  */
-int MEDCouplingUMesh::AreCellsEqualPolicy1(const int *conn, const int *connI, int cell1, int cell2)
+int MEDCouplingUMesh::AreCellsEqualPolicy1(const mcIdType *conn, const mcIdType *connI, mcIdType cell1, mcIdType cell2)
 {
-  int sz=connI[cell1+1]-connI[cell1];
+  mcIdType sz=connI[cell1+1]-connI[cell1];
   if(sz==connI[cell2+1]-connI[cell2])
     {
       if(conn[connI[cell1]]==conn[connI[cell2]])
@@ -1674,11 +1744,11 @@ int MEDCouplingUMesh::AreCellsEqualPolicy1(const int *conn, const int *connI, in
             {
               if(dim!=1)
                 {
-                  int sz1=2*(sz-1);
-                  INTERP_KERNEL::AutoPtr<int> tmp=new int[sz1];
-                  int *work=std::copy(conn+connI[cell1]+1,conn+connI[cell1+1],(int *)tmp);
+                  mcIdType sz1=2*(sz-1);
+                  INTERP_KERNEL::AutoPtr<mcIdType> tmp=new mcIdType[sz1];
+                  mcIdType *work=std::copy(conn+connI[cell1]+1,conn+connI[cell1+1],(mcIdType *)tmp);
                   std::copy(conn+connI[cell1]+1,conn+connI[cell1+1],work);
-                  work=std::search((int *)tmp,(int *)tmp+sz1,conn+connI[cell2]+1,conn+connI[cell2+1]);
+                  work=std::search((mcIdType *)tmp,(mcIdType *)tmp+sz1,conn+connI[cell2]+1,conn+connI[cell2+1]);
                   return work!=tmp+sz1?1:0;
                 }
               else
@@ -1694,14 +1764,14 @@ int MEDCouplingUMesh::AreCellsEqualPolicy1(const int *conn, const int *connI, in
 /*!
  * This method is the last step of the MEDCouplingPointSet::zipConnectivityTraducer with policy 2.
  */
-int MEDCouplingUMesh::AreCellsEqualPolicy2(const int *conn, const int *connI, int cell1, int cell2)
+int MEDCouplingUMesh::AreCellsEqualPolicy2(const mcIdType *conn, const mcIdType *connI, mcIdType cell1, mcIdType cell2)
 {
   if(connI[cell1+1]-connI[cell1]==connI[cell2+1]-connI[cell2])
     {
       if(conn[connI[cell1]]==conn[connI[cell2]])
         {
-          std::set<int> s1(conn+connI[cell1]+1,conn+connI[cell1+1]);
-          std::set<int> s2(conn+connI[cell2]+1,conn+connI[cell2+1]);
+          std::set<mcIdType> s1(conn+connI[cell1]+1,conn+connI[cell1+1]);
+          std::set<mcIdType> s2(conn+connI[cell2]+1,conn+connI[cell2+1]);
           return s1==s2?1:0;
         }
     }
@@ -1711,12 +1781,12 @@ int MEDCouplingUMesh::AreCellsEqualPolicy2(const int *conn, const int *connI, in
 /*!
  * This method is less restrictive than AreCellsEqualPolicy2. Here the geometric type is absolutely not taken into account !
  */
-int MEDCouplingUMesh::AreCellsEqualPolicy2NoType(const int *conn, const int *connI, int cell1, int cell2)
+int MEDCouplingUMesh::AreCellsEqualPolicy2NoType(const mcIdType *conn, const mcIdType *connI, mcIdType cell1, mcIdType cell2)
 {
   if(connI[cell1+1]-connI[cell1]==connI[cell2+1]-connI[cell2])
     {
-      std::set<int> s1(conn+connI[cell1]+1,conn+connI[cell1+1]);
-      std::set<int> s2(conn+connI[cell2]+1,conn+connI[cell2+1]);
+      std::set<mcIdType> s1(conn+connI[cell1]+1,conn+connI[cell1+1]);
+      std::set<mcIdType> s2(conn+connI[cell2]+1,conn+connI[cell2+1]);
       return s1==s2?1:0;
     }
   return 0;
@@ -1725,9 +1795,9 @@ int MEDCouplingUMesh::AreCellsEqualPolicy2NoType(const int *conn, const int *con
 /*!
  * This method is the last step of the MEDCouplingPointSet::zipConnectivityTraducer with policy 7.
  */
-int MEDCouplingUMesh::AreCellsEqualPolicy7(const int *conn, const int *connI, int cell1, int cell2)
+int MEDCouplingUMesh::AreCellsEqualPolicy7(const mcIdType *conn, const mcIdType *connI, mcIdType cell1, mcIdType cell2)
 {
-  int sz=connI[cell1+1]-connI[cell1];
+  mcIdType sz=connI[cell1+1]-connI[cell1];
   if(sz==connI[cell2+1]-connI[cell2])
     {
       if(conn[connI[cell1]]==conn[connI[cell2]])
@@ -1738,24 +1808,22 @@ int MEDCouplingUMesh::AreCellsEqualPolicy7(const int *conn, const int *connI, in
             {
               if(dim!=1)
                 {
-                  int sz1=2*(sz-1);
-                  INTERP_KERNEL::AutoPtr<int> tmp=new int[sz1];
-                  int *work=std::copy(conn+connI[cell1]+1,conn+connI[cell1+1],(int *)tmp);
+                  mcIdType sz1=2*(sz-1);
+                  INTERP_KERNEL::AutoPtr<mcIdType> tmp=new mcIdType[sz1];
+                  mcIdType *work=std::copy(conn+connI[cell1]+1,conn+connI[cell1+1],(mcIdType *)tmp);
                   std::copy(conn+connI[cell1]+1,conn+connI[cell1+1],work);
-                  work=std::search((int *)tmp,(int *)tmp+sz1,conn+connI[cell2]+1,conn+connI[cell2+1]);
+                  work=std::search((mcIdType *)tmp,(mcIdType *)tmp+sz1,conn+connI[cell2]+1,conn+connI[cell2+1]);
                   if(work!=tmp+sz1)
                     return 1;
                   else
                     {
-                      std::reverse_iterator<int *> it1((int *)tmp+sz1);
-                      std::reverse_iterator<int *> it2((int *)tmp);
+                      std::reverse_iterator<mcIdType *> it1((mcIdType *)tmp+sz1);
+                      std::reverse_iterator<mcIdType *> it2((mcIdType *)tmp);
                       if(std::search(it1,it2,conn+connI[cell2]+1,conn+connI[cell2+1])!=it2)
                         return 2;
                       else
                         return 0;
                     }
-
-                  return work!=tmp+sz1?1:0;
                 }
               else
                 {//case of SEG2 and SEG3
@@ -1763,8 +1831,8 @@ int MEDCouplingUMesh::AreCellsEqualPolicy7(const int *conn, const int *connI, in
                     return 1;
                   if(!cm.isQuadratic())
                     {
-                      std::reverse_iterator<const int *> it1(conn+connI[cell1+1]);
-                      std::reverse_iterator<const int *> it2(conn+connI[cell1]+1);
+                      std::reverse_iterator<const mcIdType *> it1(conn+connI[cell1+1]);
+                      std::reverse_iterator<const mcIdType *> it2(conn+connI[cell1]+1);
                       if(std::equal(it1,it2,conn+connI[cell2]+1))
                         return 2;
                       return 0;
@@ -1784,44 +1852,13 @@ int MEDCouplingUMesh::AreCellsEqualPolicy7(const int *conn, const int *connI, in
   return 0;
 }
 
-/*!
- * This method find in candidate pool defined by 'candidates' the cells equal following the polycy 'compType'.
- * If any true is returned and the results will be put at the end of 'result' output parameter. If not false is returned
- * and result remains unchanged.
- * The semantic of 'compType' is specified in MEDCouplingPointSet::zipConnectivityTraducer method.
- * If in 'candidates' pool -1 value is considered as an empty value.
- * WARNING this method returns only ONE set of result !
- */
-bool MEDCouplingUMesh::AreCellsEqualInPool(const std::vector<int>& candidates, int compType, const int *conn, const int *connI, DataArrayInt *result)
-{
-  if(candidates.size()<1)
-    return false;
-  bool ret=false;
-  std::vector<int>::const_iterator iter=candidates.begin();
-  int start=(*iter++);
-  for(;iter!=candidates.end();iter++)
-    {
-      int status=AreCellsEqual(conn,connI,start,*iter,compType);
-      if(status!=0)
-        {
-          if(!ret)
-            {
-              result->pushBackSilent(start);
-              ret=true;
-            }
-          if(status==1)
-            result->pushBackSilent(*iter);
-          else
-            result->pushBackSilent(status==2?(*iter+1):-(*iter+1));
-        }
-    }
-  return ret;
-}
 
 /*!
- * This method find cells that are equal (regarding \a compType) in \a this. The comparison is specified
- * by \a compType.
- * This method keeps the coordiantes of \a this. This method is time consuming.
+ * This method find cells that are equal (regarding \a compType) in \a this. The comparison is specified by \a compType (see zipConnectivityTraducer).
+ * This method keeps the coordinates of \a this. The comparison starts at rank \a startCellId cell id (included).
+ * If \a startCellId is equal to 0 algorithm starts at cell #0 and for each cell candidates being searched have cell id higher than current cellId.
+ * If \a startCellId is greater than 0 algorithm starts at cell #startCellId but for each cell all candidates are considered.
+ * This method is time consuming.
  *
  * \param [in] compType input specifying the technique used to compare cells each other.
  *   - 0 : exactly. A cell is detected to be the same if and only if the connectivity is exactly the same without permutation and types same too. This is the strongest policy.
@@ -1832,36 +1869,35 @@ bool MEDCouplingUMesh::AreCellsEqualInPool(const std::vector<int>& candidates, i
  * \param [in] startCellId specifies the cellId starting from which the equality computation will be carried out. By default it is 0, which it means that all cells in \a this will be scanned.
  * \param [out] commonCellsArr common cells ids (\ref numbering-indirect)
  * \param [out] commonCellsIArr common cells ids (\ref numbering-indirect)
- * \return the correspondance array old to new in a newly allocated array.
- * 
+ *
  */
-void MEDCouplingUMesh::findCommonCells(int compType, int startCellId, DataArrayInt *& commonCellsArr, DataArrayInt *& commonCellsIArr) const
+void MEDCouplingUMesh::findCommonCells(int compType, mcIdType startCellId, DataArrayIdType *& commonCellsArr, DataArrayIdType *& commonCellsIArr) const
 {
-  MCAuto<DataArrayInt> revNodal=DataArrayInt::New(),revNodalI=DataArrayInt::New();
+  MCAuto<DataArrayIdType> revNodal=DataArrayIdType::New(),revNodalI=DataArrayIdType::New();
   getReverseNodalConnectivity(revNodal,revNodalI);
   FindCommonCellsAlg(compType,startCellId,_nodal_connec,_nodal_connec_index,revNodal,revNodalI,commonCellsArr,commonCellsIArr);
 }
 
-void MEDCouplingUMesh::FindCommonCellsAlg(int compType, int startCellId, const DataArrayInt *nodal, const DataArrayInt *nodalI, const DataArrayInt *revNodal, const DataArrayInt *revNodalI,
-                                          DataArrayInt *& commonCellsArr, DataArrayInt *& commonCellsIArr)
+void MEDCouplingUMesh::FindCommonCellsAlg(int compType, mcIdType startCellId, const DataArrayIdType *nodal, const DataArrayIdType *nodalI, const DataArrayIdType *revNodal, const DataArrayIdType *revNodalI,
+                                          DataArrayIdType *& commonCellsArr, DataArrayIdType *& commonCellsIArr)
 {
-  MCAuto<DataArrayInt> commonCells=DataArrayInt::New(),commonCellsI=DataArrayInt::New(); commonCells->alloc(0,1);
-  int nbOfCells=nodalI->getNumberOfTuples()-1;
+  MCAuto<DataArrayIdType> commonCells=DataArrayIdType::New(),commonCellsI=DataArrayIdType::New(); commonCells->alloc(0,1);
+  mcIdType nbOfCells=nodalI->getNumberOfTuples()-1;
   commonCellsI->reserve(1); commonCellsI->pushBackSilent(0);
-  const int *revNodalPtr=revNodal->getConstPointer(),*revNodalIPtr=revNodalI->getConstPointer();
-  const int *connPtr=nodal->getConstPointer(),*connIPtr=nodalI->getConstPointer();
+  const mcIdType *revNodalPtr=revNodal->getConstPointer(),*revNodalIPtr=revNodalI->getConstPointer();
+  const mcIdType *connPtr=nodal->getConstPointer(),*connIPtr=nodalI->getConstPointer();
   std::vector<bool> isFetched(nbOfCells,false);
   if(startCellId==0)
     {
-      for(int i=0;i<nbOfCells;i++)
+      for(mcIdType i=startCellId;i<nbOfCells;i++)
         {
           if(!isFetched[i])
             {
-              const int *connOfNode=std::find_if(connPtr+connIPtr[i]+1,connPtr+connIPtr[i+1],std::bind2nd(std::not_equal_to<int>(),-1));
-              std::vector<int> v,v2;
+              const mcIdType *connOfNode=std::find_if(connPtr+connIPtr[i]+1,connPtr+connIPtr[i+1],std::bind(std::not_equal_to<mcIdType>(),std::placeholders::_1,-1));
+              std::vector<mcIdType> v,v2;
               if(connOfNode!=connPtr+connIPtr[i+1])
                 {
-                  const int *locRevNodal=std::find(revNodalPtr+revNodalIPtr[*connOfNode],revNodalPtr+revNodalIPtr[*connOfNode+1],i);
+                  const mcIdType *locRevNodal=std::find(revNodalPtr+revNodalIPtr[*connOfNode],revNodalPtr+revNodalIPtr[*connOfNode+1],i);
                   v2.insert(v2.end(),locRevNodal,revNodalPtr+revNodalIPtr[*connOfNode+1]);
                   connOfNode++;
                 }
@@ -1869,17 +1905,17 @@ void MEDCouplingUMesh::FindCommonCellsAlg(int compType, int startCellId, const D
                 if(*connOfNode>=0)
                   {
                     v=v2;
-                    const int *locRevNodal=std::find(revNodalPtr+revNodalIPtr[*connOfNode],revNodalPtr+revNodalIPtr[*connOfNode+1],i);
-                    std::vector<int>::iterator it=std::set_intersection(v.begin(),v.end(),locRevNodal,revNodalPtr+revNodalIPtr[*connOfNode+1],v2.begin());
+                    const mcIdType *locRevNodal=std::find(revNodalPtr+revNodalIPtr[*connOfNode],revNodalPtr+revNodalIPtr[*connOfNode+1],i);
+                    std::vector<mcIdType>::iterator it=std::set_intersection(v.begin(),v.end(),locRevNodal,revNodalPtr+revNodalIPtr[*connOfNode+1],v2.begin());
                     v2.resize(std::distance(v2.begin(),it));
                   }
               if(v2.size()>1)
                 {
                   if(AreCellsEqualInPool(v2,compType,connPtr,connIPtr,commonCells))
                     {
-                      int pos=commonCellsI->back();
+                      mcIdType pos=commonCellsI->back();
                       commonCellsI->pushBackSilent(commonCells->getNumberOfTuples());
-                      for(const int *it=commonCells->begin()+pos;it!=commonCells->end();it++)
+                      for(const mcIdType *it=commonCells->begin()+pos;it!=commonCells->end();it++)
                         isFetched[*it]=true;
                     }
                 }
@@ -1888,12 +1924,13 @@ void MEDCouplingUMesh::FindCommonCellsAlg(int compType, int startCellId, const D
     }
   else
     {
-      for(int i=startCellId;i<nbOfCells;i++)
+      for(mcIdType i=startCellId;i<nbOfCells;i++)
         {
           if(!isFetched[i])
             {
-              const int *connOfNode=std::find_if(connPtr+connIPtr[i]+1,connPtr+connIPtr[i+1],std::bind2nd(std::not_equal_to<int>(),-1));
-              std::vector<int> v,v2;
+              const mcIdType *connOfNode=std::find_if(connPtr+connIPtr[i]+1,connPtr+connIPtr[i+1],std::bind(std::not_equal_to<mcIdType>(),std::placeholders::_1,-1));
+              // v2 contains the result of successive intersections using rev nodal on on each node of cell #i
+              std::vector<mcIdType> v,v2;
               if(connOfNode!=connPtr+connIPtr[i+1])
                 {
                   v2.insert(v2.end(),revNodalPtr+revNodalIPtr[*connOfNode],revNodalPtr+revNodalIPtr[*connOfNode+1]);
@@ -1903,16 +1940,24 @@ void MEDCouplingUMesh::FindCommonCellsAlg(int compType, int startCellId, const D
                 if(*connOfNode>=0)
                   {
                     v=v2;
-                    std::vector<int>::iterator it=std::set_intersection(v.begin(),v.end(),revNodalPtr+revNodalIPtr[*connOfNode],revNodalPtr+revNodalIPtr[*connOfNode+1],v2.begin());
+                    std::vector<mcIdType>::iterator it=std::set_intersection(v.begin(),v.end(),revNodalPtr+revNodalIPtr[*connOfNode],revNodalPtr+revNodalIPtr[*connOfNode+1],v2.begin());
                     v2.resize(std::distance(v2.begin(),it));
                   }
+              // v2 contains now candidates. Problem candidates are sorted using id rank.
               if(v2.size()>1)
                 {
+                  if(v2[0]!=i)
+                  {
+                    auto it(std::find(v2.begin(),v2.end(),i));
+                    std::swap(*v2.begin(),*it);
+                  }
                   if(AreCellsEqualInPool(v2,compType,connPtr,connIPtr,commonCells))
                     {
-                      int pos=commonCellsI->back();
-                      commonCellsI->pushBackSilent(commonCells->getNumberOfTuples());
-                      for(const int *it=commonCells->begin()+pos;it!=commonCells->end();it++)
+                      mcIdType newPos(commonCells->getNumberOfTuples());
+                      mcIdType pos(commonCellsI->back());
+                      std::sort(commonCells->getPointerSilent()+pos,commonCells->getPointerSilent()+newPos);
+                      commonCellsI->pushBackSilent(newPos);
+                      for(const mcIdType *it=commonCells->begin()+pos;it!=commonCells->end();it++)
                         isFetched[*it]=true;
                     }
                 }
@@ -1929,11 +1974,11 @@ void MEDCouplingUMesh::FindCommonCellsAlg(int compType, int startCellId, const D
  * than \a this->getNumberOfCells() in the returned array means that there is no
  * corresponding cell in \a this mesh.
  * It is expected that \a this and \a other meshes share the same node coordinates
- * array, if it is not so an exception is thrown. 
+ * array, if it is not so an exception is thrown.
  *  \param [in] other - the mesh to compare with.
  *  \param [in] compType - specifies a cell comparison technique. For meaning of its
  *         valid values [0,1,2], see zipConnectivityTraducer().
- *  \param [out] arr - a new instance of DataArrayInt returning correspondence
+ *  \param [out] arr - a new instance of DataArrayIdType returning correspondence
  *         between cells of the two meshes. It contains \a other->getNumberOfCells()
  *         values. The caller is to delete this array using
  *         decrRef() as it is no more needed.
@@ -1947,10 +1992,10 @@ void MEDCouplingUMesh::FindCommonCellsAlg(int compType, int startCellId, const D
  *  \sa checkDeepEquivalOnSameNodesWith()
  *  \sa checkGeoEquivalWith()
  */
-bool MEDCouplingUMesh::areCellsIncludedIn(const MEDCouplingUMesh *other, int compType, DataArrayInt *& arr) const
+bool MEDCouplingUMesh::areCellsIncludedIn(const MEDCouplingUMesh *other, int compType, DataArrayIdType *& arr) const
 {
   MCAuto<MEDCouplingUMesh> mesh=MergeUMeshesOnSameCoords(this,other);
-  int nbOfCells=getNumberOfCells();
+  mcIdType nbOfCells=getNumberOfCells();
   static const int possibleCompType[]={0,1,2};
   if(std::find(possibleCompType,possibleCompType+sizeof(possibleCompType)/sizeof(int),compType)==possibleCompType+sizeof(possibleCompType)/sizeof(int))
     {
@@ -1959,13 +2004,30 @@ bool MEDCouplingUMesh::areCellsIncludedIn(const MEDCouplingUMesh *other, int com
       oss << " !";
       throw INTERP_KERNEL::Exception(oss.str());
     }
-  MCAuto<DataArrayInt> o2n=mesh->zipConnectivityTraducer(compType,nbOfCells);
-  arr=o2n->subArray(nbOfCells);
-  arr->setName(other->getName());
-  int tmp;
+  //
   if(other->getNumberOfCells()==0)
+  {
+    MCAuto<DataArrayIdType> dftRet(DataArrayIdType::New()); dftRet->alloc(0,1); arr=dftRet.retn(); arr->setName(other->getName());
     return true;
-  return arr->getMaxValue(tmp)<nbOfCells;
+  }
+  DataArrayIdType *commonCells(nullptr),*commonCellsI(nullptr);
+  mesh->findCommonCells(compType,nbOfCells,commonCells,commonCellsI);
+  MCAuto<DataArrayIdType> commonCellsTmp(commonCells),commonCellsITmp(commonCellsI);
+  mcIdType newNbOfCells=-1;
+  MCAuto<DataArrayIdType> o2n = DataArrayIdType::ConvertIndexArrayToO2N(ToIdType(mesh->getNumberOfCells()),commonCells->begin(),commonCellsI->begin(),commonCellsI->end(),newNbOfCells);
+  MCAuto<DataArrayIdType> p0(o2n->selectByTupleIdSafeSlice(0,nbOfCells,1));
+  mcIdType maxPart(p0->getMaxValueInArray());
+  bool ret(maxPart==newNbOfCells-1);
+  MCAuto<DataArrayIdType> p1(p0->invertArrayO2N2N2O(newNbOfCells));
+  // fill p1 array in case of presence of cells in other not in this
+  mcIdType *pt(p1->getPointer());
+  for(mcIdType i = maxPart ; i < newNbOfCells-1 ; ++i )
+    pt[i+1] = i+1;
+  //
+  MCAuto<DataArrayIdType> p2(o2n->subArray(nbOfCells));
+  p2->transformWithIndArr(p1->begin(),p1->end()); p2->setName(other->getName());
+  arr = p2.retn();
+  return ret;
 }
 
 /*!
@@ -1978,29 +2040,29 @@ bool MEDCouplingUMesh::areCellsIncludedIn(const MEDCouplingUMesh *other, int com
  * \param arr is an output parameter that returns a \b newly created instance. This array is of size 'other->getNumberOfCells()'.
  * \return If \a other is fully included in 'this 'true is returned. If not false is returned.
  */
-bool MEDCouplingUMesh::areCellsIncludedInPolicy7(const MEDCouplingUMesh *other, DataArrayInt *& arr) const
+bool MEDCouplingUMesh::areCellsIncludedInPolicy7(const MEDCouplingUMesh *other, DataArrayIdType *& arr) const
 {
   MCAuto<MEDCouplingUMesh> mesh=MergeUMeshesOnSameCoords(this,other);
-  DataArrayInt *commonCells=0,*commonCellsI=0;
-  int thisNbCells=getNumberOfCells();
+  DataArrayIdType *commonCells=0,*commonCellsI=0;
+  mcIdType thisNbCells=getNumberOfCells();
   mesh->findCommonCells(7,thisNbCells,commonCells,commonCellsI);
-  MCAuto<DataArrayInt> commonCellsTmp(commonCells),commonCellsITmp(commonCellsI);
-  const int *commonCellsPtr=commonCells->getConstPointer(),*commonCellsIPtr=commonCellsI->getConstPointer();
-  int otherNbCells=other->getNumberOfCells();
-  MCAuto<DataArrayInt> arr2=DataArrayInt::New();
+  MCAuto<DataArrayIdType> commonCellsTmp(commonCells),commonCellsITmp(commonCellsI);
+  const mcIdType *commonCellsPtr=commonCells->getConstPointer(),*commonCellsIPtr=commonCellsI->getConstPointer();
+  mcIdType otherNbCells=other->getNumberOfCells();
+  MCAuto<DataArrayIdType> arr2=DataArrayIdType::New();
   arr2->alloc(otherNbCells,1);
   arr2->fillWithZero();
-  int *arr2Ptr=arr2->getPointer();
-  int nbOfCommon=commonCellsI->getNumberOfTuples()-1;
-  for(int i=0;i<nbOfCommon;i++)
+  mcIdType *arr2Ptr=arr2->getPointer();
+  mcIdType nbOfCommon=commonCellsI->getNumberOfTuples()-1;
+  for(mcIdType i=0;i<nbOfCommon;i++)
     {
-      int start=commonCellsPtr[commonCellsIPtr[i]];
+      mcIdType start=commonCellsPtr[commonCellsIPtr[i]];
       if(start<thisNbCells)
         {
-          for(int j=commonCellsIPtr[i]+1;j!=commonCellsIPtr[i+1];j++)
+          for(mcIdType j=commonCellsIPtr[i]+1;j!=commonCellsIPtr[i+1];j++)
             {
-              int sig=commonCellsPtr[j]>0?1:-1;
-              int val=std::abs(commonCellsPtr[j])-1;
+              mcIdType sig=commonCellsPtr[j]>0?1:-1;
+              mcIdType val=std::abs(commonCellsPtr[j])-1;
               if(val>=thisNbCells)
                 arr2Ptr[val-thisNbCells]=sig*(start+1);
             }
@@ -2029,24 +2091,24 @@ MEDCouplingUMesh *MEDCouplingUMesh::mergeMyselfWithOnSameCoords(const MEDCouplin
 /*!
  * Build a sub part of \b this lying or not on the same coordinates than \b this (regarding value of \b keepCoords).
  * By default coordinates are kept. This method is close to MEDCouplingUMesh::buildPartOfMySelf except that here input
- * cellIds is not given explicitely but by a range python like.
- * 
- * \param start
- * \param end
- * \param step
+ * cellIds is not given explicitly but by a range python like.
+ *
+ * \param start starting ID
+ * \param end end ID (excluded)
+ * \param step step size
  * \param keepCoords that specifies if you want or not to keep coords as this or zip it (see MEDCoupling::MEDCouplingUMesh::zipCoords). If true zipCoords is \b NOT called, if false, zipCoords is called.
  * \return a newly allocated
- * 
+ *
  * \warning This method modifies can generate an unstructured mesh whose cells are not sorted by geometric type order.
  * In view of the MED file writing, a renumbering of cells of returned unstructured mesh (using MEDCouplingUMesh::sortCellsInMEDFileFrmt) should be necessary.
  */
-MEDCouplingUMesh *MEDCouplingUMesh::buildPartOfMySelfSlice(int start, int end, int step, bool keepCoords) const
+MEDCouplingUMesh *MEDCouplingUMesh::buildPartOfMySelfSlice(mcIdType start, mcIdType end, mcIdType step, bool keepCoords) const
 {
   if(getMeshDimension()!=-1)
     return static_cast<MEDCouplingUMesh *>(MEDCouplingPointSet::buildPartOfMySelfSlice(start,end,step,keepCoords));
   else
     {
-      int newNbOfCells=DataArray::GetNumberOfItemGivenBESRelative(start,end,step,"MEDCouplingUMesh::buildPartOfMySelfSlice for -1 dimension mesh ");
+      mcIdType newNbOfCells=DataArray::GetNumberOfItemGivenBESRelative(start,end,step,"MEDCouplingUMesh::buildPartOfMySelfSlice for -1 dimension mesh ");
       if(newNbOfCells!=1)
         throw INTERP_KERNEL::Exception("-1D mesh has only one cell !");
       if(start!=0)
@@ -2069,7 +2131,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildPartOfMySelfSlice(int start, int end, i
  *         array of \a this mesh, else "free" nodes are removed from the result mesh
  *         by calling zipCoords().
  *  \return MEDCouplingUMesh * - a new instance of MEDCouplingUMesh. The caller is
- *         to delete this mesh using decrRef() as it is no more needed. 
+ *         to delete this mesh 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 any cell id in the array \a begin is not valid.
@@ -2079,7 +2141,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildPartOfMySelfSlice(int start, int end, i
  *  \ref  py_mcumesh_buildPartOfMySelf "Here is a Python example".
  *  \endif
  */
-MEDCouplingUMesh *MEDCouplingUMesh::buildPartOfMySelf(const int *begin, const int *end, bool keepCoords) const
+MEDCouplingUMesh *MEDCouplingUMesh::buildPartOfMySelf(const mcIdType *begin, const mcIdType *end, bool keepCoords) const
 {
   if(getMeshDimension()!=-1)
     return static_cast<MEDCouplingUMesh *>(MEDCouplingPointSet::buildPartOfMySelf(begin,end,keepCoords));
@@ -2106,7 +2168,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildPartOfMySelf(const int *begin, const in
  * \param [in] otherOnSameCoordsThanThis an another mesh with same meshdimension than \b this with exactly the same number of cells than cell ids list in [\b cellIdsBg, \b cellIdsEnd ).
  *             Coordinate pointer of \b this and those of \b otherOnSameCoordsThanThis must be the same
  */
-void MEDCouplingUMesh::setPartOfMySelf(const int *cellIdsBg, const int *cellIdsEnd, const MEDCouplingUMesh& otherOnSameCoordsThanThis)
+void MEDCouplingUMesh::setPartOfMySelf(const mcIdType *cellIdsBg, const mcIdType *cellIdsEnd, const MEDCouplingUMesh& otherOnSameCoordsThanThis)
 {
   checkConnectivityFullyDefined();
   otherOnSameCoordsThanThis.checkConnectivityFullyDefined();
@@ -2118,17 +2180,17 @@ void MEDCouplingUMesh::setPartOfMySelf(const int *cellIdsBg, const int *cellIdsE
       oss << ", whereas other mesh dimension is set equal to " << otherOnSameCoordsThanThis.getMeshDimension() << " !";
       throw INTERP_KERNEL::Exception(oss.str());
     }
-  int nbOfCellsToModify=(int)std::distance(cellIdsBg,cellIdsEnd);
+  mcIdType nbOfCellsToModify( ToIdType((std::distance(cellIdsBg,cellIdsEnd))));
   if(nbOfCellsToModify!=otherOnSameCoordsThanThis.getNumberOfCells())
     {
       std::ostringstream oss; oss << "MEDCouplingUMesh::setPartOfMySelf : cells ids length (" <<  nbOfCellsToModify << ") do not match the number of cells of other mesh (" << otherOnSameCoordsThanThis.getNumberOfCells() << ") !";
       throw INTERP_KERNEL::Exception(oss.str());
     }
-  int nbOfCells=getNumberOfCells();
-  bool easyAssign=true;
-  const int *connI=_nodal_connec_index->getConstPointer();
-  const int *connIOther=otherOnSameCoordsThanThis._nodal_connec_index->getConstPointer();
-  for(const int *it=cellIdsBg;it!=cellIdsEnd && easyAssign;it++,connIOther++)
+  mcIdType nbOfCells(getNumberOfCells());
+  bool easyAssign(true);
+  const mcIdType *connI(_nodal_connec_index->begin());
+  const mcIdType *connIOther=otherOnSameCoordsThanThis._nodal_connec_index->begin();
+  for(const mcIdType *it=cellIdsBg;it!=cellIdsEnd && easyAssign;it++,connIOther++)
     {
       if(*it>=0 && *it<nbOfCells)
         {
@@ -2142,20 +2204,20 @@ void MEDCouplingUMesh::setPartOfMySelf(const int *cellIdsBg, const int *cellIdsE
     }
   if(easyAssign)
     {
-      MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx(cellIdsBg,cellIdsEnd,_nodal_connec,_nodal_connec_index,otherOnSameCoordsThanThis._nodal_connec,otherOnSameCoordsThanThis._nodal_connec_index);
+      DataArrayIdType::SetPartOfIndexedArraysSameIdx(cellIdsBg,cellIdsEnd,_nodal_connec,_nodal_connec_index,otherOnSameCoordsThanThis._nodal_connec,otherOnSameCoordsThanThis._nodal_connec_index);
       computeTypes();
     }
   else
     {
-      DataArrayInt *arrOut=0,*arrIOut=0;
-      MEDCouplingUMesh::SetPartOfIndexedArrays(cellIdsBg,cellIdsEnd,_nodal_connec,_nodal_connec_index,otherOnSameCoordsThanThis._nodal_connec,otherOnSameCoordsThanThis._nodal_connec_index,
+      DataArrayIdType *arrOut=0,*arrIOut=0;
+      DataArrayIdType::SetPartOfIndexedArrays(cellIdsBg,cellIdsEnd,_nodal_connec,_nodal_connec_index,otherOnSameCoordsThanThis._nodal_connec,otherOnSameCoordsThanThis._nodal_connec_index,
                                                arrOut,arrIOut);
-      MCAuto<DataArrayInt> arrOutAuto(arrOut),arrIOutAuto(arrIOut);
+      MCAuto<DataArrayIdType> arrOutAuto(arrOut),arrIOutAuto(arrIOut);
       setConnectivity(arrOut,arrIOut,true);
     }
 }
 
-void MEDCouplingUMesh::setPartOfMySelfSlice(int start, int end, int step, const MEDCouplingUMesh& otherOnSameCoordsThanThis)
+void MEDCouplingUMesh::setPartOfMySelfSlice(mcIdType start, mcIdType end, mcIdType step, const MEDCouplingUMesh& otherOnSameCoordsThanThis)
 {
   checkConnectivityFullyDefined();
   otherOnSameCoordsThanThis.checkConnectivityFullyDefined();
@@ -2167,18 +2229,18 @@ void MEDCouplingUMesh::setPartOfMySelfSlice(int start, int end, int step, const
       oss << ", whereas other mesh dimension is set equal to " << otherOnSameCoordsThanThis.getMeshDimension() << " !";
       throw INTERP_KERNEL::Exception(oss.str());
     }
-  int nbOfCellsToModify=DataArray::GetNumberOfItemGivenBESRelative(start,end,step,"MEDCouplingUMesh::setPartOfMySelfSlice : ");
+  mcIdType nbOfCellsToModify=DataArray::GetNumberOfItemGivenBESRelative(start,end,step,"MEDCouplingUMesh::setPartOfMySelfSlice : ");
   if(nbOfCellsToModify!=otherOnSameCoordsThanThis.getNumberOfCells())
     {
       std::ostringstream oss; oss << "MEDCouplingUMesh::setPartOfMySelfSlice : cells ids length (" <<  nbOfCellsToModify << ") do not match the number of cells of other mesh (" << otherOnSameCoordsThanThis.getNumberOfCells() << ") !";
       throw INTERP_KERNEL::Exception(oss.str());
     }
-  int nbOfCells=getNumberOfCells();
+  mcIdType nbOfCells=getNumberOfCells();
   bool easyAssign=true;
-  const int *connI=_nodal_connec_index->getConstPointer();
-  const int *connIOther=otherOnSameCoordsThanThis._nodal_connec_index->getConstPointer();
-  int it=start;
-  for(int i=0;i<nbOfCellsToModify && easyAssign;i++,it+=step,connIOther++)
+  const mcIdType *connI=_nodal_connec_index->getConstPointer();
+  const mcIdType *connIOther=otherOnSameCoordsThanThis._nodal_connec_index->getConstPointer();
+  mcIdType it=start;
+  for(mcIdType i=0;i<nbOfCellsToModify && easyAssign;i++,it+=step,connIOther++)
     {
       if(it>=0 && it<nbOfCells)
         {
@@ -2192,59 +2254,20 @@ void MEDCouplingUMesh::setPartOfMySelfSlice(int start, int end, int step, const
     }
   if(easyAssign)
     {
-      MEDCouplingUMesh::SetPartOfIndexedArraysSameIdxSlice(start,end,step,_nodal_connec,_nodal_connec_index,otherOnSameCoordsThanThis._nodal_connec,otherOnSameCoordsThanThis._nodal_connec_index);
+      DataArrayIdType::SetPartOfIndexedArraysSameIdxSlice(start,end,step,_nodal_connec,_nodal_connec_index,otherOnSameCoordsThanThis._nodal_connec,otherOnSameCoordsThanThis._nodal_connec_index);
       computeTypes();
     }
   else
     {
-      DataArrayInt *arrOut=0,*arrIOut=0;
-      MEDCouplingUMesh::SetPartOfIndexedArraysSlice(start,end,step,_nodal_connec,_nodal_connec_index,otherOnSameCoordsThanThis._nodal_connec,otherOnSameCoordsThanThis._nodal_connec_index,
+      DataArrayIdType *arrOut=0,*arrIOut=0;
+      DataArrayIdType::SetPartOfIndexedArraysSlice(start,end,step,_nodal_connec,_nodal_connec_index,otherOnSameCoordsThanThis._nodal_connec,otherOnSameCoordsThanThis._nodal_connec_index,
                                                 arrOut,arrIOut);
-      MCAuto<DataArrayInt> arrOutAuto(arrOut),arrIOutAuto(arrIOut);
+      MCAuto<DataArrayIdType> arrOutAuto(arrOut),arrIOutAuto(arrIOut);
       setConnectivity(arrOut,arrIOut,true);
     }
-}                      
-
-/*!
- * Keeps from \a this only cells which constituing point id are in the ids specified by [ \a begin,\a end ).
- * The resulting cell ids are stored at the end of the 'cellIdsKept' parameter.
- * Parameter \a fullyIn specifies if a cell that has part of its nodes in ids array is kept or not.
- * If \a fullyIn is true only cells whose ids are \b fully contained in [ \a begin,\a end ) tab will be kept.
- *
- * \param [in] begin input start of array of node ids.
- * \param [in] end input end of array of node ids.
- * \param [in] fullyIn input that specifies if all node ids must be in [ \a begin,\a end ) array to consider cell to be in.
- * \param [in,out] cellIdsKeptArr array where all candidate cell ids are put at the end.
- */
-void MEDCouplingUMesh::fillCellIdsToKeepFromNodeIds(const int *begin, const int *end, bool fullyIn, DataArrayInt *&cellIdsKeptArr) const
-{
-  MCAuto<DataArrayInt> cellIdsKept=DataArrayInt::New(); cellIdsKept->alloc(0,1);
-  checkConnectivityFullyDefined();
-  int tmp=-1;
-  int sz=getNodalConnectivity()->getMaxValue(tmp); sz=std::max(sz,0)+1;
-  std::vector<bool> fastFinder(sz,false);
-  for(const int *work=begin;work!=end;work++)
-    if(*work>=0 && *work<sz)
-      fastFinder[*work]=true;
-  int nbOfCells=getNumberOfCells();
-  const int *conn=getNodalConnectivity()->getConstPointer();
-  const int *connIndex=getNodalConnectivityIndex()->getConstPointer();
-  for(int i=0;i<nbOfCells;i++)
-    {
-      int ref=0,nbOfHit=0;
-      for(const int *work2=conn+connIndex[i]+1;work2!=conn+connIndex[i+1];work2++)
-        if(*work2>=0)
-          {
-            ref++;
-            if(fastFinder[*work2])
-              nbOfHit++;
-          }
-      if((ref==nbOfHit && fullyIn) || (nbOfHit!=0 && !fullyIn))
-        cellIdsKept->pushBackSilent(i);
-    }
-  cellIdsKeptArr=cellIdsKept.retn();
 }
 
+
 /*!
  * Creates a new MEDCouplingUMesh containing cells, of dimension one less than \a
  * this->getMeshDimension(), that bound some cells of \a this mesh.
@@ -2252,14 +2275,14 @@ void MEDCouplingUMesh::fillCellIdsToKeepFromNodeIds(const int *begin, const int
  * specified node ids and the value of \a fullyIn parameter. If \a fullyIn ==\c true, a
  * cell is copied if its all nodes are in the array \a begin of node ids. If \a fullyIn
  * ==\c false, a cell is copied if any its node is in the array of node ids. The
- * created mesh shares the node coordinates array with \a this mesh. 
+ * created mesh shares the node coordinates array with \a this mesh.
  *  \param [in] begin - the array of node ids.
  *  \param [in] end - a pointer to the (last+1)-th element of \a begin.
  *  \param [in] fullyIn - if \c true, then cells whose all nodes are in the
  *         array \a begin are added, else cells whose any node is in the
  *         array \a begin are added.
  *  \return MEDCouplingUMesh * - new instance of MEDCouplingUMesh. The caller is
- *         to delete this mesh using decrRef() as it is no more needed. 
+ *         to delete this mesh 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 any node id in \a begin is not valid.
@@ -2269,10 +2292,10 @@ void MEDCouplingUMesh::fillCellIdsToKeepFromNodeIds(const int *begin, const int
  *  \ref  py_mcumesh_buildFacePartOfMySelfNode "Here is a Python example".
  *  \endif
  */
-MEDCouplingUMesh *MEDCouplingUMesh::buildFacePartOfMySelfNode(const int *begin, const int *end, bool fullyIn) const
+MEDCouplingUMesh *MEDCouplingUMesh::buildFacePartOfMySelfNode(const mcIdType *begin, const mcIdType *end, bool fullyIn) const
 {
-  MCAuto<DataArrayInt> desc,descIndx,revDesc,revDescIndx;
-  desc=DataArrayInt::New(); descIndx=DataArrayInt::New(); revDesc=DataArrayInt::New(); revDescIndx=DataArrayInt::New();
+  MCAuto<DataArrayIdType> desc,descIndx,revDesc,revDescIndx;
+  desc=DataArrayIdType::New(); descIndx=DataArrayIdType::New(); revDesc=DataArrayIdType::New(); revDescIndx=DataArrayIdType::New();
   MCAuto<MEDCouplingUMesh> subMesh=buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx);
   desc=0; descIndx=0; revDesc=0; revDescIndx=0;
   return static_cast<MEDCouplingUMesh*>(subMesh->buildPartOfMySelfNode(begin,end,fullyIn));
@@ -2285,7 +2308,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildFacePartOfMySelfNode(const int *begin,
  *         array of \a this mesh, else "free" nodes are removed from the result mesh
  *         by calling zipCoords().
  *  \return MEDCouplingUMesh * - a new instance of MEDCouplingUMesh. The caller is
- *         to delete this mesh using decrRef() as it is no more needed. 
+ *         to delete this mesh 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.
  *
@@ -2296,19 +2319,19 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildFacePartOfMySelfNode(const int *begin,
  */
 MEDCouplingUMesh *MEDCouplingUMesh::buildBoundaryMesh(bool keepCoords) const
 {
-  DataArrayInt *desc=DataArrayInt::New();
-  DataArrayInt *descIndx=DataArrayInt::New();
-  DataArrayInt *revDesc=DataArrayInt::New();
-  DataArrayInt *revDescIndx=DataArrayInt::New();
+  DataArrayIdType *desc=DataArrayIdType::New();
+  DataArrayIdType *descIndx=DataArrayIdType::New();
+  DataArrayIdType *revDesc=DataArrayIdType::New();
+  DataArrayIdType *revDescIndx=DataArrayIdType::New();
   //
   MCAuto<MEDCouplingUMesh> meshDM1=buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx);
   revDesc->decrRef();
   desc->decrRef();
   descIndx->decrRef();
-  int nbOfCells=meshDM1->getNumberOfCells();
-  const int *revDescIndxC=revDescIndx->getConstPointer();
-  std::vector<int> boundaryCells;
-  for(int i=0;i<nbOfCells;i++)
+  mcIdType nbOfCells=meshDM1->getNumberOfCells();
+  const mcIdType *revDescIndxC=revDescIndx->getConstPointer();
+  std::vector<mcIdType> boundaryCells;
+  for(mcIdType i=0;i<nbOfCells;i++)
     if(revDescIndxC[i+1]-revDescIndxC[i]==1)
       boundaryCells.push_back(i);
   revDescIndx->decrRef();
@@ -2317,41 +2340,45 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildBoundaryMesh(bool keepCoords) const
 }
 
 /*!
- * This method returns a newly created DataArrayInt instance containing ids of cells located in boundary.
+ * This method returns a newly created DataArrayIdType instance containing ids of cells located in boundary.
  * A cell is detected to be on boundary if it contains one or more than one face having only one father.
- * This method makes the assumption that \a this is fully defined (coords,connectivity). If not an exception will be thrown. 
+ * This method makes the assumption that \a this is fully defined (coords,connectivity). If not an exception will be thrown.
  */
-DataArrayInt *MEDCouplingUMesh::findCellIdsOnBoundary() const
+DataArrayIdType *MEDCouplingUMesh::findCellIdsOnBoundary() const
 {
   checkFullyDefined();
-  MCAuto<DataArrayInt> desc=DataArrayInt::New();
-  MCAuto<DataArrayInt> descIndx=DataArrayInt::New();
-  MCAuto<DataArrayInt> revDesc=DataArrayInt::New();
-  MCAuto<DataArrayInt> revDescIndx=DataArrayInt::New();
+  MCAuto<DataArrayIdType> ret2(DataArrayIdType::New());
+
+  if (getNumberOfCells() == 0)
+    {
+      ret2->alloc(0,1);
+      return ret2.retn();
+    }
+
+  MCAuto<DataArrayIdType> desc(DataArrayIdType::New()), descIndx(DataArrayIdType::New()), revDesc(DataArrayIdType::New()), revDescIndx(DataArrayIdType::New());
   //
   buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx)->decrRef();
-  desc=(DataArrayInt*)0; descIndx=(DataArrayInt*)0;
+  desc=(DataArrayIdType*)0; descIndx=(DataArrayIdType*)0;
   //
-  MCAuto<DataArrayInt> tmp=revDescIndx->deltaShiftIndex();
-  MCAuto<DataArrayInt> faceIds=tmp->findIdsEqual(1); tmp=(DataArrayInt*)0;
-  const int *revDescPtr=revDesc->getConstPointer();
-  const int *revDescIndxPtr=revDescIndx->getConstPointer();
-  int nbOfCells=getNumberOfCells();
+  MCAuto<DataArrayIdType> tmp=revDescIndx->deltaShiftIndex();
+  MCAuto<DataArrayIdType> faceIds=tmp->findIdsEqual(1); tmp=(DataArrayIdType*)0;
+  const mcIdType *revDescPtr=revDesc->getConstPointer();
+  const mcIdType *revDescIndxPtr=revDescIndx->getConstPointer();
+  mcIdType nbOfCells=getNumberOfCells();
   std::vector<bool> ret1(nbOfCells,false);
-  int sz=0;
-  for(const int *pt=faceIds->begin();pt!=faceIds->end();pt++)
+  mcIdType sz=0;
+  for(const mcIdType *pt=faceIds->begin();pt!=faceIds->end();pt++)
     if(!ret1[revDescPtr[revDescIndxPtr[*pt]]])
       { ret1[revDescPtr[revDescIndxPtr[*pt]]]=true; sz++; }
   //
-  DataArrayInt *ret2=DataArrayInt::New();
   ret2->alloc(sz,1);
-  int *ret2Ptr=ret2->getPointer();
+  mcIdType *ret2Ptr=ret2->getPointer();
   sz=0;
   for(std::vector<bool>::const_iterator it=ret1.begin();it!=ret1.end();it++,sz++)
     if(*it)
       *ret2Ptr++=sz;
   ret2->setName("BoundaryCells");
-  return ret2;
+  return ret2.retn();
 }
 
 /*!
@@ -2367,12 +2394,12 @@ DataArrayInt *MEDCouplingUMesh::findCellIdsOnBoundary() const
  * \throw if \b otherDimM1OnSameCoords is not part of constituent of \b this, or if coordinate pointer of \b this and \b otherDimM1OnSameCoords
  *        are not same, or if this->getMeshDimension()-1!=otherDimM1OnSameCoords.getMeshDimension()
  *
- * \param [in] otherDimM1OnSameCoords
+ * \param [in] otherDimM1OnSameCoords other mesh
  * \param [out] cellIdsRk0 a newly allocated array containing the cell ids of s0 (which are cell ids of \b this) in the above algorithm.
  * \param [out] cellIdsRk1 a newly allocated array containing the cell ids of s1 \b indexed into the \b cellIdsRk0 subset. To get the absolute ids of s1, simply invoke
  *              cellIdsRk1->transformWithIndArr(cellIdsRk0->begin(),cellIdsRk0->end());
  */
-void MEDCouplingUMesh::findCellIdsLyingOn(const MEDCouplingUMesh& otherDimM1OnSameCoords, DataArrayInt *&cellIdsRk0, DataArrayInt *&cellIdsRk1) const
+void MEDCouplingUMesh::findCellIdsLyingOn(const MEDCouplingUMesh& otherDimM1OnSameCoords, DataArrayIdType *&cellIdsRk0, DataArrayIdType *&cellIdsRk1) const
 {
   if(getCoords()!=otherDimM1OnSameCoords.getCoords())
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::findCellIdsLyingOn : coordinates pointer are not the same ! Use tryToShareSameCoords method !");
@@ -2380,21 +2407,21 @@ void MEDCouplingUMesh::findCellIdsLyingOn(const MEDCouplingUMesh& otherDimM1OnSa
   otherDimM1OnSameCoords.checkConnectivityFullyDefined();
   if(getMeshDimension()-1!=otherDimM1OnSameCoords.getMeshDimension())
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::findCellIdsLyingOn : invalid mesh dimension of input mesh regarding meshdimesion of this !");
-  MCAuto<DataArrayInt> fetchedNodeIds1=otherDimM1OnSameCoords.computeFetchedNodeIds();
-  MCAuto<DataArrayInt> s0arr=getCellIdsLyingOnNodes(fetchedNodeIds1->begin(),fetchedNodeIds1->end(),false);
+  MCAuto<DataArrayIdType> fetchedNodeIds1=otherDimM1OnSameCoords.computeFetchedNodeIds();
+  MCAuto<DataArrayIdType> s0arr=getCellIdsLyingOnNodes(fetchedNodeIds1->begin(),fetchedNodeIds1->end(),false);
   MCAuto<MEDCouplingUMesh> thisPart=static_cast<MEDCouplingUMesh *>(buildPartOfMySelf(s0arr->begin(),s0arr->end(),true));
-  MCAuto<DataArrayInt> descThisPart=DataArrayInt::New(),descIThisPart=DataArrayInt::New(),revDescThisPart=DataArrayInt::New(),revDescIThisPart=DataArrayInt::New();
+  MCAuto<DataArrayIdType> descThisPart=DataArrayIdType::New(),descIThisPart=DataArrayIdType::New(),revDescThisPart=DataArrayIdType::New(),revDescIThisPart=DataArrayIdType::New();
   MCAuto<MEDCouplingUMesh> thisPartConsti=thisPart->buildDescendingConnectivity(descThisPart,descIThisPart,revDescThisPart,revDescIThisPart);
-  const int *revDescThisPartPtr=revDescThisPart->getConstPointer(),*revDescIThisPartPtr=revDescIThisPart->getConstPointer();
-  DataArrayInt *idsOtherInConsti=0;
+  const mcIdType *revDescThisPartPtr=revDescThisPart->getConstPointer(),*revDescIThisPartPtr=revDescIThisPart->getConstPointer();
+  DataArrayIdType *idsOtherInConsti=0;
   bool b=thisPartConsti->areCellsIncludedIn(&otherDimM1OnSameCoords,2,idsOtherInConsti);
-  MCAuto<DataArrayInt> idsOtherInConstiAuto(idsOtherInConsti);
+  MCAuto<DataArrayIdType> idsOtherInConstiAuto(idsOtherInConsti);
   if(!b)
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::findCellIdsLyingOn : the given mdim-1 mesh in other is not a constituent of this !");
-  std::set<int> s1;
-  for(const int *idOther=idsOtherInConsti->begin();idOther!=idsOtherInConsti->end();idOther++)
+  std::set<mcIdType> s1;
+  for(const mcIdType *idOther=idsOtherInConsti->begin();idOther!=idsOtherInConsti->end();idOther++)
     s1.insert(revDescThisPartPtr+revDescIThisPartPtr[*idOther],revDescThisPartPtr+revDescIThisPartPtr[*idOther+1]);
-  MCAuto<DataArrayInt> s1arr_renum1=DataArrayInt::New(); s1arr_renum1->alloc((int)s1.size(),1); std::copy(s1.begin(),s1.end(),s1arr_renum1->getPointer());
+  MCAuto<DataArrayIdType> s1arr_renum1=DataArrayIdType::New(); s1arr_renum1->alloc(s1.size(),1); std::copy(s1.begin(),s1.end(),s1arr_renum1->getPointer());
   s1arr_renum1->sort();
   cellIdsRk0=s0arr.retn();
   //cellIdsRk1=s_renum1.retn();
@@ -2404,26 +2431,26 @@ void MEDCouplingUMesh::findCellIdsLyingOn(const MEDCouplingUMesh& otherDimM1OnSa
 /*!
  * This method computes the skin of \b this. That is to say the consituting meshdim-1 mesh is built and only the boundary subpart is
  * returned. This subpart of meshdim-1 mesh is built using meshdim-1 cells in it shared only one cell in \b this.
- * 
+ *
  * \return a newly allocated mesh lying on the same coordinates than \b this. The caller has to deal with returned mesh.
  */
 MEDCouplingUMesh *MEDCouplingUMesh::computeSkin() const
 {
-  MCAuto<DataArrayInt> desc=DataArrayInt::New();
-  MCAuto<DataArrayInt> descIndx=DataArrayInt::New();
-  MCAuto<DataArrayInt> revDesc=DataArrayInt::New();
-  MCAuto<DataArrayInt> revDescIndx=DataArrayInt::New();
+  MCAuto<DataArrayIdType> desc=DataArrayIdType::New();
+  MCAuto<DataArrayIdType> descIndx=DataArrayIdType::New();
+  MCAuto<DataArrayIdType> revDesc=DataArrayIdType::New();
+  MCAuto<DataArrayIdType> revDescIndx=DataArrayIdType::New();
   //
   MCAuto<MEDCouplingUMesh> meshDM1=buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx);
   revDesc=0; desc=0; descIndx=0;
-  MCAuto<DataArrayInt> revDescIndx2=revDescIndx->deltaShiftIndex();
-  MCAuto<DataArrayInt> part=revDescIndx2->findIdsEqual(1);
+  MCAuto<DataArrayIdType> revDescIndx2=revDescIndx->deltaShiftIndex();
+  MCAuto<DataArrayIdType> part=revDescIndx2->findIdsEqual(1);
   return static_cast<MEDCouplingUMesh *>(meshDM1->buildPartOfMySelf(part->begin(),part->end(),true));
 }
 
 /*!
  * Finds nodes lying on the boundary of \a this mesh.
- *  \return DataArrayInt * - a new instance of DataArrayInt holding ids of found
+ *  \return DataArrayIdType * - a new instance of DataArrayIdType holding ids of found
  *          nodes. The caller is to delete this array using decrRef() as it is no
  *          more needed.
  *  \throw If the coordinates array is not set.
@@ -2434,7 +2461,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::computeSkin() const
  *  \ref  py_mcumesh_findBoundaryNodes "Here is a Python example".
  *  \endif
  */
-DataArrayInt *MEDCouplingUMesh::findBoundaryNodes() const
+DataArrayIdType *MEDCouplingUMesh::findBoundaryNodes() const
 {
   MCAuto<MEDCouplingUMesh> skin=computeSkin();
   return skin->computeFetchedNodeIds();
@@ -2449,164 +2476,268 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildUnstructured() const
 /*!
  * This method expects that \b this and \b otherDimM1OnSameCoords share the same coordinates array.
  * otherDimM1OnSameCoords->getMeshDimension() is expected to be equal to this->getMeshDimension()-1.
- * This method searches for nodes needed to be duplicated. These nodes are nodes fetched by \b otherDimM1OnSameCoords which are not part of the boundary of \b otherDimM1OnSameCoords.
- * If a node is in the boundary of \b this \b and in the boundary of \b otherDimM1OnSameCoords this node is considerd as needed to be duplicated.
+ * This method searches for nodes needed to be duplicated. Those are the nodes fetched by \b otherDimM1OnSameCoords which are not part of the boundary of \b otherDimM1OnSameCoords.
+ * If a node is in the boundary of \b this \b and in the boundary of \b otherDimM1OnSameCoords, it will be duplicated.
  * When the set of node ids \b nodeIdsToDuplicate is computed, cell ids in \b this is searched so that their connectivity includes at least 1 node in \b nodeIdsToDuplicate.
  *
- * \param [in] otherDimM1OnSameCoords a mesh lying on the same coords than \b this and with a mesh dimension equal to those of \b this minus 1. WARNING this input
+ * \param [in] crackingMesh a mesh lying on the same coords than \b this and with a mesh dimension equal to those of \b this minus 1. WARNING this input
  *             parameter is altered during the call.
- * \param [out] nodeIdsToDuplicate node ids needed to be duplicated following the algorithm explain above.
- * \param [out] cellIdsNeededToBeRenum cell ids in \b this in which the renumber of nodes should be performed.
- * \param [out] cellIdsNotModified cell ids int \b this that lies on \b otherDimM1OnSameCoords mesh whose connectivity do \b not need to be modified as it is the case for \b cellIdsNeededToBeRenum.
+ * \return node ids which need to be duplicated following the algorithm explained above.
  *
- * \warning This method modifies param \b otherDimM1OnSameCoords (for speed reasons).
  */
-void MEDCouplingUMesh::findNodesToDuplicate(const MEDCouplingUMesh& otherDimM1OnSameCoords, DataArrayInt *& nodeIdsToDuplicate,
-                                            DataArrayInt *& cellIdsNeededToBeRenum, DataArrayInt *& cellIdsNotModified) const
+DataArrayIdType* MEDCouplingUMesh::findNodesToDuplicate(const MEDCouplingUMesh& crackingMesh) const
 {
-  typedef MCAuto<DataArrayInt> DAInt;
-  typedef MCAuto<MEDCouplingUMesh> MCUMesh;
+  // DEBUG NOTE: in case of issue with the algorithm in this method, see Python script in resources/dev
+  // which mimicks the C++
+  using DAInt = MCAuto<DataArrayIdType>;
+  using MCUMesh = MCAuto<MEDCouplingUMesh>;
 
   checkFullyDefined();
-  otherDimM1OnSameCoords.checkFullyDefined();
-  if(getCoords()!=otherDimM1OnSameCoords.getCoords())
+  crackingMesh.checkFullyDefined();
+  if(getCoords()!=crackingMesh.getCoords())
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::findNodesToDuplicate : meshes do not share the same coords array !");
-  if(otherDimM1OnSameCoords.getMeshDimension()!=getMeshDimension()-1)
+  if(crackingMesh.getMeshDimension()!=getMeshDimension()-1)
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::findNodesToDuplicate : the mesh given in other parameter must have this->getMeshDimension()-1 !");
 
+  // Clean the M1 group (cracking mesh): the M1 cells which are part of M0 boundary are irrelevant (we can't create a crack on the boundary of M0!)
+  MCUMesh m0skin = computeSkin();
+  DataArrayIdType *idsToKeepP;
+  m0skin->areCellsIncludedIn(&crackingMesh,2, idsToKeepP);
+  DAInt idsToKeep(idsToKeepP);
+  DAInt ids2 = idsToKeep->findIdsNotInRange(0, m0skin->getNumberOfCells());  // discard cells on the skin of M0
+  MCUMesh otherDimM1OnSameCoords =static_cast<MEDCouplingUMesh *>(crackingMesh.buildPartOfMySelf(ids2->begin(), ids2->end(), true));
+
+  if (!otherDimM1OnSameCoords->getNumberOfCells())
+    return MCAuto<DataArrayIdType>(DataArrayIdType::New()).retn();
+
   // Checking star-shaped M1 group:
-  DAInt dt0=DataArrayInt::New(),dit0=DataArrayInt::New(),rdt0=DataArrayInt::New(),rdit0=DataArrayInt::New();
-  MCUMesh meshM2 = otherDimM1OnSameCoords.buildDescendingConnectivity(dt0, dit0, rdt0, rdit0);
+  DAInt dt0=DataArrayIdType::New(),dit0=DataArrayIdType::New(),rdt0=DataArrayIdType::New(),rdit0=DataArrayIdType::New();
+  MCUMesh meshM2 = otherDimM1OnSameCoords->buildDescendingConnectivity(dt0, dit0, rdt0, rdit0); // 2D: a mesh of points, 3D: a mesh of segs
   DAInt dsi = rdit0->deltaShiftIndex();
-  DAInt idsTmp0 = dsi->findIdsNotInRange(-1, 3);
+  DAInt idsTmp0 = dsi->findIdsNotInRange(-1, 3);  // for 2D: if a point is connected to more than 2 segs. For 3D: if a seg is connected to more than two faces.
   if(idsTmp0->getNumberOfTuples())
     throw INTERP_KERNEL::Exception("MEDFileUMesh::buildInnerBoundaryAlongM1Group: group is too complex: some points (or edges) have more than two connected segments (or faces)!");
   dt0=0; dit0=0; rdt0=0; rdit0=0; idsTmp0=0;
 
-  // Get extreme nodes from the group (they won't be duplicated), ie nodes belonging to boundary cells of M1
+  // Get extreme nodes from the group (they won't be duplicated except if they also lie on bound of M0 -- see below),
+  // ie nodes belonging to the boundary "cells" (might be points) of M1
   DAInt xtremIdsM2 = dsi->findIdsEqual(1); dsi = 0;
   MCUMesh meshM2Part = static_cast<MEDCouplingUMesh *>(meshM2->buildPartOfMySelf(xtremIdsM2->begin(), xtremIdsM2->end(),true));
   DAInt xtrem = meshM2Part->computeFetchedNodeIds();
-  // Remove from the list points on the boundary of the M0 mesh (those need duplication!)
-  dt0=DataArrayInt::New(),dit0=DataArrayInt::New(),rdt0=DataArrayInt::New(),rdit0=DataArrayInt::New();
-  MCUMesh m0desc = buildDescendingConnectivity(dt0, dit0, rdt0, rdit0); dt0=0; dit0=0; rdt0=0;
-  dsi = rdit0->deltaShiftIndex();
-  DAInt boundSegs = dsi->findIdsEqual(1);   // boundary segs/faces of the M0 mesh
-  MCUMesh m0descSkin = static_cast<MEDCouplingUMesh *>(m0desc->buildPartOfMySelf(boundSegs->begin(),boundSegs->end(), true));
-  DAInt fNodes = m0descSkin->computeFetchedNodeIds();
-  // In 3D, some points on the boundary of M0 still need duplication:
+  // Remove from the list points on the boundary of the M0 mesh (those need duplication!).
+  //    In 3D, some points on the boundary of M0 will NOT be duplicated (where as in 2D, points on the boundary of M0 are always duplicated)
+  //    Think of a partial (plane) crack in a cube: the points at the tip of the crack and not located inside the volume of the cube are not duplicated
+  //    although they are technically on the skin of the cube.
+  DAInt fNodes = m0skin->computeFetchedNodeIds();
   DAInt notDup = 0;
   if (getMeshDimension() == 3)
     {
-      DAInt dnu1=DataArrayInt::New(), dnu2=DataArrayInt::New(), dnu3=DataArrayInt::New(), dnu4=DataArrayInt::New();
-      MCUMesh m0descSkinDesc = m0descSkin->buildDescendingConnectivity(dnu1, dnu2, dnu3, dnu4);
+      DAInt dnu1=DataArrayIdType::New(), dnu2=DataArrayIdType::New(), dnu3=DataArrayIdType::New(), dnu4=DataArrayIdType::New();
+      MCUMesh m0skinDesc = m0skin->buildDescendingConnectivity(dnu1, dnu2, dnu3, dnu4); // all segments of the skin of the 3D (M0) mesh
       dnu1=0;dnu2=0;dnu3=0;dnu4=0;
-      DataArrayInt * corresp=0;
-      meshM2->areCellsIncludedIn(m0descSkinDesc,2,corresp);
+      DataArrayIdType * corresp=0;
+      meshM2->areCellsIncludedIn(m0skinDesc,2,corresp);
+      // validIds is the list of segments which are on both the skin of *this*, and in the segments of the M1 group
+      // In the cube example above, this is a U-shaped polyline.
       DAInt validIds = corresp->findIdsInRange(0, meshM2->getNumberOfCells());
       corresp->decrRef();
       if (validIds->getNumberOfTuples())
         {
-          MCUMesh m1IntersecSkin = static_cast<MEDCouplingUMesh *>(m0descSkinDesc->buildPartOfMySelf(validIds->begin(), validIds->end(), true));
+          // Build the set of segments which are: in the desc mesh of the skin of the 3D mesh (M0) **and** in the desc mesh of the M1 group:
+          // (the U-shaped polyline described above)
+          MCUMesh m1IntersecSkin = static_cast<MEDCouplingUMesh *>(m0skinDesc->buildPartOfMySelf(validIds->begin(), validIds->end(), true));
+          // Its boundary nodes should no be duplicated (this is for example the tip of the crack inside the cube described above)
           DAInt notDuplSkin = m1IntersecSkin->findBoundaryNodes();
           DAInt fNodes1 = fNodes->buildSubstraction(notDuplSkin);
+
+          // Specific logic to handle singular points :
+          //   - a point on this U-shape line used in a cell which has no face in common with M1 is deemed singular.
+          //   - indeed, if duplicated, such a point would lead to the duplication of a cell which has no face touching M1 ! The
+          //   algorithm would be duplicating too much ...
+          // This is a costly algorithm so only go into it if a simple (non sufficient) criteria is met: a node connected to more than 3 segs in meshM2:
+          dnu1=DataArrayIdType::New(), dnu2=DataArrayIdType::New(), dnu3=DataArrayIdType::New(), rdit0=DataArrayIdType::New();
+          MCUMesh meshM2Desc = meshM2->buildDescendingConnectivity(dnu1, dnu2, dnu3, rdit0);  // a mesh made of node cells
+          dnu1=0;dnu2=0;dnu3=0;
+          dsi = rdit0->deltaShiftIndex();  rdit0=0;
+          DAInt singPoints = dsi->findIdsNotInRange(-1,4) ;    dsi=0;// points connected to (strictly) more than 3 segments
+          if (singPoints->getNumberOfTuples())
+            {
+              DAInt boundNodes = m1IntersecSkin->computeFetchedNodeIds();
+              // If a point on this U-shape line is connected to cells which do not share any face with M1, then it
+              // should not be duplicated
+              //    1. Extract N D cells touching U-shape line:
+              DAInt cellsAroundBN = getCellIdsLyingOnNodes(boundNodes->begin(), boundNodes->end(), false);  // false= take cell in, even if not all nodes are in dupl
+              MCUMesh mAroundBN = static_cast<MEDCouplingUMesh *>(this->buildPartOfMySelf(cellsAroundBN->begin(), cellsAroundBN->end(), true));
+              DAInt descBN=DataArrayIdType::New(), descIBN=DataArrayIdType::New(), revDescBN=DataArrayIdType::New(), revDescIBN=DataArrayIdType::New();
+              MCUMesh mAroundBNDesc = mAroundBN->buildDescendingConnectivity(descBN,descIBN,revDescBN,revDescIBN);
+              //    2. Identify cells in sub-mesh mAroundBN which have a face in common with M1
+              DataArrayIdType *idsOfM1BNt;
+              mAroundBNDesc->areCellsIncludedIn(otherDimM1OnSameCoords,2, idsOfM1BNt);
+              DAInt idsOfM1BN(idsOfM1BNt);
+              mcIdType nCells=mAroundBN->getNumberOfCells(), nCellsDesc=mAroundBNDesc->getNumberOfCells();
+              DAInt idsTouch=DataArrayIdType::New(); idsTouch->alloc(0,1);
+              const mcIdType *revDescIBNP=revDescIBN->begin(), *revDescBNP=revDescBN->begin();
+              for(const auto& v: *idsOfM1BN)
+                {
+                  if (v >= nCellsDesc)    // Keep valid match only
+                    continue;
+                  mcIdType idx0 = revDescIBNP[v];
+                  // Keep the two cells on either side of the face v of M1:
+                  mcIdType c1=revDescBNP[idx0], c2=revDescBNP[idx0+1];
+                  idsTouch->pushBackSilent(c1);  idsTouch->pushBackSilent(c2);
+                }
+              //    3. Build complement
+              DAInt idsTouchCompl = idsTouch->buildComplement(nCells);
+              MCUMesh mAroundBNStrict = static_cast<MEDCouplingUMesh *>(mAroundBN->buildPartOfMySelf(idsTouchCompl->begin(), idsTouchCompl->end(), true));
+              DAInt nod3 = mAroundBNStrict->computeFetchedNodeIds();
+              DAInt inters = boundNodes->buildIntersection(nod3);
+              fNodes1 = fNodes1->buildSubstraction(inters);  // reminder: fNodes1 represent nodes that need dupl.
+            }
           notDup = xtrem->buildSubstraction(fNodes1);
         }
-      else
+      else  // if (validIds-> ...)
         notDup = xtrem->buildSubstraction(fNodes);
     }
-  else
+  else  // if (3D ...)
     notDup = xtrem->buildSubstraction(fNodes);
 
-  // Now compute cells around group (i.e. cells where we will do the propagation to identify the two sub-sets delimited by the group)
-  DAInt m1Nodes = otherDimM1OnSameCoords.computeFetchedNodeIds();
+  DAInt m1Nodes = otherDimM1OnSameCoords->computeFetchedNodeIds();
   DAInt dupl = m1Nodes->buildSubstraction(notDup);
-  DAInt cellsAroundGroup = getCellIdsLyingOnNodes(dupl->begin(), dupl->end(), false);  // false= take cell in, even if not all nodes are in notDup
+  return dupl.retn();
+}
 
-  //
-  MCUMesh m0Part2=static_cast<MEDCouplingUMesh *>(buildPartOfMySelf(cellsAroundGroup->begin(),cellsAroundGroup->end(),true));
-  int nCells2 = m0Part2->getNumberOfCells();
-  DAInt desc00=DataArrayInt::New(),descI00=DataArrayInt::New(),revDesc00=DataArrayInt::New(),revDescI00=DataArrayInt::New();
-  MCUMesh m01=m0Part2->buildDescendingConnectivity(desc00,descI00,revDesc00,revDescI00);
-
-  // Neighbor information of the mesh without considering the crack (serves to count how many connex pieces it is made of)
-  DataArrayInt *tmp00=0,*tmp11=0;
-  MEDCouplingUMesh::ComputeNeighborsOfCellsAdv(desc00,descI00,revDesc00,revDescI00, tmp00, tmp11);
-  DAInt neighInit00(tmp00);
-  DAInt neighIInit00(tmp11);
-  // Neighbor information of the mesh WITH the crack (some neighbors are removed):
-  DataArrayInt *idsTmp=0;
-  bool b=m01->areCellsIncludedIn(&otherDimM1OnSameCoords,2,idsTmp);
-  DAInt ids(idsTmp);
-  // In the neighbor information remove the connection between high dimension cells and its low level constituents which are part
-  // of the frontier given in parameter (i.e. the cells of low dimension from the group delimiting the crack):
-  MEDCouplingUMesh::RemoveIdsFromIndexedArrays(ids->begin(),ids->end(),desc00,descI00);
-  DataArrayInt *tmp0=0,*tmp1=0;
-  // Compute the neighbor of each cell in m0Part2, taking into account the broken link above. Two
-  // cells on either side of the crack (defined by the mesh of low dimension) are not neighbor anymore.
-  ComputeNeighborsOfCellsAdv(desc00,descI00,revDesc00,revDescI00,tmp0,tmp1);
-  DAInt neigh00(tmp0);
-  DAInt neighI00(tmp1);
-
-  // For each initial connex part of the sub-mesh (or said differently for each independent crack):
-  int seed = 0, nIter = 0;
-  int nIterMax = nCells2+1; // Safety net for the loop
-  DAInt hitCells = DataArrayInt::New(); hitCells->alloc(nCells2);
-  hitCells->fillWithValue(-1);
-  DAInt cellsToModifyConn0_torenum = DataArrayInt::New();
-  cellsToModifyConn0_torenum->alloc(0,1);
-  while (nIter < nIterMax)
-    {
-      DAInt t = hitCells->findIdsEqual(-1);
-      if (!t->getNumberOfTuples())
-        break;
-      // Connex zone without the crack (to compute the next seed really)
-      int dnu;
-      DAInt connexCheck = MEDCouplingUMesh::ComputeSpreadZoneGraduallyFromSeed(&seed, &seed+1, neighInit00,neighIInit00, -1, dnu);
-      int cnt = 0;
-      for (int * ptr = connexCheck->getPointer(); cnt < connexCheck->getNumberOfTuples(); ptr++, cnt++)
-        hitCells->setIJ(*ptr,0,1);
-      // Connex zone WITH the crack (to identify cells lying on either part of the crack)
-      DAInt spreadZone = MEDCouplingUMesh::ComputeSpreadZoneGraduallyFromSeed(&seed, &seed+1, neigh00,neighI00, -1, dnu);
-      cellsToModifyConn0_torenum = DataArrayInt::Aggregate(cellsToModifyConn0_torenum, spreadZone, 0);
-      // Compute next seed, i.e. a cell in another connex part, which was not covered by the previous iterations
-      DAInt comple = cellsToModifyConn0_torenum->buildComplement(nCells2);
-      DAInt nonHitCells = hitCells->findIdsEqual(-1);
-      DAInt intersec = nonHitCells->buildIntersection(comple);
-      if (intersec->getNumberOfTuples())
-        { seed = intersec->getIJ(0,0); }
-      else
-        { break; }
-      nIter++;
+
+/*!
+ * This method expects that \b this and \b otherDimM1OnSameCoords share the same coordinates array.
+ * otherDimM1OnSameCoords->getMeshDimension() is expected to be equal to this->getMeshDimension()-1.
+ * This method is part of the MEDFileUMesh::buildInnerBoundaryAlongM1Group() algorithm.
+ * Given a set of nodes to duplicate, this method identifies which cells should have their connectivity modified
+ * to produce the inner boundary. It is typically called after findNodesToDuplicate().
+ *
+ * \param [in] otherDimM1OnSameCoords a mesh lying on the same coords than \b this and with a mesh dimension equal to those of \b this minus 1.
+ * \param [in] nodeIdsToDuplicateBg node ids needed to be duplicated, as returned by findNodesToDuplicate.
+ * \param [in] nodeIdsToDuplicateEnd node ids needed to be duplicated, as returned by findNodesToDuplicate.
+ * \param [out] cellIdsNeededToBeRenum cell ids in \b this in which the renumber of nodes should be performed.
+ * \param [out] cellIdsNotModified cell ids in \b this that lies on \b otherDimM1OnSameCoords mesh whose connectivity do \b not need to be modified as it is the case for \b cellIdsNeededToBeRenum.
+ *
+ */
+void MEDCouplingUMesh::findCellsToRenumber(const MEDCouplingUMesh& otherDimM1OnSameCoords, const mcIdType *nodeIdsToDuplicateBg, const mcIdType *nodeIdsToDuplicateEnd,
+                                           DataArrayIdType *& cellIdsNeededToBeRenum, DataArrayIdType *& cellIdsNotModified) const
+{
+  using DAInt = MCAuto<DataArrayIdType>;
+  using MCUMesh = MCAuto<MEDCouplingUMesh>;
+
+  checkFullyDefined();
+  otherDimM1OnSameCoords.checkFullyDefined();
+  if(getCoords()!=otherDimM1OnSameCoords.getCoords())
+    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::findCellsToRenumber: meshes do not share the same coords array !");
+  if(otherDimM1OnSameCoords.getMeshDimension()!=getMeshDimension()-1)
+    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::findCellsToRenumber: the mesh given in other parameter must have this->getMeshDimension()-1 !");
+
+  // Degenerated case - no nodes to duplicate
+  if (nodeIdsToDuplicateBg == nodeIdsToDuplicateEnd)
+    {
+      cellIdsNeededToBeRenum = DataArrayIdType::New(); cellIdsNeededToBeRenum->alloc(0,1);
+      cellIdsNotModified = DataArrayIdType::New(); cellIdsNotModified->alloc(0,1);
+      return;
+    }
+
+  // Compute cell IDs of the mesh with cells that touch the M1 group with a least one node:
+  DAInt cellsAroundGroupLarge = getCellIdsLyingOnNodes(nodeIdsToDuplicateBg, nodeIdsToDuplicateEnd, false);  // false= take cell in, even if not all nodes are in dupl
+  MCUMesh mAroundGrpLarge=static_cast<MEDCouplingUMesh *>(buildPartOfMySelf(cellsAroundGroupLarge->begin(),cellsAroundGroupLarge->end(),true));
+  mcIdType nCellsLarge=cellsAroundGroupLarge->getNumberOfTuples();
+  DAInt descL=DataArrayIdType::New(),descIL=DataArrayIdType::New(),revDescL=DataArrayIdType::New(),revDescIL=DataArrayIdType::New();
+  MCUMesh mArGrpLargeDesc=mAroundGrpLarge->buildDescendingConnectivity(descL,descIL,revDescL,revDescIL);
+  const mcIdType *descILP=descIL->begin(), *descLP=descL->begin();
+  DataArrayIdType *idsOfM1t;
+  mArGrpLargeDesc->areCellsIncludedIn(&otherDimM1OnSameCoords,2, idsOfM1t);
+  DAInt idsOfM1Large(idsOfM1t);
+  mcIdType nL = mArGrpLargeDesc->getNumberOfCells();
+
+  // Computation of the neighbor information of the mesh WITH the crack (some neighbor links are removed):
+  //     In the neighbor information remove the connection between high dimension cells and its low level constituents which are part
+  //     of the frontier given in parameter (i.e. the cells of low dimension from the group delimiting the crack):
+  DAInt descLTrunc = descL->deepCopy(), descILTrunc = descIL->deepCopy();
+  DataArrayIdType::RemoveIdsFromIndexedArrays(idsOfM1Large->begin(), idsOfM1Large->end(),descLTrunc,descILTrunc);
+  DataArrayIdType *neight=0, *neighIt=0;
+  MEDCouplingUMesh::ComputeNeighborsOfCellsAdv(descLTrunc,descILTrunc,revDescL,revDescIL, neight, neighIt);
+  DAInt neighL(neight), neighIL(neighIt);
+
+  DAInt hitCellsLarge = DataArrayIdType::New(); hitCellsLarge->alloc(nCellsLarge,1);
+  hitCellsLarge->fillWithValue(0);  // 0 : not hit, +1: one side of the crack, -1: other side of the crack,
+  mcIdType* hitCellsLargeP = hitCellsLarge->rwBegin();
+
+  // Now loop on the faces of the M1 group and fill spread zones on either side of the crack:
+  const mcIdType *revDescILP=revDescIL->begin(), *revDescLP=revDescL->begin();
+  for(const auto& v: *idsOfM1Large)
+    {
+      if (v >= nL) continue;   // Keep valid match only - see doc of areCellsIncludedIn()
+      mcIdType idx0 = revDescILP[v];
+      // Retrieve the two cells on either side of the face v of M1:
+      mcIdType c1=revDescLP[idx0], c2=revDescLP[idx0+1];
+      std::map<mcIdType, mcIdType> toOther = {{c1, c2}, {c2, c1}};
+      // Handle the spread zones on the two sides of the crack:
+      for (const auto c: {c1, c2})
+        {
+          if (hitCellsLargeP[c]) continue;
+          // Identify connex zone around this cell - if we find a value already assigned there, use it.
+          mcIdType dnu;
+          DAInt spreadZone = MEDCouplingUMesh::ComputeSpreadZoneGraduallyFromSeed(&c, &c+1, neighL,neighIL, -1, dnu);
+          std::set<mcIdType> sv;
+          for (const mcIdType& s: *spreadZone)
+            if (hitCellsLargeP[s]) sv.insert(hitCellsLargeP[s]);
+          if (sv.size() > 1)
+            // Strange: we find in the same spread zone a +1 and -1 !
+            throw INTERP_KERNEL::Exception("MEDCouplingUMesh::findCellsToRenumber: internal error #0 - conflicting values - should not happen!");
+          // If a valid value was found, use it:
+          mcIdType val = sv.size()==1 ? *sv.begin() : 0;
+          // Hopefully this does not conflict with an potential value on the other side:
+          mcIdType other = toOther[c];
+          if (hitCellsLargeP[other])
+            {
+              if(val && hitCellsLargeP[other] != -val)
+                throw INTERP_KERNEL::Exception("MEDCouplingUMesh::findCellsToRenumber: internal error #1 - conflicting values - should not happen!");;
+              // We do not yet have a value, but other side has one. Use it!
+              if(!val) val = -hitCellsLargeP[other];
+            }
+          // Cover first initialisation:
+          if (!val) val = 1;
+          // And finally, fill the current spread zone:
+          for(const mcIdType& s: *spreadZone) hitCellsLargeP[s] = val;
+        }
     }
-  if (nIter >= nIterMax)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::findNodesToDuplicate(): internal error - too many iterations.");
 
-  DAInt cellsToModifyConn1_torenum=cellsToModifyConn0_torenum->buildComplement(neighI00->getNumberOfTuples()-1);
-  cellsToModifyConn0_torenum->transformWithIndArr(cellsAroundGroup->begin(),cellsAroundGroup->end());
-  cellsToModifyConn1_torenum->transformWithIndArr(cellsAroundGroup->begin(),cellsAroundGroup->end());
+  DAInt cellsRet1 = hitCellsLarge->findIdsEqual(1);
+  DAInt cellsRet2 = hitCellsLarge->findIdsEqual(-1);
+
+  if (cellsRet1->getNumberOfTuples() + cellsRet2->getNumberOfTuples() != cellsAroundGroupLarge->getNumberOfTuples())
+    {
+      DAInt nonHitCells = hitCellsLarge->findIdsEqual(0); // variable kept for debug ...
+      throw INTERP_KERNEL::Exception("MEDCouplingUMesh::findCellsToRenumber: Some cells not hit - Internal error should not happen");
+    }
+  cellsRet1->transformWithIndArr(cellsAroundGroupLarge->begin(),cellsAroundGroupLarge->end());
+  cellsRet2->transformWithIndArr(cellsAroundGroupLarge->begin(),cellsAroundGroupLarge->end());
   //
-  cellIdsNeededToBeRenum=cellsToModifyConn0_torenum.retn();
-  cellIdsNotModified=cellsToModifyConn1_torenum.retn();
-  nodeIdsToDuplicate=dupl.retn();
+  cellIdsNeededToBeRenum=cellsRet1.retn();
+  cellIdsNotModified=cellsRet2.retn();
 }
 
 /*!
  * This method operates a modification of the connectivity and coords in \b this.
- * Every time that a node id in [ \b nodeIdsToDuplicateBg, \b nodeIdsToDuplicateEnd ) will append in nodal connectivity of \b this 
+ * Every time that a node id in [ \b nodeIdsToDuplicateBg, \b nodeIdsToDuplicateEnd ) will append in nodal connectivity of \b this
  * its ids will be modified to id this->getNumberOfNodes()+std::distance(nodeIdsToDuplicateBg,std::find(nodeIdsToDuplicateBg,nodeIdsToDuplicateEnd,id)).
- * More explicitely the renumber array in nodes is not explicitely given in old2new to avoid to build a big array of renumbering whereas typically few node ids needs to be
+ * More explicitly the renumber array in nodes is not explicitly given in old2new to avoid to build a big array of renumbering whereas typically few node ids needs to be
  * renumbered. The node id nodeIdsToDuplicateBg[0] will have id this->getNumberOfNodes()+0, node id nodeIdsToDuplicateBg[1] will have id this->getNumberOfNodes()+1,
  * node id nodeIdsToDuplicateBg[2] will have id this->getNumberOfNodes()+2...
- * 
+ *
  * As a consequence nodal connectivity array length will remain unchanged by this method, and nodal connectivity index array will remain unchanged by this method.
- * 
+ *
  * \param [in] nodeIdsToDuplicateBg begin of node ids (included) to be duplicated in connectivity only
  * \param [in] nodeIdsToDuplicateEnd end of node ids (excluded) to be duplicated in connectivity only
  */
-void MEDCouplingUMesh::duplicateNodes(const int *nodeIdsToDuplicateBg, const int *nodeIdsToDuplicateEnd)
+void MEDCouplingUMesh::duplicateNodes(const mcIdType *nodeIdsToDuplicateBg, const mcIdType *nodeIdsToDuplicateEnd)
 {
-  int nbOfNodes=getNumberOfNodes();
+  mcIdType nbOfNodes=getNumberOfNodes();
   duplicateNodesInCoords(nodeIdsToDuplicateBg,nodeIdsToDuplicateEnd);
   duplicateNodesInConn(nodeIdsToDuplicateBg,nodeIdsToDuplicateEnd,nbOfNodes);
 }
@@ -2619,16 +2750,16 @@ void MEDCouplingUMesh::duplicateNodes(const int *nodeIdsToDuplicateBg, const int
  *
  * \sa renumberNodesInConn
  */
-void MEDCouplingUMesh::renumberNodesWithOffsetInConn(int offset)
+void MEDCouplingUMesh::renumberNodesWithOffsetInConn(mcIdType offset)
 {
   checkConnectivityFullyDefined();
-  int *conn(getNodalConnectivity()->getPointer());
-  const int *connIndex(getNodalConnectivityIndex()->getConstPointer());
-  int nbOfCells(getNumberOfCells());
-  for(int i=0;i<nbOfCells;i++)
-    for(int iconn=connIndex[i]+1;iconn!=connIndex[i+1];iconn++)
+  mcIdType *conn(getNodalConnectivity()->getPointer());
+  const mcIdType *connIndex(getNodalConnectivityIndex()->getConstPointer());
+  mcIdType nbOfCells=getNumberOfCells();
+  for(mcIdType i=0;i<nbOfCells;i++)
+    for(mcIdType iconn=connIndex[i]+1;iconn!=connIndex[i+1];iconn++)
       {
-        int& node=conn[iconn];
+        mcIdType& node=conn[iconn];
         if(node>=0)//avoid polyhedron separator
           {
             node+=offset;
@@ -2639,36 +2770,23 @@ void MEDCouplingUMesh::renumberNodesWithOffsetInConn(int offset)
 }
 
 /*!
- *  Same than renumberNodesInConn(const int *) except that here the format of old-to-new traducer is using map instead
+ *  Same than renumberNodesInConn(const mcIdType *) except that here the format of old-to-new traducer is using map instead
  *  of array. This method is dedicated for renumbering from a big set of nodes the a tiny set of nodes which is the case during extraction
  *  of a big mesh.
  */
-void MEDCouplingUMesh::renumberNodesInConn(const INTERP_KERNEL::HashMap<int,int>& newNodeNumbersO2N)
+void MEDCouplingUMesh::renumberNodesInConn(const INTERP_KERNEL::HashMap<mcIdType,mcIdType>& newNodeNumbersO2N)
 {
-  checkConnectivityFullyDefined();
-  int *conn(getNodalConnectivity()->getPointer());
-  const int *connIndex(getNodalConnectivityIndex()->getConstPointer());
-  int nbOfCells(getNumberOfCells());
-  for(int i=0;i<nbOfCells;i++)
-    for(int iconn=connIndex[i]+1;iconn!=connIndex[i+1];iconn++)
-      {
-        int& node=conn[iconn];
-        if(node>=0)//avoid polyhedron separator
-          {
-            INTERP_KERNEL::HashMap<int,int>::const_iterator it(newNodeNumbersO2N.find(node));
-            if(it!=newNodeNumbersO2N.end())
-              {
-                node=(*it).second;
-              }
-            else
-              {
-                std::ostringstream oss; oss << "MEDCouplingUMesh::renumberNodesInConn(map) : presence in connectivity for cell #" << i << " of node #" << node << " : Not in map !";
-                throw INTERP_KERNEL::Exception(oss.str());
-              }
-          }
-      }
-  _nodal_connec->declareAsNew();
-  updateTime();
+  this->renumberNodesInConnT< INTERP_KERNEL::HashMap<mcIdType,mcIdType> >(newNodeNumbersO2N);
+}
+
+/*!
+ *  Same than renumberNodesInConn(const mcIdType *) except that here the format of old-to-new traducer is using map instead
+ *  of array. This method is dedicated for renumbering from a big set of nodes the a tiny set of nodes which is the case during extraction
+ *  of a big mesh.
+ */
+void MEDCouplingUMesh::renumberNodesInConn(const std::map<mcIdType,mcIdType>& newNodeNumbersO2N)
+{
+  this->renumberNodesInConnT< std::map<mcIdType,mcIdType> >(newNodeNumbersO2N);
 }
 
 /*!
@@ -2677,7 +2795,7 @@ void MEDCouplingUMesh::renumberNodesInConn(const INTERP_KERNEL::HashMap<int,int>
  * This method is a generalization of shiftNodeNumbersInConn().
  *  \warning This method performs no check of validity of new ids. **Use it with care !**
  *  \param [in] newNodeNumbersO2N - a permutation array, of length \a
- *         this->getNumberOfNodes(), in "Old to New" mode. 
+ *         this->getNumberOfNodes(), in "Old to New" mode.
  *         See \ref numbering for more info on renumbering modes.
  *  \throw If the nodal connectivity of cells is not defined.
  *
@@ -2686,16 +2804,16 @@ void MEDCouplingUMesh::renumberNodesInConn(const INTERP_KERNEL::HashMap<int,int>
  *  \ref  py_mcumesh_renumberNodesInConn "Here is a Python example".
  *  \endif
  */
-void MEDCouplingUMesh::renumberNodesInConn(const int *newNodeNumbersO2N)
+void MEDCouplingUMesh::renumberNodesInConn(const mcIdType *newNodeNumbersO2N)
 {
   checkConnectivityFullyDefined();
-  int *conn=getNodalConnectivity()->getPointer();
-  const int *connIndex=getNodalConnectivityIndex()->getConstPointer();
-  int nbOfCells(getNumberOfCells());
-  for(int i=0;i<nbOfCells;i++)
-    for(int iconn=connIndex[i]+1;iconn!=connIndex[i+1];iconn++)
+  mcIdType *conn=getNodalConnectivity()->getPointer();
+  const mcIdType *connIndex=getNodalConnectivityIndex()->getConstPointer();
+  mcIdType nbOfCells=getNumberOfCells();
+  for(mcIdType i=0;i<nbOfCells;i++)
+    for(mcIdType iconn=connIndex[i]+1;iconn!=connIndex[i+1];iconn++)
       {
-        int& node=conn[iconn];
+        mcIdType& node=conn[iconn];
         if(node>=0)//avoid polyhedron separator
           {
             node=newNodeNumbersO2N[node];
@@ -2709,19 +2827,19 @@ void MEDCouplingUMesh::renumberNodesInConn(const int *newNodeNumbersO2N)
  * This method renumbers nodes \b in \b connectivity \b only \b without \b any \b reference \b to \b coords.
  * This method performs no check on the fact that new coordinate ids are valid. \b Use \b it \b with \b care !
  * This method is an specialization of \ref MEDCoupling::MEDCouplingUMesh::renumberNodesInConn "renumberNodesInConn method".
- * 
+ *
  * \param [in] delta specifies the shift size applied to nodeId in nodal connectivity in \b this.
  */
-void MEDCouplingUMesh::shiftNodeNumbersInConn(int delta)
+void MEDCouplingUMesh::shiftNodeNumbersInConn(mcIdType delta)
 {
   checkConnectivityFullyDefined();
-  int *conn=getNodalConnectivity()->getPointer();
-  const int *connIndex=getNodalConnectivityIndex()->getConstPointer();
-  int nbOfCells=getNumberOfCells();
-  for(int i=0;i<nbOfCells;i++)
-    for(int iconn=connIndex[i]+1;iconn!=connIndex[i+1];iconn++)
+  mcIdType *conn=getNodalConnectivity()->getPointer();
+  const mcIdType *connIndex=getNodalConnectivityIndex()->getConstPointer();
+  mcIdType nbOfCells=getNumberOfCells();
+  for(mcIdType i=0;i<nbOfCells;i++)
+    for(mcIdType iconn=connIndex[i]+1;iconn!=connIndex[i+1];iconn++)
       {
-        int& node=conn[iconn];
+        mcIdType& node=conn[iconn];
         if(node>=0)//avoid polyhedron separator
           {
             node+=delta;
@@ -2734,36 +2852,36 @@ void MEDCouplingUMesh::shiftNodeNumbersInConn(int delta)
 /*!
  * This method operates a modification of the connectivity in \b this.
  * Coordinates are \b NOT considered here and will remain unchanged by this method. this->_coords can ever been null for the needs of this method.
- * Every time that a node id in [ \b nodeIdsToDuplicateBg, \b nodeIdsToDuplicateEnd ) will append in nodal connectivity of \b this 
+ * Every time that a node id in [ \b nodeIdsToDuplicateBg, \b nodeIdsToDuplicateEnd ) will append in nodal connectivity of \b this
  * its ids will be modified to id offset+std::distance(nodeIdsToDuplicateBg,std::find(nodeIdsToDuplicateBg,nodeIdsToDuplicateEnd,id)).
- * More explicitely the renumber array in nodes is not explicitely given in old2new to avoid to build a big array of renumbering whereas typically few node ids needs to be
+ * More explicitly the renumber array in nodes is not explicitly given in old2new to avoid to build a big array of renumbering whereas typically few node ids needs to be
  * renumbered. The node id nodeIdsToDuplicateBg[0] will have id offset+0, node id nodeIdsToDuplicateBg[1] will have id offset+1,
  * node id nodeIdsToDuplicateBg[2] will have id offset+2...
- * 
+ *
  * As a consequence nodal connectivity array length will remain unchanged by this method, and nodal connectivity index array will remain unchanged by this method.
  * As an another consequense after the call of this method \b this can be transiently non cohrent.
- * 
+ *
  * \param [in] nodeIdsToDuplicateBg begin of node ids (included) to be duplicated in connectivity only
  * \param [in] nodeIdsToDuplicateEnd end of node ids (excluded) to be duplicated in connectivity only
- * \param [in] offset the offset applied to all node ids in connectivity that are in [ \a nodeIdsToDuplicateBg, \a nodeIdsToDuplicateEnd ). 
+ * \param [in] offset the offset applied to all node ids in connectivity that are in [ \a nodeIdsToDuplicateBg, \a nodeIdsToDuplicateEnd ).
  */
-void MEDCouplingUMesh::duplicateNodesInConn(const int *nodeIdsToDuplicateBg, const int *nodeIdsToDuplicateEnd, int offset)
+void MEDCouplingUMesh::duplicateNodesInConn(const mcIdType *nodeIdsToDuplicateBg, const mcIdType *nodeIdsToDuplicateEnd, mcIdType offset)
 {
   checkConnectivityFullyDefined();
-  std::map<int,int> m;
-  int val=offset;
-  for(const int *work=nodeIdsToDuplicateBg;work!=nodeIdsToDuplicateEnd;work++,val++)
+  std::map<mcIdType,mcIdType> m;
+  mcIdType val=offset;
+  for(const mcIdType *work=nodeIdsToDuplicateBg;work!=nodeIdsToDuplicateEnd;work++,val++)
     m[*work]=val;
-  int *conn=getNodalConnectivity()->getPointer();
-  const int *connIndex=getNodalConnectivityIndex()->getConstPointer();
-  int nbOfCells=getNumberOfCells();
-  for(int i=0;i<nbOfCells;i++)
-    for(int iconn=connIndex[i]+1;iconn!=connIndex[i+1];iconn++)
+  mcIdType *conn=getNodalConnectivity()->getPointer();
+  const mcIdType *connIndex=getNodalConnectivityIndex()->getConstPointer();
+  mcIdType nbOfCells=getNumberOfCells();
+  for(mcIdType i=0;i<nbOfCells;i++)
+    for(mcIdType iconn=connIndex[i]+1;iconn!=connIndex[i+1];iconn++)
       {
-        int& node=conn[iconn];
+        mcIdType& node=conn[iconn];
         if(node>=0)//avoid polyhedron separator
           {
-            std::map<int,int>::iterator it=m.find(node);
+            std::map<mcIdType,mcIdType>::iterator it=m.find(node);
             if(it!=m.end())
               node=(*it).second;
           }
@@ -2784,38 +2902,38 @@ void MEDCouplingUMesh::duplicateNodesInConn(const int *nodeIdsToDuplicateBg, con
  * If 'check' equals false the method will not check the content of [ \a old2NewBg ; \a old2NewEnd ).
  * To avoid any throw of SIGSEGV when 'check' equals false, the elements in [ \a old2NewBg ; \a old2NewEnd ) should be unique and
  * should be contained in[0;this->getNumberOfCells()).
- * 
+ *
  * \param [in] old2NewBg is expected to be a dynamically allocated pointer of size at least equal to this->getNumberOfCells()
- * \param check
+ * \param check whether to check content of old2NewBg
  */
-void MEDCouplingUMesh::renumberCells(const int *old2NewBg, bool check)
+void MEDCouplingUMesh::renumberCells(const mcIdType *old2NewBg, bool check)
 {
   checkConnectivityFullyDefined();
-  int nbCells=getNumberOfCells();
-  const int *array=old2NewBg;
+  mcIdType nbCells=getNumberOfCells();
+  const mcIdType *array=old2NewBg;
   if(check)
-    array=DataArrayInt::CheckAndPreparePermutation(old2NewBg,old2NewBg+nbCells);
+    array=DataArrayIdType::CheckAndPreparePermutation(old2NewBg,old2NewBg+nbCells);
   //
-  const int *conn=_nodal_connec->getConstPointer();
-  const int *connI=_nodal_connec_index->getConstPointer();
-  MCAuto<DataArrayInt> o2n=DataArrayInt::New(); o2n->useArray(array,false,C_DEALLOC,nbCells,1);
-  MCAuto<DataArrayInt> n2o=o2n->invertArrayO2N2N2O(nbCells);
-  const int *n2oPtr=n2o->begin();
-  MCAuto<DataArrayInt> newConn=DataArrayInt::New();
+  const mcIdType *conn=_nodal_connec->getConstPointer();
+  const mcIdType *connI=_nodal_connec_index->getConstPointer();
+  MCAuto<DataArrayIdType> o2n=DataArrayIdType::New(); o2n->useArray(array,false,DeallocType::C_DEALLOC,nbCells,1);
+  MCAuto<DataArrayIdType> n2o=o2n->invertArrayO2N2N2O(nbCells);
+  const mcIdType *n2oPtr=n2o->begin();
+  MCAuto<DataArrayIdType> newConn=DataArrayIdType::New();
   newConn->alloc(_nodal_connec->getNumberOfTuples(),_nodal_connec->getNumberOfComponents());
   newConn->copyStringInfoFrom(*_nodal_connec);
-  MCAuto<DataArrayInt> newConnI=DataArrayInt::New();
+  MCAuto<DataArrayIdType> newConnI=DataArrayIdType::New();
   newConnI->alloc(_nodal_connec_index->getNumberOfTuples(),_nodal_connec_index->getNumberOfComponents());
   newConnI->copyStringInfoFrom(*_nodal_connec_index);
   //
-  int *newC=newConn->getPointer();
-  int *newCI=newConnI->getPointer();
-  int loc=0;
+  mcIdType *newC=newConn->getPointer();
+  mcIdType *newCI=newConnI->getPointer();
+  mcIdType loc=0;
   newCI[0]=loc;
-  for(int i=0;i<nbCells;i++)
+  for(mcIdType i=0;i<nbCells;i++)
     {
-      int pos=n2oPtr[i];
-      int nbOfElts=connI[pos+1]-connI[pos];
+      mcIdType pos=n2oPtr[i];
+      mcIdType nbOfElts=connI[pos+1]-connI[pos];
       newC=std::copy(conn+connI[pos],conn+connI[pos+1],newC);
       loc+=nbOfElts;
       newCI[i+1]=loc;
@@ -2823,20 +2941,20 @@ void MEDCouplingUMesh::renumberCells(const int *old2NewBg, bool check)
   //
   setConnectivity(newConn,newConnI);
   if(check)
-    free(const_cast<int *>(array));
+    free(const_cast<mcIdType *>(array));
 }
 
 /*!
  * Finds cells whose bounding boxes intersect a given bounding box.
  *  \param [in] bbox - an array defining the bounding box via coordinates of its
  *         extremum points in "no interlace" mode, i.e. xMin, xMax, yMin, yMax, zMin,
- *         zMax (if in 3D). 
+ *         zMax (if in 3D).
  *  \param [in] eps - a factor used to increase size of the bounding box of cell
  *         before comparing it with \a bbox. This factor is multiplied by the maximal
  *         extent of the bounding box of cell to produce an addition to this bounding box.
- *  \return DataArrayInt * - a new instance of DataArrayInt holding ids for found
+ *  \return DataArrayIdType * - a new instance of DataArrayIdType holding ids for found
  *         cells. The caller is to delete this array using decrRef() as it is no more
- *         needed. 
+ *         needed.
  *  \throw If the coordinates array is not set.
  *  \throw If the nodal connectivity of cells is not defined.
  *
@@ -2845,9 +2963,9 @@ void MEDCouplingUMesh::renumberCells(const int *old2NewBg, bool check)
  *  \ref  py_mcumesh_getCellsInBoundingBox "Here is a Python example".
  *  \endif
  */
-DataArrayInt *MEDCouplingUMesh::getCellsInBoundingBox(const double *bbox, double eps) const
+DataArrayIdType *MEDCouplingUMesh::getCellsInBoundingBox(const double *bbox, double eps) const
 {
-  MCAuto<DataArrayInt> elems=DataArrayInt::New(); elems->alloc(0,1);
+  MCAuto<DataArrayIdType> elems=DataArrayIdType::New(); elems->alloc(0,1);
   if(getMeshDimension()==-1)
     {
       elems->pushBackSilent(0);
@@ -2855,11 +2973,11 @@ DataArrayInt *MEDCouplingUMesh::getCellsInBoundingBox(const double *bbox, double
     }
   int dim=getSpaceDimension();
   INTERP_KERNEL::AutoPtr<double> elem_bb=new double[2*dim];
-  const int* conn      = getNodalConnectivity()->getConstPointer();
-  const int* conn_index= getNodalConnectivityIndex()->getConstPointer();
+  const mcIdType* conn      = getNodalConnectivity()->getConstPointer();
+  const mcIdType* conn_index= getNodalConnectivityIndex()->getConstPointer();
   const double* coords = getCoords()->getConstPointer();
-  int nbOfCells=getNumberOfCells();
-  for ( int ielem=0; ielem<nbOfCells;ielem++ )
+  mcIdType nbOfCells=getNumberOfCells();
+  for ( mcIdType ielem=0; ielem<nbOfCells;ielem++ )
     {
       for (int i=0; i<dim; i++)
         {
@@ -2867,9 +2985,9 @@ DataArrayInt *MEDCouplingUMesh::getCellsInBoundingBox(const double *bbox, double
           elem_bb[i*2+1]=-std::numeric_limits<double>::max();
         }
 
-      for (int inode=conn_index[ielem]+1; inode<conn_index[ielem+1]; inode++)//+1 due to offset of cell type.
+      for (mcIdType inode=conn_index[ielem]+1; inode<conn_index[ielem+1]; inode++)//+1 due to offset of cell type.
         {
-          int node= conn[inode];
+          mcIdType node= conn[inode];
           if(node>=0)//avoid polyhedron separator
             {
               for (int idim=0; idim<dim; idim++)
@@ -2896,9 +3014,9 @@ DataArrayInt *MEDCouplingUMesh::getCellsInBoundingBox(const double *bbox, double
  * Warning 'elems' is incremented during the call so if elems is not empty before call returned elements will be
  * added in 'elems' parameter.
  */
-DataArrayInt *MEDCouplingUMesh::getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps)
+DataArrayIdType *MEDCouplingUMesh::getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps)
 {
-  MCAuto<DataArrayInt> elems=DataArrayInt::New(); elems->alloc(0,1);
+  MCAuto<DataArrayIdType> elems=DataArrayIdType::New(); elems->alloc(0,1);
   if(getMeshDimension()==-1)
     {
       elems->pushBackSilent(0);
@@ -2906,11 +3024,11 @@ DataArrayInt *MEDCouplingUMesh::getCellsInBoundingBox(const INTERP_KERNEL::Direc
     }
   int dim=getSpaceDimension();
   INTERP_KERNEL::AutoPtr<double> elem_bb=new double[2*dim];
-  const int* conn      = getNodalConnectivity()->getConstPointer();
-  const int* conn_index= getNodalConnectivityIndex()->getConstPointer();
+  const mcIdType* conn      = getNodalConnectivity()->getConstPointer();
+  const mcIdType* conn_index= getNodalConnectivityIndex()->getConstPointer();
   const double* coords = getCoords()->getConstPointer();
-  int nbOfCells=getNumberOfCells();
-  for ( int ielem=0; ielem<nbOfCells;ielem++ )
+  mcIdType nbOfCells=getNumberOfCells();
+  for ( mcIdType ielem=0; ielem<nbOfCells;ielem++ )
     {
       for (int i=0; i<dim; i++)
         {
@@ -2918,9 +3036,9 @@ DataArrayInt *MEDCouplingUMesh::getCellsInBoundingBox(const INTERP_KERNEL::Direc
           elem_bb[i*2+1]=-std::numeric_limits<double>::max();
         }
 
-      for (int inode=conn_index[ielem]+1; inode<conn_index[ielem+1]; inode++)//+1 due to offset of cell type.
+      for (mcIdType inode=conn_index[ielem]+1; inode<conn_index[ielem+1]; inode++)//+1 due to offset of cell type.
         {
-          int node= conn[inode];
+          mcIdType node= conn[inode];
           if(node>=0)//avoid polyhedron separator
             {
               for (int idim=0; idim<dim; idim++)
@@ -2948,11 +3066,10 @@ DataArrayInt *MEDCouplingUMesh::getCellsInBoundingBox(const INTERP_KERNEL::Direc
  *  \return INTERP_KERNEL::NormalizedCellType - enumeration item describing the cell type.
  *  \throw If \a cellId is invalid. Valid range is [0, \a this->getNumberOfCells() ).
  */
-INTERP_KERNEL::NormalizedCellType MEDCouplingUMesh::getTypeOfCell(int cellId) const
+INTERP_KERNEL::NormalizedCellType MEDCouplingUMesh::getTypeOfCell(mcIdType cellId) const
 {
-  const int *ptI=_nodal_connec_index->getConstPointer();
-  const int *pt=_nodal_connec->getConstPointer();
-  if(cellId>=0 && cellId<(int)_nodal_connec_index->getNbOfElems()-1)
+  const mcIdType *ptI(_nodal_connec_index->begin()),*pt(_nodal_connec->begin());
+  if(cellId<_nodal_connec_index->getNbOfElems()-1)
     return (INTERP_KERNEL::NormalizedCellType) pt[ptI[cellId]];
   else
     {
@@ -2970,20 +3087,20 @@ INTERP_KERNEL::NormalizedCellType MEDCouplingUMesh::getTypeOfCell(int cellId) co
  * \param [in] type the geometric type
  * \return cell ids in this having geometric type \a type.
  */
-DataArrayInt *MEDCouplingUMesh::giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const
+DataArrayIdType *MEDCouplingUMesh::giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const
 {
 
-  MCAuto<DataArrayInt> ret=DataArrayInt::New();
+  MCAuto<DataArrayIdType> ret=DataArrayIdType::New();
   ret->alloc(0,1);
   checkConnectivityFullyDefined();
-  int nbCells=getNumberOfCells();
+  mcIdType nbCells=getNumberOfCells();
   int mdim=getMeshDimension();
   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type);
-  if(mdim!=(int)cm.getDimension())
+  if(mdim!=ToIdType(cm.getDimension()))
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::giveCellsWithType : Mismatch between mesh dimension and dimension of the cell !");
-  const int *ptI=_nodal_connec_index->getConstPointer();
-  const int *pt=_nodal_connec->getConstPointer();
-  for(int i=0;i<nbCells;i++)
+  const mcIdType *ptI=_nodal_connec_index->getConstPointer();
+  const mcIdType *pt=_nodal_connec->getConstPointer();
+  for(mcIdType i=0;i<nbCells;i++)
     {
       if((INTERP_KERNEL::NormalizedCellType)pt[ptI[i]]==type)
         ret->pushBackSilent(i);
@@ -2994,13 +3111,11 @@ DataArrayInt *MEDCouplingUMesh::giveCellsWithType(INTERP_KERNEL::NormalizedCellT
 /*!
  * Returns nb of cells having the geometric type \a type. No throw if no cells in \a this has the geometric type \a type.
  */
-int MEDCouplingUMesh::getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const
+mcIdType MEDCouplingUMesh::getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const
 {
-  const int *ptI=_nodal_connec_index->getConstPointer();
-  const int *pt=_nodal_connec->getConstPointer();
-  int nbOfCells=getNumberOfCells();
-  int ret=0;
-  for(int i=0;i<nbOfCells;i++)
+  const mcIdType *ptI(_nodal_connec_index->begin()),*pt(_nodal_connec->begin());
+  mcIdType nbOfCells(getNumberOfCells()),ret(0);
+  for(mcIdType i=0;i<nbOfCells;i++)
     if((INTERP_KERNEL::NormalizedCellType) pt[ptI[i]]==type)
       ret++;
   return ret;
@@ -3015,11 +3130,10 @@ int MEDCouplingUMesh::getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType
  *         cleared before the appending.
  *  \throw If \a cellId is invalid. Valid range is [0, \a this->getNumberOfCells() ).
  */
-void MEDCouplingUMesh::getNodeIdsOfCell(int cellId, std::vector<int>& conn) const
+void MEDCouplingUMesh::getNodeIdsOfCell(mcIdType cellId, std::vector<mcIdType>& conn) const
 {
-  const int *ptI=_nodal_connec_index->getConstPointer();
-  const int *pt=_nodal_connec->getConstPointer();
-  for(const int *w=pt+ptI[cellId]+1;w!=pt+ptI[cellId+1];w++)
+  const mcIdType *ptI(_nodal_connec_index->begin()),*pt(_nodal_connec->begin());
+  for(const mcIdType *w=pt+ptI[cellId]+1;w!=pt+ptI[cellId+1];w++)
     if(*w>=0)
       conn.push_back(*w);
 }
@@ -3111,26 +3225,26 @@ std::string MEDCouplingUMesh::reprConnectivityOfThis() const
 }
 
 /*!
- * This method builds a newly allocated instance (with the same name than \a this) that the caller has the responsability to deal with.
+ * This method builds a newly allocated instance (with the same name than \a this) that the caller has the responsibility to deal with.
  * This method returns an instance with all arrays allocated (connectivity, connectivity index, coordinates)
  * but with length of these arrays set to 0. It allows to define an "empty" mesh (with nor cells nor nodes but compliant with
  * some algos).
- * 
+ *
  * This method expects that \a this has a mesh dimension set and higher or equal to 0. If not an exception will be thrown.
  * This method analyzes the 3 arrays of \a this. For each the following behaviour is done : if the array is null a newly one is created
  * with number of tuples set to 0, if not the array is taken as this in the returned instance.
  */
-MEDCouplingUMesh *MEDCouplingUMesh::buildSetInstanceFromThis(int spaceDim) const
+MEDCouplingUMesh *MEDCouplingUMesh::buildSetInstanceFromThis(std::size_t spaceDim) const
 {
   int mdim=getMeshDimension();
   if(mdim<0)
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildSetInstanceFromThis : invalid mesh dimension ! Should be >= 0 !");
   MCAuto<MEDCouplingUMesh> ret=MEDCouplingUMesh::New(getName(),mdim);
-  MCAuto<DataArrayInt> tmp1,tmp2;
+  MCAuto<DataArrayIdType> tmp1,tmp2;
   bool needToCpyCT=true;
   if(!_nodal_connec)
     {
-      tmp1=DataArrayInt::New(); tmp1->alloc(0,1);
+      tmp1=DataArrayIdType::New(); tmp1->alloc(0,1);
       needToCpyCT=false;
     }
   else
@@ -3140,7 +3254,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildSetInstanceFromThis(int spaceDim) const
     }
   if(!_nodal_connec_index)
     {
-      tmp2=DataArrayInt::New(); tmp2->alloc(1,1); tmp2->setIJ(0,0,0);
+      tmp2=DataArrayIdType::New(); tmp2->alloc(1,1); tmp2->setIJ(0,0,0);
       needToCpyCT=false;
     }
   else
@@ -3161,53 +3275,34 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildSetInstanceFromThis(int spaceDim) const
   return ret.retn();
 }
 
-void MEDCouplingUMesh::reprConnectivityOfThisLL(std::ostringstream& stream) const
-{
-  if(_nodal_connec!=0 && _nodal_connec_index!=0)
-    {
-      int nbOfCells=getNumberOfCells();
-      const int *c=_nodal_connec->getConstPointer();
-      const int *ci=_nodal_connec_index->getConstPointer();
-      for(int i=0;i<nbOfCells;i++)
-        {
-          const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)c[ci[i]]);
-          stream << "Cell #" << i << " " << cm.getRepr() << " : ";
-          std::copy(c+ci[i]+1,c+ci[i+1],std::ostream_iterator<int>(stream," "));
-          stream << "\n";
-        }
-    }
-  else
-    stream << "Connectivity not defined !\n";
-}
-
-int MEDCouplingUMesh::getNumberOfNodesInCell(int cellId) const
+mcIdType MEDCouplingUMesh::getNumberOfNodesInCell(mcIdType cellId) const
 {
-  const int *ptI=_nodal_connec_index->getConstPointer();
-  const int *pt=_nodal_connec->getConstPointer();
+  const mcIdType *ptI=_nodal_connec_index->getConstPointer();
+  const mcIdType *pt=_nodal_connec->getConstPointer();
   if(pt[ptI[cellId]]!=INTERP_KERNEL::NORM_POLYHED)
     return ptI[cellId+1]-ptI[cellId]-1;
   else
-    return (int)std::count_if(pt+ptI[cellId]+1,pt+ptI[cellId+1],std::bind2nd(std::not_equal_to<int>(),-1));
+    return ToIdType(std::count_if(pt+ptI[cellId]+1,pt+ptI[cellId+1],std::bind(std::not_equal_to<mcIdType>(),std::placeholders::_1,-1)));
 }
 
 /*!
  * Returns types of cells of the specified part of \a this mesh.
- * This method avoids computing sub-mesh explicitely to get its types.
+ * This method avoids computing sub-mesh explicitly to get its types.
  *  \param [in] begin - an array of cell ids of interest.
  *  \param [in] end - the end of \a begin, i.e. a pointer to its (last+1)-th element.
  *  \return std::set<INTERP_KERNEL::NormalizedCellType> - a set of enumeration items
- *         describing the cell types. 
+ *         describing the cell types.
  *  \throw If the coordinates array is not set.
  *  \throw If the nodal connectivity of cells is not defined.
  *  \sa getAllGeoTypes()
  */
-std::set<INTERP_KERNEL::NormalizedCellType> MEDCouplingUMesh::getTypesOfPart(const int *begin, const int *end) const
+std::set<INTERP_KERNEL::NormalizedCellType> MEDCouplingUMesh::getTypesOfPart(const mcIdType *begin, const mcIdType *end) const
 {
   checkFullyDefined();
   std::set<INTERP_KERNEL::NormalizedCellType> ret;
-  const int *conn=_nodal_connec->getConstPointer();
-  const int *connIndex=_nodal_connec_index->getConstPointer();
-  for(const int *w=begin;w!=end;w++)
+  const mcIdType *conn=_nodal_connec->getConstPointer();
+  const mcIdType *connIndex=_nodal_connec_index->getConstPointer();
+  for(const mcIdType *w=begin;w!=end;w++)
     ret.insert((INTERP_KERNEL::NormalizedCellType)conn[connIndex[*w]]);
   return ret;
 }
@@ -3215,18 +3310,18 @@ std::set<INTERP_KERNEL::NormalizedCellType> MEDCouplingUMesh::getTypesOfPart(con
 /*!
  * Defines the nodal connectivity using given connectivity arrays in \ref numbering-indirect format.
  * Optionally updates
- * a set of types of cells constituting \a this mesh. 
+ * a set of types of cells constituting \a this mesh.
  * This method is for advanced users having prepared their connectivity before. For
  * more info on using this method see \ref MEDCouplingUMeshAdvBuild.
- *  \param [in] conn - the nodal connectivity array. 
+ *  \param [in] conn - the nodal connectivity array.
  *  \param [in] connIndex - the nodal connectivity index array.
  *  \param [in] isComputingTypes - if \c true, the set of types constituting \a this
  *         mesh is updated.
  */
-void MEDCouplingUMesh::setConnectivity(DataArrayInt *conn, DataArrayInt *connIndex, bool isComputingTypes)
+void MEDCouplingUMesh::setConnectivity(DataArrayIdType *conn, DataArrayIdType *connIndex, bool isComputingTypes)
 {
-  DataArrayInt::SetArrayIn(conn,_nodal_connec);
-  DataArrayInt::SetArrayIn(connIndex,_nodal_connec_index);
+  DataArrayIdType::SetArrayIn(conn,_nodal_connec);
+  DataArrayIdType::SetArrayIn(connIndex,_nodal_connec_index);
   if(isComputingTypes)
     computeTypes();
   declareAsNew();
@@ -3236,14 +3331,14 @@ void MEDCouplingUMesh::setConnectivity(DataArrayInt *conn, DataArrayInt *connInd
  * Copy constructor. If 'deepCopy' is false \a this is a shallow copy of other.
  * If 'deeCpy' is true all arrays (coordinates and connectivities) are deeply copied.
  */
-MEDCouplingUMesh::MEDCouplingUMesh(const MEDCouplingUMesh& other, bool deepCopy):MEDCouplingPointSet(other,deepCopy),_mesh_dim(other._mesh_dim),
+MEDCouplingUMesh::MEDCouplingUMesh(const MEDCouplingUMesh& other, bool deepCpy):MEDCouplingPointSet(other,deepCpy),_mesh_dim(other._mesh_dim),
     _nodal_connec(0),_nodal_connec_index(0),
     _types(other._types)
 {
   if(other._nodal_connec)
-    _nodal_connec=other._nodal_connec->performCopyOrIncrRef(deepCopy);
+    _nodal_connec=other._nodal_connec->performCopyOrIncrRef(deepCpy);
   if(other._nodal_connec_index)
-    _nodal_connec_index=other._nodal_connec_index->performCopyOrIncrRef(deepCopy);
+    _nodal_connec_index=other._nodal_connec_index->performCopyOrIncrRef(deepCpy);
 }
 
 MEDCouplingUMesh::~MEDCouplingUMesh()
@@ -3263,31 +3358,14 @@ void MEDCouplingUMesh::computeTypes()
   ComputeAllTypesInternal(_types,_nodal_connec,_nodal_connec_index);
 }
 
-/*!
- * This method checks that all arrays are set. If yes nothing done if no an exception is thrown.
- */
-void MEDCouplingUMesh::checkFullyDefined() const
-{
-  if(!_nodal_connec_index || !_nodal_connec || !_coords)
-    throw INTERP_KERNEL::Exception("Reverse nodal connectivity computation requires full connectivity and coordinates set in unstructured mesh.");
-}
-
-/*!
- * This method checks that all connectivity arrays are set. If yes nothing done if no an exception is thrown.
- */
-void MEDCouplingUMesh::checkConnectivityFullyDefined() const
-{
-  if(!_nodal_connec_index || !_nodal_connec)
-    throw INTERP_KERNEL::Exception("Reverse nodal connectivity computation requires full connectivity set in unstructured mesh.");
-}
 
 /*!
- * Returns a number of cells constituting \a this mesh. 
- *  \return int - the number of cells in \a this mesh.
+ * Returns a number of cells constituting \a this mesh.
+ *  \return mcIdType - the number of cells in \a this mesh.
  *  \throw If the nodal connectivity of cells is not defined.
  */
-int MEDCouplingUMesh::getNumberOfCells() const
-{ 
+mcIdType MEDCouplingUMesh::getNumberOfCells() const
+{
   if(_nodal_connec_index)
     return _nodal_connec_index->getNumberOfTuples()-1;
   else
@@ -3314,9 +3392,9 @@ int MEDCouplingUMesh::getMeshDimension() const
  * Returns a length of the nodal connectivity array.
  * This method is for test reason. Normally the integer returned is not useable by
  * user.  For more info see \ref MEDCouplingUMeshNodalConnectivity.
- *  \return int - the length of the nodal connectivity array.
+ *  \return mcIdType - the length of the nodal connectivity array.
  */
-int MEDCouplingUMesh::getNodalConnectivityArrayLen() const
+mcIdType MEDCouplingUMesh::getNodalConnectivityArrayLen() const
 {
   return _nodal_connec->getNbOfElems();
 }
@@ -3324,10 +3402,10 @@ int MEDCouplingUMesh::getNodalConnectivityArrayLen() const
 /*!
  * First step of serialization process. Used by ParaMEDMEM and MEDCouplingCorba to transfert data between process.
  */
-void MEDCouplingUMesh::getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const
+void MEDCouplingUMesh::getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<mcIdType>& tinyInfo, std::vector<std::string>& littleStrings) const
 {
   MEDCouplingPointSet::getTinySerializationInformation(tinyInfoD,tinyInfo,littleStrings);
-  tinyInfo.push_back(getMeshDimension());
+  tinyInfo.push_back(ToIdType(getMeshDimension()));
   tinyInfo.push_back(getNumberOfCells());
   if(_nodal_connec)
     tinyInfo.push_back(getNodalConnectivityArrayLen());
@@ -3338,7 +3416,7 @@ void MEDCouplingUMesh::getTinySerializationInformation(std::vector<double>& tiny
 /*!
  * First step of unserialization process.
  */
-bool MEDCouplingUMesh::isEmptyMesh(const std::vector<int>& tinyInfo) const
+bool MEDCouplingUMesh::isEmptyMesh(const std::vector<mcIdType>& tinyInfo) const
 {
   return tinyInfo[6]<=0;
 }
@@ -3346,11 +3424,11 @@ bool MEDCouplingUMesh::isEmptyMesh(const std::vector<int>& tinyInfo) const
 /*!
  * Second step of serialization process.
  * \param tinyInfo must be equal to the result given by getTinySerializationInformation method.
- * \param a1
- * \param a2
- * \param littleStrings
+ * \param a1 DataArrayDouble
+ * \param a2 DataArrayDouble
+ * \param littleStrings string vector
  */
-void MEDCouplingUMesh::resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const
+void MEDCouplingUMesh::resizeForUnserialization(const std::vector<mcIdType>& tinyInfo, DataArrayIdType *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const
 {
   MEDCouplingPointSet::resizeForUnserialization(tinyInfo,a1,a2,littleStrings);
   if(tinyInfo[5]!=-1)
@@ -3360,16 +3438,16 @@ void MEDCouplingUMesh::resizeForUnserialization(const std::vector<int>& tinyInfo
 /*!
  * Third and final step of serialization process.
  */
-void MEDCouplingUMesh::serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const
+void MEDCouplingUMesh::serialize(DataArrayIdType *&a1, DataArrayDouble *&a2) const
 {
   MEDCouplingPointSet::serialize(a1,a2);
   if(getMeshDimension()>-1)
     {
-      a1=DataArrayInt::New();
+      a1=DataArrayIdType::New();
       a1->alloc(getNodalConnectivityArrayLen()+getNumberOfCells()+1,1);
-      int *ptA1=a1->getPointer();
-      const int *conn=getNodalConnectivity()->getConstPointer();
-      const int *index=getNodalConnectivityIndex()->getConstPointer();
+      mcIdType *ptA1=a1->getPointer();
+      const mcIdType *conn=getNodalConnectivity()->getConstPointer();
+      const mcIdType *index=getNodalConnectivityIndex()->getConstPointer();
       ptA1=std::copy(index,index+getNumberOfCells()+1,ptA1);
       std::copy(conn,conn+getNodalConnectivityArrayLen(),ptA1);
     }
@@ -3381,114 +3459,25 @@ void MEDCouplingUMesh::serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const
  * Second and final unserialization process.
  * \param tinyInfo must be equal to the result given by getTinySerializationInformation method.
  */
-void MEDCouplingUMesh::unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector<std::string>& littleStrings)
+void MEDCouplingUMesh::unserialization(const std::vector<double>& tinyInfoD, const std::vector<mcIdType>& tinyInfo, const DataArrayIdType *a1, DataArrayDouble *a2, const std::vector<std::string>& littleStrings)
 {
   MEDCouplingPointSet::unserialization(tinyInfoD,tinyInfo,a1,a2,littleStrings);
-  setMeshDimension(tinyInfo[5]);
+  setMeshDimension(FromIdType<int>(tinyInfo[5]));
   if(tinyInfo[7]!=-1)
     {
       // Connectivity
-      const int *recvBuffer=a1->getConstPointer();
-      MCAuto<DataArrayInt> myConnecIndex=DataArrayInt::New();
+      const mcIdType *recvBuffer=a1->getConstPointer();
+      MCAuto<DataArrayIdType> myConnecIndex=DataArrayIdType::New();
       myConnecIndex->alloc(tinyInfo[6]+1,1);
       std::copy(recvBuffer,recvBuffer+tinyInfo[6]+1,myConnecIndex->getPointer());
-      MCAuto<DataArrayInt> myConnec=DataArrayInt::New();
+      MCAuto<DataArrayIdType> myConnec=DataArrayIdType::New();
       myConnec->alloc(tinyInfo[7],1);
       std::copy(recvBuffer+tinyInfo[6]+1,recvBuffer+tinyInfo[6]+1+tinyInfo[7],myConnec->getPointer());
       setConnectivity(myConnec, myConnecIndex);
     }
 }
 
-/*!
- * This is the low algorithm of MEDCouplingUMesh::buildPartOfMySelfSlice.
- * CellIds are given using range specified by a start an end and step.
- */
-MEDCouplingUMesh *MEDCouplingUMesh::buildPartOfMySelfKeepCoordsSlice(int start, int end, int step) const
-{
-  checkFullyDefined();
-  int ncell=getNumberOfCells();
-  MCAuto<MEDCouplingUMesh> ret=MEDCouplingUMesh::New();
-  ret->_mesh_dim=_mesh_dim;
-  ret->setCoords(_coords);
-  int newNbOfCells=DataArray::GetNumberOfItemGivenBESRelative(start,end,step,"MEDCouplingUMesh::buildPartOfMySelfKeepCoordsSlice : ");
-  MCAuto<DataArrayInt> newConnI=DataArrayInt::New(); newConnI->alloc(newNbOfCells+1,1);
-  int *newConnIPtr=newConnI->getPointer(); *newConnIPtr=0;
-  int work=start;
-  const int *conn=_nodal_connec->getConstPointer();
-  const int *connIndex=_nodal_connec_index->getConstPointer();
-  for(int i=0;i<newNbOfCells;i++,newConnIPtr++,work+=step)
-    {
-      if(work>=0 && work<ncell)
-        {
-          newConnIPtr[1]=newConnIPtr[0]+connIndex[work+1]-connIndex[work];
-        }
-      else
-        {
-          std::ostringstream oss; oss << "MEDCouplingUMesh::buildPartOfMySelfKeepCoordsSlice : On pos #" << i << " input cell id =" << work << " should be in [0," << ncell << ") !";
-          throw INTERP_KERNEL::Exception(oss.str());
-        }
-    }
-  MCAuto<DataArrayInt> newConn=DataArrayInt::New(); newConn->alloc(newConnIPtr[0],1);
-  int *newConnPtr=newConn->getPointer();
-  std::set<INTERP_KERNEL::NormalizedCellType> types;
-  work=start;
-  for(int i=0;i<newNbOfCells;i++,newConnIPtr++,work+=step)
-    {
-      types.insert((INTERP_KERNEL::NormalizedCellType)conn[connIndex[work]]);
-      newConnPtr=std::copy(conn+connIndex[work],conn+connIndex[work+1],newConnPtr);
-    }
-  ret->setConnectivity(newConn,newConnI,false);
-  ret->_types=types;
-  ret->copyTinyInfoFrom(this);
-  return ret.retn();
-}
 
-/*!
- * This is the low algorithm of MEDCouplingUMesh::buildPartOfMySelf.
- * Keeps from \a this only cells which constituing point id are in the ids specified by [ \a begin,\a end ).
- * The return newly allocated mesh will share the same coordinates as \a this.
- */
-MEDCouplingUMesh *MEDCouplingUMesh::buildPartOfMySelfKeepCoords(const int *begin, const int *end) const
-{
-  checkConnectivityFullyDefined();
-  int ncell=getNumberOfCells();
-  MCAuto<MEDCouplingUMesh> ret=MEDCouplingUMesh::New();
-  ret->_mesh_dim=_mesh_dim;
-  ret->setCoords(_coords);
-  std::size_t nbOfElemsRet=std::distance(begin,end);
-  int *connIndexRet=(int *)malloc((nbOfElemsRet+1)*sizeof(int));
-  connIndexRet[0]=0;
-  const int *conn=_nodal_connec->getConstPointer();
-  const int *connIndex=_nodal_connec_index->getConstPointer();
-  int newNbring=0;
-  for(const int *work=begin;work!=end;work++,newNbring++)
-    {
-      if(*work>=0 && *work<ncell)
-        connIndexRet[newNbring+1]=connIndexRet[newNbring]+connIndex[*work+1]-connIndex[*work];
-      else
-        {
-          free(connIndexRet);
-          std::ostringstream oss; oss << "MEDCouplingUMesh::buildPartOfMySelfKeepCoords : On pos #" << std::distance(begin,work) << " input cell id =" << *work << " should be in [0," << ncell << ") !";
-          throw INTERP_KERNEL::Exception(oss.str());
-        }
-    }
-  int *connRet=(int *)malloc(connIndexRet[nbOfElemsRet]*sizeof(int));
-  int *connRetWork=connRet;
-  std::set<INTERP_KERNEL::NormalizedCellType> types;
-  for(const int *work=begin;work!=end;work++)
-    {
-      types.insert((INTERP_KERNEL::NormalizedCellType)conn[connIndex[*work]]);
-      connRetWork=std::copy(conn+connIndex[*work],conn+connIndex[*work+1],connRetWork);
-    }
-  MCAuto<DataArrayInt> connRetArr=DataArrayInt::New();
-  connRetArr->useArray(connRet,true,C_DEALLOC,connIndexRet[nbOfElemsRet],1);
-  MCAuto<DataArrayInt> connIndexRetArr=DataArrayInt::New();
-  connIndexRetArr->useArray(connIndexRet,true,C_DEALLOC,(int)nbOfElemsRet+1,1);
-  ret->setConnectivity(connRetArr,connIndexRetArr,false);
-  ret->_types=types;
-  ret->copyTinyInfoFrom(this);
-  return ret.retn();
-}
 
 /*!
  * Returns a new MEDCouplingFieldDouble containing volumes of cells constituting \a this
@@ -3506,7 +3495,7 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::getMeasureField(bool isAbs) const
 {
   std::string name="MeasureOfMesh_";
   name+=getName();
-  int nbelem=getNumberOfCells();
+  mcIdType nbelem=getNumberOfCells();
   MCAuto<MEDCouplingFieldDouble> field=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
   field->setName(name);
   MCAuto<DataArrayDouble> array=DataArrayDouble::New();
@@ -3517,20 +3506,20 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::getMeasureField(bool isAbs) const
   field->synchronizeTimeWithMesh();
   if(getMeshDimension()!=-1)
     {
-      int ipt;
+      mcIdType ipt;
       INTERP_KERNEL::NormalizedCellType type;
       int dim_space=getSpaceDimension();
       const double *coords=getCoords()->getConstPointer();
-      const int *connec=getNodalConnectivity()->getConstPointer();
-      const int *connec_index=getNodalConnectivityIndex()->getConstPointer();
-      for(int iel=0;iel<nbelem;iel++)
+      const mcIdType *connec=getNodalConnectivity()->getConstPointer();
+      const mcIdType *connec_index=getNodalConnectivityIndex()->getConstPointer();
+      for(mcIdType iel=0;iel<nbelem;iel++)
         {
           ipt=connec_index[iel];
           type=(INTERP_KERNEL::NormalizedCellType)connec[ipt];
-          area_vol[iel]=INTERP_KERNEL::computeVolSurfOfCell2<int,INTERP_KERNEL::ALL_C_MODE>(type,connec+ipt+1,connec_index[iel+1]-ipt-1,coords,dim_space);
+          area_vol[iel]=INTERP_KERNEL::computeVolSurfOfCell2<mcIdType,INTERP_KERNEL::ALL_C_MODE>(type,connec+ipt+1,connec_index[iel+1]-ipt-1,coords,dim_space);
         }
       if(isAbs)
-        std::transform(area_vol,area_vol+nbelem,area_vol,std::ptr_fun<double,double>(fabs));
+        std::transform(area_vol,area_vol+nbelem,area_vol,[](double c){return fabs(c);});
     }
   else
     {
@@ -3552,38 +3541,38 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::getMeasureField(bool isAbs) const
  *  \param [in] end - the end of \a begin, i.e. a pointer to its (last+1)-th element.
  *  \return DataArrayDouble * - a new instance of DataArrayDouble. The caller is to
  *          delete this array using decrRef() as it is no more needed.
- * 
+ *
  *  \if ENABLE_EXAMPLES
  *  \ref cpp_mcumesh_getPartMeasureField "Here is a C++ example".<br>
  *  \ref  py_mcumesh_getPartMeasureField "Here is a Python example".
  *  \endif
  *  \sa getMeasureField()
  */
-DataArrayDouble *MEDCouplingUMesh::getPartMeasureField(bool isAbs, const int *begin, const int *end) const
+DataArrayDouble *MEDCouplingUMesh::getPartMeasureField(bool isAbs, const mcIdType *begin, const mcIdType *end) const
 {
   std::string name="PartMeasureOfMesh_";
   name+=getName();
-  int nbelem=(int)std::distance(begin,end);
+  std::size_t nbelem=std::distance(begin,end);
   MCAuto<DataArrayDouble> array=DataArrayDouble::New();
   array->setName(name);
   array->alloc(nbelem,1);
   double *area_vol=array->getPointer();
   if(getMeshDimension()!=-1)
     {
-      int ipt;
+      mcIdType ipt;
       INTERP_KERNEL::NormalizedCellType type;
       int dim_space=getSpaceDimension();
       const double *coords=getCoords()->getConstPointer();
-      const int *connec=getNodalConnectivity()->getConstPointer();
-      const int *connec_index=getNodalConnectivityIndex()->getConstPointer();
-      for(const int *iel=begin;iel!=end;iel++)
+      const mcIdType *connec=getNodalConnectivity()->getConstPointer();
+      const mcIdType *connec_index=getNodalConnectivityIndex()->getConstPointer();
+      for(const mcIdType *iel=begin;iel!=end;iel++)
         {
           ipt=connec_index[*iel];
           type=(INTERP_KERNEL::NormalizedCellType)connec[ipt];
-          *area_vol++=INTERP_KERNEL::computeVolSurfOfCell2<int,INTERP_KERNEL::ALL_C_MODE>(type,connec+ipt+1,connec_index[*iel+1]-ipt-1,coords,dim_space);
+          *area_vol++=INTERP_KERNEL::computeVolSurfOfCell2<mcIdType,INTERP_KERNEL::ALL_C_MODE>(type,connec+ipt+1,connec_index[*iel+1]-ipt-1,coords,dim_space);
         }
       if(isAbs)
-        std::transform(array->getPointer(),area_vol,array->getPointer(),std::ptr_fun<double,double>(fabs));
+        std::transform(array->getPointer(),area_vol,array->getPointer(),[](double c){return fabs(c);});
     }
   else
     {
@@ -3612,22 +3601,28 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::getMeasureFieldOnNode(bool isAbs) cons
   MCAuto<MEDCouplingFieldDouble> tmp=getMeasureField(isAbs);
   std::string name="MeasureOnNodeOfMesh_";
   name+=getName();
-  int nbNodes=getNumberOfNodes();
+  mcIdType nbNodes=getNumberOfNodes();
+  MCAuto<DataArrayDouble> nnpc;
+  {
+    MCAuto<DataArrayIdType> tmp2(computeNbOfNodesPerCell());
+    nnpc=tmp2->convertToDblArr();
+  }
+  std::for_each(nnpc->rwBegin(),nnpc->rwEnd(),[](double& v) { v=1./v; });
+  const double *nnpcPtr(nnpc->begin());
   MCAuto<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(ON_NODES);
-  double cst=1./((double)getMeshDimension()+1.);
   MCAuto<DataArrayDouble> array=DataArrayDouble::New();
   array->alloc(nbNodes,1);
   double *valsToFill=array->getPointer();
   std::fill(valsToFill,valsToFill+nbNodes,0.);
   const double *values=tmp->getArray()->getConstPointer();
-  MCAuto<DataArrayInt> da=DataArrayInt::New();
-  MCAuto<DataArrayInt> daInd=DataArrayInt::New();
+  MCAuto<DataArrayIdType> da=DataArrayIdType::New();
+  MCAuto<DataArrayIdType> daInd=DataArrayIdType::New();
   getReverseNodalConnectivity(da,daInd);
-  const int *daPtr=da->getConstPointer();
-  const int *daIPtr=daInd->getConstPointer();
-  for(int i=0;i<nbNodes;i++)
-    for(const int *cell=daPtr+daIPtr[i];cell!=daPtr+daIPtr[i+1];cell++)
-      valsToFill[i]+=cst*values[*cell];
+  const mcIdType *daPtr=da->getConstPointer();
+  const mcIdType *daIPtr=daInd->getConstPointer();
+  for(mcIdType i=0;i<nbNodes;i++)
+    for(const mcIdType *cell=daPtr+daIPtr[i];cell!=daPtr+daIPtr[i+1];cell++)
+      valsToFill[i]+=nnpcPtr[*cell]*values[*cell];
   ret->setMesh(this);
   ret->setArray(array);
   return ret.retn();
@@ -3638,10 +3633,10 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::getMeasureFieldOnNode(bool isAbs) cons
  * mesh. The returned normal vectors to each cell have a norm2 equal to 1.
  * The computed vectors have <em> this->getMeshDimension()+1 </em> components
  * and are normalized.
- * <br> \a this can be either 
- * - a  2D mesh in 2D or 3D space or 
+ * <br> \a this can be either
+ * - a  2D mesh in 2D or 3D space or
  * - an 1D mesh in 2D space.
- * 
+ *
  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble on
  *          cells and one time. The caller is to delete this field using decrRef() as
  *          it is no more needed.
@@ -3656,12 +3651,12 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::buildOrthogonalField() const
     throw INTERP_KERNEL::Exception("Expected a umesh with ( meshDim == 2 spaceDim == 2 or 3 ) or ( meshDim == 1 spaceDim == 2 ) !");
   MCAuto<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
   MCAuto<DataArrayDouble> array=DataArrayDouble::New();
-  int nbOfCells=getNumberOfCells();
+  mcIdType nbOfCells=getNumberOfCells();
   int nbComp=getMeshDimension()+1;
   array->alloc(nbOfCells,nbComp);
   double *vals=array->getPointer();
-  const int *connI=_nodal_connec_index->getConstPointer();
-  const int *conn=_nodal_connec->getConstPointer();
+  const mcIdType *connI=_nodal_connec_index->getConstPointer();
+  const mcIdType *conn=_nodal_connec->getConstPointer();
   const double *coords=_coords->getConstPointer();
   if(getMeshDimension()==2)
     {
@@ -3669,31 +3664,31 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::buildOrthogonalField() const
         {
           MCAuto<DataArrayDouble> loc=computeCellCenterOfMass();
           const double *locPtr=loc->getConstPointer();
-          for(int i=0;i<nbOfCells;i++,vals+=3)
+          for(mcIdType i=0;i<nbOfCells;i++,vals+=3)
             {
-              int offset=connI[i];
+              mcIdType offset=connI[i];
               INTERP_KERNEL::crossprod<3>(locPtr+3*i,coords+3*conn[offset+1],coords+3*conn[offset+2],vals);
               double n=INTERP_KERNEL::norm<3>(vals);
-              std::transform(vals,vals+3,vals,std::bind2nd(std::multiplies<double>(),1./n));
+              std::transform(vals,vals+3,vals,std::bind(std::multiplies<double>(),std::placeholders::_1,1./n));
             }
         }
       else
         {
           MCAuto<MEDCouplingFieldDouble> isAbs=getMeasureField(false);
           const double *isAbsPtr=isAbs->getArray()->begin();
-          for(int i=0;i<nbOfCells;i++,isAbsPtr++)
+          for(mcIdType i=0;i<nbOfCells;i++,isAbsPtr++)
             { vals[3*i]=0.; vals[3*i+1]=0.; vals[3*i+2]=*isAbsPtr>0.?1.:-1.; }
         }
     }
   else//meshdimension==1
     {
       double tmp[2];
-      for(int i=0;i<nbOfCells;i++)
+      for(mcIdType i=0;i<nbOfCells;i++)
         {
-          int offset=connI[i];
+          mcIdType offset=connI[i];
           std::transform(coords+2*conn[offset+2],coords+2*conn[offset+2]+2,coords+2*conn[offset+1],tmp,std::minus<double>());
           double n=INTERP_KERNEL::norm<2>(tmp);
-          std::transform(tmp,tmp+2,tmp,std::bind2nd(std::multiplies<double>(),1./n));
+          std::transform(tmp,tmp+2,tmp,std::bind(std::multiplies<double>(),std::placeholders::_1,1./n));
           *vals++=-tmp[1];
           *vals++=tmp[0];
         }
@@ -3708,10 +3703,10 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::buildOrthogonalField() const
  * Returns a new MEDCouplingFieldDouble holding normal vectors to specified cells of
  * \a this mesh. The computed vectors have <em> this->getMeshDimension()+1 </em> components
  * and are normalized.
- * <br> \a this can be either 
- * - a  2D mesh in 2D or 3D space or 
+ * <br> \a this can be either
+ * - a  2D mesh in 2D or 3D space or
  * - an 1D mesh in 2D space.
- * 
+ *
  * This method avoids building explicitly a part of \a this mesh to perform the work.
  *  \param [in] begin - an array of cell ids of interest.
  *  \param [in] end - the end of \a begin, i.e. a pointer to its (last+1)-th element.
@@ -3729,7 +3724,7 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::buildOrthogonalField() const
  *  \ref  py_mcumesh_buildPartOrthogonalField "Here is a Python example".
  *  \endif
  */
-MEDCouplingFieldDouble *MEDCouplingUMesh::buildPartOrthogonalField(const int *begin, const int *end) const
+MEDCouplingFieldDouble *MEDCouplingUMesh::buildPartOrthogonalField(const mcIdType *begin, const mcIdType *end) const
 {
   if((getMeshDimension()!=2) && (getMeshDimension()!=1 || getSpaceDimension()!=2))
     throw INTERP_KERNEL::Exception("Expected a umesh with ( meshDim == 2 spaceDim == 2 or 3 ) or ( meshDim == 1 spaceDim == 2 ) !");
@@ -3737,10 +3732,10 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::buildPartOrthogonalField(const int *be
   MCAuto<DataArrayDouble> array=DataArrayDouble::New();
   std::size_t nbelems=std::distance(begin,end);
   int nbComp=getMeshDimension()+1;
-  array->alloc((int)nbelems,nbComp);
+  array->alloc(nbelems,nbComp);
   double *vals=array->getPointer();
-  const int *connI=_nodal_connec_index->getConstPointer();
-  const int *conn=_nodal_connec->getConstPointer();
+  const mcIdType *connI=_nodal_connec_index->getConstPointer();
+  const mcIdType *conn=_nodal_connec->getConstPointer();
   const double *coords=_coords->getConstPointer();
   if(getMeshDimension()==2)
     {
@@ -3748,12 +3743,12 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::buildPartOrthogonalField(const int *be
         {
           MCAuto<DataArrayDouble> loc=getPartBarycenterAndOwner(begin,end);
           const double *locPtr=loc->getConstPointer();
-          for(const int *i=begin;i!=end;i++,vals+=3,locPtr+=3)
+          for(const mcIdType *i=begin;i!=end;i++,vals+=3,locPtr+=3)
             {
-              int offset=connI[*i];
+              mcIdType offset=connI[*i];
               INTERP_KERNEL::crossprod<3>(locPtr,coords+3*conn[offset+1],coords+3*conn[offset+2],vals);
               double n=INTERP_KERNEL::norm<3>(vals);
-              std::transform(vals,vals+3,vals,std::bind2nd(std::multiplies<double>(),1./n));
+              std::transform(vals,vals+3,vals,std::bind(std::multiplies<double>(),std::placeholders::_1,1./n));
             }
         }
       else
@@ -3765,12 +3760,12 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::buildPartOrthogonalField(const int *be
   else//meshdimension==1
     {
       double tmp[2];
-      for(const int *i=begin;i!=end;i++)
+      for(const mcIdType *i=begin;i!=end;i++)
         {
-          int offset=connI[*i];
+          mcIdType offset=connI[*i];
           std::transform(coords+2*conn[offset+2],coords+2*conn[offset+2]+2,coords+2*conn[offset+1],tmp,std::minus<double>());
           double n=INTERP_KERNEL::norm<2>(tmp);
-          std::transform(tmp,tmp+2,tmp,std::bind2nd(std::multiplies<double>(),1./n));
+          std::transform(tmp,tmp+2,tmp,std::bind(std::multiplies<double>(),std::placeholders::_1,1./n));
           *vals++=-tmp[1];
           *vals++=tmp[0];
         }
@@ -3801,14 +3796,14 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::buildDirectionVectorField() const
     throw INTERP_KERNEL::Exception("Expected a umesh with only NORM_SEG2 type of elements for buildDirectionVectorField !");
   MCAuto<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
   MCAuto<DataArrayDouble> array=DataArrayDouble::New();
-  int nbOfCells=getNumberOfCells();
+  mcIdType nbOfCells=getNumberOfCells();
   int spaceDim=getSpaceDimension();
   array->alloc(nbOfCells,spaceDim);
   double *pt=array->getPointer();
   const double *coo=getCoords()->getConstPointer();
-  std::vector<int> conn;
+  std::vector<mcIdType> conn;
   conn.reserve(2);
-  for(int i=0;i<nbOfCells;i++)
+  for(mcIdType i=0;i<nbOfCells;i++)
     {
       conn.resize(0);
       getNodeIdsOfCell(i,conn);
@@ -3822,7 +3817,7 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::buildDirectionVectorField() const
 
 /*!
  * Creates a 2D mesh by cutting \a this 3D mesh with a plane. In addition to the mesh,
- * returns a new DataArrayInt, of length equal to the number of 2D cells in the result
+ * returns a new DataArrayIdType, of length equal to the number of 2D cells in the result
  * mesh, holding, for each cell in the result mesh, an id of a 3D cell it comes
  * from. If a result face is shared by two 3D cells, then the face in included twice in
  * the result mesh.
@@ -3830,12 +3825,12 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::buildDirectionVectorField() const
  *  \param [in] vec - 3 components of a vector normal to the plane. Vector magnitude
  *         must be greater than 1e-6.
  *  \param [in] eps - half-thickness of the plane.
- *  \param [out] cellIds - a new instance of DataArrayInt holding ids of 3D cells
+ *  \param [out] cellIds - a new instance of DataArrayIdType holding ids of 3D cells
  *         producing correspondent 2D cells. The caller is to delete this array
  *         using decrRef() as it is no more needed.
  *  \return MEDCouplingUMesh * - a new instance of MEDCouplingUMesh. This mesh does
  *         not share the node coordinates array with \a this mesh. The caller is to
- *         delete this mesh using decrRef() as it is no more needed.  
+ *         delete this mesh 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 \a this->getMeshDimension() != 3 or \a this->getSpaceDimension() != 3.
@@ -3843,38 +3838,42 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::buildDirectionVectorField() const
  *  \throw If the plane does not intersect any 3D cell of \a this mesh.
  *  \throw If \a this includes quadratic cells.
  */
-MEDCouplingUMesh *MEDCouplingUMesh::buildSlice3D(const double *origin, const double *vec, double eps, DataArrayInt *&cellIds) const
+MEDCouplingUMesh *MEDCouplingUMesh::buildSlice3D(const double *origin, const double *vec, double eps, DataArrayIdType *&cellIds) const
 {
   checkFullyDefined();
   if(getMeshDimension()!=3 || getSpaceDimension()!=3)
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildSlice3D works on umeshes with meshdim equal to 3 and spaceDim equal to 3 too!");
-  MCAuto<DataArrayInt> candidates=getCellIdsCrossingPlane(origin,vec,eps);
+  MCAuto<DataArrayIdType> candidates=getCellIdsCrossingPlane(origin,vec,eps);
   if(candidates->empty())
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildSlice3D : No 3D cells in this intercepts the specified plane considering bounding boxes !");
-  std::vector<int> nodes;
-  DataArrayInt *cellIds1D=0;
+  std::vector<mcIdType> nodes;
+  DataArrayIdType *cellIds1D=0;
   MCAuto<MEDCouplingUMesh> subMesh=static_cast<MEDCouplingUMesh*>(buildPartOfMySelf(candidates->begin(),candidates->end(),false));
   subMesh->findNodesOnPlane(origin,vec,eps,nodes);
-  MCAuto<DataArrayInt> desc1=DataArrayInt::New(),desc2=DataArrayInt::New();
-  MCAuto<DataArrayInt> descIndx1=DataArrayInt::New(),descIndx2=DataArrayInt::New();
-  MCAuto<DataArrayInt> revDesc1=DataArrayInt::New(),revDesc2=DataArrayInt::New();
-  MCAuto<DataArrayInt> revDescIndx1=DataArrayInt::New(),revDescIndx2=DataArrayInt::New();
+  MCAuto<DataArrayIdType> desc1=DataArrayIdType::New(),desc2=DataArrayIdType::New();
+  MCAuto<DataArrayIdType> descIndx1=DataArrayIdType::New(),descIndx2=DataArrayIdType::New();
+  MCAuto<DataArrayIdType> revDesc1=DataArrayIdType::New(),revDesc2=DataArrayIdType::New();
+  MCAuto<DataArrayIdType> revDescIndx1=DataArrayIdType::New(),revDescIndx2=DataArrayIdType::New();
   MCAuto<MEDCouplingUMesh> mDesc2=subMesh->buildDescendingConnectivity(desc2,descIndx2,revDesc2,revDescIndx2);//meshDim==2 spaceDim==3
   revDesc2=0; revDescIndx2=0;
   MCAuto<MEDCouplingUMesh> mDesc1=mDesc2->buildDescendingConnectivity(desc1,descIndx1,revDesc1,revDescIndx1);//meshDim==1 spaceDim==3
   revDesc1=0; revDescIndx1=0;
-  mDesc1->fillCellIdsToKeepFromNodeIds(&nodes[0],&nodes[0]+nodes.size(),true,cellIds1D);
-  MCAuto<DataArrayInt> cellIds1DTmp(cellIds1D);
+  //Marking all 1D cells that contained at least one node located on the plane
+  //the intersection between those cells and the plane, which consist of the nodes previously tagged, thus don't need to be computed afterwards
+  //(if said intersection is computed in MEDCouplingUMesh::split3DCurveWithPlane, then we might create additional nodes
+  //due to accuracy errors when the needed nodes already exist)
+  mDesc1->fillCellIdsToKeepFromNodeIds(&nodes[0],&nodes[0]+nodes.size(),false,cellIds1D);
+  MCAuto<DataArrayIdType> cellIds1DTmp(cellIds1D);
   //
-  std::vector<int> cut3DCurve(mDesc1->getNumberOfCells(),-2);
-  for(const int *it=cellIds1D->begin();it!=cellIds1D->end();it++)
+  std::vector<mcIdType> cut3DCurve(mDesc1->getNumberOfCells(),-2);
+  for(const mcIdType *it=cellIds1D->begin();it!=cellIds1D->end();it++)
     cut3DCurve[*it]=-1;
   mDesc1->split3DCurveWithPlane(origin,vec,eps,cut3DCurve);
-  std::vector< std::pair<int,int> > cut3DSurf(mDesc2->getNumberOfCells());
+  std::vector< std::pair<mcIdType,mcIdType> > cut3DSurf(mDesc2->getNumberOfCells());
   AssemblyForSplitFrom3DCurve(cut3DCurve,nodes,mDesc2->getNodalConnectivity()->getConstPointer(),mDesc2->getNodalConnectivityIndex()->getConstPointer(),
                               mDesc1->getNodalConnectivity()->getConstPointer(),mDesc1->getNodalConnectivityIndex()->getConstPointer(),
                               desc1->getConstPointer(),descIndx1->getConstPointer(),cut3DSurf);
-  MCAuto<DataArrayInt> conn(DataArrayInt::New()),connI(DataArrayInt::New()),cellIds2(DataArrayInt::New());
+  MCAuto<DataArrayIdType> conn(DataArrayIdType::New()),connI(DataArrayIdType::New()),cellIds2(DataArrayIdType::New());
   connI->pushBackSilent(0); conn->alloc(0,1); cellIds2->alloc(0,1);
   subMesh->assemblyForSplitFrom3DSurf(cut3DSurf,desc2->getConstPointer(),descIndx2->getConstPointer(),conn,connI,cellIds2);
   if(cellIds2->empty())
@@ -3888,20 +3887,20 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildSlice3D(const double *origin, const dou
 
 /*!
  * Creates an 1D mesh by cutting \a this 2D mesh in 3D space with a plane. In
-addition to the mesh, returns a new DataArrayInt, of length equal to the number of 1D cells in the result mesh, holding, for each cell in the result mesh, an id of a 2D cell it comes
+addition to the mesh, returns a new DataArrayIdType, of length equal to the number of 1D cells in the result mesh, holding, for each cell in the result mesh, an id of a 2D cell it comes
 from. If a result segment is shared by two 2D cells, then the segment in included twice in
 the result mesh.
  *  \param [in] origin - 3 components of a point defining location of the plane.
  *  \param [in] vec - 3 components of a vector normal to the plane. Vector magnitude
  *         must be greater than 1e-6.
  *  \param [in] eps - half-thickness of the plane.
- *  \param [out] cellIds - a new instance of DataArrayInt holding ids of faces
+ *  \param [out] cellIds - a new instance of DataArrayIdType holding ids of faces
  *         producing correspondent segments. The caller is to delete this array
  *         using decrRef() as it is no more needed.
  *  \return MEDCouplingUMesh * - a new instance of MEDCouplingUMesh. This is an 1D
  *         mesh in 3D space. This mesh does not share the node coordinates array with
  *         \a this mesh. The caller is to delete this mesh using decrRef() as it is
- *         no more needed. 
+ *         no more needed.
  *  \throw If the coordinates array is not set.
  *  \throw If the nodal connectivity of cells is not defined.
  *  \throw If \a this->getMeshDimension() != 2 or \a this->getSpaceDimension() != 3.
@@ -3909,54 +3908,54 @@ the result mesh.
  *  \throw If the plane does not intersect any 2D cell of \a this mesh.
  *  \throw If \a this includes quadratic cells.
  */
-MEDCouplingUMesh *MEDCouplingUMesh::buildSlice3DSurf(const double *origin, const double *vec, double eps, DataArrayInt *&cellIds) const
+MEDCouplingUMesh *MEDCouplingUMesh::buildSlice3DSurf(const double *origin, const double *vec, double eps, DataArrayIdType *&cellIds) const
 {
   checkFullyDefined();
   if(getMeshDimension()!=2 || getSpaceDimension()!=3)
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildSlice3DSurf works on umeshes with meshdim equal to 2 and spaceDim equal to 3 !");
-  MCAuto<DataArrayInt> candidates(getCellIdsCrossingPlane(origin,vec,eps));
+  MCAuto<DataArrayIdType> candidates(getCellIdsCrossingPlane(origin,vec,eps));
   if(candidates->empty())
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildSlice3DSurf : No 3D surf cells in this intercepts the specified plane considering bounding boxes !");
-  std::vector<int> nodes;
-  DataArrayInt *cellIds1D(0);
+  std::vector<mcIdType> nodes;
+  DataArrayIdType *cellIds1D(0);
   MCAuto<MEDCouplingUMesh> subMesh(buildPartOfMySelf(candidates->begin(),candidates->end(),false));
   subMesh->findNodesOnPlane(origin,vec,eps,nodes);
-  MCAuto<DataArrayInt> desc1(DataArrayInt::New()),descIndx1(DataArrayInt::New()),revDesc1(DataArrayInt::New()),revDescIndx1(DataArrayInt::New());
+  MCAuto<DataArrayIdType> desc1(DataArrayIdType::New()),descIndx1(DataArrayIdType::New()),revDesc1(DataArrayIdType::New()),revDescIndx1(DataArrayIdType::New());
   MCAuto<MEDCouplingUMesh> mDesc1(subMesh->buildDescendingConnectivity(desc1,descIndx1,revDesc1,revDescIndx1));//meshDim==1 spaceDim==3
   mDesc1->fillCellIdsToKeepFromNodeIds(&nodes[0],&nodes[0]+nodes.size(),true,cellIds1D);
-  MCAuto<DataArrayInt> cellIds1DTmp(cellIds1D);
+  MCAuto<DataArrayIdType> cellIds1DTmp(cellIds1D);
   //
-  std::vector<int> cut3DCurve(mDesc1->getNumberOfCells(),-2);
-  for(const int *it=cellIds1D->begin();it!=cellIds1D->end();it++)
+  std::vector<mcIdType> cut3DCurve(mDesc1->getNumberOfCells(),-2);
+  for(const mcIdType *it=cellIds1D->begin();it!=cellIds1D->end();it++)
     cut3DCurve[*it]=-1;
   mDesc1->split3DCurveWithPlane(origin,vec,eps,cut3DCurve);
-  int ncellsSub=subMesh->getNumberOfCells();
-  std::vector< std::pair<int,int> > cut3DSurf(ncellsSub);
+  mcIdType ncellsSub=subMesh->getNumberOfCells();
+  std::vector< std::pair<mcIdType,mcIdType> > cut3DSurf(ncellsSub);
   AssemblyForSplitFrom3DCurve(cut3DCurve,nodes,subMesh->getNodalConnectivity()->getConstPointer(),subMesh->getNodalConnectivityIndex()->getConstPointer(),
                               mDesc1->getNodalConnectivity()->getConstPointer(),mDesc1->getNodalConnectivityIndex()->getConstPointer(),
                               desc1->getConstPointer(),descIndx1->getConstPointer(),cut3DSurf);
-  MCAuto<DataArrayInt> conn(DataArrayInt::New()),connI(DataArrayInt::New()),cellIds2(DataArrayInt::New()); connI->pushBackSilent(0);
+  MCAuto<DataArrayIdType> conn(DataArrayIdType::New()),connI(DataArrayIdType::New()),cellIds2(DataArrayIdType::New()); connI->pushBackSilent(0);
   conn->alloc(0,1);
-  const int *nodal=subMesh->getNodalConnectivity()->getConstPointer();
-  const int *nodalI=subMesh->getNodalConnectivityIndex()->getConstPointer();
-  for(int i=0;i<ncellsSub;i++)
+  const mcIdType *nodal=subMesh->getNodalConnectivity()->getConstPointer();
+  const mcIdType *nodalI=subMesh->getNodalConnectivityIndex()->getConstPointer();
+  for(mcIdType i=0;i<ncellsSub;i++)
     {
       if(cut3DSurf[i].first!=-1 && cut3DSurf[i].second!=-1)
         {
           if(cut3DSurf[i].first!=-2)
             {
-              conn->pushBackSilent((int)INTERP_KERNEL::NORM_SEG2); conn->pushBackSilent(cut3DSurf[i].first); conn->pushBackSilent(cut3DSurf[i].second);
+              conn->pushBackSilent(ToIdType(INTERP_KERNEL::NORM_SEG2)); conn->pushBackSilent(cut3DSurf[i].first); conn->pushBackSilent(cut3DSurf[i].second);
               connI->pushBackSilent(conn->getNumberOfTuples());
               cellIds2->pushBackSilent(i);
             }
           else
             {
-              int cellId3DSurf=cut3DSurf[i].second;
-              int offset=nodalI[cellId3DSurf]+1;
-              int nbOfEdges=nodalI[cellId3DSurf+1]-offset;
-              for(int j=0;j<nbOfEdges;j++)
+              mcIdType cellId3DSurf=cut3DSurf[i].second;
+              mcIdType offset=nodalI[cellId3DSurf]+1;
+              mcIdType nbOfEdges=nodalI[cellId3DSurf+1]-offset;
+              for(mcIdType j=0;j<nbOfEdges;j++)
                 {
-                  conn->pushBackSilent((int)INTERP_KERNEL::NORM_SEG2); conn->pushBackSilent(nodal[offset+j]); conn->pushBackSilent(nodal[offset+(j+1)%nbOfEdges]);
+                  conn->pushBackSilent(ToIdType(INTERP_KERNEL::NORM_SEG2)); conn->pushBackSilent(nodal[offset+j]); conn->pushBackSilent(nodal[offset+(j+1)%nbOfEdges]);
                   connI->pushBackSilent(conn->getNumberOfTuples());
                   cellIds2->pushBackSilent(cellId3DSurf);
                 }
@@ -3980,47 +3979,52 @@ MCAuto<MEDCouplingUMesh> MEDCouplingUMesh::clipSingle3DCellByPlane(const double
   if(getNumberOfCells()!=1)
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::clipSingle3DCellByPlane works only on mesh containing exactly one cell !");
   //
-  std::vector<int> nodes;
+  std::vector<mcIdType> nodes;
   findNodesOnPlane(origin,vec,eps,nodes);
-  MCAuto<DataArrayInt> desc1(DataArrayInt::New()),desc2(DataArrayInt::New()),descIndx1(DataArrayInt::New()),descIndx2(DataArrayInt::New()),revDesc1(DataArrayInt::New()),revDesc2(DataArrayInt::New()),revDescIndx1(DataArrayInt::New()),revDescIndx2(DataArrayInt::New());
+  MCAuto<DataArrayIdType> desc1(DataArrayIdType::New()),desc2(DataArrayIdType::New()),descIndx1(DataArrayIdType::New()),descIndx2(DataArrayIdType::New()),revDesc1(DataArrayIdType::New()),revDesc2(DataArrayIdType::New()),revDescIndx1(DataArrayIdType::New()),revDescIndx2(DataArrayIdType::New());
   MCAuto<MEDCouplingUMesh> mDesc2(buildDescendingConnectivity(desc2,descIndx2,revDesc2,revDescIndx2));//meshDim==2 spaceDim==3
   revDesc2=0; revDescIndx2=0;
   MCAuto<MEDCouplingUMesh> mDesc1(mDesc2->buildDescendingConnectivity(desc1,descIndx1,revDesc1,revDescIndx1));//meshDim==1 spaceDim==3
   revDesc1=0; revDescIndx1=0;
-  DataArrayInt *cellIds1D(0);
+  DataArrayIdType *cellIds1D(0);
   mDesc1->fillCellIdsToKeepFromNodeIds(&nodes[0],&nodes[0]+nodes.size(),true,cellIds1D);
-  MCAuto<DataArrayInt> cellIds1DTmp(cellIds1D);
-  std::vector<int> cut3DCurve(mDesc1->getNumberOfCells(),-2);
-  for(const int *it=cellIds1D->begin();it!=cellIds1D->end();it++)
+  MCAuto<DataArrayIdType> cellIds1DTmp(cellIds1D);
+  std::vector<mcIdType> cut3DCurve(mDesc1->getNumberOfCells(),-2);
+  for(const mcIdType *it=cellIds1D->begin();it!=cellIds1D->end();it++)
     cut3DCurve[*it]=-1;
-  mDesc1->split3DCurveWithPlane(origin,vec,eps,cut3DCurve);
-  std::vector< std::pair<int,int> > cut3DSurf(mDesc2->getNumberOfCells());
+  bool sameNbNodes;
+  {
+    mcIdType oldNbNodes(mDesc1->getNumberOfNodes());
+    mDesc1->split3DCurveWithPlane(origin,vec,eps,cut3DCurve);
+    sameNbNodes=(mDesc1->getNumberOfNodes()==oldNbNodes);
+  }
+  std::vector< std::pair<mcIdType,mcIdType> > cut3DSurf(mDesc2->getNumberOfCells());
   AssemblyForSplitFrom3DCurve(cut3DCurve,nodes,mDesc2->getNodalConnectivity()->begin(),mDesc2->getNodalConnectivityIndex()->begin(),
                               mDesc1->getNodalConnectivity()->begin(),mDesc1->getNodalConnectivityIndex()->begin(),
                               desc1->begin(),descIndx1->begin(),cut3DSurf);
-  MCAuto<DataArrayInt> conn(DataArrayInt::New()),connI(DataArrayInt::New());
+  MCAuto<DataArrayIdType> conn(DataArrayIdType::New()),connI(DataArrayIdType::New());
   connI->pushBackSilent(0); conn->alloc(0,1);
   {
-    MCAuto<DataArrayInt> cellIds2(DataArrayInt::New()); cellIds2->alloc(0,1);
+    MCAuto<DataArrayIdType> cellIds2(DataArrayIdType::New()); cellIds2->alloc(0,1);
     assemblyForSplitFrom3DSurf(cut3DSurf,desc2->begin(),descIndx2->begin(),conn,connI,cellIds2);
     if(cellIds2->empty())
       throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildSlice3D : No 3D cells in this intercepts the specified plane !");
   }
-  std::vector<std::vector<int> > res;
+  std::vector<std::vector<mcIdType> > res;
   buildSubCellsFromCut(cut3DSurf,desc2->begin(),descIndx2->begin(),mDesc1->getCoords()->begin(),eps,res);
   std::size_t sz(res.size());
-  if(res.size()==mDesc1->getNumberOfCells())
+  if(ToIdType(res.size())==mDesc1->getNumberOfCells() && sameNbNodes)
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::clipSingle3DCellByPlane : cell is not clipped !");
   for(std::size_t i=0;i<sz;i++)
     {
-      conn->pushBackSilent((int)INTERP_KERNEL::NORM_POLYGON);
+      conn->pushBackSilent(ToIdType(INTERP_KERNEL::NORM_POLYGON));
       conn->insertAtTheEnd(res[i].begin(),res[i].end());
       connI->pushBackSilent(conn->getNumberOfTuples());
     }
   MCAuto<MEDCouplingUMesh> ret(MEDCouplingUMesh::New("",2));
   ret->setCoords(mDesc1->getCoords());
   ret->setConnectivity(conn,connI,true);
-  int nbCellsRet(ret->getNumberOfCells());
+  mcIdType nbCellsRet(ret->getNumberOfCells());
   //
   MCAuto<DataArrayDouble> vec2(DataArrayDouble::New()); vec2->alloc(1,3); std::copy(vec,vec+3,vec2->getPointer());
   MCAuto<MEDCouplingFieldDouble> ortho(ret->buildOrthogonalField());
@@ -4036,13 +4040,13 @@ MCAuto<MEDCouplingUMesh> MEDCouplingUMesh::clipSingle3DCellByPlane(const double
   vec2->setPartOfValuesSimple1(vec[0],0,nbCellsRet,1,0,1,1); vec2->setPartOfValuesSimple1(vec[1],0,nbCellsRet,1,1,2,1); vec2->setPartOfValuesSimple1(vec[2],0,nbCellsRet,1,2,3,1);
   MCAuto<DataArrayDouble> dott2(DataArrayDouble::Dot(occm,vec2));
   //
-  const int *cPtr(ret->getNodalConnectivity()->begin()),*ciPtr(ret->getNodalConnectivityIndex()->begin());
+  const mcIdType *cPtr(ret->getNodalConnectivity()->begin()),*ciPtr(ret->getNodalConnectivityIndex()->begin());
   MCAuto<MEDCouplingUMesh> ret2(MEDCouplingUMesh::New("Clip3D",3));
   ret2->setCoords(mDesc1->getCoords());
-  MCAuto<DataArrayInt> conn2(DataArrayInt::New()),conn2I(DataArrayInt::New());
+  MCAuto<DataArrayIdType> conn2(DataArrayIdType::New()),conn2I(DataArrayIdType::New());
   conn2I->pushBackSilent(0); conn2->alloc(0,1);
-  std::vector<int> cell0(1,(int)INTERP_KERNEL::NORM_POLYHED);
-  std::vector<int> cell1(1,(int)INTERP_KERNEL::NORM_POLYHED);
+  std::vector<mcIdType> cell0(1,ToIdType(INTERP_KERNEL::NORM_POLYHED));
+  std::vector<mcIdType> cell1(1,ToIdType(INTERP_KERNEL::NORM_POLYHED));
   if(dott->getIJ(0,0)>0)
     {
       cell0.insert(cell0.end(),cPtr+1,cPtr+ciPtr[1]);
@@ -4053,7 +4057,7 @@ MCAuto<MEDCouplingUMesh> MEDCouplingUMesh::clipSingle3DCellByPlane(const double
       cell1.insert(cell1.end(),cPtr+1,cPtr+ciPtr[1]);
       std::reverse_copy(cPtr+1,cPtr+ciPtr[1],std::inserter(cell0,cell0.end()));
     }
-  for(int i=1;i<nbCellsRet;i++)
+  for(mcIdType i=1;i<nbCellsRet;i++)
     {
       if(dott2->getIJ(i,0)<0)
         {
@@ -4078,7 +4082,6 @@ MCAuto<MEDCouplingUMesh> MEDCouplingUMesh::clipSingle3DCellByPlane(const double
   conn2I->pushBackSilent(conn2->getNumberOfTuples());
   ret2->setConnectivity(conn2,conn2I,true);
   ret2->checkConsistencyLight();
-  ret2->writeVTK("ret2.vtu");
   ret2->orientCorrectlyPolyhedrons();
   return ret2;
 }
@@ -4089,7 +4092,7 @@ MCAuto<MEDCouplingUMesh> MEDCouplingUMesh::clipSingle3DCellByPlane(const double
  *  \param [in] vec - 3 components of a vector normal to the plane. Vector magnitude
  *         must be greater than 1e-6.
  *  \param [in] eps - half-thickness of the plane.
- *  \return DataArrayInt * - a new instance of DataArrayInt holding ids of the found
+ *  \return DataArrayIdType * - a new instance of DataArrayIdType holding ids of the found
  *         cells. The caller is to delete this array using decrRef() as it is no more
  *         needed.
  *  \throw If the coordinates array is not set.
@@ -4098,7 +4101,7 @@ MCAuto<MEDCouplingUMesh> MEDCouplingUMesh::clipSingle3DCellByPlane(const double
  *  \throw If magnitude of \a vec is less than 1e-6.
  *  \sa buildSlice3D()
  */
-DataArrayInt *MEDCouplingUMesh::getCellIdsCrossingPlane(const double *origin, const double *vec, double eps) const
+DataArrayIdType *MEDCouplingUMesh::getCellIdsCrossingPlane(const double *origin, const double *vec, double eps) const
 {
   checkFullyDefined();
   if(getSpaceDimension()!=3)
@@ -4109,7 +4112,7 @@ DataArrayInt *MEDCouplingUMesh::getCellIdsCrossingPlane(const double *origin, co
   double vec2[3];
   vec2[0]=vec[1]; vec2[1]=-vec[0]; vec2[2]=0.;//vec2 is the result of cross product of vec with (0,0,1)
   double angle=acos(vec[2]/normm);
-  MCAuto<DataArrayInt> cellIds;
+  MCAuto<DataArrayIdType> cellIds;
   double bbox[6];
   if(angle>eps)
     {
@@ -4137,18 +4140,18 @@ DataArrayInt *MEDCouplingUMesh::getCellIdsCrossingPlane(const double *origin, co
  * If not an exception will thrown. If this is an empty mesh with no cell an exception will be thrown too.
  * No consideration of coordinate is done by this method.
  * A 1D mesh is said contiguous if : a cell i with nodal connectivity (k,p) the cell i+1 the nodal connectivity should be (p,m)
- * If not false is returned. In case that false is returned a call to MEDCoupling::MEDCouplingUMesh::mergeNodes could be usefull.
+ * If not false is returned. In case that false is returned a call to MEDCoupling::MEDCouplingUMesh::mergeNodes could be useful.
  */
 bool MEDCouplingUMesh::isContiguous1D() const
 {
   if(getMeshDimension()!=1)
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::isContiguous1D : this method has a sense only for 1D mesh !");
-  int nbCells=getNumberOfCells();
+  mcIdType nbCells=getNumberOfCells();
   if(nbCells<1)
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::isContiguous1D : this method has a sense for non empty mesh !");
-  const int *connI(_nodal_connec_index->begin()),*conn(_nodal_connec->begin());
-  int ref=conn[connI[0]+2];
-  for(int i=1;i<nbCells;i++)
+  const mcIdType *connI(_nodal_connec_index->begin()),*conn(_nodal_connec->begin());
+  mcIdType ref=conn[connI[0]+2];
+  for(mcIdType i=1;i<nbCells;i++)
     {
       if(conn[connI[i]+1]!=ref)
         return false;
@@ -4176,7 +4179,7 @@ void MEDCouplingUMesh::project1D(const double *pt, const double *v, double eps,
   MCAuto<MEDCouplingFieldDouble> f=buildDirectionVectorField();
   const double *fPtr=f->getArray()->getConstPointer();
   double tmp[3];
-  for(int i=0;i<getNumberOfCells();i++)
+  for(mcIdType i=0;i<getNumberOfCells();i++)
     {
       const double *tmp1=fPtr+3*i;
       tmp[0]=tmp1[1]*v[2]-tmp1[2]*v[1];
@@ -4188,7 +4191,7 @@ void MEDCouplingUMesh::project1D(const double *pt, const double *v, double eps,
         throw INTERP_KERNEL::Exception("UMesh::Projection 1D failed !");
     }
   const double *coo=getCoords()->getConstPointer();
-  for(int i=0;i<getNumberOfNodes();i++)
+  for(mcIdType i=0;i<getNumberOfNodes();i++)
     {
       std::transform(coo+i*3,coo+i*3+3,pt,tmp,std::minus<double>());
       std::transform(tmp,tmp+3,v,tmp,std::multiplies<double>());
@@ -4197,7 +4200,7 @@ void MEDCouplingUMesh::project1D(const double *pt, const double *v, double eps,
 }
 
 /*!
- * This method computes the distance from a point \a pt to \a this and the first \a cellId in \a this corresponding to the returned distance. 
+ * This method computes the distance from a point \a pt to \a this and the first \a cellId in \a this corresponding to the returned distance.
  * \a this is expected to be a mesh so that its space dimension is equal to its
  * mesh dimension + 1. Furthermore only mesh dimension 1 and 2 are supported for the moment.
  * Distance from \a ptBg to \a ptEnd is expected to be equal to the space dimension. \a this is also expected to be fully defined (connectivity and coordinates).
@@ -4217,7 +4220,7 @@ void MEDCouplingUMesh::project1D(const double *pt, const double *v, double eps,
  * dimension - 1.
  * \sa DataArrayDouble::distanceToTuple, MEDCouplingUMesh::distanceToPoints
  */
-double MEDCouplingUMesh::distanceToPoint(const double *ptBg, const double *ptEnd, int& cellId) const
+double MEDCouplingUMesh::distanceToPoint(const double *ptBg, const double *ptEnd, mcIdType& cellId) const
 {
   int meshDim=getMeshDimension(),spaceDim=getSpaceDimension();
   if(meshDim!=spaceDim-1)
@@ -4225,23 +4228,23 @@ double MEDCouplingUMesh::distanceToPoint(const double *ptBg, const double *ptEnd
   if(meshDim!=2 && meshDim!=1)
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::distanceToPoint : only mesh dimension 2 and 1 are implemented !");
   checkFullyDefined();
-  if((int)std::distance(ptBg,ptEnd)!=spaceDim)
+  if(ToIdType(std::distance(ptBg,ptEnd))!=spaceDim)
     { std::ostringstream oss; oss << "MEDCouplingUMesh::distanceToPoint : input point has to have dimension equal to the space dimension of this (" << spaceDim << ") !"; throw INTERP_KERNEL::Exception(oss.str()); }
-  DataArrayInt *ret1=0;
-  MCAuto<DataArrayDouble> pts=DataArrayDouble::New(); pts->useArray(ptBg,false,C_DEALLOC,1,spaceDim);
+  DataArrayIdType *ret1=0;
+  MCAuto<DataArrayDouble> pts=DataArrayDouble::New(); pts->useArray(ptBg,false,DeallocType::C_DEALLOC,1,spaceDim);
   MCAuto<DataArrayDouble> ret0=distanceToPoints(pts,ret1);
-  MCAuto<DataArrayInt> ret1Safe(ret1);
+  MCAuto<DataArrayIdType> ret1Safe(ret1);
   cellId=*ret1Safe->begin();
   return *ret0->begin();
 }
 
 /*!
  * This method computes the distance from each point of points serie \a pts (stored in a DataArrayDouble in which each tuple represents a point)
- *  to \a this  and the first \a cellId in \a this corresponding to the returned distance. 
+ *  to \a this  and the first \a cellId in \a this corresponding to the returned distance.
  * WARNING, if there is some orphan nodes in \a this (nodes not fetched by any cells in \a this ( see MEDCouplingUMesh::zipCoords ) ) these nodes will ** not ** been taken
  * into account in this method. Only cells and nodes lying on them are considered in the algorithm (even if one of these orphan nodes is closer than returned distance).
  * A user that needs to consider orphan nodes should invoke DataArrayDouble::minimalDistanceTo method on the coordinates array of \a this.
- * 
+ *
  * \a this is expected to be a mesh so that its space dimension is equal to its
  * mesh dimension + 1. Furthermore only mesh dimension 1 and 2 are supported for the moment.
  * Number of components of \a pts is expected to be equal to the space dimension. \a this is also expected to be fully defined (connectivity and coordinates).
@@ -4256,7 +4259,7 @@ double MEDCouplingUMesh::distanceToPoint(const double *ptBg, const double *ptEnd
  * \throw if mesh dimension of \a this is not equal to space dimension - 1.
  * \sa DataArrayDouble::distanceToTuple, MEDCouplingUMesh::distanceToPoint
  */
-DataArrayDouble *MEDCouplingUMesh::distanceToPoints(const DataArrayDouble *pts, DataArrayInt *& cellIds) const
+DataArrayDouble *MEDCouplingUMesh::distanceToPoints(const DataArrayDouble *pts, DataArrayIdType *& cellIds) const
 {
   if(!pts)
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::distanceToPoints : input points pointer is NULL !");
@@ -4266,20 +4269,20 @@ DataArrayDouble *MEDCouplingUMesh::distanceToPoints(const DataArrayDouble *pts,
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::distanceToPoints works only for spaceDim=meshDim+1 !");
   if(meshDim!=2 && meshDim!=1)
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::distanceToPoints : only mesh dimension 2 and 1 are implemented !");
-  if(pts->getNumberOfComponents()!=spaceDim)
+  if(ToIdType(pts->getNumberOfComponents())!=spaceDim)
     {
       std::ostringstream oss; oss << "MEDCouplingUMesh::distanceToPoints : input pts DataArrayDouble has " << pts->getNumberOfComponents() << " components whereas it should be equal to " << spaceDim << " (mesh spaceDimension) !";
       throw INTERP_KERNEL::Exception(oss.str());
     }
   checkFullyDefined();
-  int nbCells=getNumberOfCells();
+  mcIdType nbCells=getNumberOfCells();
   if(nbCells==0)
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::distanceToPoints : no cells in this !");
-  int nbOfPts=pts->getNumberOfTuples();
+  mcIdType nbOfPts=pts->getNumberOfTuples();
   MCAuto<DataArrayDouble> ret0=DataArrayDouble::New(); ret0->alloc(nbOfPts,1);
-  MCAuto<DataArrayInt> ret1=DataArrayInt::New(); ret1->alloc(nbOfPts,1);
-  const int *nc=_nodal_connec->begin(),*ncI=_nodal_connec_index->begin(); const double *coords=_coords->begin();
-  double *ret0Ptr=ret0->getPointer(); int *ret1Ptr=ret1->getPointer(); const double *ptsPtr=pts->begin();
+  MCAuto<DataArrayIdType> ret1=DataArrayIdType::New(); ret1->alloc(nbOfPts,1);
+  const mcIdType *nc=_nodal_connec->begin(),*ncI=_nodal_connec_index->begin(); const double *coords=_coords->begin();
+  double *ret0Ptr=ret0->getPointer(); mcIdType *ret1Ptr=ret1->getPointer(); const double *ptsPtr=pts->begin();
   MCAuto<DataArrayDouble> bboxArr(getBoundingBoxForBBTree());
   const double *bbox(bboxArr->begin());
   switch(spaceDim)
@@ -4287,10 +4290,10 @@ DataArrayDouble *MEDCouplingUMesh::distanceToPoints(const DataArrayDouble *pts,
     case 3:
       {
         BBTreeDst<3> myTree(bbox,0,0,nbCells);
-        for(int i=0;i<nbOfPts;i++,ret0Ptr++,ret1Ptr++,ptsPtr+=3)
+        for(mcIdType i=0;i<nbOfPts;i++,ret0Ptr++,ret1Ptr++,ptsPtr+=3)
           {
             double x=std::numeric_limits<double>::max();
-            std::vector<int> elems;
+            std::vector<mcIdType> elems;
             myTree.getMinDistanceOfMax(ptsPtr,x);
             myTree.getElemsWhoseMinDistanceToPtSmallerThan(ptsPtr,x,elems);
             DistanceToPoint3DSurfAlg(ptsPtr,&elems[0],&elems[0]+elems.size(),coords,nc,ncI,*ret0Ptr,*ret1Ptr);
@@ -4300,10 +4303,10 @@ DataArrayDouble *MEDCouplingUMesh::distanceToPoints(const DataArrayDouble *pts,
     case 2:
       {
         BBTreeDst<2> myTree(bbox,0,0,nbCells);
-        for(int i=0;i<nbOfPts;i++,ret0Ptr++,ret1Ptr++,ptsPtr+=2)
+        for(mcIdType i=0;i<nbOfPts;i++,ret0Ptr++,ret1Ptr++,ptsPtr+=2)
           {
             double x=std::numeric_limits<double>::max();
-            std::vector<int> elems;
+            std::vector<mcIdType> elems;
             myTree.getMinDistanceOfMax(ptsPtr,x);
             myTree.getElemsWhoseMinDistanceToPtSmallerThan(ptsPtr,x,elems);
             DistanceToPoint2DCurveAlg(ptsPtr,&elems[0],&elems[0]+elems.size(),coords,nc,ncI,*ret0Ptr,*ret1Ptr);
@@ -4319,97 +4322,26 @@ DataArrayDouble *MEDCouplingUMesh::distanceToPoints(const DataArrayDouble *pts,
 
 /// @cond INTERNAL
 
-/*!
- * \param [in] pt the start pointer (included) of the coordinates of the point
- * \param [in] cellIdsBg the start pointer (included) of cellIds
- * \param [in] cellIdsEnd the end pointer (excluded) of cellIds
- * \param [in] nc nodal connectivity
- * \param [in] ncI nodal connectivity index
- * \param [in,out] ret0 the min distance between \a this and the external input point
- * \param [out] cellId that corresponds to minimal distance. If the closer node is not linked to any cell in \a this -1 is returned.
- * \sa MEDCouplingUMesh::distanceToPoint, MEDCouplingUMesh::distanceToPoints
- */
-void MEDCouplingUMesh::DistanceToPoint3DSurfAlg(const double *pt, const int *cellIdsBg, const int *cellIdsEnd, const double *coords, const int *nc, const int *ncI, double& ret0, int& cellId)
-{
-  cellId=-1;
-  ret0=std::numeric_limits<double>::max();
-  for(const int *zeCell=cellIdsBg;zeCell!=cellIdsEnd;zeCell++)
-    {
-      switch((INTERP_KERNEL::NormalizedCellType)nc[ncI[*zeCell]])
-      {
-        case INTERP_KERNEL::NORM_TRI3:
-          {
-            double tmp=INTERP_KERNEL::DistanceFromPtToTriInSpaceDim3(pt,coords+3*nc[ncI[*zeCell]+1],coords+3*nc[ncI[*zeCell]+2],coords+3*nc[ncI[*zeCell]+3]);
-            if(tmp<ret0)
-              { ret0=tmp; cellId=*zeCell; }
-            break;
-          }
-        case INTERP_KERNEL::NORM_QUAD4:
-        case INTERP_KERNEL::NORM_POLYGON:
-          {
-            double tmp=INTERP_KERNEL::DistanceFromPtToPolygonInSpaceDim3(pt,nc+ncI[*zeCell]+1,nc+ncI[*zeCell+1],coords);
-            if(tmp<ret0)
-              { ret0=tmp; cellId=*zeCell; }
-            break;
-          }
-        default:
-          throw INTERP_KERNEL::Exception("MEDCouplingUMesh::distanceToPoint3DSurfAlg : not managed cell type ! Supporting TRI3, QUAD4 and POLYGON !");
-      }
-    }
-}
-
-/*!
- * \param [in] pt the start pointer (included) of the coordinates of the point
- * \param [in] cellIdsBg the start pointer (included) of cellIds
- * \param [in] cellIdsEnd the end pointer (excluded) of cellIds
- * \param [in] nc nodal connectivity
- * \param [in] ncI nodal connectivity index
- * \param [in,out] ret0 the min distance between \a this and the external input point
- * \param [out] cellId that corresponds to minimal distance. If the closer node is not linked to any cell in \a this -1 is returned.
- * \sa MEDCouplingUMesh::distanceToPoint, MEDCouplingUMesh::distanceToPoints
- */
-void MEDCouplingUMesh::DistanceToPoint2DCurveAlg(const double *pt, const int *cellIdsBg, const int *cellIdsEnd, const double *coords, const int *nc, const int *ncI, double& ret0, int& cellId)
-{
-  cellId=-1;
-  ret0=std::numeric_limits<double>::max();
-  for(const int *zeCell=cellIdsBg;zeCell!=cellIdsEnd;zeCell++)
-    {
-      switch((INTERP_KERNEL::NormalizedCellType)nc[ncI[*zeCell]])
-      {
-        case INTERP_KERNEL::NORM_SEG2:
-          {
-            std::size_t uselessEntry=0;
-            double tmp=INTERP_KERNEL::SquareDistanceFromPtToSegInSpaceDim2(pt,coords+2*nc[ncI[*zeCell]+1],coords+2*nc[ncI[*zeCell]+2],uselessEntry);
-            tmp=sqrt(tmp);
-            if(tmp<ret0)
-              { ret0=tmp; cellId=*zeCell; }
-            break;
-          }
-        default:
-          throw INTERP_KERNEL::Exception("MEDCouplingUMesh::distanceToPoint2DCurveAlg : not managed cell type ! Supporting SEG2 !");
-      }
-    }
-}
 /// @endcond
 
 /*!
- * Finds cells in contact with a ball (i.e. a point with precision). 
+ * Finds cells in contact with a ball (i.e. a point with precision).
  * For speed reasons, the INTERP_KERNEL::NORM_QUAD4, INTERP_KERNEL::NORM_TRI6 and INTERP_KERNEL::NORM_QUAD8 cells are considered as convex cells to detect if a point is IN or OUT.
  * If it is not the case, please change their types to INTERP_KERNEL::NORM_POLYGON or INTERP_KERNEL::NORM_QPOLYG before invoking this method.
  *
  * \warning This method is suitable if the caller intends to evaluate only one
  *          point, for more points getCellsContainingPoints() is recommended as it is
- *          faster. 
+ *          faster.
  *  \param [in] pos - array of coordinates of the ball central point.
  *  \param [in] eps - ball radius.
- *  \return int - a smallest id of cells being in contact with the ball, -1 in case
+ *  \return mcIdType - a smallest id of cells being in contact with the ball, -1 in case
  *         if there are no such cells.
  *  \throw If the coordinates array is not set.
  *  \throw If \a this->getMeshDimension() != \a this->getSpaceDimension().
  */
-int MEDCouplingUMesh::getCellContainingPoint(const double *pos, double eps) const
+mcIdType MEDCouplingUMesh::getCellContainingPoint(const double *pos, double eps) const
 {
-  std::vector<int> elts;
+  std::vector<mcIdType> elts;
   getCellsContainingPoint(pos,eps,elts);
   if(elts.empty())
     return -1;
@@ -4422,9 +4354,9 @@ int MEDCouplingUMesh::getCellContainingPoint(const double *pos, double eps) cons
  * If it is not the case, please change their types to INTERP_KERNEL::NORM_POLYGON or INTERP_KERNEL::NORM_QPOLYG before invoking this method.
  * \warning This method is suitable if the caller intends to evaluate only one
  *          point, for more points getCellsContainingPoints() is recommended as it is
- *          faster. 
+ *          faster.
  *  \param [in] pos - array of coordinates of the ball central point.
- *  \param [in] eps - ball radius.
+ *  \param [in] eps - ball radius (i.e. the precision) relative to max dimension along X, Y or Z of the the considered cell bounding box.
  *  \param [out] elts - vector returning ids of the found cells. It is cleared
  *         before inserting ids.
  *  \throw If the coordinates array is not set.
@@ -4435,236 +4367,52 @@ int MEDCouplingUMesh::getCellContainingPoint(const double *pos, double eps) cons
  *  \ref  py_mcumesh_getCellsContainingPoint "Here is a Python example".
  *  \endif
  */
-void MEDCouplingUMesh::getCellsContainingPoint(const double *pos, double eps, std::vector<int>& elts) const
+void MEDCouplingUMesh::getCellsContainingPoint(const double *pos, double eps, std::vector<mcIdType>& elts) const
 {
-  MCAuto<DataArrayInt> eltsUg,eltsIndexUg;
+  MCAuto<DataArrayIdType> eltsUg,eltsIndexUg;
   getCellsContainingPoints(pos,1,eps,eltsUg,eltsIndexUg);
   elts.clear(); elts.insert(elts.end(),eltsUg->begin(),eltsUg->end());
 }
 
-/// @cond INTERNAL
-
-namespace MEDCoupling
+void MEDCouplingUMesh::getCellsContainingPointsZeAlg(const double *pos, mcIdType nbOfPoints, double eps,
+                                                     MCAuto<DataArrayIdType>& elts, MCAuto<DataArrayIdType>& eltsIndex,
+                                                     std::function<bool(INTERP_KERNEL::NormalizedCellType,mcIdType)> sensibilityTo2DQuadraticLinearCellsFunc) const
 {
-  template<const int SPACEDIMM>
-  class DummyClsMCUG
-  {
-  public:
-    static const int MY_SPACEDIM=SPACEDIMM;
-    static const int MY_MESHDIM=8;
-    typedef int MyConnType;
-    static const INTERP_KERNEL::NumberingPolicy My_numPol=INTERP_KERNEL::ALL_C_MODE;
-    // begin
-    // useless, but for windows compilation ...
-    const double* getCoordinatesPtr() const { return 0; }
-    const int* getConnectivityPtr() const { return 0; }
-    const int* getConnectivityIndexPtr() const { return 0; }
-    INTERP_KERNEL::NormalizedCellType getTypeOfElement(int) const { return (INTERP_KERNEL::NormalizedCellType)0; }
-    // end
-  };
-
-  INTERP_KERNEL::Edge *MEDCouplingUMeshBuildQPFromEdge2(INTERP_KERNEL::NormalizedCellType typ, const int *bg, const double *coords2D, std::map< MCAuto<INTERP_KERNEL::Node>,int>& m)
-  {
-    INTERP_KERNEL::Edge *ret(0);
-    MCAuto<INTERP_KERNEL::Node> n0(new INTERP_KERNEL::Node(coords2D[2*bg[0]],coords2D[2*bg[0]+1])),n1(new INTERP_KERNEL::Node(coords2D[2*bg[1]],coords2D[2*bg[1]+1]));
-    m[n0]=bg[0]; m[n1]=bg[1];
-    switch(typ)
+  int spaceDim(getSpaceDimension()),mDim(getMeshDimension());
+  if(spaceDim==3)
     {
-      case INTERP_KERNEL::NORM_SEG2:
-        {
-          ret=new INTERP_KERNEL::EdgeLin(n0,n1);
-          break;
-        }
-      case INTERP_KERNEL::NORM_SEG3:
+      if(mDim==3)
         {
-          INTERP_KERNEL::Node *n2(new INTERP_KERNEL::Node(coords2D[2*bg[2]],coords2D[2*bg[2]+1])); m[n2]=bg[2];
-          INTERP_KERNEL::EdgeLin *e1(new INTERP_KERNEL::EdgeLin(n0,n2)),*e2(new INTERP_KERNEL::EdgeLin(n2,n1));
-          INTERP_KERNEL::SegSegIntersector inters(*e1,*e2);
-          // is the SEG3 degenerated, and thus can be reduced to a SEG2?
-          bool colinearity(inters.areColinears());
-          delete e1; delete e2;
-          if(colinearity)
-            { ret=new INTERP_KERNEL::EdgeLin(n0,n1); }
-          else
-            { ret=new INTERP_KERNEL::EdgeArcCircle(n0,n2,n1); }
-          break;
+          const double *coords=_coords->getConstPointer();
+          getCellsContainingPointsAlg<3>(coords,pos,nbOfPoints,eps,elts,eltsIndex,sensibilityTo2DQuadraticLinearCellsFunc);
         }
-      default:
-        throw INTERP_KERNEL::Exception("MEDCouplingUMeshBuildQPFromEdge2 : Expecting a mesh with spaceDim==2 and meshDim==1 !");
+      else
+        throw INTERP_KERNEL::Exception("For spaceDim==3 only meshDim==3 implemented for getelementscontainingpoints !");
     }
-    return ret;
-  }
-
-  INTERP_KERNEL::Edge *MEDCouplingUMeshBuildQPFromEdge(INTERP_KERNEL::NormalizedCellType typ, std::map<int, std::pair<INTERP_KERNEL::Node *,bool> >& mapp2, const int *bg)
-  {
-    INTERP_KERNEL::Edge *ret=0;
-    switch(typ)
+  else if(spaceDim==2)
     {
-      case INTERP_KERNEL::NORM_SEG2:
-        {
-          ret=new INTERP_KERNEL::EdgeLin(mapp2[bg[0]].first,mapp2[bg[1]].first);
-          break;
-        }
-      case INTERP_KERNEL::NORM_SEG3:
+      if(mDim==2)
         {
-          INTERP_KERNEL::EdgeLin *e1=new INTERP_KERNEL::EdgeLin(mapp2[bg[0]].first,mapp2[bg[2]].first);
-          INTERP_KERNEL::EdgeLin *e2=new INTERP_KERNEL::EdgeLin(mapp2[bg[2]].first,mapp2[bg[1]].first);
-          INTERP_KERNEL::SegSegIntersector inters(*e1,*e2);
-          // is the SEG3 degenerated, and thus can be reduced to a SEG2?
-          bool colinearity=inters.areColinears();
-          delete e1; delete e2;
-          if(colinearity)
-            ret=new INTERP_KERNEL::EdgeLin(mapp2[bg[0]].first,mapp2[bg[1]].first);
-          else
-            ret=new INTERP_KERNEL::EdgeArcCircle(mapp2[bg[0]].first,mapp2[bg[2]].first,mapp2[bg[1]].first);
-          mapp2[bg[2]].second=false;
-          break;
+          const double *coords=_coords->getConstPointer();
+          getCellsContainingPointsAlg<2>(coords,pos,nbOfPoints,eps,elts,eltsIndex,sensibilityTo2DQuadraticLinearCellsFunc);
         }
-      default:
-        throw INTERP_KERNEL::Exception("MEDCouplingUMeshBuildQPFromEdge : Expecting a mesh with spaceDim==2 and meshDim==1 !");
+      else
+        throw INTERP_KERNEL::Exception("For spaceDim==2 only meshDim==2 implemented for getelementscontainingpoints !");
     }
-    return ret;
-  }
-
-  /*!
-   * This method creates a sub mesh in Geometric2D DS. The sub mesh is composed by the sub set of cells in 'candidates' taken from
-   * the global mesh 'mDesc'.
-   * The input mesh 'mDesc' must be so that mDim==1 and spaceDim==2.
-   * 'mapp' returns a mapping between local numbering in submesh (represented by a Node*) and the global node numbering in 'mDesc'.
-   */
-  INTERP_KERNEL::QuadraticPolygon *MEDCouplingUMeshBuildQPFromMesh(const MEDCouplingUMesh *mDesc, const std::vector<int>& candidates,
-                                                                   std::map<INTERP_KERNEL::Node *,int>& mapp)
-  {
-    mapp.clear();
-    std::map<int, std::pair<INTERP_KERNEL::Node *,bool> > mapp2;//bool is for a flag specifying if node is boundary (true) or only a middle for SEG3.
-    const double *coo=mDesc->getCoords()->getConstPointer();
-    const int *c=mDesc->getNodalConnectivity()->getConstPointer();
-    const int *cI=mDesc->getNodalConnectivityIndex()->getConstPointer();
-    std::set<int> s;
-    for(std::vector<int>::const_iterator it=candidates.begin();it!=candidates.end();it++)
-      s.insert(c+cI[*it]+1,c+cI[(*it)+1]);
-    for(std::set<int>::const_iterator it2=s.begin();it2!=s.end();it2++)
-      {
-        INTERP_KERNEL::Node *n=new INTERP_KERNEL::Node(coo[2*(*it2)],coo[2*(*it2)+1]);
-        mapp2[*it2]=std::pair<INTERP_KERNEL::Node *,bool>(n,true);
-      }
-    INTERP_KERNEL::QuadraticPolygon *ret=new INTERP_KERNEL::QuadraticPolygon;
-    for(std::vector<int>::const_iterator it=candidates.begin();it!=candidates.end();it++)
-      {
-        INTERP_KERNEL::NormalizedCellType typ=(INTERP_KERNEL::NormalizedCellType)c[cI[*it]];
-        ret->pushBack(MEDCouplingUMeshBuildQPFromEdge(typ,mapp2,c+cI[*it]+1));
-      }
-    for(std::map<int, std::pair<INTERP_KERNEL::Node *,bool> >::const_iterator it2=mapp2.begin();it2!=mapp2.end();it2++)
-      {
-        if((*it2).second.second)
-          mapp[(*it2).second.first]=(*it2).first;
-        ((*it2).second.first)->decrRef();
-      }
-    return ret;
-  }
-
-  INTERP_KERNEL::Node *MEDCouplingUMeshBuildQPNode(int nodeId, const double *coo1, int offset1, const double *coo2, int offset2, const std::vector<double>& addCoo)
-  {
-    if(nodeId>=offset2)
-      {
-        int locId=nodeId-offset2;
-        return new INTERP_KERNEL::Node(addCoo[2*locId],addCoo[2*locId+1]);
-      }
-    if(nodeId>=offset1)
-      {
-        int locId=nodeId-offset1;
-        return new INTERP_KERNEL::Node(coo2[2*locId],coo2[2*locId+1]);
-      }
-    return new INTERP_KERNEL::Node(coo1[2*nodeId],coo1[2*nodeId+1]);
-  }
-
-  /**
-   * Construct a mapping between set of Nodes and the standart MEDCoupling connectivity format (c, cI).
-   */
-  void MEDCouplingUMeshBuildQPFromMesh3(const double *coo1, int offset1, const double *coo2, int offset2, const std::vector<double>& addCoo,
-                                        const int *desc1Bg, const int *desc1End, const std::vector<std::vector<int> >& intesctEdges1,
-                                        /*output*/std::map<INTERP_KERNEL::Node *,int>& mapp, std::map<int,INTERP_KERNEL::Node *>& mappRev)
-  {
-    for(const int *desc1=desc1Bg;desc1!=desc1End;desc1++)
-      {
-        int eltId1=abs(*desc1)-1;
-        for(std::vector<int>::const_iterator it1=intesctEdges1[eltId1].begin();it1!=intesctEdges1[eltId1].end();it1++)
-          {
-            std::map<int,INTERP_KERNEL::Node *>::const_iterator it=mappRev.find(*it1);
-            if(it==mappRev.end())
-              {
-                INTERP_KERNEL::Node *node=MEDCouplingUMeshBuildQPNode(*it1,coo1,offset1,coo2,offset2,addCoo);
-                mapp[node]=*it1;
-                mappRev[*it1]=node;
-              }
-          }
-      }
-  }
-}
-
-/// @endcond
-
-template<int SPACEDIM>
-void MEDCouplingUMesh::getCellsContainingPointsAlg(const double *coords, const double *pos, int nbOfPoints,
-                                                   double eps, MCAuto<DataArrayInt>& elts, MCAuto<DataArrayInt>& eltsIndex) const
-{
-  elts=DataArrayInt::New(); eltsIndex=DataArrayInt::New(); eltsIndex->alloc(nbOfPoints+1,1); eltsIndex->setIJ(0,0,0); elts->alloc(0,1);
-  int *eltsIndexPtr(eltsIndex->getPointer());
-  MCAuto<DataArrayDouble> bboxArr(getBoundingBoxForBBTree(eps));
-  const double *bbox(bboxArr->begin());
-  int nbOfCells=getNumberOfCells();
-  const int *conn=_nodal_connec->getConstPointer();
-  const int *connI=_nodal_connec_index->getConstPointer();
-  double bb[2*SPACEDIM];
-  BBTree<SPACEDIM,int> myTree(&bbox[0],0,0,nbOfCells,-eps);
-  for(int i=0;i<nbOfPoints;i++)
-    {
-      eltsIndexPtr[i+1]=eltsIndexPtr[i];
-      for(int j=0;j<SPACEDIM;j++)
-        {
-          bb[2*j]=pos[SPACEDIM*i+j];
-          bb[2*j+1]=pos[SPACEDIM*i+j];
-        }
-      std::vector<int> candidates;
-      myTree.getIntersectingElems(bb,candidates);
-      for(std::vector<int>::const_iterator iter=candidates.begin();iter!=candidates.end();iter++)
+  else if(spaceDim==1)
+    {
+      if(mDim==1)
         {
-          int sz(connI[(*iter)+1]-connI[*iter]-1);
-          INTERP_KERNEL::NormalizedCellType ct((INTERP_KERNEL::NormalizedCellType)conn[connI[*iter]]);
-          bool status(false);
-          if(ct!=INTERP_KERNEL::NORM_POLYGON && ct!=INTERP_KERNEL::NORM_QPOLYG)
-            status=INTERP_KERNEL::PointLocatorAlgos<DummyClsMCUG<SPACEDIM> >::isElementContainsPoint(pos+i*SPACEDIM,ct,coords,conn+connI[*iter]+1,sz,eps);
-          else
-            {
-              if(SPACEDIM!=2)
-                throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getCellsContainingPointsAlg : not implemented yet for POLYGON and QPOLYGON in spaceDim 3 !");
-              INTERP_KERNEL::QUADRATIC_PLANAR::_precision=eps;
-              INTERP_KERNEL::QUADRATIC_PLANAR::_arc_detection_precision=eps;
-              std::vector<INTERP_KERNEL::Node *> nodes(sz);
-              INTERP_KERNEL::QuadraticPolygon *pol(0);
-              for(int j=0;j<sz;j++)
-                {
-                  int nodeId(conn[connI[*iter]+1+j]);
-                  nodes[j]=new INTERP_KERNEL::Node(coords[nodeId*SPACEDIM],coords[nodeId*SPACEDIM+1]);
-                }
-              if(!INTERP_KERNEL::CellModel::GetCellModel(ct).isQuadratic())
-                pol=INTERP_KERNEL::QuadraticPolygon::BuildLinearPolygon(nodes);
-              else
-                pol=INTERP_KERNEL::QuadraticPolygon::BuildArcCirclePolygon(nodes);
-              INTERP_KERNEL::Node *n(new INTERP_KERNEL::Node(pos[i*SPACEDIM],pos[i*SPACEDIM+1]));
-              double a(0.),b(0.),c(0.);
-              a=pol->normalizeMe(b,c); n->applySimilarity(b,c,a);
-              status=pol->isInOrOut2(n);
-              delete pol; n->decrRef();
-            }
-          if(status)
-            {
-              eltsIndexPtr[i+1]++;
-              elts->pushBackSilent(*iter);
-            }
+          const double *coords=_coords->getConstPointer();
+          getCellsContainingPointsAlg<1>(coords,pos,nbOfPoints,eps,elts,eltsIndex,sensibilityTo2DQuadraticLinearCellsFunc);
         }
+      else
+        throw INTERP_KERNEL::Exception("For spaceDim==1 only meshDim==1 implemented for getelementscontainingpoints !");
     }
+  else
+    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getCellsContainingPoints : not managed for mdim not in [1,2,3] !");
 }
+
 /*!
  * Finds cells in contact with several balls (i.e. points with precision).
  * This method is an extension of getCellContainingPoint() and
@@ -4673,9 +4421,9 @@ void MEDCouplingUMesh::getCellsContainingPointsAlg(const double *coords, const d
  * If it is not the case, please change their types to INTERP_KERNEL::NORM_POLYGON or INTERP_KERNEL::NORM_QPOLYG before invoking this method.
  *  \param [in] pos - an array of coordinates of points in full interlace mode :
  *         X0,Y0,Z0,X1,Y1,Z1,... Size of the array must be \a
- *         this->getSpaceDimension() * \a nbOfPoints 
+ *         this->getSpaceDimension() * \a nbOfPoints
  *  \param [in] nbOfPoints - number of points to locate within \a this mesh.
- *  \param [in] eps - radius of balls (i.e. the precision).
+ *  \param [in] eps - ball radius (i.e. the precision) relative to max dimension along X, Y or Z of the the considered cell bounding box.
  *  \param [out] elts - vector returning ids of found cells.
  *  \param [out] eltsIndex - an array, of length \a nbOfPoints + 1,
  *         dividing cell ids in \a elts into groups each referring to one
@@ -4694,47 +4442,24 @@ void MEDCouplingUMesh::getCellsContainingPointsAlg(const double *coords, const d
  *  \ref  py_mcumesh_getCellsContainingPoints "Here is a Python example".
  *  \endif
  */
-void MEDCouplingUMesh::getCellsContainingPoints(const double *pos, int nbOfPoints, double eps,
-                                                MCAuto<DataArrayInt>& elts, MCAuto<DataArrayInt>& eltsIndex) const
+void MEDCouplingUMesh::getCellsContainingPoints(const double *pos, mcIdType nbOfPoints, double eps,
+                                                MCAuto<DataArrayIdType>& elts, MCAuto<DataArrayIdType>& eltsIndex) const
 {
-  int spaceDim=getSpaceDimension();
-  int mDim=getMeshDimension();
-  if(spaceDim==3)
-    {
-      if(mDim==3)
-        {
-          const double *coords=_coords->getConstPointer();
-          getCellsContainingPointsAlg<3>(coords,pos,nbOfPoints,eps,elts,eltsIndex);
-        }
-      /*else if(mDim==2)
-        {
+  auto yesImSensibleTo2DQuadraticLinearCellsFunc([](INTERP_KERNEL::NormalizedCellType ct, int mdim) { return INTERP_KERNEL::CellModel::GetCellModel(ct).isQuadratic() && mdim == 2; } );
+  this->getCellsContainingPointsZeAlg(pos,nbOfPoints,eps,elts,eltsIndex,yesImSensibleTo2DQuadraticLinearCellsFunc);
+}
 
-        }*/
-      else
-        throw INTERP_KERNEL::Exception("For spaceDim==3 only meshDim==3 implemented for getelementscontainingpoints !");
-    }
-  else if(spaceDim==2)
-    {
-      if(mDim==2)
-        {
-          const double *coords=_coords->getConstPointer();
-          getCellsContainingPointsAlg<2>(coords,pos,nbOfPoints,eps,elts,eltsIndex);
-        }
-      else
-        throw INTERP_KERNEL::Exception("For spaceDim==2 only meshDim==2 implemented for getelementscontainingpoints !");
-    }
-  else if(spaceDim==1)
-    {
-      if(mDim==1)
-        {
-          const double *coords=_coords->getConstPointer();
-          getCellsContainingPointsAlg<1>(coords,pos,nbOfPoints,eps,elts,eltsIndex);
-        }
-      else
-        throw INTERP_KERNEL::Exception("For spaceDim==1 only meshDim==1 implemented for getelementscontainingpoints !");
-    }
-  else
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getCellsContainingPoints : not managed for mdim not in [1,2,3] !");
+/*!
+ * Behaves like MEDCouplingMesh::getCellsContainingPoints for cells in \a this that are linear.
+ * For quadratic cells in \a this, this method behaves by just considering linear part of cells.
+ * This method is here only for backward compatibility (interpolation GaussPoints to GaussPoints).
+ * 
+ * \sa MEDCouplingUMesh::getCellsContainingPoints, MEDCouplingRemapper::prepareNotInterpKernelOnlyGaussGauss
+ */
+void MEDCouplingUMesh::getCellsContainingPointsLinearPartOnlyOnNonDynType(const double *pos, mcIdType nbOfPoints, double eps, MCAuto<DataArrayIdType>& elts, MCAuto<DataArrayIdType>& eltsIndex) const
+{
+  auto noImNotSensibleTo2DQuadraticLinearCellsFunc([](INTERP_KERNEL::NormalizedCellType,mcIdType) { return false; } );
+  this->getCellsContainingPointsZeAlg(pos,nbOfPoints,eps,elts,eltsIndex,noImNotSensibleTo2DQuadraticLinearCellsFunc);
 }
 
 /*!
@@ -4747,7 +4472,7 @@ void MEDCouplingUMesh::getCellsContainingPoints(const double *pos, int nbOfPoint
  *  \throw If \a this->getMeshDimension() != 2.
  *  \throw If \a this->getSpaceDimension() != 2 && \a this->getSpaceDimension() != 3.
  */
-void MEDCouplingUMesh::checkButterflyCells(std::vector<int>& cells, double eps) const
+void MEDCouplingUMesh::checkButterflyCells(std::vector<mcIdType>& cells, double eps) const
 {
   const char msg[]="Butterfly detection work only for 2D cells with spaceDim==2 or 3!";
   if(getMeshDimension()!=2)
@@ -4755,14 +4480,14 @@ void MEDCouplingUMesh::checkButterflyCells(std::vector<int>& cells, double eps)
   int spaceDim=getSpaceDimension();
   if(spaceDim!=2 && spaceDim!=3)
     throw INTERP_KERNEL::Exception(msg);
-  const int *conn=_nodal_connec->getConstPointer();
-  const int *connI=_nodal_connec_index->getConstPointer();
-  int nbOfCells=getNumberOfCells();
+  const mcIdType *conn=_nodal_connec->getConstPointer();
+  const mcIdType *connI=_nodal_connec_index->getConstPointer();
+  mcIdType nbOfCells=getNumberOfCells();
   std::vector<double> cell2DinS2;
-  for(int i=0;i<nbOfCells;i++)
+  for(mcIdType i=0;i<nbOfCells;i++)
     {
-      int offset=connI[i];
-      int nbOfNodesForCell=connI[i+1]-offset-1;
+      mcIdType offset=connI[i];
+      mcIdType nbOfNodesForCell=connI[i+1]-offset-1;
       if(nbOfNodesForCell<=3)
         continue;
       bool isQuad=INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)conn[offset]).isQuadratic();
@@ -4778,7 +4503,7 @@ void MEDCouplingUMesh::checkButterflyCells(std::vector<int>& cells, double eps)
  *
  * This method expects that space dimension is equal to 2 and mesh dimension is equal to 2 too. If it is not the case an INTERP_KERNEL::Exception will be thrown.
  * This method works only for linear 2D cells. If there is any of non linear cells (INTERP_KERNEL::NORM_QUAD8 for example) an INTERP_KERNEL::Exception will be thrown too.
- * 
+ *
  * For each 2D linear cell in \b this, this method builds the convex envelop (or the convex hull) of the current cell.
  * This convex envelop is computed using Jarvis march algorithm.
  * The coordinates and the number of cells of \b this remain unchanged on invocation of this method.
@@ -4788,26 +4513,26 @@ void MEDCouplingUMesh::checkButterflyCells(std::vector<int>& cells, double eps)
  * \return a newly allocated array containing cellIds that have been modified if any. If no cells have been impacted by this method NULL is returned.
  * \sa MEDCouplingUMesh::colinearize2D
  */
-DataArrayInt *MEDCouplingUMesh::convexEnvelop2D()
+DataArrayIdType *MEDCouplingUMesh::convexEnvelop2D()
 {
   if(getMeshDimension()!=2 || getSpaceDimension()!=2)
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::convexEnvelop2D  works only for meshDim=2 and spaceDim=2 !");
   checkFullyDefined();
   const double *coords=getCoords()->getConstPointer();
-  int nbOfCells=getNumberOfCells();
-  MCAuto<DataArrayInt> nodalConnecIndexOut=DataArrayInt::New();
+  mcIdType nbOfCells=getNumberOfCells();
+  MCAuto<DataArrayIdType> nodalConnecIndexOut=DataArrayIdType::New();
   nodalConnecIndexOut->alloc(nbOfCells+1,1);
-  MCAuto<DataArrayInt> nodalConnecOut(DataArrayInt::New());
-  int *workIndexOut=nodalConnecIndexOut->getPointer();
+  MCAuto<DataArrayIdType> nodalConnecOut(DataArrayIdType::New());
+  mcIdType *workIndexOut=nodalConnecIndexOut->getPointer();
   *workIndexOut=0;
-  const int *nodalConnecIn=_nodal_connec->getConstPointer();
-  const int *nodalConnecIndexIn=_nodal_connec_index->getConstPointer();
+  const mcIdType *nodalConnecIn=_nodal_connec->getConstPointer();
+  const mcIdType *nodalConnecIndexIn=_nodal_connec_index->getConstPointer();
   std::set<INTERP_KERNEL::NormalizedCellType> types;
-  MCAuto<DataArrayInt> isChanged(DataArrayInt::New());
+  MCAuto<DataArrayIdType> isChanged(DataArrayIdType::New());
   isChanged->alloc(0,1);
-  for(int i=0;i<nbOfCells;i++,workIndexOut++)
+  for(mcIdType i=0;i<nbOfCells;i++,workIndexOut++)
     {
-      int pos=nodalConnecOut->getNumberOfTuples();
+      mcIdType pos=nodalConnecOut->getNumberOfTuples();
       if(BuildConvexEnvelopOf2DCellJarvis(coords,nodalConnecIn+nodalConnecIndexIn[i],nodalConnecIn+nodalConnecIndexIn[i+1],nodalConnecOut))
         isChanged->pushBackSilent(i);
       types.insert((INTERP_KERNEL::NormalizedCellType)nodalConnecOut->getIJ(pos,0));
@@ -4831,7 +4556,7 @@ DataArrayInt *MEDCouplingUMesh::convexEnvelop2D()
  *   the 3 preceding points of the 1D mesh. The center of the arc is the center of rotation for each level, the rotation is done
  *   along an axis normal to the plane containing the arc, and finally the angle of rotation is defined by the first two points on the
  *   arc.
- * \return an unstructured mesh with meshDim==3 and spaceDim==3. The returned mesh has the same coords than \a this.  
+ * \return an unstructured mesh with meshDim==3 and spaceDim==3. The returned mesh has the same coords than \a this.
  */
 MEDCouplingUMesh *MEDCouplingUMesh::buildExtrudedMesh(const MEDCouplingUMesh *mesh1D, int policy)
 {
@@ -4853,7 +4578,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildExtrudedMesh(const MEDCouplingUMesh *me
       else
         throw INTERP_KERNEL::Exception("Invalid 2D mesh and 1D mesh because 2D mesh has quadratic cells and 1D is not fully quadratic !");
     }
-  int oldNbOfNodes(getNumberOfNodes());
+  mcIdType oldNbOfNodes(getNumberOfNodes());
   MCAuto<DataArrayDouble> newCoords;
   switch(policy)
   {
@@ -4876,296 +4601,6 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildExtrudedMesh(const MEDCouplingUMesh *me
   return ret.retn();
 }
 
-/*!
- * This method works on a 3D curve linear mesh that is to say (meshDim==1 and spaceDim==3).
- * If it is not the case an exception will be thrown.
- * This method is non const because the coordinate of \a this can be appended with some new points issued from
- * intersection of plane defined by ('origin','vec').
- * This method has one in/out parameter : 'cut3DCurve'.
- * Param 'cut3DCurve' is expected to be of size 'this->getNumberOfCells()'. For each i in [0,'this->getNumberOfCells()')
- * if cut3DCurve[i]==-2, it means that for cell #i in \a this nothing has been detected previously.
- * if cut3DCurve[i]==-1, it means that cell#i has been already detected to be fully part of plane defined by ('origin','vec').
- * This method will throw an exception if \a this contains a non linear segment.
- */
-void MEDCouplingUMesh::split3DCurveWithPlane(const double *origin, const double *vec, double eps, std::vector<int>& cut3DCurve)
-{
-  checkFullyDefined();
-  if(getMeshDimension()!=1 || getSpaceDimension()!=3)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::split3DCurveWithPlane works on umeshes with meshdim equal to 1 and spaceDim equal to 3 !");
-  int ncells=getNumberOfCells();
-  int nnodes=getNumberOfNodes();
-  double vec2[3],vec3[3],vec4[3];
-  double normm=sqrt(vec[0]*vec[0]+vec[1]*vec[1]+vec[2]*vec[2]);
-  if(normm<1e-6)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::split3DCurveWithPlane : parameter 'vec' should have a norm2 greater than 1e-6 !");
-  vec2[0]=vec[0]/normm; vec2[1]=vec[1]/normm; vec2[2]=vec[2]/normm;
-  const int *conn=_nodal_connec->getConstPointer();
-  const int *connI=_nodal_connec_index->getConstPointer();
-  const double *coo=_coords->getConstPointer();
-  std::vector<double> addCoo;
-  for(int i=0;i<ncells;i++)
-    {
-      if(conn[connI[i]]==(int)INTERP_KERNEL::NORM_SEG2)
-        {
-          if(cut3DCurve[i]==-2)
-            {
-              int st=conn[connI[i]+1],endd=conn[connI[i]+2];
-              vec3[0]=coo[3*endd]-coo[3*st]; vec3[1]=coo[3*endd+1]-coo[3*st+1]; vec3[2]=coo[3*endd+2]-coo[3*st+2];
-              double normm2=sqrt(vec3[0]*vec3[0]+vec3[1]*vec3[1]+vec3[2]*vec3[2]);
-              double colin=std::abs((vec3[0]*vec2[0]+vec3[1]*vec2[1]+vec3[2]*vec2[2])/normm2);
-              if(colin>eps)//if colin<=eps -> current SEG2 is colinear to the input plane
-                {
-                  const double *st2=coo+3*st;
-                  vec4[0]=st2[0]-origin[0]; vec4[1]=st2[1]-origin[1]; vec4[2]=st2[2]-origin[2];
-                  double pos=-(vec4[0]*vec2[0]+vec4[1]*vec2[1]+vec4[2]*vec2[2])/((vec3[0]*vec2[0]+vec3[1]*vec2[1]+vec3[2]*vec2[2]));
-                  if(pos>eps && pos<1-eps)
-                    {
-                      int nNode=((int)addCoo.size())/3;
-                      vec4[0]=st2[0]+pos*vec3[0]; vec4[1]=st2[1]+pos*vec3[1]; vec4[2]=st2[2]+pos*vec3[2];
-                      addCoo.insert(addCoo.end(),vec4,vec4+3);
-                      cut3DCurve[i]=nnodes+nNode;
-                    }
-                }
-            }
-        }
-      else
-        throw INTERP_KERNEL::Exception("MEDCouplingUMesh::split3DCurveWithPlane : this method is only available for linear cell (NORM_SEG2) !");
-    }
-  if(!addCoo.empty())
-    {
-      int newNbOfNodes=nnodes+((int)addCoo.size())/3;
-      MCAuto<DataArrayDouble> coo2=DataArrayDouble::New();
-      coo2->alloc(newNbOfNodes,3);
-      double *tmp=coo2->getPointer();
-      tmp=std::copy(_coords->begin(),_coords->end(),tmp);
-      std::copy(addCoo.begin(),addCoo.end(),tmp);
-      DataArrayDouble::SetArrayIn(coo2,_coords);
-    }
-}
-
-/*!
- * This method incarnates the policy 0 for MEDCouplingUMesh::buildExtrudedMesh method.
- * \param mesh1D is the input 1D mesh used for translation computation.
- * \return newCoords new coords filled by this method. 
- */
-DataArrayDouble *MEDCouplingUMesh::fillExtCoordsUsingTranslation(const MEDCouplingUMesh *mesh1D, bool isQuad) const
-{
-  int oldNbOfNodes=getNumberOfNodes();
-  int nbOf1DCells=mesh1D->getNumberOfCells();
-  int spaceDim=getSpaceDimension();
-  DataArrayDouble *ret=DataArrayDouble::New();
-  std::vector<bool> isQuads;
-  int nbOfLevsInVec=isQuad?2*nbOf1DCells+1:nbOf1DCells+1;
-  ret->alloc(oldNbOfNodes*nbOfLevsInVec,spaceDim);
-  double *retPtr=ret->getPointer();
-  const double *coords=getCoords()->getConstPointer();
-  double *work=std::copy(coords,coords+spaceDim*oldNbOfNodes,retPtr);
-  std::vector<int> v;
-  std::vector<double> c;
-  double vec[3];
-  v.reserve(3);
-  c.reserve(6);
-  for(int i=0;i<nbOf1DCells;i++)
-    {
-      v.resize(0);
-      mesh1D->getNodeIdsOfCell(i,v);
-      c.resize(0);
-      mesh1D->getCoordinatesOfNode(v[isQuad?2:1],c);
-      mesh1D->getCoordinatesOfNode(v[0],c);
-      std::transform(c.begin(),c.begin()+spaceDim,c.begin()+spaceDim,vec,std::minus<double>());
-      for(int j=0;j<oldNbOfNodes;j++)
-        work=std::transform(vec,vec+spaceDim,retPtr+spaceDim*(i*oldNbOfNodes+j),work,std::plus<double>());
-      if(isQuad)
-        {
-          c.resize(0);
-          mesh1D->getCoordinatesOfNode(v[1],c);
-          mesh1D->getCoordinatesOfNode(v[0],c);
-          std::transform(c.begin(),c.begin()+spaceDim,c.begin()+spaceDim,vec,std::minus<double>());
-          for(int j=0;j<oldNbOfNodes;j++)
-            work=std::transform(vec,vec+spaceDim,retPtr+spaceDim*(i*oldNbOfNodes+j),work,std::plus<double>());
-        }
-    }
-  ret->copyStringInfoFrom(*getCoords());
-  return ret;
-}
-
-/*!
- * This method incarnates the policy 1 for MEDCouplingUMesh::buildExtrudedMesh method.
- * \param mesh1D is the input 1D mesh used for translation and automatic rotation computation.
- * \return newCoords new coords filled by this method. 
- */
-DataArrayDouble *MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation(const MEDCouplingUMesh *mesh1D, bool isQuad) const
-{
-  if(mesh1D->getSpaceDimension()==2)
-    return fillExtCoordsUsingTranslAndAutoRotation2D(mesh1D,isQuad);
-  if(mesh1D->getSpaceDimension()==3)
-    return fillExtCoordsUsingTranslAndAutoRotation3D(mesh1D,isQuad);
-  throw INTERP_KERNEL::Exception("Not implemented rotation and translation alg. for spacedim other than 2 and 3 !");
-}
-
-/*!
- * This method incarnates the policy 1 for MEDCouplingUMesh::buildExtrudedMesh method.
- * \param mesh1D is the input 1D mesh used for translation and automatic rotation computation.
- * \return newCoords new coords filled by this method. 
- */
-DataArrayDouble *MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation2D(const MEDCouplingUMesh *mesh1D, bool isQuad) const
-{
-  if(isQuad)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation2D : not implemented for quadratic cells !");
-  int oldNbOfNodes=getNumberOfNodes();
-  int nbOf1DCells=mesh1D->getNumberOfCells();
-  if(nbOf1DCells<2)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation2D : impossible to detect any angle of rotation ! Change extrusion policy 1->0 !");
-  MCAuto<DataArrayDouble> ret=DataArrayDouble::New();
-  int nbOfLevsInVec=nbOf1DCells+1;
-  ret->alloc(oldNbOfNodes*nbOfLevsInVec,2);
-  double *retPtr=ret->getPointer();
-  retPtr=std::copy(getCoords()->getConstPointer(),getCoords()->getConstPointer()+getCoords()->getNbOfElems(),retPtr);
-  MCAuto<MEDCouplingUMesh> tmp=MEDCouplingUMesh::New();
-  MCAuto<DataArrayDouble> tmp2=getCoords()->deepCopy();
-  tmp->setCoords(tmp2);
-  const double *coo1D=mesh1D->getCoords()->getConstPointer();
-  const int *conn1D=mesh1D->getNodalConnectivity()->getConstPointer();
-  const int *connI1D=mesh1D->getNodalConnectivityIndex()->getConstPointer();
-  for(int i=1;i<nbOfLevsInVec;i++)
-    {
-      const double *begin=coo1D+2*conn1D[connI1D[i-1]+1];
-      const double *end=coo1D+2*conn1D[connI1D[i-1]+2];
-      const double *third=i+1<nbOfLevsInVec?coo1D+2*conn1D[connI1D[i]+2]:coo1D+2*conn1D[connI1D[i-2]+1];
-      const double vec[2]={end[0]-begin[0],end[1]-begin[1]};
-      tmp->translate(vec);
-      double tmp3[2],radius,alpha,alpha0;
-      const double *p0=i+1<nbOfLevsInVec?begin:third;
-      const double *p1=i+1<nbOfLevsInVec?end:begin;
-      const double *p2=i+1<nbOfLevsInVec?third:end;
-      INTERP_KERNEL::EdgeArcCircle::GetArcOfCirclePassingThru(p0,p1,p2,tmp3,radius,alpha,alpha0);
-      double cosangle=i+1<nbOfLevsInVec?(p0[0]-tmp3[0])*(p1[0]-tmp3[0])+(p0[1]-tmp3[1])*(p1[1]-tmp3[1]):(p2[0]-tmp3[0])*(p1[0]-tmp3[0])+(p2[1]-tmp3[1])*(p1[1]-tmp3[1]);
-      double angle=acos(cosangle/(radius*radius));
-      tmp->rotate(end,0,angle);
-      retPtr=std::copy(tmp2->getConstPointer(),tmp2->getConstPointer()+tmp2->getNbOfElems(),retPtr);
-    }
-  return ret.retn();
-}
-
-/*!
- * This method incarnates the policy 1 for MEDCouplingUMesh::buildExtrudedMesh method.
- * \param mesh1D is the input 1D mesh used for translation and automatic rotation computation.
- * \return newCoords new coords filled by this method. 
- */
-DataArrayDouble *MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation3D(const MEDCouplingUMesh *mesh1D, bool isQuad) const
-{
-  if(isQuad)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation3D : not implemented for quadratic cells !");
-  int oldNbOfNodes=getNumberOfNodes();
-  int nbOf1DCells=mesh1D->getNumberOfCells();
-  if(nbOf1DCells<2)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation3D : impossible to detect any angle of rotation ! Change extrusion policy 1->0 !");
-  MCAuto<DataArrayDouble> ret=DataArrayDouble::New();
-  int nbOfLevsInVec=nbOf1DCells+1;
-  ret->alloc(oldNbOfNodes*nbOfLevsInVec,3);
-  double *retPtr=ret->getPointer();
-  retPtr=std::copy(getCoords()->getConstPointer(),getCoords()->getConstPointer()+getCoords()->getNbOfElems(),retPtr);
-  MCAuto<MEDCouplingUMesh> tmp=MEDCouplingUMesh::New();
-  MCAuto<DataArrayDouble> tmp2=getCoords()->deepCopy();
-  tmp->setCoords(tmp2);
-  const double *coo1D=mesh1D->getCoords()->getConstPointer();
-  const int *conn1D=mesh1D->getNodalConnectivity()->getConstPointer();
-  const int *connI1D=mesh1D->getNodalConnectivityIndex()->getConstPointer();
-  for(int i=1;i<nbOfLevsInVec;i++)
-    {
-      const double *begin=coo1D+3*conn1D[connI1D[i-1]+1];
-      const double *end=coo1D+3*conn1D[connI1D[i-1]+2];
-      const double *third=i+1<nbOfLevsInVec?coo1D+3*conn1D[connI1D[i]+2]:coo1D+3*conn1D[connI1D[i-2]+1];
-      const double vec[3]={end[0]-begin[0],end[1]-begin[1],end[2]-begin[2]};
-      tmp->translate(vec);
-      double tmp3[2],radius,alpha,alpha0;
-      const double *p0=i+1<nbOfLevsInVec?begin:third;
-      const double *p1=i+1<nbOfLevsInVec?end:begin;
-      const double *p2=i+1<nbOfLevsInVec?third:end;
-      double vecPlane[3]={
-        (p1[1]-p0[1])*(p2[2]-p1[2])-(p1[2]-p0[2])*(p2[1]-p1[1]),
-        (p1[2]-p0[2])*(p2[0]-p1[0])-(p1[0]-p0[0])*(p2[2]-p1[2]),
-        (p1[0]-p0[0])*(p2[1]-p1[1])-(p1[1]-p0[1])*(p2[0]-p1[0]),
-      };
-      double norm=sqrt(vecPlane[0]*vecPlane[0]+vecPlane[1]*vecPlane[1]+vecPlane[2]*vecPlane[2]);
-      if(norm>1.e-7)
-        {
-          vecPlane[0]/=norm; vecPlane[1]/=norm; vecPlane[2]/=norm;
-          double norm2=sqrt(vecPlane[0]*vecPlane[0]+vecPlane[1]*vecPlane[1]);
-          double vec2[2]={vecPlane[1]/norm2,-vecPlane[0]/norm2};
-          double s2=norm2;
-          double c2=cos(asin(s2));
-          double m[3][3]={
-            {vec2[0]*vec2[0]*(1-c2)+c2, vec2[0]*vec2[1]*(1-c2), vec2[1]*s2},
-            {vec2[0]*vec2[1]*(1-c2), vec2[1]*vec2[1]*(1-c2)+c2, -vec2[0]*s2},
-            {-vec2[1]*s2, vec2[0]*s2, c2}
-          };
-          double p0r[3]={m[0][0]*p0[0]+m[0][1]*p0[1]+m[0][2]*p0[2], m[1][0]*p0[0]+m[1][1]*p0[1]+m[1][2]*p0[2], m[2][0]*p0[0]+m[2][1]*p0[1]+m[2][2]*p0[2]};
-          double p1r[3]={m[0][0]*p1[0]+m[0][1]*p1[1]+m[0][2]*p1[2], m[1][0]*p1[0]+m[1][1]*p1[1]+m[1][2]*p1[2], m[2][0]*p1[0]+m[2][1]*p1[1]+m[2][2]*p1[2]};
-          double p2r[3]={m[0][0]*p2[0]+m[0][1]*p2[1]+m[0][2]*p2[2], m[1][0]*p2[0]+m[1][1]*p2[1]+m[1][2]*p2[2], m[2][0]*p2[0]+m[2][1]*p2[1]+m[2][2]*p2[2]};
-          INTERP_KERNEL::EdgeArcCircle::GetArcOfCirclePassingThru(p0r,p1r,p2r,tmp3,radius,alpha,alpha0);
-          double cosangle=i+1<nbOfLevsInVec?(p0r[0]-tmp3[0])*(p1r[0]-tmp3[0])+(p0r[1]-tmp3[1])*(p1r[1]-tmp3[1]):(p2r[0]-tmp3[0])*(p1r[0]-tmp3[0])+(p2r[1]-tmp3[1])*(p1r[1]-tmp3[1]);
-          double angle=acos(cosangle/(radius*radius));
-          tmp->rotate(end,vecPlane,angle);
-        }
-      retPtr=std::copy(tmp2->getConstPointer(),tmp2->getConstPointer()+tmp2->getNbOfElems(),retPtr);
-    }
-  return ret.retn();
-}
-
-/*!
- * This method is private because not easy to use for end user. This method is const contrary to
- * MEDCouplingUMesh::buildExtrudedMesh method because this->_coords are expected to contain
- * the coords sorted slice by slice.
- * \param isQuad specifies presence of quadratic cells.
- */
-MEDCouplingUMesh *MEDCouplingUMesh::buildExtrudedMeshFromThisLowLev(int nbOfNodesOf1Lev, bool isQuad) const
-{
-  int nbOf1DCells(getNumberOfNodes()/nbOfNodesOf1Lev-1);
-  int nbOf2DCells(getNumberOfCells());
-  int nbOf3DCells(nbOf2DCells*nbOf1DCells);
-  MEDCouplingUMesh *ret(MEDCouplingUMesh::New("Extruded",getMeshDimension()+1));
-  const int *conn(_nodal_connec->begin()),*connI(_nodal_connec_index->begin());
-  MCAuto<DataArrayInt> newConn(DataArrayInt::New()),newConnI(DataArrayInt::New());
-  newConnI->alloc(nbOf3DCells+1,1);
-  int *newConnIPtr(newConnI->getPointer());
-  *newConnIPtr++=0;
-  std::vector<int> newc;
-  for(int j=0;j<nbOf2DCells;j++)
-    {
-      AppendExtrudedCell(conn+connI[j],conn+connI[j+1],nbOfNodesOf1Lev,isQuad,newc);
-      *newConnIPtr++=(int)newc.size();
-    }
-  newConn->alloc((int)(newc.size())*nbOf1DCells,1);
-  int *newConnPtr(newConn->getPointer());
-  int deltaPerLev(isQuad?2*nbOfNodesOf1Lev:nbOfNodesOf1Lev);
-  newConnIPtr=newConnI->getPointer();
-  for(int iz=0;iz<nbOf1DCells;iz++)
-    {
-      if(iz!=0)
-        std::transform(newConnIPtr+1,newConnIPtr+1+nbOf2DCells,newConnIPtr+1+iz*nbOf2DCells,std::bind2nd(std::plus<int>(),newConnIPtr[iz*nbOf2DCells]));
-      const int *posOfTypeOfCell(newConnIPtr);
-      for(std::vector<int>::const_iterator iter=newc.begin();iter!=newc.end();iter++,newConnPtr++)
-        {
-          int icell((int)(iter-newc.begin()));//std::distance unfortunately cannot been called here in C++98
-          if(icell!=*posOfTypeOfCell)
-            {
-              if(*iter!=-1)
-                *newConnPtr=(*iter)+iz*deltaPerLev;
-              else
-                *newConnPtr=-1;
-            }
-          else
-            {
-              *newConnPtr=*iter;
-              posOfTypeOfCell++;
-            }
-        }
-    }
-  ret->setConnectivity(newConn,newConnI,true);
-  ret->setCoords(getCoords());
-  return ret;
-}
 
 /*!
  * Checks if \a this mesh is constituted by only quadratic cells.
@@ -5177,8 +4612,8 @@ bool MEDCouplingUMesh::isFullyQuadratic() const
 {
   checkFullyDefined();
   bool ret=true;
-  int nbOfCells=getNumberOfCells();
-  for(int i=0;i<nbOfCells && ret;i++)
+  mcIdType nbOfCells=getNumberOfCells();
+  for(mcIdType i=0;i<nbOfCells && ret;i++)
     {
       INTERP_KERNEL::NormalizedCellType type=getTypeOfCell(i);
       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type);
@@ -5197,8 +4632,8 @@ bool MEDCouplingUMesh::isPresenceOfQuadratic() const
 {
   checkFullyDefined();
   bool ret=false;
-  int nbOfCells=getNumberOfCells();
-  for(int i=0;i<nbOfCells && !ret;i++)
+  mcIdType nbOfCells=getNumberOfCells();
+  for(mcIdType i=0;i<nbOfCells && !ret;i++)
     {
       INTERP_KERNEL::NormalizedCellType type=getTypeOfCell(i);
       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type);
@@ -5216,10 +4651,10 @@ bool MEDCouplingUMesh::isPresenceOfQuadratic() const
 void MEDCouplingUMesh::convertQuadraticCellsToLinear()
 {
   checkFullyDefined();
-  int nbOfCells(getNumberOfCells());
-  int delta=0;
-  const int *iciptr=_nodal_connec_index->begin();
-  for(int i=0;i<nbOfCells;i++)
+  mcIdType nbOfCells=getNumberOfCells();
+  mcIdType delta=0;
+  const mcIdType *iciptr=_nodal_connec_index->begin();
+  for(mcIdType i=0;i<nbOfCells;i++)
     {
       INTERP_KERNEL::NormalizedCellType type=getTypeOfCell(i);
       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type);
@@ -5235,14 +4670,14 @@ void MEDCouplingUMesh::convertQuadraticCellsToLinear()
     }
   if(delta==0)
     return ;
-  MCAuto<DataArrayInt> newConn(DataArrayInt::New()),newConnI(DataArrayInt::New());
-  const int *icptr(_nodal_connec->begin());
+  MCAuto<DataArrayIdType> newConn(DataArrayIdType::New()),newConnI(DataArrayIdType::New());
+  const mcIdType *icptr(_nodal_connec->begin());
   newConn->alloc(getNodalConnectivityArrayLen()-delta,1);
   newConnI->alloc(nbOfCells+1,1);
-  int *ocptr(newConn->getPointer()),*ociptr(newConnI->getPointer());
+  mcIdType *ocptr(newConn->getPointer()),*ociptr(newConnI->getPointer());
   *ociptr=0;
   _types.clear();
-  for(int i=0;i<nbOfCells;i++,ociptr++)
+  for(mcIdType i=0;i<nbOfCells;i++,ociptr++)
     {
       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)icptr[iciptr[i]];
       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type);
@@ -5257,10 +4692,10 @@ void MEDCouplingUMesh::convertQuadraticCellsToLinear()
           INTERP_KERNEL::NormalizedCellType typel=cm.getLinearType();
           _types.insert(typel);
           const INTERP_KERNEL::CellModel& cml=INTERP_KERNEL::CellModel::GetCellModel(typel);
-          int newNbOfNodes=cml.getNumberOfNodes();
+          mcIdType newNbOfNodes=cml.getNumberOfNodes();
           if(cml.isDynamic())
             newNbOfNodes=(iciptr[i+1]-iciptr[i]-1)/2;
-          *ocptr++=(int)typel;
+          *ocptr++=ToIdType(typel);
           ocptr=std::copy(icptr+iciptr[i]+1,icptr+iciptr[i]+newNbOfNodes+1,ocptr);
           ociptr[1]=ociptr[0]+newNbOfNodes+1;
         }
@@ -5275,22 +4710,22 @@ void MEDCouplingUMesh::convertQuadraticCellsToLinear()
  * or to INTERP_KERNEL::NORM_TRI7 if \a conversionType is equal to 1. All non linear cells and polyhedron in \a this are let untouched.
  * Contrary to MEDCouplingUMesh::convertQuadraticCellsToLinear method, the coordinates in \a this can be become bigger. All created nodes will be put at the
  * end of the existing coordinates.
- * 
+ *
  * \param [in] conversionType specifies the type of conversion expected. Only 0 (default) and 1 are supported presently. 0 those that creates the 'most' simple
  *             corresponding quadratic cells. 1 is those creating the 'most' complex.
- * \return a newly created DataArrayInt instance that the caller should deal with containing cell ids of converted cells.
- * 
+ * \return a newly created DataArrayIdType instance that the caller should deal with containing cell ids of converted cells.
+ *
  * \throw if \a this is not fully defined. It throws too if \a conversionType is not in [0,1].
  *
  * \sa MEDCouplingUMesh::convertQuadraticCellsToLinear
  */
-DataArrayInt *MEDCouplingUMesh::convertLinearCellsToQuadratic(int conversionType)
+DataArrayIdType *MEDCouplingUMesh::convertLinearCellsToQuadratic(int conversionType)
 {
-  DataArrayInt *conn=0,*connI=0;
+  DataArrayIdType *conn=0,*connI=0;
   DataArrayDouble *coords=0;
   std::set<INTERP_KERNEL::NormalizedCellType> types;
   checkFullyDefined();
-  MCAuto<DataArrayInt> ret,connSafe,connISafe;
+  MCAuto<DataArrayIdType> ret,connSafe,connISafe;
   MCAuto<DataArrayDouble> coordsSafe;
   int meshDim=getMeshDimension();
   switch(conversionType)
@@ -5373,16 +4808,6 @@ void MEDCouplingUMesh::tessellate2D(double eps)
       throw INTERP_KERNEL::Exception("MEDCouplingUMesh::tessellate2D : mesh dimension must be in [1,2] !");
     }
 }
-/*!
- * Tessellates \a this 1D mesh in 2D space by dividing not straight quadratic edges.
- * \warning This method can lead to a huge amount of nodes if \a eps is very low.
- *  \param [in] eps - specifies the maximal angle (in radian) between 2 sub-edges of
- *         a sub-divided edge.
- *  \throw If the coordinates array is not set.
- *  \throw If the nodal connectivity of cells is not defined.
- *  \throw If \a this->getMeshDimension() != 1.
- *  \throw If \a this->getSpaceDimension() != 2.
- */
 
 #if 0
 /*!
@@ -5405,8 +4830,8 @@ void MEDCouplingUMesh::tessellate2D(double eps)
  *
  * \sa buildDescendingConnectivity2
  */
-void MEDCouplingUMesh::splitSomeEdgesOf2DMesh(const DataArrayInt *nodeIdsToAdd, const DataArrayInt *nodeIdsIndexToAdd, const DataArrayInt *edgeIdsToBeSplit,
-                                              const MEDCouplingUMesh *mesh1Desc, const DataArrayInt *desc, const DataArrayInt *descI, const DataArrayInt *revDesc, const DataArrayInt *revDescI)
+void MEDCouplingUMesh::splitSomeEdgesOf2DMesh(const DataArrayIdType *nodeIdsToAdd, const DataArrayIdType *nodeIdsIndexToAdd, const DataArrayIdType *edgeIdsToBeSplit,
+                                              const MEDCouplingUMesh *mesh1Desc, const DataArrayIdType *desc, const DataArrayIdType *descI, const DataArrayIdType *revDesc, const DataArrayIdType *revDescI)
 {
   if(!nodeIdsToAdd || !nodeIdsIndexToAdd || !edgeIdsToBeSplit || !mesh1Desc || !desc || !descI || !revDesc || !revDescI)
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::splitSomeEdgesOf2DMesh : input pointers must be not NULL !");
@@ -5415,255 +4840,13 @@ void MEDCouplingUMesh::splitSomeEdgesOf2DMesh(const DataArrayInt *nodeIdsToAdd,
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::splitSomeEdgesOf2DMesh : this must have spacedim=meshdim=2 !");
   if(mesh1Desc->getSpaceDimension()!=2 || mesh1Desc->getMeshDimension()!=1)
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::splitSomeEdgesOf2DMesh : mesh1Desc must be the explosion of this with spaceDim=2 and meshDim = 1 !");
-  //DataArrayInt *out0(0),*outi0(0);
+  //DataArrayIdType *out0(0),*outi0(0);
   //MEDCouplingUMesh::ExtractFromIndexedArrays(idsInDesc2DToBeRefined->begin(),idsInDesc2DToBeRefined->end(),dd3,dd4,out0,outi0);
-  //MCAuto<DataArrayInt> out0s(out0),outi0s(outi0);
+  //MCAuto<DataArrayIdType> out0s(out0),outi0s(outi0);
   //out0s=out0s->buildUnique(); out0s->sort(true);
 }
 #endif
 
-/*!
- * Implementes \a conversionType 0 for meshes with meshDim = 1, of MEDCouplingUMesh::convertLinearCellsToQuadratic method.
- * \return a newly created DataArrayInt instance that the caller should deal with containing cell ids of converted cells.
- * \sa MEDCouplingUMesh::convertLinearCellsToQuadratic.
- */
-DataArrayInt *MEDCouplingUMesh::convertLinearCellsToQuadratic1D0(DataArrayInt *&conn, DataArrayInt *&connI, DataArrayDouble *& coords, std::set<INTERP_KERNEL::NormalizedCellType>& types) const
-{
-  MCAuto<DataArrayDouble> bary=computeCellCenterOfMass();
-  MCAuto<DataArrayInt> newConn=DataArrayInt::New(); newConn->alloc(0,1);
-  MCAuto<DataArrayInt> newConnI=DataArrayInt::New(); newConnI->alloc(1,1); newConnI->setIJ(0,0,0);
-  MCAuto<DataArrayInt> ret=DataArrayInt::New(); ret->alloc(0,1);
-  int nbOfCells=getNumberOfCells();
-  int nbOfNodes=getNumberOfNodes();
-  const int *cPtr=_nodal_connec->begin();
-  const int *icPtr=_nodal_connec_index->begin();
-  int lastVal=0,offset=nbOfNodes;
-  for(int i=0;i<nbOfCells;i++,icPtr++)
-    {
-      INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)cPtr[*icPtr];
-      if(type==INTERP_KERNEL::NORM_SEG2)
-        {
-          types.insert(INTERP_KERNEL::NORM_SEG3);
-          newConn->pushBackSilent((int)INTERP_KERNEL::NORM_SEG3);
-          newConn->pushBackValsSilent(cPtr+icPtr[0]+1,cPtr+icPtr[0]+3);
-          newConn->pushBackSilent(offset++);
-          lastVal+=4;
-          newConnI->pushBackSilent(lastVal);
-          ret->pushBackSilent(i);
-        }
-      else
-        {
-          types.insert(type);
-          lastVal+=(icPtr[1]-icPtr[0]);
-          newConnI->pushBackSilent(lastVal);
-          newConn->pushBackValsSilent(cPtr+icPtr[0],cPtr+icPtr[1]);
-        }
-    }
-  MCAuto<DataArrayDouble> tmp=bary->selectByTupleIdSafe(ret->begin(),ret->end());
-  coords=DataArrayDouble::Aggregate(getCoords(),tmp); conn=newConn.retn(); connI=newConnI.retn();
-  return ret.retn();
-}
-
-DataArrayInt *MEDCouplingUMesh::convertLinearCellsToQuadratic2DAnd3D0(const MEDCouplingUMesh *m1D, const DataArrayInt *desc, const DataArrayInt *descI, DataArrayInt *&conn, DataArrayInt *&connI, DataArrayDouble *& coords, std::set<INTERP_KERNEL::NormalizedCellType>& types) const
-{
-  MCAuto<DataArrayInt> newConn=DataArrayInt::New(); newConn->alloc(0,1);
-  MCAuto<DataArrayInt> newConnI=DataArrayInt::New(); newConnI->alloc(1,1); newConnI->setIJ(0,0,0);
-  MCAuto<DataArrayInt> ret=DataArrayInt::New(); ret->alloc(0,1);
-  //
-  const int *descPtr(desc->begin()),*descIPtr(descI->begin());
-  DataArrayInt *conn1D=0,*conn1DI=0;
-  std::set<INTERP_KERNEL::NormalizedCellType> types1D;
-  DataArrayDouble *coordsTmp=0;
-  MCAuto<DataArrayInt> ret1D=m1D->convertLinearCellsToQuadratic1D0(conn1D,conn1DI,coordsTmp,types1D); ret1D=0;
-  MCAuto<DataArrayDouble> coordsTmpSafe(coordsTmp);
-  MCAuto<DataArrayInt> conn1DSafe(conn1D),conn1DISafe(conn1DI);
-  const int *c1DPtr=conn1D->begin();
-  const int *c1DIPtr=conn1DI->begin();
-  int nbOfCells=getNumberOfCells();
-  const int *cPtr=_nodal_connec->begin();
-  const int *icPtr=_nodal_connec_index->begin();
-  int lastVal=0;
-  for(int i=0;i<nbOfCells;i++,icPtr++,descIPtr++)
-    {
-      INTERP_KERNEL::NormalizedCellType typ=(INTERP_KERNEL::NormalizedCellType)cPtr[*icPtr];
-      const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
-      if(!cm.isQuadratic())
-        {
-          INTERP_KERNEL::NormalizedCellType typ2=cm.getQuadraticType();
-          types.insert(typ2); newConn->pushBackSilent(typ2);
-          newConn->pushBackValsSilent(cPtr+icPtr[0]+1,cPtr+icPtr[1]);
-          for(const int *d=descPtr+descIPtr[0];d!=descPtr+descIPtr[1];d++)
-            newConn->pushBackSilent(c1DPtr[c1DIPtr[*d]+3]);
-          lastVal+=(icPtr[1]-icPtr[0])+(descIPtr[1]-descIPtr[0]);
-          newConnI->pushBackSilent(lastVal);
-          ret->pushBackSilent(i);
-        }
-      else
-        {
-          types.insert(typ);
-          lastVal+=(icPtr[1]-icPtr[0]);
-          newConnI->pushBackSilent(lastVal);
-          newConn->pushBackValsSilent(cPtr+icPtr[0],cPtr+icPtr[1]);
-        }
-    }
-  conn=newConn.retn(); connI=newConnI.retn(); coords=coordsTmpSafe.retn();
-  return ret.retn();
-}
-
-/*!
- * Implementes \a conversionType 0 for meshes with meshDim = 2, of MEDCouplingUMesh::convertLinearCellsToQuadratic method.
- * \return a newly created DataArrayInt instance that the caller should deal with containing cell ids of converted cells.
- * \sa MEDCouplingUMesh::convertLinearCellsToQuadratic.
- */
-DataArrayInt *MEDCouplingUMesh::convertLinearCellsToQuadratic2D0(DataArrayInt *&conn, DataArrayInt *&connI, DataArrayDouble *& coords, std::set<INTERP_KERNEL::NormalizedCellType>& types) const
-{
-  MCAuto<DataArrayInt> desc(DataArrayInt::New()),descI(DataArrayInt::New()),tmp2(DataArrayInt::New()),tmp3(DataArrayInt::New());
-  MCAuto<MEDCouplingUMesh> m1D=buildDescendingConnectivity(desc,descI,tmp2,tmp3); tmp2=0; tmp3=0;
-  return convertLinearCellsToQuadratic2DAnd3D0(m1D,desc,descI,conn,connI,coords,types);
-}
-
-DataArrayInt *MEDCouplingUMesh::convertLinearCellsToQuadratic2D1(DataArrayInt *&conn, DataArrayInt *&connI, DataArrayDouble *& coords, std::set<INTERP_KERNEL::NormalizedCellType>& types) const
-{
-  MCAuto<DataArrayInt> desc(DataArrayInt::New()),descI(DataArrayInt::New()),tmp2(DataArrayInt::New()),tmp3(DataArrayInt::New());
-  MCAuto<MEDCouplingUMesh> m1D=buildDescendingConnectivity(desc,descI,tmp2,tmp3); tmp2=0; tmp3=0;
-  //
-  MCAuto<DataArrayInt> newConn=DataArrayInt::New(); newConn->alloc(0,1);
-  MCAuto<DataArrayInt> newConnI=DataArrayInt::New(); newConnI->alloc(1,1); newConnI->setIJ(0,0,0);
-  MCAuto<DataArrayInt> ret=DataArrayInt::New(); ret->alloc(0,1);
-  //
-  MCAuto<DataArrayDouble> bary=computeCellCenterOfMass();
-  const int *descPtr(desc->begin()),*descIPtr(descI->begin());
-  DataArrayInt *conn1D=0,*conn1DI=0;
-  std::set<INTERP_KERNEL::NormalizedCellType> types1D;
-  DataArrayDouble *coordsTmp=0;
-  MCAuto<DataArrayInt> ret1D=m1D->convertLinearCellsToQuadratic1D0(conn1D,conn1DI,coordsTmp,types1D); ret1D=0;
-  MCAuto<DataArrayDouble> coordsTmpSafe(coordsTmp);
-  MCAuto<DataArrayInt> conn1DSafe(conn1D),conn1DISafe(conn1DI);
-  const int *c1DPtr=conn1D->begin();
-  const int *c1DIPtr=conn1DI->begin();
-  int nbOfCells=getNumberOfCells();
-  const int *cPtr=_nodal_connec->begin();
-  const int *icPtr=_nodal_connec_index->begin();
-  int lastVal=0,offset=coordsTmpSafe->getNumberOfTuples();
-  for(int i=0;i<nbOfCells;i++,icPtr++,descIPtr++)
-    {
-      INTERP_KERNEL::NormalizedCellType typ=(INTERP_KERNEL::NormalizedCellType)cPtr[*icPtr];
-      const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
-      if(!cm.isQuadratic())
-        {
-          INTERP_KERNEL::NormalizedCellType typ2=cm.getQuadraticType2();
-          types.insert(typ2); newConn->pushBackSilent(typ2);
-          newConn->pushBackValsSilent(cPtr+icPtr[0]+1,cPtr+icPtr[1]);
-          for(const int *d=descPtr+descIPtr[0];d!=descPtr+descIPtr[1];d++)
-            newConn->pushBackSilent(c1DPtr[c1DIPtr[*d]+3]);
-          newConn->pushBackSilent(offset+ret->getNumberOfTuples());
-          lastVal+=(icPtr[1]-icPtr[0])+(descIPtr[1]-descIPtr[0])+1;
-          newConnI->pushBackSilent(lastVal);
-          ret->pushBackSilent(i);
-        }
-      else
-        {
-          types.insert(typ);
-          lastVal+=(icPtr[1]-icPtr[0]);
-          newConnI->pushBackSilent(lastVal);
-          newConn->pushBackValsSilent(cPtr+icPtr[0],cPtr+icPtr[1]);
-        }
-    }
-  MCAuto<DataArrayDouble> tmp=bary->selectByTupleIdSafe(ret->begin(),ret->end());
-  coords=DataArrayDouble::Aggregate(coordsTmpSafe,tmp); conn=newConn.retn(); connI=newConnI.retn();
-  return ret.retn();
-}
-
-/*!
- * Implementes \a conversionType 0 for meshes with meshDim = 3, of MEDCouplingUMesh::convertLinearCellsToQuadratic method.
- * \return a newly created DataArrayInt instance that the caller should deal with containing cell ids of converted cells.
- * \sa MEDCouplingUMesh::convertLinearCellsToQuadratic.
- */
-DataArrayInt *MEDCouplingUMesh::convertLinearCellsToQuadratic3D0(DataArrayInt *&conn, DataArrayInt *&connI, DataArrayDouble *& coords, std::set<INTERP_KERNEL::NormalizedCellType>& types) const
-{
-  MCAuto<DataArrayInt> desc(DataArrayInt::New()),descI(DataArrayInt::New()),tmp2(DataArrayInt::New()),tmp3(DataArrayInt::New());
-  MCAuto<MEDCouplingUMesh> m1D=explode3DMeshTo1D(desc,descI,tmp2,tmp3); tmp2=0; tmp3=0;
-  return convertLinearCellsToQuadratic2DAnd3D0(m1D,desc,descI,conn,connI,coords,types);
-}
-
-DataArrayInt *MEDCouplingUMesh::convertLinearCellsToQuadratic3D1(DataArrayInt *&conn, DataArrayInt *&connI, DataArrayDouble *& coords, std::set<INTERP_KERNEL::NormalizedCellType>& types) const
-{
-  MCAuto<DataArrayInt> desc2(DataArrayInt::New()),desc2I(DataArrayInt::New()),tmp2(DataArrayInt::New()),tmp3(DataArrayInt::New());
-  MCAuto<MEDCouplingUMesh> m2D=buildDescendingConnectivityGen<MinusOneSonsGeneratorBiQuadratic>(desc2,desc2I,tmp2,tmp3,MEDCouplingFastNbrer); tmp2=0; tmp3=0;
-  MCAuto<DataArrayInt> desc1(DataArrayInt::New()),desc1I(DataArrayInt::New()),tmp4(DataArrayInt::New()),tmp5(DataArrayInt::New());
-  MCAuto<MEDCouplingUMesh> m1D=explode3DMeshTo1D(desc1,desc1I,tmp4,tmp5); tmp4=0; tmp5=0;
-  //
-  MCAuto<DataArrayInt> newConn=DataArrayInt::New(); newConn->alloc(0,1);
-  MCAuto<DataArrayInt> newConnI=DataArrayInt::New(); newConnI->alloc(1,1); newConnI->setIJ(0,0,0);
-  MCAuto<DataArrayInt> ret=DataArrayInt::New(),ret2=DataArrayInt::New(); ret->alloc(0,1); ret2->alloc(0,1);
-  //
-  MCAuto<DataArrayDouble> bary=computeCellCenterOfMass();
-  const int *descPtr(desc1->begin()),*descIPtr(desc1I->begin()),*desc2Ptr(desc2->begin()),*desc2IPtr(desc2I->begin());
-  DataArrayInt *conn1D=0,*conn1DI=0,*conn2D=0,*conn2DI=0;
-  std::set<INTERP_KERNEL::NormalizedCellType> types1D,types2D;
-  DataArrayDouble *coordsTmp=0,*coordsTmp2=0;
-  MCAuto<DataArrayInt> ret1D=m1D->convertLinearCellsToQuadratic1D0(conn1D,conn1DI,coordsTmp,types1D); ret1D=DataArrayInt::New(); ret1D->alloc(0,1);
-  MCAuto<DataArrayInt> conn1DSafe(conn1D),conn1DISafe(conn1DI);
-  MCAuto<DataArrayDouble> coordsTmpSafe(coordsTmp);
-  MCAuto<DataArrayInt> ret2D=m2D->convertLinearCellsToQuadratic2D1(conn2D,conn2DI,coordsTmp2,types2D); ret2D=DataArrayInt::New(); ret2D->alloc(0,1);
-  MCAuto<DataArrayDouble> coordsTmp2Safe(coordsTmp2);
-  MCAuto<DataArrayInt> conn2DSafe(conn2D),conn2DISafe(conn2DI);
-  const int *c1DPtr=conn1D->begin(),*c1DIPtr=conn1DI->begin(),*c2DPtr=conn2D->begin(),*c2DIPtr=conn2DI->begin();
-  int nbOfCells=getNumberOfCells();
-  const int *cPtr=_nodal_connec->begin();
-  const int *icPtr=_nodal_connec_index->begin();
-  int lastVal=0,offset=coordsTmpSafe->getNumberOfTuples();
-  for(int i=0;i<nbOfCells;i++,icPtr++,descIPtr++,desc2IPtr++)
-    {
-      INTERP_KERNEL::NormalizedCellType typ=(INTERP_KERNEL::NormalizedCellType)cPtr[*icPtr];
-      const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
-      if(!cm.isQuadratic())
-        {
-          INTERP_KERNEL::NormalizedCellType typ2=cm.getQuadraticType2();
-          if(typ2==INTERP_KERNEL::NORM_ERROR)
-            {
-              std::ostringstream oss; oss << "MEDCouplingUMesh::convertLinearCellsToQuadratic3D1 : On cell #" << i << " the linear cell type does not support advanced quadratization !";
-              throw INTERP_KERNEL::Exception(oss.str());
-            }
-          types.insert(typ2); newConn->pushBackSilent(typ2);
-          newConn->pushBackValsSilent(cPtr+icPtr[0]+1,cPtr+icPtr[1]);
-          for(const int *d=descPtr+descIPtr[0];d!=descPtr+descIPtr[1];d++)
-            newConn->pushBackSilent(c1DPtr[c1DIPtr[*d]+3]);
-          for(const int *d=desc2Ptr+desc2IPtr[0];d!=desc2Ptr+desc2IPtr[1];d++)
-            {
-              int nodeId2=c2DPtr[c2DIPtr[(*d)+1]-1];
-              int tmpPos=newConn->getNumberOfTuples();
-              newConn->pushBackSilent(nodeId2);
-              ret2D->pushBackSilent(nodeId2); ret1D->pushBackSilent(tmpPos);
-            }
-          newConn->pushBackSilent(offset+ret->getNumberOfTuples());
-          lastVal+=(icPtr[1]-icPtr[0])+(descIPtr[1]-descIPtr[0])+(desc2IPtr[1]-desc2IPtr[0])+1;
-          newConnI->pushBackSilent(lastVal);
-          ret->pushBackSilent(i);
-        }
-      else
-        {
-          types.insert(typ);
-          lastVal+=(icPtr[1]-icPtr[0]);
-          newConnI->pushBackSilent(lastVal);
-          newConn->pushBackValsSilent(cPtr+icPtr[0],cPtr+icPtr[1]);
-        }
-    }
-  MCAuto<DataArrayInt> diffRet2D=ret2D->getDifferentValues();
-  MCAuto<DataArrayInt> o2nRet2D=diffRet2D->invertArrayN2O2O2N(coordsTmp2Safe->getNumberOfTuples());
-  coordsTmp2Safe=coordsTmp2Safe->selectByTupleId(diffRet2D->begin(),diffRet2D->end());
-  MCAuto<DataArrayDouble> tmp=bary->selectByTupleIdSafe(ret->begin(),ret->end());
-  std::vector<const DataArrayDouble *> v(3); v[0]=coordsTmpSafe; v[1]=coordsTmp2Safe; v[2]=tmp;
-  int *c=newConn->getPointer();
-  const int *cI(newConnI->begin());
-  for(const int *elt=ret1D->begin();elt!=ret1D->end();elt++)
-    c[*elt]=o2nRet2D->getIJ(c[*elt],0)+offset;
-  offset=coordsTmp2Safe->getNumberOfTuples();
-  for(const int *elt=ret->begin();elt!=ret->end();elt++)
-    c[cI[(*elt)+1]-1]+=offset;
-  coords=DataArrayDouble::Aggregate(v); conn=newConn.retn(); connI=newConnI.retn();
-  return ret.retn();
-}
 
 /*!
  * Divides every cell of \a this mesh into simplices (triangles in 2D and tetrahedra in 3D).
@@ -5680,18 +4863,18 @@ DataArrayInt *MEDCouplingUMesh::convertLinearCellsToQuadratic3D1(DataArrayInt *&
  * - INTERP_KERNEL::PLANAR_FACE_6 - to split HEXA8  into 6 TETRA4 (for 3D mesh only - see INTERP_KERNEL::SplittingPolicy for an image).
  *
  *
- *  \return DataArrayInt * - a new instance of DataArrayInt holding, for each new cell,
+ *  \return DataArrayIdType * - a new instance of DataArrayIdType holding, for each new cell,
  *          an id of old cell producing it. The caller is to delete this array using
  *         decrRef() as it is no more needed.
  *
  *  \throw If \a policy is 0 or 1 and \a this->getMeshDimension() != 2.
  *  \throw If \a policy is INTERP_KERNEL::PLANAR_FACE_5 or INTERP_KERNEL::PLANAR_FACE_6
- *          and \a this->getMeshDimension() != 3. 
+ *          and \a this->getMeshDimension() != 3.
  *  \throw If \a policy is not one of the four discussed above.
  *  \throw If the nodal connectivity of cells is not defined.
  * \sa MEDCouplingUMesh::tetrahedrize, MEDCoupling1SGTUMesh::sortHexa8EachOther
  */
-DataArrayInt *MEDCouplingUMesh::simplexize(int policy)
+DataArrayIdType *MEDCouplingUMesh::simplexize(int policy)
 {
   switch(policy)
   {
@@ -5699,9 +4882,9 @@ DataArrayInt *MEDCouplingUMesh::simplexize(int policy)
       return simplexizePol0();
     case 1:
       return simplexizePol1();
-    case (int) INTERP_KERNEL::PLANAR_FACE_5:
+    case INTERP_KERNEL::PLANAR_FACE_5:
         return simplexizePlanarFace5();
-    case (int) INTERP_KERNEL::PLANAR_FACE_6:
+    case INTERP_KERNEL::PLANAR_FACE_6:
         return simplexizePlanarFace6();
     default:
       throw INTERP_KERNEL::Exception("MEDCouplingUMesh::simplexize : unrecognized policy ! Must be :\n  - 0 or 1 (only available for meshdim=2) \n  - PLANAR_FACE_5, PLANAR_FACE_6  (only for meshdim=3)");
@@ -5728,10 +4911,10 @@ bool MEDCouplingUMesh::areOnlySimplexCells() const
   int mdim=getMeshDimension();
   if(mdim<1 || mdim>3)
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::areOnlySimplexCells : only available with meshes having a meshdim 1, 2 or 3 !");
-  int nbCells=getNumberOfCells();
-  const int *conn=_nodal_connec->begin();
-  const int *connI=_nodal_connec_index->begin();
-  for(int i=0;i<nbCells;i++)
+  mcIdType nbCells=getNumberOfCells();
+  const mcIdType *conn=_nodal_connec->begin();
+  const mcIdType *connI=_nodal_connec_index->begin();
+  for(mcIdType i=0;i<nbCells;i++)
     {
       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)conn[connI[i]]);
       if(!cm.isSimplex())
@@ -5740,448 +4923,150 @@ bool MEDCouplingUMesh::areOnlySimplexCells() const
   return true;
 }
 
+
+
 /*!
- * This method implements policy 0 of virtual method MEDCoupling::MEDCouplingUMesh::simplexize.
+ * Converts degenerated 2D or 3D linear cells of \a this mesh into cells of simpler
+ * type. For example an INTERP_KERNEL::NORM_QUAD4 cell having only three unique nodes in
+ * its connectivity is transformed into an INTERP_KERNEL::NORM_TRI3 cell.
+ * Quadratic cells in 2D are also handled. In those cells edges where start=end=midpoint are removed.
+ * This method does \b not perform geometrical checks and checks only nodal connectivity of cells,
+ * so it can be useful to call mergeNodes() before calling this method.
+ *  \throw If \a this->getMeshDimension() <= 1.
+ *  \throw If the coordinates array is not set.
+ *  \throw If the nodal connectivity of cells is not defined.
  */
-DataArrayInt *MEDCouplingUMesh::simplexizePol0()
+void MEDCouplingUMesh::convertDegeneratedCells()
 {
-  checkConnectivityFullyDefined();
-  if(getMeshDimension()!=2)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::simplexizePol0 : this policy is only available for mesh with meshdim == 2 !");
-  int nbOfCells=getNumberOfCells();
-  MCAuto<DataArrayInt> ret=DataArrayInt::New();
-  int nbOfCutCells=getNumberOfCellsWithType(INTERP_KERNEL::NORM_QUAD4);
-  ret->alloc(nbOfCells+nbOfCutCells,1);
-  if(nbOfCutCells==0) { ret->iota(0); return ret.retn(); }
-  int *retPt=ret->getPointer();
-  MCAuto<DataArrayInt> newConn=DataArrayInt::New();
-  MCAuto<DataArrayInt> newConnI=DataArrayInt::New();
-  newConnI->alloc(nbOfCells+nbOfCutCells+1,1);
-  newConn->alloc(getNodalConnectivityArrayLen()+3*nbOfCutCells,1);
-  int *pt=newConn->getPointer();
-  int *ptI=newConnI->getPointer();
-  ptI[0]=0;
-  const int *oldc=_nodal_connec->begin();
-  const int *ci=_nodal_connec_index->begin();
-  for(int i=0;i<nbOfCells;i++,ci++)
-    {
-      if((INTERP_KERNEL::NormalizedCellType)oldc[ci[0]]==INTERP_KERNEL::NORM_QUAD4)
-        {
-          const int tmp[8]={(int)INTERP_KERNEL::NORM_TRI3,oldc[ci[0]+1],oldc[ci[0]+2],oldc[ci[0]+3],
-            (int)INTERP_KERNEL::NORM_TRI3,oldc[ci[0]+1],oldc[ci[0]+3],oldc[ci[0]+4]};
-          pt=std::copy(tmp,tmp+8,pt);
-          ptI[1]=ptI[0]+4;
-          ptI[2]=ptI[0]+8;
-          *retPt++=i;
-          *retPt++=i;
-          ptI+=2;
-        }
-      else
-        {
-          pt=std::copy(oldc+ci[0],oldc+ci[1],pt);
-          ptI[1]=ptI[0]+ci[1]-ci[0];
-          ptI++;
-          *retPt++=i;
-        }
+  checkFullyDefined();
+  if(getMeshDimension()<=1)
+    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::convertDegeneratedCells works on umeshes with meshdim equals to 2 or 3 !");
+  mcIdType nbOfCells=getNumberOfCells();
+  if(nbOfCells<1)
+    return ;
+  mcIdType initMeshLgth=getNodalConnectivityArrayLen();
+  mcIdType *conn=_nodal_connec->getPointer();
+  mcIdType *index=_nodal_connec_index->getPointer();
+  mcIdType posOfCurCell=0;
+  mcIdType newPos=0;
+  mcIdType lgthOfCurCell;
+  for(mcIdType i=0;i<nbOfCells;i++)
+    {
+      lgthOfCurCell=index[i+1]-posOfCurCell;
+      INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)conn[posOfCurCell];
+      mcIdType newLgth;
+      INTERP_KERNEL::NormalizedCellType newType=INTERP_KERNEL::CellSimplify::simplifyDegeneratedCell(type,conn+posOfCurCell+1,lgthOfCurCell-1,
+                                                                                                     conn+newPos+1,newLgth);
+      conn[newPos]=newType;
+      newPos+=newLgth+1;
+      posOfCurCell=index[i+1];
+      index[i+1]=newPos;
     }
-  _nodal_connec->decrRef();
-  _nodal_connec=newConn.retn();
-  _nodal_connec_index->decrRef();
-  _nodal_connec_index=newConnI.retn();
+  if(newPos!=initMeshLgth)
+    _nodal_connec->reAlloc(newPos);
   computeTypes();
-  updateTime();
-  return ret.retn();
 }
 
 /*!
- * This method implements policy 1 of virtual method MEDCoupling::MEDCouplingUMesh::simplexize.
+ * Same as MEDCouplingUMesh::convertDegeneratedCells() plus deletion of the flat cells.
+ * A cell is flat in the following cases:
+ *   - for a linear cell, all points in the connectivity are equal
+ *   - for a quadratic cell, either the above, or a quadratic polygon with two (linear) points and two
+ *   identical quadratic points
+ * \return a new instance of DataArrayIdType holding ids of removed cells. The caller is to delete
+ *      this array using decrRef() as it is no more needed.
  */
-DataArrayInt *MEDCouplingUMesh::simplexizePol1()
+DataArrayIdType *MEDCouplingUMesh::convertDegeneratedCellsAndRemoveFlatOnes()
 {
-  checkConnectivityFullyDefined();
-  if(getMeshDimension()!=2)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::simplexizePol0 : this policy is only available for mesh with meshdim == 2 !");
-  int nbOfCells=getNumberOfCells();
-  MCAuto<DataArrayInt> ret=DataArrayInt::New();
-  int nbOfCutCells=getNumberOfCellsWithType(INTERP_KERNEL::NORM_QUAD4);
-  ret->alloc(nbOfCells+nbOfCutCells,1);
-  if(nbOfCutCells==0) { ret->iota(0); return ret.retn(); }
-  int *retPt=ret->getPointer();
-  MCAuto<DataArrayInt> newConn=DataArrayInt::New();
-  MCAuto<DataArrayInt> newConnI=DataArrayInt::New();
-  newConnI->alloc(nbOfCells+nbOfCutCells+1,1);
-  newConn->alloc(getNodalConnectivityArrayLen()+3*nbOfCutCells,1);
-  int *pt=newConn->getPointer();
-  int *ptI=newConnI->getPointer();
-  ptI[0]=0;
-  const int *oldc=_nodal_connec->begin();
-  const int *ci=_nodal_connec_index->begin();
-  for(int i=0;i<nbOfCells;i++,ci++)
-    {
-      if((INTERP_KERNEL::NormalizedCellType)oldc[ci[0]]==INTERP_KERNEL::NORM_QUAD4)
+  checkFullyDefined();
+  if(getMeshDimension()<=1)
+    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::convertDegeneratedCells works on umeshes with meshdim equals to 2 or 3 !");
+  mcIdType nbOfCells=getNumberOfCells();
+  MCAuto<DataArrayIdType> ret(DataArrayIdType::New()); ret->alloc(0,1);
+  if(nbOfCells<1)
+    return ret.retn();
+  mcIdType initMeshLgth=getNodalConnectivityArrayLen();
+  mcIdType *conn=_nodal_connec->getPointer();
+  mcIdType *index=_nodal_connec_index->getPointer();
+  mcIdType posOfCurCell=0;
+  mcIdType newPos=0;
+  mcIdType lgthOfCurCell, nbDelCells(0);
+  for(mcIdType i=0;i<nbOfCells;i++)
+    {
+      lgthOfCurCell=index[i+1]-posOfCurCell;
+      INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)conn[posOfCurCell];
+      mcIdType newLgth;
+      INTERP_KERNEL::NormalizedCellType newType=INTERP_KERNEL::CellSimplify::simplifyDegeneratedCell(type,conn+posOfCurCell+1,lgthOfCurCell-1,
+                                                                                                     conn+newPos+1,newLgth);
+      // Shall we delete the cell if it is completely degenerated:
+      bool delCell=INTERP_KERNEL::CellSimplify::isFlatCell(conn, newPos, newLgth, newType);
+      if (delCell)
         {
-          const int tmp[8]={(int)INTERP_KERNEL::NORM_TRI3,oldc[ci[0]+1],oldc[ci[0]+2],oldc[ci[0]+4],
-            (int)INTERP_KERNEL::NORM_TRI3,oldc[ci[0]+2],oldc[ci[0]+3],oldc[ci[0]+4]};
-          pt=std::copy(tmp,tmp+8,pt);
-          ptI[1]=ptI[0]+4;
-          ptI[2]=ptI[0]+8;
-          *retPt++=i;
-          *retPt++=i;
-          ptI+=2;
+          nbDelCells++;
+          ret->pushBackSilent(i);
         }
-      else
+      else   //if the cell is to be deleted, simply stay at the same place
         {
-          pt=std::copy(oldc+ci[0],oldc+ci[1],pt);
-          ptI[1]=ptI[0]+ci[1]-ci[0];
-          ptI++;
-          *retPt++=i;
+          conn[newPos]=newType;
+          newPos+=newLgth+1;
         }
+      posOfCurCell=index[i+1];
+      index[i+1-nbDelCells]=newPos;
     }
-  _nodal_connec->decrRef();
-  _nodal_connec=newConn.retn();
-  _nodal_connec_index->decrRef();
-  _nodal_connec_index=newConnI.retn();
+  if(newPos!=initMeshLgth)
+    _nodal_connec->reAlloc(newPos);
+  const mcIdType nCellDel=ret->getNumberOfTuples();
+  if (nCellDel)
+    _nodal_connec_index->reAlloc(nbOfCells-nCellDel+1);
   computeTypes();
-  updateTime();
   return ret.retn();
 }
 
 /*!
- * This method implements policy INTERP_KERNEL::PLANAR_FACE_5 of virtual method MEDCoupling::MEDCouplingUMesh::simplexize.
+ * This method remove null 1D cells from \a this. A 1D cell is considered null if start node is equal to end node.
+ * Only connectivity is considered here.
  */
-DataArrayInt *MEDCouplingUMesh::simplexizePlanarFace5()
+bool MEDCouplingUMesh::removeDegenerated1DCells()
 {
   checkConnectivityFullyDefined();
-  if(getMeshDimension()!=3)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::simplexizePlanarFace5 : this policy is only available for mesh with meshdim == 3 !");
-  int nbOfCells=getNumberOfCells();
-  MCAuto<DataArrayInt> ret=DataArrayInt::New();
-  int nbOfCutCells=getNumberOfCellsWithType(INTERP_KERNEL::NORM_HEXA8);
-  ret->alloc(nbOfCells+4*nbOfCutCells,1);
-  if(nbOfCutCells==0) { ret->iota(0); return ret.retn(); }
-  int *retPt=ret->getPointer();
-  MCAuto<DataArrayInt> newConn=DataArrayInt::New();
-  MCAuto<DataArrayInt> newConnI=DataArrayInt::New();
-  newConnI->alloc(nbOfCells+4*nbOfCutCells+1,1);
-  newConn->alloc(getNodalConnectivityArrayLen()+16*nbOfCutCells,1);//21
-  int *pt=newConn->getPointer();
-  int *ptI=newConnI->getPointer();
-  ptI[0]=0;
-  const int *oldc=_nodal_connec->begin();
-  const int *ci=_nodal_connec_index->begin();
-  for(int i=0;i<nbOfCells;i++,ci++)
-    {
-      if((INTERP_KERNEL::NormalizedCellType)oldc[ci[0]]==INTERP_KERNEL::NORM_HEXA8)
-        {
-          for(int j=0;j<5;j++,pt+=5,ptI++)
-            {
-              pt[0]=(int)INTERP_KERNEL::NORM_TETRA4;
-              pt[1]=oldc[ci[0]+INTERP_KERNEL::SPLIT_NODES_5_WO[4*j+0]+1]; pt[2]=oldc[ci[0]+INTERP_KERNEL::SPLIT_NODES_5_WO[4*j+1]+1]; pt[3]=oldc[ci[0]+INTERP_KERNEL::SPLIT_NODES_5_WO[4*j+2]+1]; pt[4]=oldc[ci[0]+INTERP_KERNEL::SPLIT_NODES_5_WO[4*j+3]+1];
-              *retPt++=i;
-              ptI[1]=ptI[0]+5;
-            }
-        }
-      else
+  if(getMeshDimension()!=1)
+    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::removeDegenerated1DCells works on umeshes with meshdim equals to 1 !");
+  std::size_t nbCells(getNumberOfCells()),newSize(0),newSize2(0);
+  const mcIdType *conn(getNodalConnectivity()->begin()),*conni(getNodalConnectivityIndex()->begin());
+  {
+    for(std::size_t i=0;i<nbCells;i++)
+      {
+        INTERP_KERNEL::NormalizedCellType ct((INTERP_KERNEL::NormalizedCellType)conn[conni[i]]);
+        if(ct==INTERP_KERNEL::NORM_SEG2 || ct==INTERP_KERNEL::NORM_SEG3)
+          {
+            if(conn[conni[i]+1]!=conn[conni[i]+2])
+              {
+                newSize++;
+                newSize2+=conni[i+1]-conni[i];
+              }
+          }
+        else
+          {
+            std::ostringstream oss; oss << "MEDCouplingUMesh::removeDegenerated1DCells : cell #" << i << " in this is not of type SEG2/SEG3 !";
+            throw INTERP_KERNEL::Exception(oss.str());
+          }
+      }
+  }
+  if(newSize==nbCells)//no cells has been removed -> do nothing
+    return false;
+  MCAuto<DataArrayIdType> newConn(DataArrayIdType::New()),newConnI(DataArrayIdType::New()); newConnI->alloc(newSize+1,1); newConn->alloc(newSize2,1);
+  mcIdType *newConnPtr(newConn->getPointer()),*newConnIPtr(newConnI->getPointer()); newConnIPtr[0]=0;
+  for(std::size_t i=0;i<nbCells;i++)
+    {
+      if(conn[conni[i]+1]!=conn[conni[i]+2])
         {
-          pt=std::copy(oldc+ci[0],oldc+ci[1],pt);
-          ptI[1]=ptI[0]+ci[1]-ci[0];
-          ptI++;
-          *retPt++=i;
+          newConnIPtr[1]=newConnIPtr[0]+conni[i+1]-conni[i];
+          newConnPtr=std::copy(conn+conni[i],conn+conni[i+1],newConnPtr);
+          newConnIPtr++;
         }
     }
-  _nodal_connec->decrRef();
-  _nodal_connec=newConn.retn();
-  _nodal_connec_index->decrRef();
-  _nodal_connec_index=newConnI.retn();
-  computeTypes();
-  updateTime();
-  return ret.retn();
-}
-
-/*!
- * This method implements policy INTERP_KERNEL::PLANAR_FACE_6 of virtual method MEDCoupling::MEDCouplingUMesh::simplexize.
- */
-DataArrayInt *MEDCouplingUMesh::simplexizePlanarFace6()
-{
-  checkConnectivityFullyDefined();
-  if(getMeshDimension()!=3)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::simplexizePlanarFace6 : this policy is only available for mesh with meshdim == 3 !");
-  int nbOfCells=getNumberOfCells();
-  MCAuto<DataArrayInt> ret=DataArrayInt::New();
-  int nbOfCutCells=getNumberOfCellsWithType(INTERP_KERNEL::NORM_HEXA8);
-  ret->alloc(nbOfCells+5*nbOfCutCells,1);
-  if(nbOfCutCells==0) { ret->iota(0); return ret.retn(); }
-  int *retPt=ret->getPointer();
-  MCAuto<DataArrayInt> newConn=DataArrayInt::New();
-  MCAuto<DataArrayInt> newConnI=DataArrayInt::New();
-  newConnI->alloc(nbOfCells+5*nbOfCutCells+1,1);
-  newConn->alloc(getNodalConnectivityArrayLen()+21*nbOfCutCells,1);
-  int *pt=newConn->getPointer();
-  int *ptI=newConnI->getPointer();
-  ptI[0]=0;
-  const int *oldc=_nodal_connec->begin();
-  const int *ci=_nodal_connec_index->begin();
-  for(int i=0;i<nbOfCells;i++,ci++)
-    {
-      if((INTERP_KERNEL::NormalizedCellType)oldc[ci[0]]==INTERP_KERNEL::NORM_HEXA8)
-        {
-          for(int j=0;j<6;j++,pt+=5,ptI++)
-            {
-              pt[0]=(int)INTERP_KERNEL::NORM_TETRA4;
-              pt[1]=oldc[ci[0]+INTERP_KERNEL::SPLIT_NODES_6_WO[4*j+0]+1]; pt[2]=oldc[ci[0]+INTERP_KERNEL::SPLIT_NODES_6_WO[4*j+1]+1]; pt[3]=oldc[ci[0]+INTERP_KERNEL::SPLIT_NODES_6_WO[4*j+2]+1]; pt[4]=oldc[ci[0]+INTERP_KERNEL::SPLIT_NODES_6_WO[4*j+3]+1];
-              *retPt++=i;
-              ptI[1]=ptI[0]+5;
-            }
-        }
-      else
-        {
-          pt=std::copy(oldc+ci[0],oldc+ci[1],pt);
-          ptI[1]=ptI[0]+ci[1]-ci[0];
-          ptI++;
-          *retPt++=i;
-        }
-    }
-  _nodal_connec->decrRef();
-  _nodal_connec=newConn.retn();
-  _nodal_connec_index->decrRef();
-  _nodal_connec_index=newConnI.retn();
-  computeTypes();
-  updateTime();
-  return ret.retn();
-}
-
-/*!
- * Tessellates \a this 2D mesh by dividing not straight edges of quadratic faces,
- * so that the number of cells remains the same. Quadratic faces are converted to
- * polygons. This method works only for 2D meshes in
- * 2D space. If no cells are quadratic (INTERP_KERNEL::NORM_QUAD8,
- * INTERP_KERNEL::NORM_TRI6, INTERP_KERNEL::NORM_QPOLYG ), \a this mesh remains unchanged.
- * \warning This method can lead to a huge amount of nodes if \a eps is very low.
- *  \param [in] eps - specifies the maximal angle (in radians) between 2 sub-edges of
- *         a polylinized edge constituting the input polygon.
- *  \throw If the coordinates array is not set.
- *  \throw If the nodal connectivity of cells is not defined.
- *  \throw If \a this->getMeshDimension() != 2.
- *  \throw If \a this->getSpaceDimension() != 2.
- */
-void MEDCouplingUMesh::tessellate2DInternal(double eps)
-{
-  checkFullyDefined();
-  if(getMeshDimension()!=2 || getSpaceDimension()!=2)  
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::tessellate2DInternal works on umeshes with meshdim equal to 2 and spaceDim equal to 2 too!");
-  double epsa=fabs(eps);
-  if(epsa<std::numeric_limits<double>::min())
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::tessellate2DInternal : epsilon is null ! Please specify a higher epsilon. If too tiny it can lead to a huge amount of nodes and memory !");
-  MCAuto<DataArrayInt> desc1(DataArrayInt::New()),descIndx1(DataArrayInt::New()),revDesc1(DataArrayInt::New()),revDescIndx1(DataArrayInt::New());
-  MCAuto<MEDCouplingUMesh> mDesc(buildDescendingConnectivity2(desc1,descIndx1,revDesc1,revDescIndx1));
-  revDesc1=0; revDescIndx1=0;
-  mDesc->tessellate2D(eps);
-  subDivide2DMesh(mDesc->_nodal_connec->begin(),mDesc->_nodal_connec_index->begin(),desc1->begin(),descIndx1->begin());
-  setCoords(mDesc->getCoords());
-}
-
-/*!
- * Tessellates \a this 1D mesh in 2D space by dividing not straight quadratic edges.
- * \warning This method can lead to a huge amount of nodes if \a eps is very low.
- *  \param [in] eps - specifies the maximal angle (in radian) between 2 sub-edges of
- *         a sub-divided edge.
- *  \throw If the coordinates array is not set.
- *  \throw If the nodal connectivity of cells is not defined.
- *  \throw If \a this->getMeshDimension() != 1.
- *  \throw If \a this->getSpaceDimension() != 2.
- */
-void MEDCouplingUMesh::tessellate2DCurveInternal(double eps)
-{
-  checkFullyDefined();
-  if(getMeshDimension()!=1 || getSpaceDimension()!=2)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::tessellate2DCurveInternal works on umeshes with meshdim equal to 1 and spaceDim equal to 2 too!");
-  double epsa=fabs(eps);
-  if(epsa<std::numeric_limits<double>::min())
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::tessellate2DCurveInternal : epsilon is null ! Please specify a higher epsilon. If too tiny it can lead to a huge amount of nodes and memory !");
-  INTERP_KERNEL::QUADRATIC_PLANAR::_arc_detection_precision=1.e-10;
-  int nbCells=getNumberOfCells();
-  int nbNodes=getNumberOfNodes();
-  const int *conn=_nodal_connec->begin();
-  const int *connI=_nodal_connec_index->begin();
-  const double *coords=_coords->begin();
-  std::vector<double> addCoo;
-  std::vector<int> newConn;//no direct DataArrayInt because interface with Geometric2D
-  MCAuto<DataArrayInt> newConnI(DataArrayInt::New());
-  newConnI->alloc(nbCells+1,1);
-  int *newConnIPtr=newConnI->getPointer();
-  *newConnIPtr=0;
-  int tmp1[3];
-  INTERP_KERNEL::Node *tmp2[3];
-  std::set<INTERP_KERNEL::NormalizedCellType> types;
-  for(int i=0;i<nbCells;i++,newConnIPtr++)
-    {
-      const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)conn[connI[i]]);
-      if(cm.isQuadratic())
-        {//assert(connI[i+1]-connI[i]-1==3)
-          tmp1[0]=conn[connI[i]+1+0]; tmp1[1]=conn[connI[i]+1+1]; tmp1[2]=conn[connI[i]+1+2];
-          tmp2[0]=new INTERP_KERNEL::Node(coords[2*tmp1[0]],coords[2*tmp1[0]+1]);
-          tmp2[1]=new INTERP_KERNEL::Node(coords[2*tmp1[1]],coords[2*tmp1[1]+1]);
-          tmp2[2]=new INTERP_KERNEL::Node(coords[2*tmp1[2]],coords[2*tmp1[2]+1]);
-          INTERP_KERNEL::EdgeArcCircle *eac=INTERP_KERNEL::EdgeArcCircle::BuildFromNodes(tmp2[0],tmp2[2],tmp2[1]);
-          if(eac)
-            {
-              eac->tesselate(tmp1,nbNodes,epsa,newConn,addCoo);
-              types.insert((INTERP_KERNEL::NormalizedCellType)newConn[newConnIPtr[0]]);
-              delete eac;
-              newConnIPtr[1]=(int)newConn.size();
-            }
-          else
-            {
-              types.insert(INTERP_KERNEL::NORM_SEG2);
-              newConn.push_back(INTERP_KERNEL::NORM_SEG2);
-              newConn.insert(newConn.end(),conn+connI[i]+1,conn+connI[i]+3);
-              newConnIPtr[1]=newConnIPtr[0]+3;
-            }
-        }
-      else
-        {
-          types.insert((INTERP_KERNEL::NormalizedCellType)conn[connI[i]]);
-          newConn.insert(newConn.end(),conn+connI[i],conn+connI[i+1]);
-          newConnIPtr[1]=newConnIPtr[0]+3;
-        }
-    }
-  if(addCoo.empty() && ((int)newConn.size())==_nodal_connec->getNumberOfTuples())//nothing happens during tessellation : no update needed
-    return ;
-  _types=types;
-  DataArrayInt::SetArrayIn(newConnI,_nodal_connec_index);
-  MCAuto<DataArrayInt> newConnArr=DataArrayInt::New();
-  newConnArr->alloc((int)newConn.size(),1);
-  std::copy(newConn.begin(),newConn.end(),newConnArr->getPointer());
-  DataArrayInt::SetArrayIn(newConnArr,_nodal_connec);
-  MCAuto<DataArrayDouble> newCoords=DataArrayDouble::New();
-  newCoords->alloc(nbNodes+((int)addCoo.size())/2,2);
-  double *work=std::copy(_coords->begin(),_coords->end(),newCoords->getPointer());
-  std::copy(addCoo.begin(),addCoo.end(),work);
-  DataArrayDouble::SetArrayIn(newCoords,_coords);
-  updateTime();
-}
-
-/*!
- * This private method is used to subdivide edges of a mesh with meshdim==2. If \a this has no a meshdim equal to 2 an exception will be thrown.
- * This method completly ignore coordinates.
- * \param nodeSubdived is the nodal connectivity of subdivision of edges
- * \param nodeIndxSubdived is the nodal connectivity index of subdivision of edges
- * \param desc is descending connectivity in format specified in MEDCouplingUMesh::buildDescendingConnectivity2
- * \param descIndex is descending connectivity index in format specified in MEDCouplingUMesh::buildDescendingConnectivity2
- */
-void MEDCouplingUMesh::subDivide2DMesh(const int *nodeSubdived, const int *nodeIndxSubdived, const int *desc, const int *descIndex)
-{
-  checkFullyDefined();
-  if(getMeshDimension()!=2)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::subDivide2DMesh : works only on umesh with meshdim==2 !");
-  int nbOfCells=getNumberOfCells();
-  int *connI=_nodal_connec_index->getPointer();
-  int newConnLgth=0;
-  for(int i=0;i<nbOfCells;i++,connI++)
-    {
-      int offset=descIndex[i];
-      int nbOfEdges=descIndex[i+1]-offset;
-      //
-      bool ddirect=desc[offset+nbOfEdges-1]>0;
-      int eedgeId=std::abs(desc[offset+nbOfEdges-1])-1;
-      int ref=ddirect?nodeSubdived[nodeIndxSubdived[eedgeId+1]-1]:nodeSubdived[nodeIndxSubdived[eedgeId]+1];
-      for(int j=0;j<nbOfEdges;j++)
-        {
-          bool direct=desc[offset+j]>0;
-          int edgeId=std::abs(desc[offset+j])-1;
-          if(!INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)nodeSubdived[nodeIndxSubdived[edgeId]]).isQuadratic())
-            {
-              int id1=nodeSubdived[nodeIndxSubdived[edgeId]+1];
-              int id2=nodeSubdived[nodeIndxSubdived[edgeId+1]-1];
-              int ref2=direct?id1:id2;
-              if(ref==ref2)
-                {
-                  int nbOfSubNodes=nodeIndxSubdived[edgeId+1]-nodeIndxSubdived[edgeId]-1;
-                  newConnLgth+=nbOfSubNodes-1;
-                  ref=direct?id2:id1;
-                }
-              else
-                {
-                  std::ostringstream oss; oss << "MEDCouplingUMesh::subDivide2DMesh : On polygon #" << i << " edgeid #" << j << " subedges mismatch : end subedge k!=start subedge k+1 !";
-                  throw INTERP_KERNEL::Exception(oss.str());
-                }
-            }
-          else
-            {
-              throw INTERP_KERNEL::Exception("MEDCouplingUMesh::subDivide2DMesh : this method only subdivides into linear edges !");
-            }
-        }
-      newConnLgth++;//+1 is for cell type
-      connI[1]=newConnLgth;
-    }
-  //
-  MCAuto<DataArrayInt> newConn=DataArrayInt::New();
-  newConn->alloc(newConnLgth,1);
-  int *work=newConn->getPointer();
-  for(int i=0;i<nbOfCells;i++)
-    {
-      *work++=INTERP_KERNEL::NORM_POLYGON;
-      int offset=descIndex[i];
-      int nbOfEdges=descIndex[i+1]-offset;
-      for(int j=0;j<nbOfEdges;j++)
-        {
-          bool direct=desc[offset+j]>0;
-          int edgeId=std::abs(desc[offset+j])-1;
-          if(direct)
-            work=std::copy(nodeSubdived+nodeIndxSubdived[edgeId]+1,nodeSubdived+nodeIndxSubdived[edgeId+1]-1,work);
-          else
-            {
-              int nbOfSubNodes=nodeIndxSubdived[edgeId+1]-nodeIndxSubdived[edgeId]-1;
-              std::reverse_iterator<const int *> it(nodeSubdived+nodeIndxSubdived[edgeId+1]);
-              work=std::copy(it,it+nbOfSubNodes-1,work);
-            }
-        }
-    }
-  DataArrayInt::SetArrayIn(newConn,_nodal_connec);
-  _types.clear();
-  if(nbOfCells>0)
-    _types.insert(INTERP_KERNEL::NORM_POLYGON);
-}
-
-/*!
- * Converts degenerated 2D or 3D linear cells of \a this mesh into cells of simpler
- * type. For example an INTERP_KERNEL::NORM_QUAD4 cell having only three unique nodes in
- * its connectivity is transformed into an INTERP_KERNEL::NORM_TRI3 cell. This method
- * does \b not perform geometrical checks and checks only nodal connectivity of cells,
- * so it can be useful to call mergeNodes() before calling this method.
- *  \throw If \a this->getMeshDimension() <= 1.
- *  \throw If the coordinates array is not set.
- *  \throw If the nodal connectivity of cells is not defined.
- */
-void MEDCouplingUMesh::convertDegeneratedCells()
-{
-  checkFullyDefined();
-  if(getMeshDimension()<=1)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::convertDegeneratedCells works on umeshes with meshdim equals to 2 or 3 !");
-  int nbOfCells=getNumberOfCells();
-  if(nbOfCells<1)
-    return ;
-  int initMeshLgth=getNodalConnectivityArrayLen();
-  int *conn=_nodal_connec->getPointer();
-  int *index=_nodal_connec_index->getPointer();
-  int posOfCurCell=0;
-  int newPos=0;
-  int lgthOfCurCell;
-  for(int i=0;i<nbOfCells;i++)
-    {
-      lgthOfCurCell=index[i+1]-posOfCurCell;
-      INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)conn[posOfCurCell];
-      int newLgth;
-      INTERP_KERNEL::NormalizedCellType newType=INTERP_KERNEL::CellSimplify::simplifyDegeneratedCell(type,conn+posOfCurCell+1,lgthOfCurCell-1,
-                                                                                                     conn+newPos+1,newLgth);
-      conn[newPos]=newType;
-      newPos+=newLgth+1;
-      posOfCurCell=index[i+1];
-      index[i+1]=newPos;
-    }
-  if(newPos!=initMeshLgth)
-    _nodal_connec->reAlloc(newPos);
-  computeTypes();
+  setConnectivity(newConn,newConnI,true);
+  return true;
 }
 
 /*!
@@ -6189,7 +5074,7 @@ void MEDCouplingUMesh::convertDegeneratedCells()
  * A cell is considered to be oriented correctly if an angle between its
  * normal vector and a given vector is less than \c PI / \c 2.
  *  \param [in] vec - 3 components of the vector specifying the correct orientation of
- *         cells. 
+ *         cells.
  *  \param [in] polyOnly - if \c true, only polygons are checked, else, all cells are
  *         checked.
  *  \param [in,out] cells - a vector returning ids of incorrectly oriented cells. It
@@ -6202,15 +5087,15 @@ void MEDCouplingUMesh::convertDegeneratedCells()
  *  \ref  py_mcumesh_are2DCellsNotCorrectlyOriented "Here is a Python example".
  *  \endif
  */
-void MEDCouplingUMesh::are2DCellsNotCorrectlyOriented(const double *vec, bool polyOnly, std::vector<int>& cells) const
+void MEDCouplingUMesh::are2DCellsNotCorrectlyOriented(const double *vec, bool polyOnly, std::vector<mcIdType>& cells) const
 {
   if(getMeshDimension()!=2 || getSpaceDimension()!=3)
     throw INTERP_KERNEL::Exception("Invalid mesh to apply are2DCellsNotCorrectlyOriented on it : must be meshDim==2 and spaceDim==3 !");
-  int nbOfCells=getNumberOfCells();
-  const int *conn=_nodal_connec->begin();
-  const int *connI=_nodal_connec_index->begin();
+  mcIdType nbOfCells=getNumberOfCells();
+  const mcIdType *conn=_nodal_connec->begin();
+  const mcIdType *connI=_nodal_connec_index->begin();
   const double *coordsPtr=_coords->begin();
-  for(int i=0;i<nbOfCells;i++)
+  for(mcIdType i=0;i<nbOfCells;i++)
     {
       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)conn[connI[i]];
       if(!polyOnly || (type==INTERP_KERNEL::NORM_POLYGON || type==INTERP_KERNEL::NORM_QPOLYG))
@@ -6225,9 +5110,9 @@ void MEDCouplingUMesh::are2DCellsNotCorrectlyOriented(const double *vec, bool po
 /*!
  * Reverse connectivity of 2D cells whose orientation is not correct. A cell is
  * considered to be oriented correctly if an angle between its normal vector and a
- * given vector is less than \c PI / \c 2. 
+ * given vector is less than \c PI / \c 2.
  *  \param [in] vec - 3 components of the vector specifying the correct orientation of
- *         cells. 
+ *         cells.
  *  \param [in] polyOnly - if \c true, only polygons are checked, else, all cells are
  *         checked.
  *  \throw If \a this->getMeshDimension() != 2.
@@ -6244,11 +5129,12 @@ void MEDCouplingUMesh::orientCorrectly2DCells(const double *vec, bool polyOnly)
 {
   if(getMeshDimension()!=2 || getSpaceDimension()!=3)
     throw INTERP_KERNEL::Exception("Invalid mesh to apply orientCorrectly2DCells on it : must be meshDim==2 and spaceDim==3 !");
-  int nbOfCells(getNumberOfCells()),*conn(_nodal_connec->getPointer());
-  const int *connI(_nodal_connec_index->begin());
+  mcIdType nbOfCells=getNumberOfCells();
+  mcIdType *conn(_nodal_connec->getPointer());
+  const mcIdType *connI(_nodal_connec_index->begin());
   const double *coordsPtr(_coords->begin());
   bool isModified(false);
-  for(int i=0;i<nbOfCells;i++)
+  for(mcIdType i=0;i<nbOfCells;i++)
     {
       INTERP_KERNEL::NormalizedCellType type((INTERP_KERNEL::NormalizedCellType)conn[connI[i]]);
       if(!polyOnly || (type==INTERP_KERNEL::NORM_POLYGON || type==INTERP_KERNEL::NORM_QPOLYG))
@@ -6277,11 +5163,12 @@ void MEDCouplingUMesh::changeOrientationOfCells()
   int mdim(getMeshDimension());
   if(mdim!=2 && mdim!=1)
     throw INTERP_KERNEL::Exception("Invalid mesh to apply changeOrientationOfCells on it : must be meshDim==2 or meshDim==1 !");
-  int nbOfCells(getNumberOfCells()),*conn(_nodal_connec->getPointer());
-  const int *connI(_nodal_connec_index->begin());
+  mcIdType nbOfCells=getNumberOfCells();
+  mcIdType *conn(_nodal_connec->getPointer());
+  const mcIdType *connI(_nodal_connec_index->begin());
   if(mdim==2)
     {//2D
-      for(int i=0;i<nbOfCells;i++)
+      for(mcIdType i=0;i<nbOfCells;i++)
         {
           INTERP_KERNEL::NormalizedCellType type((INTERP_KERNEL::NormalizedCellType)conn[connI[i]]);
           const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(type));
@@ -6290,7 +5177,7 @@ void MEDCouplingUMesh::changeOrientationOfCells()
     }
   else
     {//1D
-      for(int i=0;i<nbOfCells;i++)
+      for(mcIdType i=0;i<nbOfCells;i++)
         {
           INTERP_KERNEL::NormalizedCellType type((INTERP_KERNEL::NormalizedCellType)conn[connI[i]]);
           const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(type));
@@ -6314,15 +5201,15 @@ void MEDCouplingUMesh::changeOrientationOfCells()
  *  \ref  py_mcumesh_arePolyhedronsNotCorrectlyOriented "Here is a Python example".
  *  \endif
  */
-void MEDCouplingUMesh::arePolyhedronsNotCorrectlyOriented(std::vector<int>& cells) const
+void MEDCouplingUMesh::arePolyhedronsNotCorrectlyOriented(std::vector<mcIdType>& cells) const
 {
   if(getMeshDimension()!=3 || getSpaceDimension()!=3)
     throw INTERP_KERNEL::Exception("Invalid mesh to apply arePolyhedronsNotCorrectlyOriented on it : must be meshDim==3 and spaceDim==3 !");
-  int nbOfCells=getNumberOfCells();
-  const int *conn=_nodal_connec->begin();
-  const int *connI=_nodal_connec_index->begin();
+  mcIdType nbOfCells=getNumberOfCells();
+  const mcIdType *conn=_nodal_connec->begin();
+  const mcIdType *connI=_nodal_connec_index->begin();
   const double *coordsPtr=_coords->begin();
-  for(int i=0;i<nbOfCells;i++)
+  for(mcIdType i=0;i<nbOfCells;i++)
     {
       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)conn[connI[i]];
       if(type==INTERP_KERNEL::NORM_POLYHED)
@@ -6335,7 +5222,7 @@ void MEDCouplingUMesh::arePolyhedronsNotCorrectlyOriented(std::vector<int>& cell
 
 /*!
  * Tries to fix connectivity of polyhedra, so that normal vector of all facets to point
- * out of the cell. 
+ * out of the cell.
  *  \throw If \a this->getMeshDimension() != 3.
  *  \throw If \a this->getSpaceDimension() != 3.
  *  \throw If the coordinates array is not set.
@@ -6352,11 +5239,11 @@ void MEDCouplingUMesh::orientCorrectlyPolyhedrons()
 {
   if(getMeshDimension()!=3 || getSpaceDimension()!=3)
     throw INTERP_KERNEL::Exception("Invalid mesh to apply orientCorrectlyPolyhedrons on it : must be meshDim==3 and spaceDim==3 !");
-  int nbOfCells=getNumberOfCells();
-  int *conn=_nodal_connec->getPointer();
-  const int *connI=_nodal_connec_index->begin();
+  mcIdType nbOfCells=getNumberOfCells();
+  mcIdType *conn=_nodal_connec->getPointer();
+  const mcIdType *connI=_nodal_connec_index->begin();
   const double *coordsPtr=_coords->begin();
-  for(int i=0;i<nbOfCells;i++)
+  for(mcIdType i=0;i<nbOfCells;i++)
     {
       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)conn[connI[i]];
       if(type==INTERP_KERNEL::NORM_POLYHED)
@@ -6376,14 +5263,35 @@ void MEDCouplingUMesh::orientCorrectlyPolyhedrons()
   updateTime();
 }
 
+/*!
+ * This method invert orientation of all cells in \a this.
+ * After calling this method the absolute value of measure of cells in \a this are the same than before calling.
+ * This method only operates on the connectivity so coordinates are not touched at all.
+ */
+void MEDCouplingUMesh::invertOrientationOfAllCells()
+{
+  checkConnectivityFullyDefined();
+  std::set<INTERP_KERNEL::NormalizedCellType> gts(getAllGeoTypes());
+  mcIdType *conn(_nodal_connec->getPointer());
+  const mcIdType *conni(_nodal_connec_index->begin());
+  for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator gt=gts.begin();gt!=gts.end();gt++)
+    {
+      INTERP_KERNEL::AutoCppPtr<INTERP_KERNEL::OrientationInverter> oi(INTERP_KERNEL::OrientationInverter::BuildInstanceFrom(*gt));
+      MCAuto<DataArrayIdType> cwt(giveCellsWithType(*gt));
+      for(const mcIdType *it=cwt->begin();it!=cwt->end();it++)
+        oi->operate(conn+conni[*it]+1,conn+conni[*it+1]);
+    }
+  updateTime();
+}
+
 /*!
  * Finds and fixes incorrectly oriented linear extruded volumes (INTERP_KERNEL::NORM_HEXA8,
  * INTERP_KERNEL::NORM_PENTA6, INTERP_KERNEL::NORM_HEXGP12 etc) to respect the MED convention
  * according to which the first facet of the cell should be oriented to have the normal vector
  * pointing out of cell.
- *  \return DataArrayInt * - a new instance of DataArrayInt holding ids of fixed
+ *  \return DataArrayIdType * - a new instance of DataArrayIdType holding ids of fixed
  *         cells. The caller is to delete this array using decrRef() as it is no more
- *         needed. 
+ *         needed.
  *  \throw If \a this->getMeshDimension() != 3.
  *  \throw If \a this->getSpaceDimension() != 3.
  *  \throw If the coordinates array is not set.
@@ -6395,7 +5303,7 @@ void MEDCouplingUMesh::orientCorrectlyPolyhedrons()
  *  \endif
  * \sa MEDCouplingUMesh::findAndCorrectBadOriented3DCells
  */
-DataArrayInt *MEDCouplingUMesh::findAndCorrectBadOriented3DExtrudedCells()
+DataArrayIdType *MEDCouplingUMesh::findAndCorrectBadOriented3DExtrudedCells()
 {
   const char msg[]="check3DCellsWellOriented detection works only for 3D cells !";
   if(getMeshDimension()!=3)
@@ -6404,12 +5312,12 @@ DataArrayInt *MEDCouplingUMesh::findAndCorrectBadOriented3DExtrudedCells()
   if(spaceDim!=3)
     throw INTERP_KERNEL::Exception(msg);
   //
-  int nbOfCells=getNumberOfCells();
-  int *conn=_nodal_connec->getPointer();
-  const int *connI=_nodal_connec_index->begin();
+  mcIdType nbOfCells=getNumberOfCells();
+  mcIdType *conn=_nodal_connec->getPointer();
+  const mcIdType *connI=_nodal_connec_index->begin();
   const double *coo=getCoords()->begin();
-  MCAuto<DataArrayInt> cells(DataArrayInt::New()); cells->alloc(0,1);
-  for(int i=0;i<nbOfCells;i++)
+  MCAuto<DataArrayIdType> cells(DataArrayIdType::New()); cells->alloc(0,1);
+  for(mcIdType i=0;i<nbOfCells;i++)
     {
       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)conn[connI[i]]);
       if(cm.isExtruded() && !cm.isDynamic() && !cm.isQuadratic())
@@ -6428,20 +5336,20 @@ DataArrayInt *MEDCouplingUMesh::findAndCorrectBadOriented3DExtrudedCells()
  * This method is a faster method to correct orientation of all 3D cells in \a this.
  * This method works only if \a this is a 3D mesh, that is to say a mesh with mesh dimension 3 and a space dimension 3.
  * This method makes the hypothesis that \a this a coherent that is to say MEDCouplingUMesh::checkConsistency should throw no exception.
- * 
- * \return a newly allocated int array with one components containing cell ids renumbered to fit the convention of MED (MED file and MEDCoupling)
- * \sa MEDCouplingUMesh::orientCorrectlyPolyhedrons, 
+ *
+ * \return a newly allocated mcIdType array with one components containing cell ids renumbered to fit the convention of MED (MED file and MEDCoupling)
+ * \sa MEDCouplingUMesh::orientCorrectlyPolyhedrons,
  */
-DataArrayInt *MEDCouplingUMesh::findAndCorrectBadOriented3DCells()
+DataArrayIdType *MEDCouplingUMesh::findAndCorrectBadOriented3DCells()
 {
   if(getMeshDimension()!=3 || getSpaceDimension()!=3)
     throw INTERP_KERNEL::Exception("Invalid mesh to apply findAndCorrectBadOriented3DCells on it : must be meshDim==3 and spaceDim==3 !");
-  int nbOfCells=getNumberOfCells();
-  int *conn=_nodal_connec->getPointer();
-  const int *connI=_nodal_connec_index->begin();
+  mcIdType nbOfCells=getNumberOfCells();
+  mcIdType *conn=_nodal_connec->getPointer();
+  const mcIdType *connI=_nodal_connec_index->begin();
   const double *coordsPtr=_coords->begin();
-  MCAuto<DataArrayInt> ret=DataArrayInt::New(); ret->alloc(0,1);
-  for(int i=0;i<nbOfCells;i++)
+  MCAuto<DataArrayIdType> ret=DataArrayIdType::New(); ret->alloc(0,1);
+  for(mcIdType i=0;i<nbOfCells;i++)
     {
       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)conn[connI[i]];
       switch(type)
@@ -6503,10 +5411,10 @@ void MEDCouplingUMesh::getFastAveragePlaneOfThis(double *vec, double *pos) const
 {
   if(getMeshDimension()!=2 || getSpaceDimension()!=3)
     throw INTERP_KERNEL::Exception("Invalid mesh to apply getFastAveragePlaneOfThis on it : must be meshDim==2 and spaceDim==3 !");
-  const int *conn=_nodal_connec->begin();
-  const int *connI=_nodal_connec_index->begin();
+  const mcIdType *conn=_nodal_connec->begin();
+  const mcIdType *connI=_nodal_connec_index->begin();
   const double *coordsPtr=_coords->begin();
-  INTERP_KERNEL::areaVectorOfPolygon<int,INTERP_KERNEL::ALL_C_MODE>(conn+1,connI[1]-connI[0]-1,coordsPtr,vec);
+  INTERP_KERNEL::areaVectorOfPolygon<mcIdType,INTERP_KERNEL::ALL_C_MODE>(conn+1,connI[1]-connI[0]-1,coordsPtr,vec);
   std::copy(coordsPtr+3*conn[1],coordsPtr+3*conn[1]+3,pos);
 }
 
@@ -6516,13 +5424,13 @@ void MEDCouplingUMesh::getFastAveragePlaneOfThis(double *vec, double *pos) const
  * INTERP_KERNEL::NORM_TRI3, INTERP_KERNEL::NORM_QUAD4 and INTERP_KERNEL::NORM_TETRA4.
  * For a cell of other type an exception is thrown.
  * Space dimension of a 2D mesh can be either 2 or 3.
- * The Edge Ratio of a cell \f$t\f$ is: 
+ * The Edge Ratio of a cell \f$t\f$ is:
  *  \f$\frac{|t|_\infty}{|t|_0}\f$,
  *  where \f$|t|_\infty\f$ and \f$|t|_0\f$ respectively denote the greatest and
  *  the smallest edge lengths of \f$t\f$.
  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble on
  *          cells and one time, lying on \a this mesh. The caller is to delete this
- *          field using decrRef() as it is no more needed. 
+ *          field using decrRef() as it is no more needed.
  *  \throw If the coordinates array is not set.
  *  \throw If \a this mesh contains elements of dimension different from the mesh dimension.
  *  \throw If the connectivity data array has more than one component.
@@ -6544,16 +5452,16 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::getEdgeRatioField() const
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getEdgeRatioField : MeshDimension must be equal to 2 or 3 !");
   MCAuto<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
   ret->setMesh(this);
-  int nbOfCells=getNumberOfCells();
+  mcIdType nbOfCells=getNumberOfCells();
   MCAuto<DataArrayDouble> arr=DataArrayDouble::New();
   arr->alloc(nbOfCells,1);
   double *pt=arr->getPointer();
   ret->setArray(arr);//In case of throw to avoid mem leaks arr will be used after decrRef.
-  const int *conn=_nodal_connec->begin();
-  const int *connI=_nodal_connec_index->begin();
+  const mcIdType *conn=_nodal_connec->begin();
+  const mcIdType *connI=_nodal_connec_index->begin();
   const double *coo=_coords->begin();
   double tmp[12];
-  for(int i=0;i<nbOfCells;i++,pt++)
+  for(mcIdType i=0;i<nbOfCells;i++,pt++)
     {
       INTERP_KERNEL::NormalizedCellType t=(INTERP_KERNEL::NormalizedCellType)*conn;
       switch(t)
@@ -6594,7 +5502,7 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::getEdgeRatioField() const
  * Space dimension of a 2D mesh can be either 2 or 3.
  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble on
  *          cells and one time, lying on \a this mesh. The caller is to delete this
- *          field using decrRef() as it is no more needed. 
+ *          field using decrRef() as it is no more needed.
  *  \throw If the coordinates array is not set.
  *  \throw If \a this mesh contains elements of dimension different from the mesh dimension.
  *  \throw If the connectivity data array has more than one component.
@@ -6616,16 +5524,16 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::getAspectRatioField() const
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getAspectRatioField : MeshDimension must be equal to 2 or 3 !");
   MCAuto<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
   ret->setMesh(this);
-  int nbOfCells=getNumberOfCells();
+  mcIdType nbOfCells=getNumberOfCells();
   MCAuto<DataArrayDouble> arr=DataArrayDouble::New();
   arr->alloc(nbOfCells,1);
   double *pt=arr->getPointer();
   ret->setArray(arr);//In case of throw to avoid mem leaks arr will be used after decrRef.
-  const int *conn=_nodal_connec->begin();
-  const int *connI=_nodal_connec_index->begin();
+  const mcIdType *conn=_nodal_connec->begin();
+  const mcIdType *connI=_nodal_connec_index->begin();
   const double *coo=_coords->begin();
   double tmp[12];
-  for(int i=0;i<nbOfCells;i++,pt++)
+  for(mcIdType i=0;i<nbOfCells;i++,pt++)
     {
       INTERP_KERNEL::NormalizedCellType t=(INTERP_KERNEL::NormalizedCellType)*conn;
       switch(t)
@@ -6675,7 +5583,7 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::getAspectRatioField() const
  *  \f]
  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble on
  *          cells and one time, lying on \a this mesh. The caller is to delete this
- *          field using decrRef() as it is no more needed. 
+ *          field using decrRef() as it is no more needed.
  *  \throw If the coordinates array is not set.
  *  \throw If \a this mesh contains elements of dimension different from the mesh dimension.
  *  \throw If the connectivity data array has more than one component.
@@ -6697,16 +5605,16 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::getWarpField() const
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getWarpField : MeshDimension must be equal to 2 !");
   MCAuto<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
   ret->setMesh(this);
-  int nbOfCells=getNumberOfCells();
+  mcIdType nbOfCells=getNumberOfCells();
   MCAuto<DataArrayDouble> arr=DataArrayDouble::New();
   arr->alloc(nbOfCells,1);
   double *pt=arr->getPointer();
   ret->setArray(arr);//In case of throw to avoid mem leaks arr will be used after decrRef.
-  const int *conn=_nodal_connec->begin();
-  const int *connI=_nodal_connec_index->begin();
+  const mcIdType *conn=_nodal_connec->begin();
+  const mcIdType *connI=_nodal_connec_index->begin();
   const double *coo=_coords->begin();
   double tmp[12];
-  for(int i=0;i<nbOfCells;i++,pt++)
+  for(mcIdType i=0;i<nbOfCells;i++,pt++)
     {
       INTERP_KERNEL::NormalizedCellType t=(INTERP_KERNEL::NormalizedCellType)*conn;
       switch(t)
@@ -6742,7 +5650,7 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::getWarpField() const
  * For a cell of other type an exception is thrown.
  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble on
  *          cells and one time, lying on \a this mesh. The caller is to delete this
- *          field using decrRef() as it is no more needed. 
+ *          field using decrRef() as it is no more needed.
  *  \throw If the coordinates array is not set.
  *  \throw If \a this mesh contains elements of dimension different from the mesh dimension.
  *  \throw If the connectivity data array has more than one component.
@@ -6764,16 +5672,16 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::getSkewField() const
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getSkewField : MeshDimension must be equal to 2 !");
   MCAuto<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
   ret->setMesh(this);
-  int nbOfCells=getNumberOfCells();
+  mcIdType nbOfCells=getNumberOfCells();
   MCAuto<DataArrayDouble> arr=DataArrayDouble::New();
   arr->alloc(nbOfCells,1);
   double *pt=arr->getPointer();
   ret->setArray(arr);//In case of throw to avoid mem leaks arr will be used after decrRef.
-  const int *conn=_nodal_connec->begin();
-  const int *connI=_nodal_connec_index->begin();
+  const mcIdType *conn=_nodal_connec->begin();
+  const mcIdType *connI=_nodal_connec_index->begin();
   const double *coo=_coords->begin();
   double tmp[12];
-  for(int i=0;i<nbOfCells;i++,pt++)
+  for(mcIdType i=0;i<nbOfCells;i++,pt++)
     {
       INTERP_KERNEL::NormalizedCellType t=(INTERP_KERNEL::NormalizedCellType)*conn;
       switch(t)
@@ -6808,13 +5716,14 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::computeDiameterField() const
   ret->setMesh(this);
   std::set<INTERP_KERNEL::NormalizedCellType> types;
   ComputeAllTypesInternal(types,_nodal_connec,_nodal_connec_index);
-  int spaceDim(getSpaceDimension()),nbCells(getNumberOfCells());
+  int spaceDim(getSpaceDimension());
+  mcIdType nbCells(getNumberOfCells());
   MCAuto<DataArrayDouble> arr(DataArrayDouble::New());
   arr->alloc(nbCells,1);
   for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=types.begin();it!=types.end();it++)
     {
       INTERP_KERNEL::AutoCppPtr<INTERP_KERNEL::DiameterCalculator> dc(INTERP_KERNEL::CellModel::GetCellModel(*it).buildInstanceOfDiameterCalulator(spaceDim));
-      MCAuto<DataArrayInt> cellIds(giveCellsWithType(*it));
+      MCAuto<DataArrayIdType> cellIds(giveCellsWithType(*it));
       dc->computeForListOfCellIdsUMeshFrmt(cellIds->begin(),cellIds->end(),_nodal_connec_index->begin(),_nodal_connec->begin(),getCoords()->begin(),arr->getPointer());
     }
   ret->setArray(arr);
@@ -6824,11 +5733,11 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::computeDiameterField() const
 
 /*!
  * This method aggregate the bbox of each cell and put it into bbox parameter (xmin,xmax,ymin,ymax,zmin,zmax).
- * 
+ *
  * \param [in] arcDetEps - a parameter specifying in case of 2D quadratic polygon cell the detection limit between linear and arc circle. (By default 1e-12)
  *                         For all other cases this input parameter is ignored.
  * \return DataArrayDouble * - newly created object (to be managed by the caller) \a this number of cells tuples and 2*spacedim components.
- * 
+ *
  * \throw If \a this is not fully set (coordinates and connectivity).
  * \throw If a cell in \a this has no valid nodeId.
  * \sa MEDCouplingUMesh::getBoundingBoxForBBTreeFast, MEDCouplingUMesh::getBoundingBoxForBBTree2DQuadratic
@@ -6860,32 +5769,33 @@ DataArrayDouble *MEDCouplingUMesh::getBoundingBoxForBBTree(double arcDetEps) con
 /*!
  * This method aggregate the bbox of each cell only considering the nodes constituting each cell and put it into bbox parameter.
  * So meshes having quadratic cells the computed bounding boxes can be invalid !
- * 
+ *
  * \return DataArrayDouble * - newly created object (to be managed by the caller) \a this number of cells tuples and 2*spacedim components.
- * 
+ *
  * \throw If \a this is not fully set (coordinates and connectivity).
  * \throw If a cell in \a this has no valid nodeId.
  */
 DataArrayDouble *MEDCouplingUMesh::getBoundingBoxForBBTreeFast() const
 {
   checkFullyDefined();
-  int spaceDim(getSpaceDimension()),nbOfCells(getNumberOfCells()),nbOfNodes(getNumberOfNodes());
+  int spaceDim(getSpaceDimension());
+  mcIdType nbOfCells(getNumberOfCells()), nbOfNodes(getNumberOfNodes());
   MCAuto<DataArrayDouble> ret(DataArrayDouble::New()); ret->alloc(nbOfCells,2*spaceDim);
   double *bbox(ret->getPointer());
-  for(int i=0;i<nbOfCells*spaceDim;i++)
+  for(mcIdType i=0;i<nbOfCells*spaceDim;i++)
     {
       bbox[2*i]=std::numeric_limits<double>::max();
       bbox[2*i+1]=-std::numeric_limits<double>::max();
     }
   const double *coordsPtr(_coords->begin());
-  const int *conn(_nodal_connec->begin()),*connI(_nodal_connec_index->begin());
-  for(int i=0;i<nbOfCells;i++)
+  const mcIdType *conn(_nodal_connec->begin()),*connI(_nodal_connec_index->begin());
+  for(mcIdType i=0;i<nbOfCells;i++)
     {
-      int offset=connI[i]+1;
-      int nbOfNodesForCell(connI[i+1]-offset),kk(0);
-      for(int j=0;j<nbOfNodesForCell;j++)
+      mcIdType offset=connI[i]+1;
+      mcIdType nbOfNodesForCell(connI[i+1]-offset),kk(0);
+      for(mcIdType j=0;j<nbOfNodesForCell;j++)
         {
-          int nodeId=conn[offset+j];
+          mcIdType nodeId=conn[offset+j];
           if(nodeId>=0 && nodeId<nbOfNodes)
             {
               for(int k=0;k<spaceDim;k++)
@@ -6910,7 +5820,7 @@ DataArrayDouble *MEDCouplingUMesh::getBoundingBoxForBBTreeFast() const
  * useful for 2D meshes having quadratic cells
  * because for this type of cells getBoundingBoxForBBTreeFast method may return invalid bounding boxes (since it just considers
  * the two extremities of the arc of circle).
- * 
+ *
  * \param [in] arcDetEps - a parameter specifying in case of 2D quadratic polygon cell the detection limit between linear and arc circle. (By default 1e-12)
  * \return DataArrayDouble * - newly created object (to be managed by the caller) \a this number of cells tuples and 2*spacedim components.
  * \throw If \a this is not fully defined.
@@ -6921,23 +5831,25 @@ DataArrayDouble *MEDCouplingUMesh::getBoundingBoxForBBTreeFast() const
 DataArrayDouble *MEDCouplingUMesh::getBoundingBoxForBBTree2DQuadratic(double arcDetEps) const
 {
   checkFullyDefined();
-  int spaceDim(getSpaceDimension()),mDim(getMeshDimension()),nbOfCells(getNumberOfCells());
+  INTERP_KERNEL::QuadraticPlanarPrecision arcPrec(arcDetEps);
+
+  int spaceDim(getSpaceDimension()),mDim(getMeshDimension());
+  mcIdType nbOfCells=getNumberOfCells();
   if(spaceDim!=2 || mDim!=2)
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getBoundingBoxForBBTree2DQuadratic : This method should be applied on mesh with mesh dimension equal to 2 and space dimension also equal to 2!");
   MCAuto<DataArrayDouble> ret(DataArrayDouble::New()); ret->alloc(nbOfCells,2*spaceDim);
   double *bbox(ret->getPointer());
   const double *coords(_coords->begin());
-  const int *conn(_nodal_connec->begin()),*connI(_nodal_connec_index->begin());
-  for(int i=0;i<nbOfCells;i++,bbox+=4,connI++)
+  const mcIdType *conn(_nodal_connec->begin()),*connI(_nodal_connec_index->begin());
+  for(mcIdType i=0;i<nbOfCells;i++,bbox+=4,connI++)
     {
       const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)conn[*connI]));
-      int sz(connI[1]-connI[0]-1);
-      INTERP_KERNEL::QUADRATIC_PLANAR::_arc_detection_precision=arcDetEps;
+      mcIdType sz(connI[1]-connI[0]-1);
       std::vector<INTERP_KERNEL::Node *> nodes(sz);
       INTERP_KERNEL::QuadraticPolygon *pol(0);
-      for(int j=0;j<sz;j++)
+      for(mcIdType j=0;j<sz;j++)
         {
-          int nodeId(conn[*connI+1+j]);
+          mcIdType nodeId(conn[*connI+1+j]);
           nodes[j]=new INTERP_KERNEL::Node(coords[nodeId*2],coords[nodeId*2+1]);
         }
       if(!cm.isQuadratic())
@@ -6945,7 +5857,7 @@ DataArrayDouble *MEDCouplingUMesh::getBoundingBoxForBBTree2DQuadratic(double arc
       else
         pol=INTERP_KERNEL::QuadraticPolygon::BuildArcCirclePolygon(nodes);
       INTERP_KERNEL::Bounds b; b.prepareForAggregation(); pol->fillBounds(b); delete pol;
-      bbox[0]=b.getXMin(); bbox[1]=b.getXMax(); bbox[2]=b.getYMin(); bbox[3]=b.getYMax(); 
+      bbox[0]=b.getXMin(); bbox[1]=b.getXMax(); bbox[2]=b.getYMin(); bbox[3]=b.getYMax();
     }
   return ret.retn();
 }
@@ -6955,7 +5867,7 @@ DataArrayDouble *MEDCouplingUMesh::getBoundingBoxForBBTree2DQuadratic(double arc
  * useful for 2D meshes having quadratic cells
  * because for this type of cells getBoundingBoxForBBTreeFast method may return invalid bounding boxes (since it just considers
  * the two extremities of the arc of circle).
- * 
+ *
  * \param [in] arcDetEps - a parameter specifying in case of 2D quadratic polygon cell the detection limit between linear and arc circle. (By default 1e-12)
  * \return DataArrayDouble * - newly created object (to be managed by the caller) \a this number of cells tuples and 2*spacedim components.
  * \throw If \a this is not fully defined.
@@ -6966,23 +5878,24 @@ DataArrayDouble *MEDCouplingUMesh::getBoundingBoxForBBTree2DQuadratic(double arc
 DataArrayDouble *MEDCouplingUMesh::getBoundingBoxForBBTree1DQuadratic(double arcDetEps) const
 {
   checkFullyDefined();
-  int spaceDim(getSpaceDimension()),mDim(getMeshDimension()),nbOfCells(getNumberOfCells());
+  int spaceDim(getSpaceDimension()),mDim(getMeshDimension());
+  mcIdType nbOfCells=getNumberOfCells();
   if(spaceDim!=2 || mDim!=1)
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getBoundingBoxForBBTree1DQuadratic : This method should be applied on mesh with mesh dimension equal to 1 and space dimension also equal to 2!");
+  INTERP_KERNEL::QuadraticPlanarPrecision arcPrec(arcDetEps);
   MCAuto<DataArrayDouble> ret(DataArrayDouble::New()); ret->alloc(nbOfCells,2*spaceDim);
   double *bbox(ret->getPointer());
   const double *coords(_coords->begin());
-  const int *conn(_nodal_connec->begin()),*connI(_nodal_connec_index->begin());
-  for(int i=0;i<nbOfCells;i++,bbox+=4,connI++)
+  const mcIdType *conn(_nodal_connec->begin()),*connI(_nodal_connec_index->begin());
+  for(mcIdType i=0;i<nbOfCells;i++,bbox+=4,connI++)
     {
       const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)conn[*connI]));
-      int sz(connI[1]-connI[0]-1);
-      INTERP_KERNEL::QUADRATIC_PLANAR::_arc_detection_precision=arcDetEps;
+      mcIdType sz(connI[1]-connI[0]-1);
       std::vector<INTERP_KERNEL::Node *> nodes(sz);
       INTERP_KERNEL::Edge *edge(0);
-      for(int j=0;j<sz;j++)
+      for(mcIdType j=0;j<sz;j++)
         {
-          int nodeId(conn[*connI+1+j]);
+          mcIdType nodeId(conn[*connI+1+j]);
           nodes[j]=new INTERP_KERNEL::Node(coords[nodeId*2],coords[nodeId*2+1]);
         }
       if(!cm.isQuadratic())
@@ -7002,21 +5915,21 @@ namespace MEDCouplingImpl
   class ConnReader
   {
   public:
-    ConnReader(const int *c, int val):_conn(c),_val(val) { }
-    bool operator() (const int& pos) { return _conn[pos]!=_val; }
+    ConnReader(const mcIdType *c, mcIdType val):_conn(c),_val(val) { }
+    bool operator() (const mcIdType& pos) { return _conn[pos]!=_val; }
   private:
-    const int *_conn;
-    int _val;
+    const mcIdType *_conn;
+    mcIdType _val;
   };
 
   class ConnReader2
   {
   public:
-    ConnReader2(const int *c, int val):_conn(c),_val(val) { }
-    bool operator() (const int& pos) { return _conn[pos]==_val; }
+    ConnReader2(const mcIdType *c, mcIdType val):_conn(c),_val(val) { }
+    bool operator() (const mcIdType& pos) { return _conn[pos]==_val; }
   private:
-    const int *_conn;
-    int _val;
+    const mcIdType *_conn;
+    mcIdType _val;
   };
 }
 
@@ -7026,19 +5939,19 @@ namespace MEDCouplingImpl
  * This method expects that \a this is sorted by types. If not an exception will be thrown.
  * This method returns in the same format as code (see MEDCouplingUMesh::checkTypeConsistencyAndContig or MEDCouplingUMesh::splitProfilePerType) how
  * \a this is composed in cell types.
- * The returned array is of size 3*n where n is the number of different types present in \a this. 
- * For every k in [0,n] ret[3*k+2]==-1 because it has no sense here. 
- * This parameter is kept only for compatibility with other methode listed above.
+ * The returned array is of size 3*n where n is the number of different types present in \a this.
+ * For every k in [0,n] ret[3*k+2]==-1 because it has no sense here.
+ * This parameter is kept only for compatibility with other method listed above.
  */
-std::vector<int> MEDCouplingUMesh::getDistributionOfTypes() const
+std::vector<mcIdType> MEDCouplingUMesh::getDistributionOfTypes() const
 {
   checkConnectivityFullyDefined();
-  const int *conn=_nodal_connec->begin();
-  const int *connI=_nodal_connec_index->begin();
-  const int *work=connI;
-  int nbOfCells=getNumberOfCells();
+  const mcIdType *conn=_nodal_connec->begin();
+  const mcIdType *connI=_nodal_connec_index->begin();
+  const mcIdType *work=connI;
+  mcIdType nbOfCells=getNumberOfCells();
   std::size_t n=getAllGeoTypes().size();
-  std::vector<int> ret(3*n,-1); //ret[3*k+2]==-1 because it has no sense here
+  std::vector<mcIdType> ret(3*n,-1); //ret[3*k+2]==-1 because it has no sense here
   std::set<INTERP_KERNEL::NormalizedCellType> types;
   for(std::size_t i=0;work!=connI+nbOfCells;i++)
     {
@@ -7051,8 +5964,8 @@ std::vector<int> MEDCouplingUMesh::getDistributionOfTypes() const
         }
       types.insert(typ);
       ret[3*i]=typ;
-      const int *work2=std::find_if(work+1,connI+nbOfCells,MEDCouplingImpl::ConnReader(conn,typ));
-      ret[3*i+1]=(int)std::distance(work,work2);
+      const mcIdType *work2=std::find_if(work+1,connI+nbOfCells,MEDCouplingImpl::ConnReader(conn,typ));
+      ret[3*i+1]=ToIdType(std::distance(work,work2));
       work=work2;
     }
   return ret;
@@ -7070,12 +5983,12 @@ std::vector<int> MEDCouplingUMesh::getDistributionOfTypes() const
  * If it exists k so that 3*k geometric type is not in geometric types of this an exception will be thrown.
  * If it exists k so that 3*k geometric type exists but the number of consecutive cell types does not match,
  * an exception is thrown too.
- * 
+ *
  * If all geometric types in \a code are exactly those in \a this null pointer is returned.
- * If it exists a geometric type in \a this \b not in \a code \b no exception is thrown 
- * and a DataArrayInt instance is returned that the user has the responsability to deallocate.
+ * If it exists a geometric type in \a this \b not in \a code \b no exception is thrown
+ * and a DataArrayIdType instance is returned that the user has the responsibility to deallocate.
  */
-DataArrayInt *MEDCouplingUMesh::checkTypeConsistencyAndContig(const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const
+DataArrayIdType *MEDCouplingUMesh::checkTypeConsistencyAndContig(const std::vector<mcIdType>& code, const std::vector<const DataArrayIdType *>& idsPerType) const
 {
   if(code.empty())
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::checkTypeConsistencyAndContig : code is empty, should not !");
@@ -7084,7 +5997,7 @@ DataArrayInt *MEDCouplingUMesh::checkTypeConsistencyAndContig(const std::vector<
   if(sz%3!=0)
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::checkTypeConsistencyAndContig : code size is NOT %3 !");
   std::vector<INTERP_KERNEL::NormalizedCellType> types;
-  int nb=0;
+  mcIdType nb=0;
   bool isNoPflUsed=true;
   for(std::size_t i=0;i<n;i++)
     if(std::find(types.begin(),types.end(),(INTERP_KERNEL::NormalizedCellType)code[3*i])==types.end())
@@ -7104,35 +6017,35 @@ DataArrayInt *MEDCouplingUMesh::checkTypeConsistencyAndContig(const std::vector<
       if(types.size()==_types.size())
         return 0;
     }
-  MCAuto<DataArrayInt> ret=DataArrayInt::New();
+  MCAuto<DataArrayIdType> ret=DataArrayIdType::New();
   ret->alloc(nb,1);
-  int *retPtr=ret->getPointer();
-  const int *connI=_nodal_connec_index->begin();
-  const int *conn=_nodal_connec->begin();
-  int nbOfCells=getNumberOfCells();
-  const int *i=connI;
+  mcIdType *retPtr=ret->getPointer();
+  const mcIdType *connI=_nodal_connec_index->begin();
+  const mcIdType *conn=_nodal_connec->begin();
+  mcIdType nbOfCells=getNumberOfCells();
+  const mcIdType *i=connI;
   int kk=0;
   for(std::vector<INTERP_KERNEL::NormalizedCellType>::const_iterator it=types.begin();it!=types.end();it++,kk++)
     {
-      i=std::find_if(i,connI+nbOfCells,MEDCouplingImpl::ConnReader2(conn,(int)(*it)));
-      int offset=(int)std::distance(connI,i);
-      const int *j=std::find_if(i+1,connI+nbOfCells,MEDCouplingImpl::ConnReader(conn,(int)(*it)));
-      int nbOfCellsOfCurType=(int)std::distance(i,j);
+      i=std::find_if(i,connI+nbOfCells,MEDCouplingImpl::ConnReader2(conn,ToIdType((*it))));
+      mcIdType offset=ToIdType(std::distance(connI,i));
+      const mcIdType *j=std::find_if(i+1,connI+nbOfCells,MEDCouplingImpl::ConnReader(conn,ToIdType((*it))));
+      mcIdType nbOfCellsOfCurType=ToIdType(std::distance(i,j));
       if(code[3*kk+2]==-1)
-        for(int k=0;k<nbOfCellsOfCurType;k++)
+        for(mcIdType k=0;k<nbOfCellsOfCurType;k++)
           *retPtr++=k+offset;
       else
         {
-          int idInIdsPerType=code[3*kk+2];
-          if(idInIdsPerType>=0 && idInIdsPerType<(int)idsPerType.size())
+          mcIdType idInIdsPerType=code[3*kk+2];
+          if(idInIdsPerType>=0 && idInIdsPerType<ToIdType(idsPerType.size()))
             {
-              const DataArrayInt *zePfl=idsPerType[idInIdsPerType];
+              const DataArrayIdType *zePfl=idsPerType[idInIdsPerType];
               if(zePfl)
                 {
                   zePfl->checkAllocated();
                   if(zePfl->getNumberOfComponents()==1)
                     {
-                      for(const int *k=zePfl->begin();k!=zePfl->end();k++,retPtr++)
+                      for(const mcIdType *k=zePfl->begin();k!=zePfl->end();k++,retPtr++)
                         {
                           if(*k>=0 && *k<nbOfCellsOfCurType)
                             *retPtr=(*k)+offset;
@@ -7167,8 +6080,8 @@ DataArrayInt *MEDCouplingUMesh::checkTypeConsistencyAndContig(const std::vector<
  * This method is the opposite of MEDCouplingUMesh::checkTypeConsistencyAndContig method. Given a list of cells in \a profile it returns a list of sub-profiles sorted by geo type.
  * The result is put in the array \a idsPerType. In the returned parameter \a code, foreach i \a code[3*i+2] refers (if different from -1) to a location into the \a idsPerType.
  * This method has 1 input \a profile and 3 outputs \a code \a idsInPflPerType and \a idsPerType.
- * 
- * \param [in] profile
+ *
+ * \param [in] profile list of IDs constituing the profile
  * \param [out] code is a vector of size 3*n where n is the number of different geometric type in \a this \b reduced to the profile \a profile. \a code has exactly the same semantic than in MEDCouplingUMesh::checkTypeConsistencyAndContig method.
  * \param [out] idsInPflPerType is a vector of size of different geometric type in the subpart defined by \a profile of \a this ( equal to \a code.size()/3). For each i,
  *              \a idsInPflPerType[i] stores the tuple ids in \a profile that correspond to the geometric type code[3*i+0]
@@ -7176,19 +6089,19 @@ DataArrayInt *MEDCouplingUMesh::checkTypeConsistencyAndContig(const std::vector<
  *              This vector can be empty in case of all geometric type cells are fully covered in ascending in the given input \a profile.
  * \throw if \a profile has not exactly one component. It throws too, if \a profile contains some values not in [0,getNumberOfCells()) or if \a this is not fully defined
  */
-void MEDCouplingUMesh::splitProfilePerType(const DataArrayInt *profile, std::vector<int>& code, std::vector<DataArrayInt *>& idsInPflPerType, std::vector<DataArrayInt *>& idsPerType) const
+void MEDCouplingUMesh::splitProfilePerType(const DataArrayIdType *profile, std::vector<mcIdType>& code, std::vector<DataArrayIdType *>& idsInPflPerType, std::vector<DataArrayIdType *>& idsPerType, bool smartPflKiller) const
 {
   if(!profile)
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::splitProfilePerType : input profile is NULL !");
   if(profile->getNumberOfComponents()!=1)
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::splitProfilePerType : input profile should have exactly one component !");
   checkConnectivityFullyDefined();
-  const int *conn=_nodal_connec->begin();
-  const int *connI=_nodal_connec_index->begin();
-  int nbOfCells=getNumberOfCells();
+  const mcIdType *conn=_nodal_connec->begin();
+  const mcIdType *connI=_nodal_connec_index->begin();
+  mcIdType nbOfCells=getNumberOfCells();
   std::vector<INTERP_KERNEL::NormalizedCellType> types;
-  std::vector<int> typeRangeVals(1);
-  for(const int *i=connI;i!=connI+nbOfCells;)
+  std::vector<mcIdType> typeRangeVals(1);
+  for(const mcIdType *i=connI;i!=connI+nbOfCells;)
     {
       INTERP_KERNEL::NormalizedCellType curType=(INTERP_KERNEL::NormalizedCellType)conn[*i];
       if(std::find(types.begin(),types.end(),curType)!=types.end())
@@ -7196,33 +6109,33 @@ void MEDCouplingUMesh::splitProfilePerType(const DataArrayInt *profile, std::vec
           throw INTERP_KERNEL::Exception("MEDCouplingUMesh::splitProfilePerType : current mesh is not sorted by type !");
         }
       types.push_back(curType);
-      i=std::find_if(i+1,connI+nbOfCells,MEDCouplingImpl::ConnReader(conn,(int)curType));
-      typeRangeVals.push_back((int)std::distance(connI,i));
+      i=std::find_if(i+1,connI+nbOfCells,MEDCouplingImpl::ConnReader(conn,ToIdType(curType)));
+      typeRangeVals.push_back(ToIdType(std::distance(connI,i)));
     }
   //
-  DataArrayInt *castArr=0,*rankInsideCast=0,*castsPresent=0;
+  DataArrayIdType *castArr=0,*rankInsideCast=0,*castsPresent=0;
   profile->splitByValueRange(&typeRangeVals[0],&typeRangeVals[0]+typeRangeVals.size(),castArr,rankInsideCast,castsPresent);
-  MCAuto<DataArrayInt> tmp0=castArr;
-  MCAuto<DataArrayInt> tmp1=rankInsideCast;
-  MCAuto<DataArrayInt> tmp2=castsPresent;
+  MCAuto<DataArrayIdType> tmp0=castArr;
+  MCAuto<DataArrayIdType> tmp1=rankInsideCast;
+  MCAuto<DataArrayIdType> tmp2=castsPresent;
   //
-  int nbOfCastsFinal=castsPresent->getNumberOfTuples();
+  mcIdType nbOfCastsFinal=castsPresent->getNumberOfTuples();
   code.resize(3*nbOfCastsFinal);
-  std::vector< MCAuto<DataArrayInt> > idsInPflPerType2;
-  std::vector< MCAuto<DataArrayInt> > idsPerType2;
-  for(int i=0;i<nbOfCastsFinal;i++)
+  std::vector< MCAuto<DataArrayIdType> > idsInPflPerType2;
+  std::vector< MCAuto<DataArrayIdType> > idsPerType2;
+  for(mcIdType i=0;i<nbOfCastsFinal;i++)
     {
-      int castId=castsPresent->getIJ(i,0);
-      MCAuto<DataArrayInt> tmp3=castArr->findIdsEqual(castId);
+      mcIdType castId=castsPresent->getIJ(i,0);
+      MCAuto<DataArrayIdType> tmp3=castArr->findIdsEqual(castId);
       idsInPflPerType2.push_back(tmp3);
-      code[3*i]=(int)types[castId];
+      code[3*i]=ToIdType(types[castId]);
       code[3*i+1]=tmp3->getNumberOfTuples();
-      MCAuto<DataArrayInt> tmp4=rankInsideCast->selectByTupleId(tmp3->begin(),tmp3->begin()+tmp3->getNumberOfTuples());
-      if(!tmp4->isIota(typeRangeVals[castId+1]-typeRangeVals[castId]))
+      MCAuto<DataArrayIdType> tmp4=rankInsideCast->selectByTupleId(tmp3->begin(),tmp3->begin()+tmp3->getNumberOfTuples());
+      if(!smartPflKiller || !tmp4->isIota(typeRangeVals[castId+1]-typeRangeVals[castId]))
         {
           tmp4->copyStringInfoFrom(*profile);
           idsPerType2.push_back(tmp4);
-          code[3*i+2]=(int)idsPerType2.size()-1;
+          code[3*i+2]=ToIdType(idsPerType2.size())-1;
         }
       else
         {
@@ -7233,7 +6146,7 @@ void MEDCouplingUMesh::splitProfilePerType(const DataArrayInt *profile, std::vec
   idsInPflPerType.resize(sz2);
   for(std::size_t i=0;i<sz2;i++)
     {
-      DataArrayInt *locDa=idsInPflPerType2[i];
+      DataArrayIdType *locDa=idsInPflPerType2[i];
       locDa->incrRef();
       idsInPflPerType[i]=locDa;
     }
@@ -7241,7 +6154,7 @@ void MEDCouplingUMesh::splitProfilePerType(const DataArrayInt *profile, std::vec
   idsPerType.resize(sz);
   for(std::size_t i=0;i<sz;i++)
     {
-      DataArrayInt *locDa=idsPerType2[i];
+      DataArrayIdType *locDa=idsPerType2[i];
       locDa->incrRef();
       idsPerType[i]=locDa;
     }
@@ -7253,7 +6166,7 @@ void MEDCouplingUMesh::splitProfilePerType(const DataArrayInt *profile, std::vec
  * The following equality should be verified 'nM1LevMesh->getMeshDimension()==this->getMeshDimension()-1'
  * This method returns 5+2 elements. 'desc', 'descIndx', 'revDesc', 'revDescIndx' and 'meshnM1' behaves exactly as MEDCoupling::MEDCouplingUMesh::buildDescendingConnectivity except the content as described after. The returned array specifies the n-1 mesh reordered by type as MEDMEM does. 'nM1LevMeshIds' contains the ids in returned 'meshnM1'. Finally 'meshnM1Old2New' contains numbering old2new that is to say the cell #k in coarse 'nM1LevMesh' will have the number ret[k] in returned mesh 'nM1LevMesh' MEDMEM reordered.
  */
-MEDCouplingUMesh *MEDCouplingUMesh::emulateMEDMEMBDC(const MEDCouplingUMesh *nM1LevMesh, DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *&revDesc, DataArrayInt *&revDescIndx, DataArrayInt *& nM1LevMeshIds, DataArrayInt *&meshnM1Old2New) const
+MEDCouplingUMesh *MEDCouplingUMesh::emulateMEDMEMBDC(const MEDCouplingUMesh *nM1LevMesh, DataArrayIdType *desc, DataArrayIdType *descIndx, DataArrayIdType *&revDesc, DataArrayIdType *&revDescIndx, DataArrayIdType *& nM1LevMeshIds, DataArrayIdType *&meshnM1Old2New) const
 {
   checkFullyDefined();
   nM1LevMesh->checkFullyDefined();
@@ -7261,20 +6174,20 @@ MEDCouplingUMesh *MEDCouplingUMesh::emulateMEDMEMBDC(const MEDCouplingUMesh *nM1
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::emulateMEDMEMBDC : The mesh passed as first argument should have a meshDim equal to this->getMeshDimension()-1 !" );
   if(_coords!=nM1LevMesh->getCoords())
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::emulateMEDMEMBDC : 'this' and mesh in first argument should share the same coords : Use tryToShareSameCoords method !");
-  MCAuto<DataArrayInt> tmp0=DataArrayInt::New();
-  MCAuto<DataArrayInt> tmp1=DataArrayInt::New();
+  MCAuto<DataArrayIdType> tmp0=DataArrayIdType::New();
+  MCAuto<DataArrayIdType> tmp1=DataArrayIdType::New();
   MCAuto<MEDCouplingUMesh> ret1=buildDescendingConnectivity(desc,descIndx,tmp0,tmp1);
-  MCAuto<DataArrayInt> ret0=ret1->sortCellsInMEDFileFrmt();
+  MCAuto<DataArrayIdType> ret0=ret1->sortCellsInMEDFileFrmt();
   desc->transformWithIndArr(ret0->begin(),ret0->begin()+ret0->getNbOfElems());
   MCAuto<MEDCouplingUMesh> tmp=MEDCouplingUMesh::New();
   tmp->setConnectivity(tmp0,tmp1);
   tmp->renumberCells(ret0->begin(),false);
   revDesc=tmp->getNodalConnectivity();
   revDescIndx=tmp->getNodalConnectivityIndex();
-  DataArrayInt *ret=0;
+  DataArrayIdType *ret=0;
   if(!ret1->areCellsIncludedIn(nM1LevMesh,2,ret))
     {
-      int tmp2;
+      mcIdType tmp2;
       ret->getMaxValue(tmp2);
       ret->decrRef();
       std::ostringstream oss; oss << "MEDCouplingUMesh::emulateMEDMEMBDC : input N-1 mesh present a cell not in descending mesh ... Id of cell is " << tmp2 << " !";
@@ -7294,14 +6207,14 @@ MEDCouplingUMesh *MEDCouplingUMesh::emulateMEDMEMBDC(const MEDCouplingUMesh *nM1
  * Permutes the nodal connectivity arrays so that the cells are sorted by type, which is
  * necessary for writing the mesh to MED file. Additionally returns a permutation array
  * in "Old to New" mode.
- *  \return DataArrayInt * - a new instance of DataArrayInt. The caller is to delete
+ *  \return DataArrayIdType * - a new instance of DataArrayIdType. The caller is to delete
  *          this array using decrRef() as it is no more needed.
  *  \throw If the nodal connectivity of cells is not defined.
  */
-DataArrayInt *MEDCouplingUMesh::sortCellsInMEDFileFrmt()
+DataArrayIdType *MEDCouplingUMesh::sortCellsInMEDFileFrmt()
 {
   checkConnectivityFullyDefined();
-  MCAuto<DataArrayInt> ret=getRenumArrForMEDFileFrmt();
+  MCAuto<DataArrayIdType> ret=getRenumArrForMEDFileFrmt();
   renumberCells(ret->begin(),false);
   return ret.retn();
 }
@@ -7313,17 +6226,17 @@ DataArrayInt *MEDCouplingUMesh::sortCellsInMEDFileFrmt()
 bool MEDCouplingUMesh::checkConsecutiveCellTypes() const
 {
   checkFullyDefined();
-  const int *conn=_nodal_connec->begin();
-  const int *connI=_nodal_connec_index->begin();
-  int nbOfCells=getNumberOfCells();
+  const mcIdType *conn=_nodal_connec->begin();
+  const mcIdType *connI=_nodal_connec_index->begin();
+  mcIdType nbOfCells=getNumberOfCells();
   std::set<INTERP_KERNEL::NormalizedCellType> types;
-  for(const int *i=connI;i!=connI+nbOfCells;)
+  for(const mcIdType *i=connI;i!=connI+nbOfCells;)
     {
       INTERP_KERNEL::NormalizedCellType curType=(INTERP_KERNEL::NormalizedCellType)conn[*i];
       if(types.find(curType)!=types.end())
         return false;
       types.insert(curType);
-      i=std::find_if(i+1,connI+nbOfCells,MEDCouplingImpl::ConnReader(conn,(int)curType));
+      i=std::find_if(i+1,connI+nbOfCells,MEDCouplingImpl::ConnReader(conn,ToIdType(curType)));
     }
   return true;
 }
@@ -7331,7 +6244,7 @@ bool MEDCouplingUMesh::checkConsecutiveCellTypes() const
 /*!
  * This method is a specialization of MEDCouplingUMesh::checkConsecutiveCellTypesAndOrder method that is called here.
  * The geometric type order is specified by MED file.
- * 
+ *
  * \sa  MEDCouplingUMesh::checkConsecutiveCellTypesAndOrder
  */
 bool MEDCouplingUMesh::checkConsecutiveCellTypesForMEDFileFrmt() const
@@ -7348,30 +6261,30 @@ bool MEDCouplingUMesh::checkConsecutiveCellTypesForMEDFileFrmt() const
 bool MEDCouplingUMesh::checkConsecutiveCellTypesAndOrder(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd) const
 {
   checkFullyDefined();
-  const int *conn=_nodal_connec->begin();
-  const int *connI=_nodal_connec_index->begin();
-  int nbOfCells=getNumberOfCells();
+  const mcIdType *conn=_nodal_connec->begin();
+  const mcIdType *connI=_nodal_connec_index->begin();
+  mcIdType nbOfCells=getNumberOfCells();
   if(nbOfCells==0)
     return true;
-  int lastPos=-1;
+  mcIdType lastPos=-1;
   std::set<INTERP_KERNEL::NormalizedCellType> sg;
-  for(const int *i=connI;i!=connI+nbOfCells;)
+  for(const mcIdType *i=connI;i!=connI+nbOfCells;)
     {
       INTERP_KERNEL::NormalizedCellType curType=(INTERP_KERNEL::NormalizedCellType)conn[*i];
       const INTERP_KERNEL::NormalizedCellType *isTypeExists=std::find(orderBg,orderEnd,curType);
       if(isTypeExists!=orderEnd)
         {
-          int pos=(int)std::distance(orderBg,isTypeExists);
+          mcIdType pos=ToIdType(std::distance(orderBg,isTypeExists));
           if(pos<=lastPos)
             return false;
           lastPos=pos;
-          i=std::find_if(i+1,connI+nbOfCells,MEDCouplingImpl::ConnReader(conn,(int)curType));
+          i=std::find_if(i+1,connI+nbOfCells,MEDCouplingImpl::ConnReader(conn,ToIdType(curType)));
         }
       else
         {
           if(sg.find(curType)==sg.end())
             {
-              i=std::find_if(i+1,connI+nbOfCells,MEDCouplingImpl::ConnReader(conn,(int)curType));
+              i=std::find_if(i+1,connI+nbOfCells,MEDCouplingImpl::ConnReader(conn,ToIdType(curType)));
               sg.insert(curType);
             }
           else
@@ -7382,29 +6295,29 @@ bool MEDCouplingUMesh::checkConsecutiveCellTypesAndOrder(const INTERP_KERNEL::No
 }
 
 /*!
- * This method returns 2 newly allocated DataArrayInt instances. The first is an array of size 'this->getNumberOfCells()' with one component,
+ * This method returns 2 newly allocated DataArrayIdType instances. The first is an array of size 'this->getNumberOfCells()' with one component,
  * that tells for each cell the pos of its type in the array on type given in input parameter. The 2nd output parameter is an array with the same
- * number of tuples than input type array and with one component. This 2nd output array gives type by type the number of occurence of type in 'this'.
+ * number of tuples than input type array and with one component. This 2nd output array gives type by type the number of occurrence of type in 'this'.
  */
-DataArrayInt *MEDCouplingUMesh::getLevArrPerCellTypes(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd, DataArrayInt *&nbPerType) const
+DataArrayIdType *MEDCouplingUMesh::getLevArrPerCellTypes(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd, DataArrayIdType *&nbPerType) const
 {
   checkConnectivityFullyDefined();
-  int nbOfCells=getNumberOfCells();
-  const int *conn=_nodal_connec->begin();
-  const int *connI=_nodal_connec_index->begin();
-  MCAuto<DataArrayInt> tmpa=DataArrayInt::New();
-  MCAuto<DataArrayInt> tmpb=DataArrayInt::New();
+  mcIdType nbOfCells=getNumberOfCells();
+  const mcIdType *conn=_nodal_connec->begin();
+  const mcIdType *connI=_nodal_connec_index->begin();
+  MCAuto<DataArrayIdType> tmpa=DataArrayIdType::New();
+  MCAuto<DataArrayIdType> tmpb=DataArrayIdType::New();
   tmpa->alloc(nbOfCells,1);
-  tmpb->alloc((int)std::distance(orderBg,orderEnd),1);
+  tmpb->alloc(std::distance(orderBg,orderEnd),1);
   tmpb->fillWithZero();
-  int *tmp=tmpa->getPointer();
-  int *tmp2=tmpb->getPointer();
-  for(const int *i=connI;i!=connI+nbOfCells;i++)
+  mcIdType *tmp=tmpa->getPointer();
+  mcIdType *tmp2=tmpb->getPointer();
+  for(const mcIdType *i=connI;i!=connI+nbOfCells;i++)
     {
       const INTERP_KERNEL::NormalizedCellType *where=std::find(orderBg,orderEnd,(INTERP_KERNEL::NormalizedCellType)conn[*i]);
       if(where!=orderEnd)
         {
-          int pos=(int)std::distance(orderBg,where);
+          mcIdType pos=ToIdType(std::distance(orderBg,where));
           tmp2[pos]++;
           tmp[std::distance(connI,i)]=pos;
         }
@@ -7423,25 +6336,25 @@ DataArrayInt *MEDCouplingUMesh::getLevArrPerCellTypes(const INTERP_KERNEL::Norma
 /*!
  * This method behaves exactly as MEDCouplingUMesh::getRenumArrForConsecutiveCellTypesSpec but the order is those defined in MED file spec.
  *
- * \return a new object containing the old to new correspondance.
+ * \return a new object containing the old to new correspondence.
  *
  * \sa MEDCouplingUMesh::getRenumArrForConsecutiveCellTypesSpec, MEDCouplingUMesh::sortCellsInMEDFileFrmt.
  */
-DataArrayInt *MEDCouplingUMesh::getRenumArrForMEDFileFrmt() const
+DataArrayIdType *MEDCouplingUMesh::getRenumArrForMEDFileFrmt() const
 {
   return getRenumArrForConsecutiveCellTypesSpec(MEDMEM_ORDER,MEDMEM_ORDER+N_MEDMEM_ORDER);
 }
 
 /*!
- * This method is similar to method MEDCouplingUMesh::rearrange2ConsecutiveCellTypes except that the type order is specfied by [ \a orderBg , \a orderEnd ) (as MEDCouplingUMesh::checkConsecutiveCellTypesAndOrder method) and that this method is \b const and performs \b NO permutation in \a this.
+ * This method is similar to method MEDCouplingUMesh::rearrange2ConsecutiveCellTypes except that the type order is specified by [ \a orderBg , \a orderEnd ) (as MEDCouplingUMesh::checkConsecutiveCellTypesAndOrder method) and that this method is \b const and performs \b NO permutation in \a this.
  * This method returns an array of size getNumberOfCells() that gives a renumber array old2New that can be used as input of MEDCouplingMesh::renumberCells.
  * The mesh after this call to MEDCouplingMesh::renumberCells will pass the test of MEDCouplingUMesh::checkConsecutiveCellTypesAndOrder with the same inputs.
  * The returned array minimizes the permutations that is to say the order of cells inside same geometric type remains the same.
  */
-DataArrayInt *MEDCouplingUMesh::getRenumArrForConsecutiveCellTypesSpec(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd) const
+DataArrayIdType *MEDCouplingUMesh::getRenumArrForConsecutiveCellTypesSpec(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd) const
 {
-  DataArrayInt *nbPerType=0;
-  MCAuto<DataArrayInt> tmpa=getLevArrPerCellTypes(orderBg,orderEnd,nbPerType);
+  DataArrayIdType *nbPerType=0;
+  MCAuto<DataArrayIdType> tmpa=getLevArrPerCellTypes(orderBg,orderEnd,nbPerType);
   nbPerType->decrRef();
   return tmpa->buildPermArrPerLevel();
 }
@@ -7452,31 +6365,31 @@ DataArrayInt *MEDCouplingUMesh::getRenumArrForConsecutiveCellTypesSpec(const INT
  * This method tries to minimizes the number of needed permutations. So, this method behaves not exactly as
  * MEDCouplingUMesh::sortCellsInMEDFileFrmt.
  *
- * \return the array giving the correspondance old to new.
+ * \return the array giving the correspondence old to new.
  */
-DataArrayInt *MEDCouplingUMesh::rearrange2ConsecutiveCellTypes()
+DataArrayIdType *MEDCouplingUMesh::rearrange2ConsecutiveCellTypes()
 {
   checkFullyDefined();
   computeTypes();
-  const int *conn=_nodal_connec->begin();
-  const int *connI=_nodal_connec_index->begin();
-  int nbOfCells=getNumberOfCells();
+  const mcIdType *conn=_nodal_connec->begin();
+  const mcIdType *connI=_nodal_connec_index->begin();
+  mcIdType nbOfCells=getNumberOfCells();
   std::vector<INTERP_KERNEL::NormalizedCellType> types;
-  for(const int *i=connI;i!=connI+nbOfCells && (types.size()!=_types.size());)
+  for(const mcIdType *i=connI;i!=connI+nbOfCells && (types.size()!=_types.size());)
     if(std::find(types.begin(),types.end(),(INTERP_KERNEL::NormalizedCellType)conn[*i])==types.end())
       {
         INTERP_KERNEL::NormalizedCellType curType=(INTERP_KERNEL::NormalizedCellType)conn[*i];
         types.push_back(curType);
         for(i++;i!=connI+nbOfCells && (INTERP_KERNEL::NormalizedCellType)conn[*i]==curType;i++);
       }
-  DataArrayInt *ret=DataArrayInt::New();
+  DataArrayIdType *ret=DataArrayIdType::New();
   ret->alloc(nbOfCells,1);
-  int *retPtr=ret->getPointer();
+  mcIdType *retPtr=ret->getPointer();
   std::fill(retPtr,retPtr+nbOfCells,-1);
-  int newCellId=0;
+  mcIdType newCellId=0;
   for(std::vector<INTERP_KERNEL::NormalizedCellType>::const_iterator iter=types.begin();iter!=types.end();iter++)
     {
-      for(const int *i=connI;i!=connI+nbOfCells;i++)
+      for(const mcIdType *i=connI;i!=connI+nbOfCells;i++)
         if((INTERP_KERNEL::NormalizedCellType)conn[*i]==(*iter))
           retPtr[std::distance(connI,i)]=newCellId++;
     }
@@ -7492,19 +6405,19 @@ DataArrayInt *MEDCouplingUMesh::rearrange2ConsecutiveCellTypes()
 std::vector<MEDCouplingUMesh *> MEDCouplingUMesh::splitByType() const
 {
   checkConnectivityFullyDefined();
-  const int *conn=_nodal_connec->begin();
-  const int *connI=_nodal_connec_index->begin();
-  int nbOfCells=getNumberOfCells();
+  const mcIdType *conn=_nodal_connec->begin();
+  const mcIdType *connI=_nodal_connec_index->begin();
+  mcIdType nbOfCells=getNumberOfCells();
   std::vector<MEDCouplingUMesh *> ret;
-  for(const int *i=connI;i!=connI+nbOfCells;)
+  for(const mcIdType *i=connI;i!=connI+nbOfCells;)
     {
       INTERP_KERNEL::NormalizedCellType curType=(INTERP_KERNEL::NormalizedCellType)conn[*i];
-      int beginCellId=(int)std::distance(connI,i);
-      i=std::find_if(i+1,connI+nbOfCells,MEDCouplingImpl::ConnReader(conn,(int)curType));
-      int endCellId=(int)std::distance(connI,i);
-      int sz=endCellId-beginCellId;
-      int *cells=new int[sz];
-      for(int j=0;j<sz;j++)
+      mcIdType beginCellId=ToIdType(std::distance(connI,i));
+      i=std::find_if(i+1,connI+nbOfCells,MEDCouplingImpl::ConnReader(conn,ToIdType(curType)));
+      mcIdType endCellId=ToIdType(std::distance(connI,i));
+      mcIdType sz=endCellId-beginCellId;
+      mcIdType *cells=new mcIdType[sz];
+      for(mcIdType j=0;j<sz;j++)
         cells[j]=beginCellId+j;
       MEDCouplingUMesh *m=(MEDCouplingUMesh *)buildPartOfMySelf(cells,cells+sz,true);
       delete [] cells;
@@ -7534,7 +6447,7 @@ MEDCoupling1GTUMesh *MEDCouplingUMesh::convertIntoSingleGeoTypeMesh() const
   MEDCoupling1SGTUMesh *retC=dynamic_cast<MEDCoupling1SGTUMesh *>((MEDCoupling1GTUMesh*)ret);
   if(retC)
     {
-      MCAuto<DataArrayInt> c=convertNodalConnectivityToStaticGeoTypeMesh();
+      MCAuto<DataArrayIdType> c=convertNodalConnectivityToStaticGeoTypeMesh();
       retC->setNodalConnectivity(c);
     }
   else
@@ -7542,15 +6455,15 @@ MEDCoupling1GTUMesh *MEDCouplingUMesh::convertIntoSingleGeoTypeMesh() const
       MEDCoupling1DGTUMesh *retD=dynamic_cast<MEDCoupling1DGTUMesh *>((MEDCoupling1GTUMesh*)ret);
       if(!retD)
         throw INTERP_KERNEL::Exception("MEDCouplingUMesh::convertIntoSingleGeoTypeMesh : Internal error !");
-      DataArrayInt *c=0,*ci=0;
+      DataArrayIdType *c=0,*ci=0;
       convertNodalConnectivityToDynamicGeoTypeMesh(c,ci);
-      MCAuto<DataArrayInt> cs(c),cis(ci);
+      MCAuto<DataArrayIdType> cs(c),cis(ci);
       retD->setNodalConnectivity(cs,cis);
     }
   return ret.retn();
 }
 
-DataArrayInt *MEDCouplingUMesh::convertNodalConnectivityToStaticGeoTypeMesh() const
+DataArrayIdType *MEDCouplingUMesh::convertNodalConnectivityToStaticGeoTypeMesh() const
 {
   checkConnectivityFullyDefined();
   if(_types.size()!=1)
@@ -7563,15 +6476,15 @@ DataArrayInt *MEDCouplingUMesh::convertNodalConnectivityToStaticGeoTypeMesh() co
       oss << "this type is dynamic ! Only static geometric type is possible for that type ! call convertNodalConnectivityToDynamicGeoTypeMesh instead !";
       throw INTERP_KERNEL::Exception(oss.str());
     }
-  int nbCells=getNumberOfCells();
-  int typi=(int)typ;
-  int nbNodesPerCell=(int)cm.getNumberOfNodes();
-  MCAuto<DataArrayInt> connOut=DataArrayInt::New(); connOut->alloc(nbCells*nbNodesPerCell,1);
-  int *outPtr=connOut->getPointer();
-  const int *conn=_nodal_connec->begin();
-  const int *connI=_nodal_connec_index->begin();
+  mcIdType nbCells=getNumberOfCells();
+  mcIdType typi=ToIdType(typ);
+  mcIdType nbNodesPerCell=ToIdType(cm.getNumberOfNodes());
+  MCAuto<DataArrayIdType> connOut=DataArrayIdType::New(); connOut->alloc(nbCells*nbNodesPerCell,1);
+  mcIdType *outPtr=connOut->getPointer();
+  const mcIdType *conn=_nodal_connec->begin();
+  const mcIdType *connI=_nodal_connec_index->begin();
   nbNodesPerCell++;
-  for(int i=0;i<nbCells;i++,connI++)
+  for(mcIdType i=0;i<nbCells;i++,connI++)
     {
       if(conn[connI[0]]==typi && connI[1]-connI[0]==nbNodesPerCell)
         outPtr=std::copy(conn+connI[0]+1,conn+connI[1],outPtr);
@@ -7587,27 +6500,28 @@ DataArrayInt *MEDCouplingUMesh::convertNodalConnectivityToStaticGeoTypeMesh() co
 /*!
  * Convert the nodal connectivity of the mesh so that all the cells are of dynamic types (polygon or quadratic
  * polygon). This returns the corresponding new nodal connectivity in \ref numbering-indirect format.
- * \param nodalConn
- * \param nodalConnI
+ * \param nodalConn nodal connectivity
+ * \param nodalConnIndex nodal connectivity indices
  */
-void MEDCouplingUMesh::convertNodalConnectivityToDynamicGeoTypeMesh(DataArrayInt *&nodalConn, DataArrayInt *&nodalConnIndex) const
+void MEDCouplingUMesh::convertNodalConnectivityToDynamicGeoTypeMesh(DataArrayIdType *&nodalConn, DataArrayIdType *&nodalConnIndex) const
 {
   static const char msg0[]="MEDCouplingUMesh::convertNodalConnectivityToDynamicGeoTypeMesh : nodal connectivity in this are invalid ! Call checkConsistency !";
   checkConnectivityFullyDefined();
   if(_types.size()!=1)
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::convertNodalConnectivityToDynamicGeoTypeMesh : current mesh does not contain exactly one geometric type !");
-  int nbCells=getNumberOfCells(),lgth=_nodal_connec->getNumberOfTuples();
+  mcIdType nbCells=getNumberOfCells(),
+           lgth=_nodal_connec->getNumberOfTuples();
   if(lgth<nbCells)
     throw INTERP_KERNEL::Exception(msg0);
-  MCAuto<DataArrayInt> c(DataArrayInt::New()),ci(DataArrayInt::New());
+  MCAuto<DataArrayIdType> c(DataArrayIdType::New()),ci(DataArrayIdType::New());
   c->alloc(lgth-nbCells,1); ci->alloc(nbCells+1,1);
-  int *cp(c->getPointer()),*cip(ci->getPointer());
-  const int *incp(_nodal_connec->begin()),*incip(_nodal_connec_index->begin());
+  mcIdType *cp(c->getPointer()),*cip(ci->getPointer());
+  const mcIdType *incp(_nodal_connec->begin()),*incip(_nodal_connec_index->begin());
   cip[0]=0;
-  for(int i=0;i<nbCells;i++,cip++,incip++)
+  for(mcIdType i=0;i<nbCells;i++,cip++,incip++)
     {
-      int strt(incip[0]+1),stop(incip[1]);//+1 to skip geo type
-      int delta(stop-strt);
+      mcIdType strt(incip[0]+1),stop(incip[1]);//+1 to skip geo type
+      mcIdType delta(stop-strt);
       if(delta>=1)
         {
           if((strt>=0 && strt<lgth) && (stop>=0 && stop<=lgth))
@@ -7625,22 +6539,22 @@ void MEDCouplingUMesh::convertNodalConnectivityToDynamicGeoTypeMesh(DataArrayInt
 /*!
  * This method takes in input a vector of MEDCouplingUMesh instances lying on the same coordinates with same mesh dimensions.
  * Each mesh in \b ms must be sorted by type with the same order (typically using MEDCouplingUMesh::sortCellsInMEDFileFrmt).
- * This method is particulary useful for MED file interaction. It allows to aggregate several meshes and keeping the type sorting
+ * This method is particularly useful for MED file interaction. It allows to aggregate several meshes and keeping the type sorting
  * and the track of the permutation by chunk of same geotype cells to retrieve it. The traditional formats old2new and new2old
  * are not used here to avoid the build of big permutation array.
  *
  * \param [in] ms meshes with same mesh dimension lying on the same coords and sorted by type following de the same geometric type order than
  *                those specified in MEDCouplingUMesh::sortCellsInMEDFileFrmt method.
- * \param [out] szOfCellGrpOfSameType is a newly allocated DataArrayInt instance whose number of tuples is equal to the number of chunks of same geotype
+ * \param [out] szOfCellGrpOfSameType is a newly allocated DataArrayIdType instance whose number of tuples is equal to the number of chunks of same geotype
  *              in all meshes in \b ms. The accumulation of all values of this array is equal to the number of cells of returned mesh.
- * \param [out] idInMsOfCellGrpOfSameType is a newly allocated DataArrayInt instance having the same size than \b szOfCellGrpOfSameType. This
+ * \param [out] idInMsOfCellGrpOfSameType is a newly allocated DataArrayIdType instance having the same size than \b szOfCellGrpOfSameType. This
  *              output array gives for each chunck of same type the corresponding mesh id in \b ms.
  * \return A newly allocated unstructured mesh that is the result of the aggregation on same coords of all meshes in \b ms. This returned mesh
  *         is sorted by type following the geo cell types order of MEDCouplingUMesh::sortCellsInMEDFileFrmt method.
  */
 MEDCouplingUMesh *MEDCouplingUMesh::AggregateSortedByTypeMeshesOnSameCoords(const std::vector<const MEDCouplingUMesh *>& ms,
-                                                                            DataArrayInt *&szOfCellGrpOfSameType,
-                                                                            DataArrayInt *&idInMsOfCellGrpOfSameType)
+                                                                            DataArrayIdType *&szOfCellGrpOfSameType,
+                                                                            DataArrayIdType *&idInMsOfCellGrpOfSameType)
 {
   std::vector<const MEDCouplingUMesh *> ms2;
   for(std::vector<const MEDCouplingUMesh *>::const_iterator it=ms.begin();it!=ms.end();it++)
@@ -7658,8 +6572,8 @@ MEDCouplingUMesh *MEDCouplingUMesh::AggregateSortedByTypeMeshesOnSameCoords(cons
   //
   std::vector<const MEDCouplingUMesh *> m1ssmSingle;
   std::vector< MCAuto<MEDCouplingUMesh> > m1ssmSingleAuto;
-  int fake=0,rk=0;
-  MCAuto<DataArrayInt> ret1(DataArrayInt::New()),ret2(DataArrayInt::New());
+  mcIdType fake=0,rk=0;
+  MCAuto<DataArrayIdType> ret1(DataArrayIdType::New()),ret2(DataArrayIdType::New());
   ret1->alloc(0,1); ret2->alloc(0,1);
   for(std::vector<const MEDCouplingUMesh *>::const_iterator it=ms2.begin();it!=ms2.end();it++,rk++)
     {
@@ -7679,9 +6593,9 @@ MEDCouplingUMesh *MEDCouplingUMesh::AggregateSortedByTypeMeshesOnSameCoords(cons
         }
     }
   MCAuto<MEDCouplingUMesh> m1ssmSingle2=MEDCouplingUMesh::MergeUMeshesOnSameCoords(m1ssmSingle);
-  MCAuto<DataArrayInt> renum=m1ssmSingle2->sortCellsInMEDFileFrmt();
+  MCAuto<DataArrayIdType> renum=m1ssmSingle2->sortCellsInMEDFileFrmt();
   std::vector<const MEDCouplingUMesh *> m1ssmfinal(m1ssm.size());
-  for(std::size_t i=0;i<m1ssm.size();i++)
+  for(mcIdType i=0;i<ToIdType(m1ssm.size());i++)
     m1ssmfinal[renum->getIJ(i,0)]=m1ssm[i];
   MCAuto<MEDCouplingUMesh> ret0=MEDCouplingUMesh::MergeUMeshesOnSameCoords(m1ssmfinal);
   szOfCellGrpOfSameType=ret1->renumber(renum->begin());
@@ -7690,16 +6604,16 @@ MEDCouplingUMesh *MEDCouplingUMesh::AggregateSortedByTypeMeshesOnSameCoords(cons
 }
 
 /*!
- * This method returns a newly created DataArrayInt instance.
+ * This method returns a newly created DataArrayIdType instance.
  * This method retrieves cell ids in [ \a begin, \a end ) that have the type \a type.
  */
-DataArrayInt *MEDCouplingUMesh::keepCellIdsByType(INTERP_KERNEL::NormalizedCellType type, const int *begin, const int *end) const
+DataArrayIdType *MEDCouplingUMesh::keepCellIdsByType(INTERP_KERNEL::NormalizedCellType type, const mcIdType *begin, const mcIdType *end) const
 {
   checkFullyDefined();
-  const int *conn=_nodal_connec->begin();
-  const int *connIndex=_nodal_connec_index->begin();
-  MCAuto<DataArrayInt> ret(DataArrayInt::New()); ret->alloc(0,1);
-  for(const int *w=begin;w!=end;w++)
+  const mcIdType *conn=_nodal_connec->begin();
+  const mcIdType *connIndex=_nodal_connec_index->begin();
+  MCAuto<DataArrayIdType> ret(DataArrayIdType::New()); ret->alloc(0,1);
+  for(const mcIdType *w=begin;w!=end;w++)
     if((INTERP_KERNEL::NormalizedCellType)conn[connIndex[*w]]==type)
       ret->pushBackSilent(*w);
   return ret.retn();
@@ -7709,28 +6623,28 @@ DataArrayInt *MEDCouplingUMesh::keepCellIdsByType(INTERP_KERNEL::NormalizedCellT
  * This method makes the assumption that da->getNumberOfTuples()<this->getNumberOfCells(). This method makes the assumption that ids contained in 'da'
  * are in [0:getNumberOfCells())
  */
-DataArrayInt *MEDCouplingUMesh::convertCellArrayPerGeoType(const DataArrayInt *da) const
+DataArrayIdType *MEDCouplingUMesh::convertCellArrayPerGeoType(const DataArrayIdType *da) const
 {
   checkFullyDefined();
-  const int *conn=_nodal_connec->begin();
-  const int *connI=_nodal_connec_index->begin();
-  int nbOfCells=getNumberOfCells();
+  const mcIdType *conn=_nodal_connec->begin();
+  const mcIdType *connI=_nodal_connec_index->begin();
+  mcIdType nbOfCells=getNumberOfCells();
   std::set<INTERP_KERNEL::NormalizedCellType> types(getAllGeoTypes());
-  int *tmp=new int[nbOfCells];
+  mcIdType *tmp=new mcIdType[nbOfCells];
   for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator iter=types.begin();iter!=types.end();iter++)
     {
-      int j=0;
-      for(const int *i=connI;i!=connI+nbOfCells;i++)
+      mcIdType j=0;
+      for(const mcIdType *i=connI;i!=connI+nbOfCells;i++)
         if((INTERP_KERNEL::NormalizedCellType)conn[*i]==(*iter))
           tmp[std::distance(connI,i)]=j++;
     }
-  DataArrayInt *ret=DataArrayInt::New();
+  DataArrayIdType *ret=DataArrayIdType::New();
   ret->alloc(da->getNumberOfTuples(),da->getNumberOfComponents());
   ret->copyStringInfoFrom(*da);
-  int *retPtr=ret->getPointer();
-  const int *daPtr=da->begin();
-  int nbOfElems=da->getNbOfElems();
-  for(int k=0;k<nbOfElems;k++)
+  mcIdType *retPtr=ret->getPointer();
+  const mcIdType *daPtr=da->begin();
+  mcIdType nbOfElems=da->getNbOfElems();
+  for(mcIdType k=0;k<nbOfElems;k++)
     retPtr[k]=tmp[daPtr[k]];
   delete [] tmp;
   return ret;
@@ -7742,11 +6656,11 @@ DataArrayInt *MEDCouplingUMesh::convertCellArrayPerGeoType(const DataArrayInt *d
  * cells whose ids is in 'idsPerGeoType' array.
  * This method conserves coords and name of mesh.
  */
-MEDCouplingUMesh *MEDCouplingUMesh::keepSpecifiedCells(INTERP_KERNEL::NormalizedCellType type, const int *idsPerGeoTypeBg, const int *idsPerGeoTypeEnd) const
+MEDCouplingUMesh *MEDCouplingUMesh::keepSpecifiedCells(INTERP_KERNEL::NormalizedCellType type, const mcIdType *idsPerGeoTypeBg, const mcIdType *idsPerGeoTypeEnd) const
 {
-  std::vector<int> code=getDistributionOfTypes();
+  std::vector<mcIdType> code=getDistributionOfTypes();
   std::size_t nOfTypesInThis=code.size()/3;
-  int sz=0,szOfType=0;
+  mcIdType sz=0,szOfType=0;
   for(std::size_t i=0;i<nOfTypesInThis;i++)
     {
       if(code[3*i]!=type)
@@ -7754,23 +6668,23 @@ MEDCouplingUMesh *MEDCouplingUMesh::keepSpecifiedCells(INTERP_KERNEL::Normalized
       else
         szOfType=code[3*i+1];
     }
-  for(const int *work=idsPerGeoTypeBg;work!=idsPerGeoTypeEnd;work++)
+  for(const mcIdType *work=idsPerGeoTypeBg;work!=idsPerGeoTypeEnd;work++)
     if(*work<0 || *work>=szOfType)
       {
         std::ostringstream oss; oss << "MEDCouplingUMesh::keepSpecifiedCells : Request on type " << type << " at place #" << std::distance(idsPerGeoTypeBg,work) << " value " << *work;
         oss << ". It should be in [0," << szOfType << ") !";
         throw INTERP_KERNEL::Exception(oss.str());
       }
-  MCAuto<DataArrayInt> idsTokeep=DataArrayInt::New(); idsTokeep->alloc(sz+(int)std::distance(idsPerGeoTypeBg,idsPerGeoTypeEnd),1);
-  int *idsPtr=idsTokeep->getPointer();
-  int offset=0;
+  MCAuto<DataArrayIdType> idsTokeep=DataArrayIdType::New(); idsTokeep->alloc(sz+std::distance(idsPerGeoTypeBg,idsPerGeoTypeEnd),1);
+  mcIdType *idsPtr=idsTokeep->getPointer();
+  mcIdType offset=0;
   for(std::size_t i=0;i<nOfTypesInThis;i++)
     {
       if(code[3*i]!=type)
-        for(int j=0;j<code[3*i+1];j++)
+        for(mcIdType j=0;j<code[3*i+1];j++)
           *idsPtr++=offset+j;
       else
-        idsPtr=std::transform(idsPerGeoTypeBg,idsPerGeoTypeEnd,idsPtr,std::bind2nd(std::plus<int>(),offset));
+        idsPtr=std::transform(idsPerGeoTypeBg,idsPerGeoTypeEnd,idsPtr,std::bind(std::plus<mcIdType>(),std::placeholders::_1,offset));
       offset+=code[3*i+1];
     }
   MCAuto<MEDCouplingUMesh> ret=static_cast<MEDCouplingUMesh *>(buildPartOfMySelf(idsTokeep->begin(),idsTokeep->end(),true));
@@ -7784,11 +6698,11 @@ MEDCouplingUMesh *MEDCouplingUMesh::keepSpecifiedCells(INTERP_KERNEL::Normalized
  */
 std::vector<bool> MEDCouplingUMesh::getQuadraticStatus() const
 {
-  int ncell=getNumberOfCells();
+  mcIdType ncell=getNumberOfCells();
   std::vector<bool> ret(ncell);
-  const int *cI=getNodalConnectivityIndex()->begin();
-  const int *c=getNodalConnectivity()->begin();
-  for(int i=0;i<ncell;i++)
+  const mcIdType *cI=getNodalConnectivityIndex()->begin();
+  const mcIdType *c=getNodalConnectivity()->begin();
+  for(mcIdType i=0;i<ncell;i++)
     {
       INTERP_KERNEL::NormalizedCellType typ=(INTERP_KERNEL::NormalizedCellType)c[cI[i]];
       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
@@ -7811,7 +6725,9 @@ MEDCouplingMesh *MEDCouplingUMesh::mergeMyselfWith(const MEDCouplingMesh *other)
 /*!
  * Returns a new DataArrayDouble holding barycenters of all cells. The barycenter is
  * computed by averaging coordinates of cell nodes, so this method is not a right
- * choice for degnerated meshes (not well oriented, cells with measure close to zero).
+ * choice for degenerated meshes (not well oriented, cells with measure close to zero).
+ * Beware also that for quadratic meshes, degenerated arc of circles are turned into linear edges for the computation.
+ * This happens with a default detection precision of eps=1.0e-14. If you need control over this use computeCellCenterOfMassWithPrecision().
  *  \return DataArrayDouble * - a new instance of DataArrayDouble, of size \a
  *          this->getNumberOfCells() tuples per \a this->getSpaceDimension()
  *          components. The caller is to delete this array using decrRef() as it is
@@ -7819,34 +6735,56 @@ MEDCouplingMesh *MEDCouplingUMesh::mergeMyselfWith(const MEDCouplingMesh *other)
  *  \throw If the coordinates array is not set.
  *  \throw If the nodal connectivity of cells is not defined.
  *  \sa MEDCouplingUMesh::computeIsoBarycenterOfNodesPerCell
+ *  \sa MEDCouplingUMesh::computeCellCenterOfMassWithPrecision
  */
 DataArrayDouble *MEDCouplingUMesh::computeCellCenterOfMass() const
 {
   MCAuto<DataArrayDouble> ret=DataArrayDouble::New();
   int spaceDim=getSpaceDimension();
-  int nbOfCells=getNumberOfCells();
+  mcIdType nbOfCells=getNumberOfCells();
   ret->alloc(nbOfCells,spaceDim);
   ret->copyStringInfoFrom(*getCoords());
   double *ptToFill=ret->getPointer();
-  const int *nodal=_nodal_connec->begin();
-  const int *nodalI=_nodal_connec_index->begin();
+  const mcIdType *nodal=_nodal_connec->begin();
+  const mcIdType *nodalI=_nodal_connec_index->begin();
   const double *coor=_coords->begin();
-  for(int i=0;i<nbOfCells;i++)
+  for(mcIdType i=0;i<nbOfCells;i++)
     {
       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)nodal[nodalI[i]];
-      INTERP_KERNEL::computeBarycenter2<int,INTERP_KERNEL::ALL_C_MODE>(type,nodal+nodalI[i]+1,nodalI[i+1]-nodalI[i]-1,coor,spaceDim,ptToFill);
+      INTERP_KERNEL::computeBarycenter2<mcIdType,INTERP_KERNEL::ALL_C_MODE>(type,nodal+nodalI[i]+1,nodalI[i+1]-nodalI[i]-1,coor,spaceDim,ptToFill);
       ptToFill+=spaceDim;
     }
   return ret.retn();
 }
 
+
+/*!
+ * See computeCellCenterOfMass().
+ *  \param eps a precision for the detection of degenerated arc of circles.
+ *  \return DataArrayDouble * - a new instance of DataArrayDouble, of size \a
+ *          this->getNumberOfCells() tuples per \a this->getSpaceDimension()
+ *          components. 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.
+ *  \sa MEDCouplingUMesh::computeIsoBarycenterOfNodesPerCell
+ *  \sa MEDCouplingUMesh::computeCellCenterOfMassWithPrecision
+ */
+DataArrayDouble *MEDCouplingUMesh::computeCellCenterOfMassWithPrecision(double eps) const
+{
+  INTERP_KERNEL::QuadraticPlanarPrecision prec(eps);
+  MCAuto<DataArrayDouble> ret = computeCellCenterOfMass();
+  return ret.retn();
+}
+
+
 /*!
  * This method computes for each cell in \a this, the location of the iso barycenter of nodes constituting
- * the cell. Contrary to badly named MEDCouplingUMesh::computeCellCenterOfMass method that returns the center of inertia of the 
- * 
- * \return a newly allocated DataArrayDouble instance that the caller has to deal with. The returned 
+ * the cell. Contrary to badly named MEDCouplingUMesh::computeCellCenterOfMass method that returns the center of inertia of the
+ *
+ * \return a newly allocated DataArrayDouble instance that the caller has to deal with. The returned
  *          DataArrayDouble instance will have \c this->getNumberOfCells() tuples and \c this->getSpaceDimension() components.
- * 
+ *
  * \sa MEDCouplingUMesh::computeCellCenterOfMass
  * \throw If \a this is not fully defined (coordinates and connectivity)
  * \throw If there is presence in nodal connectivity in \a this of node ids not in [0, \c this->getNumberOfNodes() )
@@ -7856,20 +6794,20 @@ DataArrayDouble *MEDCouplingUMesh::computeIsoBarycenterOfNodesPerCell() const
   checkFullyDefined();
   MCAuto<DataArrayDouble> ret=DataArrayDouble::New();
   int spaceDim=getSpaceDimension();
-  int nbOfCells=getNumberOfCells();
-  int nbOfNodes=getNumberOfNodes();
+  mcIdType nbOfCells=getNumberOfCells();
+  mcIdType nbOfNodes=getNumberOfNodes();
   ret->alloc(nbOfCells,spaceDim);
   double *ptToFill=ret->getPointer();
-  const int *nodal=_nodal_connec->begin();
-  const int *nodalI=_nodal_connec_index->begin();
+  const mcIdType *nodal=_nodal_connec->begin();
+  const mcIdType *nodalI=_nodal_connec_index->begin();
   const double *coor=_coords->begin();
-  for(int i=0;i<nbOfCells;i++,ptToFill+=spaceDim)
+  for(mcIdType i=0;i<nbOfCells;i++,ptToFill+=spaceDim)
     {
       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)nodal[nodalI[i]];
       std::fill(ptToFill,ptToFill+spaceDim,0.);
       if(type!=INTERP_KERNEL::NORM_POLYHED)
         {
-          for(const int *conn=nodal+nodalI[i]+1;conn!=nodal+nodalI[i+1];conn++)
+          for(const mcIdType *conn=nodal+nodalI[i]+1;conn!=nodal+nodalI[i+1];conn++)
             {
               if(*conn>=0 && *conn<nbOfNodes)
                 std::transform(coor+spaceDim*conn[0],coor+spaceDim*(conn[0]+1),ptToFill,ptToFill,std::plus<double>());
@@ -7879,9 +6817,9 @@ DataArrayDouble *MEDCouplingUMesh::computeIsoBarycenterOfNodesPerCell() const
                   throw INTERP_KERNEL::Exception(oss.str());
                 }
             }
-          int nbOfNodesInCell=nodalI[i+1]-nodalI[i]-1;
+          mcIdType nbOfNodesInCell=nodalI[i+1]-nodalI[i]-1;
           if(nbOfNodesInCell>0)
-            std::transform(ptToFill,ptToFill+spaceDim,ptToFill,std::bind2nd(std::multiplies<double>(),1./(double)nbOfNodesInCell));
+            std::transform(ptToFill,ptToFill+spaceDim,ptToFill,std::bind(std::multiplies<double>(),std::placeholders::_1,1./(double)nbOfNodesInCell));
           else
             {
               std::ostringstream oss; oss << "MEDCouplingUMesh::computeIsoBarycenterOfNodesPerCell : on cell #" << i << " presence of cell with no nodes !";
@@ -7890,9 +6828,9 @@ DataArrayDouble *MEDCouplingUMesh::computeIsoBarycenterOfNodesPerCell() const
         }
       else
         {
-          std::set<int> s(nodal+nodalI[i]+1,nodal+nodalI[i+1]);
+          std::set<mcIdType> s(nodal+nodalI[i]+1,nodal+nodalI[i+1]);
           s.erase(-1);
-          for(std::set<int>::const_iterator it=s.begin();it!=s.end();it++)
+          for(std::set<mcIdType>::const_iterator it=s.begin();it!=s.end();it++)
             {
               if(*it>=0 && *it<nbOfNodes)
                 std::transform(coor+spaceDim*(*it),coor+spaceDim*((*it)+1),ptToFill,ptToFill,std::plus<double>());
@@ -7903,7 +6841,7 @@ DataArrayDouble *MEDCouplingUMesh::computeIsoBarycenterOfNodesPerCell() const
                 }
             }
           if(!s.empty())
-            std::transform(ptToFill,ptToFill+spaceDim,ptToFill,std::bind2nd(std::multiplies<double>(),1./(double)s.size()));
+            std::transform(ptToFill,ptToFill+spaceDim,ptToFill,std::bind(std::multiplies<double>(),std::placeholders::_1,1./(double)s.size()));
           else
             {
               std::ostringstream oss; oss << "MEDCouplingUMesh::computeIsoBarycenterOfNodesPerCell : on polyhedron cell #" << i << " there are no nodes !";
@@ -7917,14 +6855,14 @@ DataArrayDouble *MEDCouplingUMesh::computeIsoBarycenterOfNodesPerCell() const
 /*!
  * Returns a new DataArrayDouble holding barycenters of specified cells. The
  * barycenter is computed by averaging coordinates of cell nodes. The cells to treat
- * are specified via an array of cell ids. 
- *  \warning Validity of the specified cell ids is not checked! 
+ * are specified via an array of cell ids.
+ *  \warning Validity of the specified cell ids is not checked!
  *           Valid range is [ 0, \a this->getNumberOfCells() ).
  *  \param [in] begin - an array of cell ids of interest.
  *  \param [in] end - the end of \a begin, i.e. a pointer to its (last+1)-th element.
  *  \return DataArrayDouble * - a new instance of DataArrayDouble, of size ( \a
  *          end - \a begin ) tuples per \a this->getSpaceDimension() components. The
- *          caller is to delete this array using decrRef() as it is no more needed. 
+ *          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.
  *
@@ -7933,21 +6871,21 @@ DataArrayDouble *MEDCouplingUMesh::computeIsoBarycenterOfNodesPerCell() const
  *  \ref  py_mcumesh_getPartBarycenterAndOwner "Here is a Python example".
  *  \endif
  */
-DataArrayDouble *MEDCouplingUMesh::getPartBarycenterAndOwner(const int *begin, const int *end) const
+DataArrayDouble *MEDCouplingUMesh::getPartBarycenterAndOwner(const mcIdType *begin, const mcIdType *end) const
 {
   DataArrayDouble *ret=DataArrayDouble::New();
   int spaceDim=getSpaceDimension();
-  int nbOfTuple=(int)std::distance(begin,end);
+  std::size_t nbOfTuple=std::distance(begin,end);
   ret->alloc(nbOfTuple,spaceDim);
   double *ptToFill=ret->getPointer();
   double *tmp=new double[spaceDim];
-  const int *nodal=_nodal_connec->begin();
-  const int *nodalI=_nodal_connec_index->begin();
+  const mcIdType *nodal=_nodal_connec->begin();
+  const mcIdType *nodalI=_nodal_connec_index->begin();
   const double *coor=_coords->begin();
-  for(const int *w=begin;w!=end;w++)
+  for(const mcIdType *w=begin;w!=end;w++)
     {
       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)nodal[nodalI[*w]];
-      INTERP_KERNEL::computeBarycenter2<int,INTERP_KERNEL::ALL_C_MODE>(type,nodal+nodalI[*w]+1,nodalI[*w+1]-nodalI[*w]-1,coor,spaceDim,ptToFill);
+      INTERP_KERNEL::computeBarycenter2<mcIdType,INTERP_KERNEL::ALL_C_MODE>(type,nodal+nodalI[*w]+1,nodalI[*w+1]-nodalI[*w]-1,coor,spaceDim,ptToFill);
       ptToFill+=spaceDim;
     }
   delete [] tmp;
@@ -7960,7 +6898,7 @@ DataArrayDouble *MEDCouplingUMesh::getPartBarycenterAndOwner(const int *begin, c
  * So this method expects that \a this has a spaceDimension equal to 3 and meshDimension equal to 2.
  * The computation of the plane equation is done using each time the 3 first nodes of 2D cells.
  * This method is useful to detect 2D cells in 3D space that are not coplanar.
- * 
+ *
  * \return DataArrayDouble * - a new instance of DataArrayDouble having 4 components and a number of tuples equal to number of cells in \a this.
  * \throw If spaceDim!=3 or meshDim!=2.
  * \throw If connectivity of \a this is invalid.
@@ -7969,21 +6907,30 @@ DataArrayDouble *MEDCouplingUMesh::getPartBarycenterAndOwner(const int *begin, c
 DataArrayDouble *MEDCouplingUMesh::computePlaneEquationOf3DFaces() const
 {
   MCAuto<DataArrayDouble> ret(DataArrayDouble::New());
-  int nbOfCells(getNumberOfCells()),nbOfNodes(getNumberOfNodes());
+  mcIdType nbOfCells=getNumberOfCells();
+  mcIdType nbOfNodes(getNumberOfNodes());
   if(getSpaceDimension()!=3 || getMeshDimension()!=2)
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::computePlaneEquationOf3DFaces : This method must be applied on a mesh having meshDimension equal 2 and a spaceDimension equal to 3 !");
   ret->alloc(nbOfCells,4);
   double *retPtr(ret->getPointer());
-  const int *nodal(_nodal_connec->begin()),*nodalI(_nodal_connec_index->begin());
+  const mcIdType *nodal(_nodal_connec->begin()),*nodalI(_nodal_connec_index->begin());
   const double *coor(_coords->begin());
-  for(int i=0;i<nbOfCells;i++,nodalI++,retPtr+=4)
+  for(mcIdType i=0;i<nbOfCells;i++,nodalI++,retPtr+=4)
     {
       double matrix[16]={0,0,0,1,0,0,0,1,0,0,0,1,1,1,1,0},matrix2[16];
-      if(nodalI[1]-nodalI[0]>=3)
-        {
+      if(nodalI[1]-nodalI[0]>=4)
+        {
+          double aa[3]={coor[nodal[nodalI[0]+1+1]*3+0]-coor[nodal[nodalI[0]+1+0]*3+0],
+                        coor[nodal[nodalI[0]+1+1]*3+1]-coor[nodal[nodalI[0]+1+0]*3+1],
+                        coor[nodal[nodalI[0]+1+1]*3+2]-coor[nodal[nodalI[0]+1+0]*3+2]}
+          ,bb[3]={coor[nodal[nodalI[0]+1+2]*3+0]-coor[nodal[nodalI[0]+1+0]*3+0],
+                        coor[nodal[nodalI[0]+1+2]*3+1]-coor[nodal[nodalI[0]+1+0]*3+1],
+                        coor[nodal[nodalI[0]+1+2]*3+2]-coor[nodal[nodalI[0]+1+0]*3+2]};
+          double cc[3]={aa[1]*bb[2]-aa[2]*bb[1],aa[2]*bb[0]-aa[0]*bb[2],aa[0]*bb[1]-aa[1]*bb[0]};
+          double aa_norm(sqrt(aa[0]*aa[0]+aa[1]*aa[1]+aa[2]*aa[2])),bb_norm(sqrt(bb[0]*bb[0]+bb[1]*bb[1]+bb[2]*bb[2]));
           for(int j=0;j<3;j++)
             {
-              int nodeId(nodal[nodalI[0]+1+j]);
+              mcIdType nodeId(nodal[nodalI[0]+1+j]);
               if(nodeId>=0 && nodeId<nbOfNodes)
                 std::copy(coor+nodeId*3,coor+(nodeId+1)*3,matrix+4*j);
               else
@@ -7992,38 +6939,59 @@ DataArrayDouble *MEDCouplingUMesh::computePlaneEquationOf3DFaces() const
                   throw INTERP_KERNEL::Exception(oss.str());
                 }
             }
+          if(sqrt(cc[0]*cc[0]+cc[1]*cc[1]+cc[2]*cc[2])>(1e-3*aa_norm*bb_norm))
+            {
+              INTERP_KERNEL::inverseMatrix(matrix,4,matrix2);
+              retPtr[0]=matrix2[3]; retPtr[1]=matrix2[7]; retPtr[2]=matrix2[11]; retPtr[3]=matrix2[15];
+            }
+          else
+            {
+              if(nodalI[1]-nodalI[0]==4)
+                {
+                  std::ostringstream oss; oss << "MEDCouplingUMesh::computePlaneEquationOf3DFaces : cell" << i << " : Presence of The 3 colinear points !";
+                  throw INTERP_KERNEL::Exception(oss.str());
+                }
+              //
+              double dd[3]={0.,0.,0.};
+              for(mcIdType offset=nodalI[0]+1;offset<nodalI[1];offset++)
+                std::transform(coor+3*nodal[offset],coor+3*(nodal[offset]+1),dd,dd,std::plus<double>());
+              mcIdType nbOfNodesInCell(nodalI[1]-nodalI[0]-1);
+              std::transform(dd,dd+3,dd,std::bind(std::multiplies<double>(),std::placeholders::_1,1./(double)nbOfNodesInCell));
+              std::copy(dd,dd+3,matrix+4*2);
+              INTERP_KERNEL::inverseMatrix(matrix,4,matrix2);
+              retPtr[0]=matrix2[3]; retPtr[1]=matrix2[7]; retPtr[2]=matrix2[11]; retPtr[3]=matrix2[15];
+            }
         }
       else
         {
           std::ostringstream oss; oss << "MEDCouplingUMesh::computePlaneEquationOf3DFaces : invalid 2D cell #" << i << " ! Must be constitued by more than 3 nodes !";
           throw INTERP_KERNEL::Exception(oss.str());
         }
-      INTERP_KERNEL::inverseMatrix(matrix,4,matrix2);
-      retPtr[0]=matrix2[3]; retPtr[1]=matrix2[7]; retPtr[2]=matrix2[11]; retPtr[3]=matrix2[15];
     }
   return ret.retn();
 }
 
 /*!
  * This method expects as input a DataArrayDouble non nul instance 'da' that should be allocated. If not an exception is thrown.
- * 
+ *
  */
 MEDCouplingUMesh *MEDCouplingUMesh::Build0DMeshFromCoords(DataArrayDouble *da)
 {
   if(!da)
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::Build0DMeshFromCoords : instance of DataArrayDouble must be not null !");
   da->checkAllocated();
-  MCAuto<MEDCouplingUMesh> ret=MEDCouplingUMesh::New(da->getName(),0);
+  std::string name(da->getName());
+  MCAuto<MEDCouplingUMesh> ret(MEDCouplingUMesh::New(name,0));
+  if(name.empty())
+    ret->setName("Mesh");
   ret->setCoords(da);
-  int nbOfTuples=da->getNumberOfTuples();
-  MCAuto<DataArrayInt> c=DataArrayInt::New();
-  MCAuto<DataArrayInt> cI=DataArrayInt::New();
+  mcIdType nbOfTuples(da->getNumberOfTuples());
+  MCAuto<DataArrayIdType> c(DataArrayIdType::New()),cI(DataArrayIdType::New());
   c->alloc(2*nbOfTuples,1);
   cI->alloc(nbOfTuples+1,1);
-  int *cp=c->getPointer();
-  int *cip=cI->getPointer();
+  mcIdType *cp(c->getPointer()),*cip(cI->getPointer());
   *cip++=0;
-  for(int i=0;i<nbOfTuples;i++)
+  for(mcIdType i=0;i<nbOfTuples;i++)
     {
       *cp++=INTERP_KERNEL::NORM_POINT1;
       *cp++=i;
@@ -8032,6 +7000,29 @@ MEDCouplingUMesh *MEDCouplingUMesh::Build0DMeshFromCoords(DataArrayDouble *da)
   ret->setConnectivity(c,cI,true);
   return ret.retn();
 }
+
+MCAuto<MEDCouplingUMesh> MEDCouplingUMesh::Build1DMeshFromCoords(DataArrayDouble *da)
+{
+  if(!da)
+    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::Build01MeshFromCoords : instance of DataArrayDouble must be not null !");
+  da->checkAllocated();
+  std::string name(da->getName());
+  MCAuto<MEDCouplingUMesh> ret;
+  {
+    MCAuto<MEDCouplingCMesh> tmp(MEDCouplingCMesh::New());
+    MCAuto<DataArrayDouble> arr(DataArrayDouble::New());
+    arr->alloc(da->getNumberOfTuples());
+    tmp->setCoordsAt(0,arr);
+    ret=tmp->buildUnstructured();
+  }
+  ret->setCoords(da);
+  if(name.empty())
+    ret->setName("Mesh");
+  else
+    ret->setName(name);
+  return ret;
+}
+
 /*!
  * Creates a new MEDCouplingUMesh by concatenating two given meshes of the same dimension.
  * Cells and nodes of
@@ -8086,7 +7077,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshes(const std::vector<const MEDCoup
       const MEDCouplingUMesh *cur=a[i];
       const DataArrayDouble *coo=cur->getCoords();
       if(coo)
-        spaceDim=coo->getNumberOfComponents();
+        spaceDim=int(coo->getNumberOfComponents());
     }
   if(spaceDim==-3)
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::MergeUMeshes : no spaceDim specified ! unable to perform merge !");
@@ -8098,70 +7089,11 @@ MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshes(const std::vector<const MEDCoup
   return MergeUMeshesLL(aa);
 }
 
-/// @cond INTERNAL
-
-MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshesLL(const std::vector<const MEDCouplingUMesh *>& a)
-{
-  if(a.empty())
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::MergeUMeshes : input array must be NON EMPTY !");
-  std::vector<const MEDCouplingUMesh *>::const_iterator it=a.begin();
-  int meshDim=(*it)->getMeshDimension();
-  int nbOfCells=(*it)->getNumberOfCells();
-  int meshLgth=(*it++)->getNodalConnectivityArrayLen();
-  for(;it!=a.end();it++)
-    {
-      if(meshDim!=(*it)->getMeshDimension())
-        throw INTERP_KERNEL::Exception("Mesh dimensions mismatches, MergeUMeshes impossible !");
-      nbOfCells+=(*it)->getNumberOfCells();
-      meshLgth+=(*it)->getNodalConnectivityArrayLen();
-    }
-  std::vector<const MEDCouplingPointSet *> aps(a.size());
-  std::copy(a.begin(),a.end(),aps.begin());
-  MCAuto<DataArrayDouble> pts=MergeNodesArray(aps);
-  MCAuto<MEDCouplingUMesh> ret=MEDCouplingUMesh::New("merge",meshDim);
-  ret->setCoords(pts);
-  MCAuto<DataArrayInt> c=DataArrayInt::New();
-  c->alloc(meshLgth,1);
-  int *cPtr=c->getPointer();
-  MCAuto<DataArrayInt> cI=DataArrayInt::New();
-  cI->alloc(nbOfCells+1,1);
-  int *cIPtr=cI->getPointer();
-  *cIPtr++=0;
-  int offset=0;
-  int offset2=0;
-  for(it=a.begin();it!=a.end();it++)
-    {
-      int curNbOfCell=(*it)->getNumberOfCells();
-      const int *curCI=(*it)->_nodal_connec_index->begin();
-      const int *curC=(*it)->_nodal_connec->begin();
-      cIPtr=std::transform(curCI+1,curCI+curNbOfCell+1,cIPtr,std::bind2nd(std::plus<int>(),offset));
-      for(int j=0;j<curNbOfCell;j++)
-        {
-          const int *src=curC+curCI[j];
-          *cPtr++=*src++;
-          for(;src!=curC+curCI[j+1];src++,cPtr++)
-            {
-              if(*src!=-1)
-                *cPtr=*src+offset2;
-              else
-                *cPtr=-1;
-            }
-        }
-      offset+=curCI[curNbOfCell];
-      offset2+=(*it)->getNumberOfNodes();
-    }
-  //
-  ret->setConnectivity(c,cI,true);
-  return ret.retn();
-}
-
-/// @endcond
-
 /*!
  * Creates a new MEDCouplingUMesh by concatenating cells of two given meshes of same
  * dimension and sharing the node coordinates array.
  * All cells of the first mesh precede all cells of the second mesh
- * within the result mesh. 
+ * within the result mesh.
  *  \param [in] mesh1 - the first mesh.
  *  \param [in] mesh2 - the second mesh.
  *  \return MEDCouplingUMesh * - the result mesh. It is a new instance of
@@ -8207,8 +7139,8 @@ MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshesOnSameCoords(const std::vector<c
   const DataArrayDouble *coords=meshes.front()->getCoords();
   int meshDim=meshes.front()->getMeshDimension();
   std::vector<const MEDCouplingUMesh *>::const_iterator iter=meshes.begin();
-  int meshLgth=0;
-  int meshIndexLgth=0;
+  mcIdType meshLgth=0;
+  mcIdType meshIndexLgth=0;
   for(;iter!=meshes.end();iter++)
     {
       if(coords!=(*iter)->getCoords())
@@ -8218,22 +7150,22 @@ MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshesOnSameCoords(const std::vector<c
       meshLgth+=(*iter)->getNodalConnectivityArrayLen();
       meshIndexLgth+=(*iter)->getNumberOfCells();
     }
-  MCAuto<DataArrayInt> nodal=DataArrayInt::New();
+  MCAuto<DataArrayIdType> nodal=DataArrayIdType::New();
   nodal->alloc(meshLgth,1);
-  int *nodalPtr=nodal->getPointer();
-  MCAuto<DataArrayInt> nodalIndex=DataArrayInt::New();
+  mcIdType *nodalPtr=nodal->getPointer();
+  MCAuto<DataArrayIdType> nodalIndex=DataArrayIdType::New();
   nodalIndex->alloc(meshIndexLgth+1,1);
-  int *nodalIndexPtr=nodalIndex->getPointer();
-  int offset=0;
+  mcIdType *nodalIndexPtr=nodalIndex->getPointer();
+  mcIdType offset=0;
   for(iter=meshes.begin();iter!=meshes.end();iter++)
     {
-      const int *nod=(*iter)->getNodalConnectivity()->begin();
-      const int *index=(*iter)->getNodalConnectivityIndex()->begin();
-      int nbOfCells=(*iter)->getNumberOfCells();
-      int meshLgth2=(*iter)->getNodalConnectivityArrayLen();
+      const mcIdType *nod=(*iter)->getNodalConnectivity()->begin();
+      const mcIdType *index=(*iter)->getNodalConnectivityIndex()->begin();
+      mcIdType nbOfCells=(*iter)->getNumberOfCells();
+      mcIdType meshLgth2=(*iter)->getNodalConnectivityArrayLen();
       nodalPtr=std::copy(nod,nod+meshLgth2,nodalPtr);
       if(iter!=meshes.begin())
-        nodalIndexPtr=std::transform(index+1,index+nbOfCells+1,nodalIndexPtr,std::bind2nd(std::plus<int>(),offset));
+        nodalIndexPtr=std::transform(index+1,index+nbOfCells+1,nodalIndexPtr,std::bind(std::plus<mcIdType>(),std::placeholders::_1,offset));
       else
         nodalIndexPtr=std::copy(index,index+nbOfCells+1,nodalIndexPtr);
       offset+=meshLgth2;
@@ -8255,7 +7187,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshesOnSameCoords(const std::vector<c
  *  \param [in] meshes - a vector of meshes (MEDCouplingUMesh) to concatenate.
  *  \param [in] compType - specifies a cell comparison technique. For meaning of its
  *          valid values [0,1,2], see zipConnectivityTraducer().
- *  \param [in,out] corr - an array of DataArrayInt, of the same size as \a
+ *  \param [in,out] corr - an array of DataArrayIdType, of the same size as \a
  *          meshes. The *i*-th array describes cell ids mapping for \a meshes[ *i* ]
  *          mesh. The caller is to delete each of the arrays using decrRef() as it is
  *          no more needed.
@@ -8270,19 +7202,19 @@ MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshesOnSameCoords(const std::vector<c
  *  \throw If the nodal connectivity of cells of any of \a meshes is not defined.
  *  \throw If the nodal connectivity any of \a meshes includes an invalid id.
  */
-MEDCouplingUMesh *MEDCouplingUMesh::FuseUMeshesOnSameCoords(const std::vector<const MEDCouplingUMesh *>& meshes, int compType, std::vector<DataArrayInt *>& corr)
+MEDCouplingUMesh *MEDCouplingUMesh::FuseUMeshesOnSameCoords(const std::vector<const MEDCouplingUMesh *>& meshes, int compType, std::vector<DataArrayIdType *>& corr)
 {
   //All checks are delegated to MergeUMeshesOnSameCoords
   MCAuto<MEDCouplingUMesh> ret=MergeUMeshesOnSameCoords(meshes);
-  MCAuto<DataArrayInt> o2n=ret->zipConnectivityTraducer(compType);
+  MCAuto<DataArrayIdType> o2n=ret->zipConnectivityTraducer(compType);
   corr.resize(meshes.size());
   std::size_t nbOfMeshes=meshes.size();
-  int offset=0;
-  const int *o2nPtr=o2n->begin();
+  mcIdType offset=0;
+  const mcIdType *o2nPtr=o2n->begin();
   for(std::size_t i=0;i<nbOfMeshes;i++)
     {
-      DataArrayInt *tmp=DataArrayInt::New();
-      int curNbOfCells=meshes[i]->getNumberOfCells();
+      DataArrayIdType *tmp=DataArrayIdType::New();
+      mcIdType curNbOfCells=meshes[i]->getNumberOfCells();
       tmp->alloc(curNbOfCells,1);
       std::copy(o2nPtr+offset,o2nPtr+offset+curNbOfCells,tmp->getPointer());
       offset+=curNbOfCells;
@@ -8296,7 +7228,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::FuseUMeshesOnSameCoords(const std::vector<co
  * Makes all given meshes share the nodal connectivity array. The common connectivity
  * array is created by concatenating the connectivity arrays of all given meshes. All
  * the given meshes must be of the same space dimension but dimension of cells **can
- * differ**. This method is particulary useful in MEDLoader context to build a \ref
+ * differ**. This method is particularly useful in MEDLoader context to build a \ref
  * MEDCoupling::MEDFileUMesh "MEDFileUMesh" instance that expects that underlying
  * MEDCouplingUMesh'es of different dimension share the same nodal connectivity array.
  *  \param [in,out] meshes - a vector of meshes to update.
@@ -8336,11 +7268,11 @@ void MEDCouplingUMesh::PutUMeshesOnSameAggregatedCoords(const std::vector<MEDCou
     }
   MCAuto<DataArrayDouble> res=DataArrayDouble::Aggregate(coords);
   std::vector<MEDCouplingUMesh *>::const_iterator it=meshes.begin();
-  int offset=(*it)->getNumberOfNodes();
+  mcIdType offset=(*it)->getNumberOfNodes();
   (*it++)->setCoords(res);
   for(;it!=meshes.end();it++)
     {
-      int oldNumberOfNodes=(*it)->getNumberOfNodes();
+      mcIdType oldNumberOfNodes=(*it)->getNumberOfNodes();
       (*it)->setCoords(res);
       (*it)->shiftNodeNumbersInConn(offset);
       offset+=oldNumberOfNodes;
@@ -8350,9 +7282,9 @@ void MEDCouplingUMesh::PutUMeshesOnSameAggregatedCoords(const std::vector<MEDCou
 /*!
  * Merges nodes coincident with a given precision within all given meshes that share
  * the nodal connectivity array. The given meshes **can be of different** mesh
- * dimension. This method is particulary useful in MEDLoader context to build a \ref
+ * dimension. This method is particularly useful in MEDLoader context to build a \ref
  * MEDCoupling::MEDFileUMesh "MEDFileUMesh" instance that expects that underlying
- * MEDCouplingUMesh'es of different dimension share the same nodal connectivity array. 
+ * MEDCouplingUMesh'es of different dimension share the same nodal connectivity array.
  *  \param [in,out] meshes - a vector of meshes to update.
  *  \param [in] eps - the precision used to detect coincident nodes (infinite norm).
  *  \throw If any of \a meshes is NULL.
@@ -8383,12 +7315,12 @@ void MEDCouplingUMesh::MergeNodesOnUMeshesSharingSameCoords(const std::vector<ME
   if(!coo)
     return;
   //
-  DataArrayInt *comm,*commI;
+  DataArrayIdType *comm,*commI;
   coo->findCommonTuples(eps,-1,comm,commI);
-  MCAuto<DataArrayInt> tmp1(comm),tmp2(commI);
-  int oldNbOfNodes=coo->getNumberOfTuples();
-  int newNbOfNodes;
-  MCAuto<DataArrayInt> o2n=DataArrayInt::ConvertIndexArrayToO2N(oldNbOfNodes,comm->begin(),commI->begin(),commI->end(),newNbOfNodes);
+  MCAuto<DataArrayIdType> tmp1(comm),tmp2(commI);
+  mcIdType oldNbOfNodes=coo->getNumberOfTuples();
+  mcIdType newNbOfNodes;
+  MCAuto<DataArrayIdType> o2n=DataArrayIdType::ConvertIndexArrayToO2N(oldNbOfNodes,comm->begin(),commI->begin(),commI->end(),newNbOfNodes);
   if(oldNbOfNodes==newNbOfNodes)
     return ;
   MCAuto<DataArrayDouble> newCoords=coo->renumberAndReduce(o2n->begin(),newNbOfNodes);
@@ -8396,183 +7328,101 @@ void MEDCouplingUMesh::MergeNodesOnUMeshesSharingSameCoords(const std::vector<ME
     {
       (*it)->renumberNodesInConn(o2n->begin());
       (*it)->setCoords(newCoords);
-    } 
+    }
 }
 
-/*!
- * This method takes in input a cell defined by its MEDcouplingUMesh connectivity [ \a connBg , \a connEnd ) and returns its extruded cell by inserting the result at the end of ret.
- * \param nbOfNodesPerLev in parameter that specifies the number of nodes of one slice of global dataset
- * \param isQuad specifies the policy of connectivity.
- * @ret in/out parameter in which the result will be append
- */
-void MEDCouplingUMesh::AppendExtrudedCell(const int *connBg, const int *connEnd, int nbOfNodesPerLev, bool isQuad, std::vector<int>& ret)
-{
-  INTERP_KERNEL::NormalizedCellType flatType=(INTERP_KERNEL::NormalizedCellType)connBg[0];
-  const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(flatType);
-  ret.push_back(cm.getExtrudedType());
-  int deltaz=isQuad?2*nbOfNodesPerLev:nbOfNodesPerLev;
-  switch(flatType)
-  {
-    case INTERP_KERNEL::NORM_POINT1:
-      {
-        ret.push_back(connBg[1]);
-        ret.push_back(connBg[1]+nbOfNodesPerLev);
-        break;
-      }
-    case INTERP_KERNEL::NORM_SEG2:
-      {
-        int conn[4]={connBg[1],connBg[2],connBg[2]+deltaz,connBg[1]+deltaz};
-        ret.insert(ret.end(),conn,conn+4);
-        break;
-      }
-    case INTERP_KERNEL::NORM_SEG3:
-      {
-        int conn[8]={connBg[1],connBg[3],connBg[3]+deltaz,connBg[1]+deltaz,connBg[2],connBg[3]+nbOfNodesPerLev,connBg[2]+deltaz,connBg[1]+nbOfNodesPerLev};
-        ret.insert(ret.end(),conn,conn+8);
-        break;
-      }
-    case INTERP_KERNEL::NORM_QUAD4:
-      {
-        int conn[8]={connBg[1],connBg[2],connBg[3],connBg[4],connBg[1]+deltaz,connBg[2]+deltaz,connBg[3]+deltaz,connBg[4]+deltaz};
-        ret.insert(ret.end(),conn,conn+8);
-        break;
-      }
-    case INTERP_KERNEL::NORM_TRI3:
-      {
-        int conn[6]={connBg[1],connBg[2],connBg[3],connBg[1]+deltaz,connBg[2]+deltaz,connBg[3]+deltaz};
-        ret.insert(ret.end(),conn,conn+6);
-        break;
-      }
-    case INTERP_KERNEL::NORM_TRI6:
-      {
-        int conn[15]={connBg[1],connBg[2],connBg[3],connBg[1]+deltaz,connBg[2]+deltaz,connBg[3]+deltaz,connBg[4],connBg[5],connBg[6],connBg[4]+deltaz,connBg[5]+deltaz,connBg[6]+deltaz,
-          connBg[1]+nbOfNodesPerLev,connBg[2]+nbOfNodesPerLev,connBg[3]+nbOfNodesPerLev};
-        ret.insert(ret.end(),conn,conn+15);
-        break;
-      }
-    case INTERP_KERNEL::NORM_QUAD8:
-      {
-        int conn[20]={
-          connBg[1],connBg[2],connBg[3],connBg[4],connBg[1]+deltaz,connBg[2]+deltaz,connBg[3]+deltaz,connBg[4]+deltaz,
-          connBg[5],connBg[6],connBg[7],connBg[8],connBg[5]+deltaz,connBg[6]+deltaz,connBg[7]+deltaz,connBg[8]+deltaz,
-          connBg[1]+nbOfNodesPerLev,connBg[2]+nbOfNodesPerLev,connBg[3]+nbOfNodesPerLev,connBg[4]+nbOfNodesPerLev
-        };
-        ret.insert(ret.end(),conn,conn+20);
-        break;
-      }
-    case INTERP_KERNEL::NORM_POLYGON:
-      {
-        std::back_insert_iterator< std::vector<int> > ii(ret);
-        std::copy(connBg+1,connEnd,ii);
-        *ii++=-1;
-        std::reverse_iterator<const int *> rConnBg(connEnd);
-        std::reverse_iterator<const int *> rConnEnd(connBg+1);
-        std::transform(rConnBg,rConnEnd,ii,std::bind2nd(std::plus<int>(),deltaz));
-        std::size_t nbOfRadFaces=std::distance(connBg+1,connEnd);
-        for(std::size_t i=0;i<nbOfRadFaces;i++)
-          {
-            *ii++=-1;
-            int conn[4]={connBg[(i+1)%nbOfRadFaces+1],connBg[i+1],connBg[i+1]+deltaz,connBg[(i+1)%nbOfRadFaces+1]+deltaz};
-            std::copy(conn,conn+4,ii);
-          }
-        break;
-      }
-    default:
-      throw INTERP_KERNEL::Exception("A flat type has been detected that has not its extruded representation !");
-  }
-}
 
 /*!
- * This static operates only for coords in 3D. The polygon is specfied by its connectivity nodes in [ \a begin , \a end ).
+ * This static operates only for coords in 3D. The polygon is specified by its connectivity nodes in [ \a begin , \a end ).
  */
-bool MEDCouplingUMesh::IsPolygonWellOriented(bool isQuadratic, const double *vec, const int *begin, const int *end, const double *coords)
+bool MEDCouplingUMesh::IsPolygonWellOriented(bool isQuadratic, const double *vec, const mcIdType *begin, const mcIdType *end, const double *coords)
 {
   std::size_t i, ip1;
   double v[3]={0.,0.,0.};
   std::size_t sz=std::distance(begin,end);
-  if(isQuadratic)
-    sz/=2;
-  for(i=0;i<sz;i++)
-    {
-      v[0]+=coords[3*begin[i]+1]*coords[3*begin[(i+1)%sz]+2]-coords[3*begin[i]+2]*coords[3*begin[(i+1)%sz]+1];
-      v[1]+=coords[3*begin[i]+2]*coords[3*begin[(i+1)%sz]]-coords[3*begin[i]]*coords[3*begin[(i+1)%sz]+2];
-      v[2]+=coords[3*begin[i]]*coords[3*begin[(i+1)%sz]+1]-coords[3*begin[i]+1]*coords[3*begin[(i+1)%sz]];
-    }
-  double ret = vec[0]*v[0]+vec[1]*v[1]+vec[2]*v[2];
-
-  // Try using quadratic points if standard points are degenerated (for example a QPOLYG with two
-  // SEG3 forming a circle):
-  if (fabs(ret) < INTERP_KERNEL::DEFAULT_ABS_TOL && isQuadratic)
+  if(!isQuadratic)
+    for(i=0;i<sz;i++)
+      {
+        // Algorithm: sum in v the cross products of (e1, e2) where e_i it the vector between (0,0,0) and point i
+        // and e2 is linear point directly following e1 in the connectivity. All points are used.
+        v[0]+=coords[3*begin[i]+1]*coords[3*begin[(i+1)%sz]+2]-coords[3*begin[i]+2]*coords[3*begin[(i+1)%sz]+1];
+        v[1]+=coords[3*begin[i]+2]*coords[3*begin[(i+1)%sz]]-coords[3*begin[i]]*coords[3*begin[(i+1)%sz]+2];
+        v[2]+=coords[3*begin[i]]*coords[3*begin[(i+1)%sz]+1]-coords[3*begin[i]+1]*coords[3*begin[(i+1)%sz]];
+      }
+  else
     {
-      v[0] = 0.0; v[1] = 0.0; v[2] = 0.0;
+      // Same algorithm as above but also using intermediate quadratic points.
+      // (taking only linear points might lead to issues if the linearized version of the
+      // polygon is not convex or self-intersecting ... see testCellOrientation4)
+      std::size_t hsz = sz/2;
       for(std::size_t j=0;j<sz;j++)
         {
           if (j%2)  // current point i is quadratic, next point i+1 is standard
             {
-              i = sz+j;
-              ip1 = (j+1)%sz; // ip1 = "i+1"
+              i = hsz+(j-1)/2;
+              ip1 = ((j-1)/2 + 1)%hsz; // ip1 means "i+1", i.e. next point
             }
           else      // current point i is standard, next point i+1 is quadratic
             {
-              i = j;
-              ip1 = j+sz;
+              i = j/2;
+              ip1 = j/2+hsz;
             }
           v[0]+=coords[3*begin[i]+1]*coords[3*begin[ip1]+2]-coords[3*begin[i]+2]*coords[3*begin[ip1]+1];
           v[1]+=coords[3*begin[i]+2]*coords[3*begin[ip1]]-coords[3*begin[i]]*coords[3*begin[ip1]+2];
           v[2]+=coords[3*begin[i]]*coords[3*begin[ip1]+1]-coords[3*begin[i]+1]*coords[3*begin[ip1]];
         }
-      ret = vec[0]*v[0]+vec[1]*v[1]+vec[2]*v[2];
     }
+  double ret = vec[0]*v[0]+vec[1]*v[1]+vec[2]*v[2];
   return (ret>0.);
 }
 
 /*!
- * The polyhedron is specfied by its connectivity nodes in [ \a begin , \a end ).
+ * The polyhedron is specified by its connectivity nodes in [ \a begin , \a end ).
  */
-bool MEDCouplingUMesh::IsPolyhedronWellOriented(const int *begin, const int *end, const double *coords)
+bool MEDCouplingUMesh::IsPolyhedronWellOriented(const mcIdType *begin, const mcIdType *end, const double *coords)
 {
-  std::vector<std::pair<int,int> > edges;
+  std::vector<std::pair<mcIdType,mcIdType> > edges;
   std::size_t nbOfFaces=std::count(begin,end,-1)+1;
-  const int *bgFace=begin;
+  const mcIdType *bgFace=begin;
   for(std::size_t i=0;i<nbOfFaces;i++)
     {
-      const int *endFace=std::find(bgFace+1,end,-1);
+      const mcIdType *endFace=std::find(bgFace+1,end,-1);
       std::size_t nbOfEdgesInFace=std::distance(bgFace,endFace);
       for(std::size_t j=0;j<nbOfEdgesInFace;j++)
         {
-          std::pair<int,int> p1(bgFace[j],bgFace[(j+1)%nbOfEdgesInFace]);
+          std::pair<mcIdType,mcIdType> p1(bgFace[j],bgFace[(j+1)%nbOfEdgesInFace]);
           if(std::find(edges.begin(),edges.end(),p1)!=edges.end())
             return false;
           edges.push_back(p1);
         }
       bgFace=endFace+1;
     }
-  return INTERP_KERNEL::calculateVolumeForPolyh2<int,INTERP_KERNEL::ALL_C_MODE>(begin,(int)std::distance(begin,end),coords)>-EPS_FOR_POLYH_ORIENTATION;
+  return INTERP_KERNEL::calculateVolumeForPolyh2<mcIdType,INTERP_KERNEL::ALL_C_MODE>(begin,ToIdType(std::distance(begin,end)),coords)>-EPS_FOR_POLYH_ORIENTATION;
 }
 
 /*!
  * The 3D extruded static cell (PENTA6,HEXA8,HEXAGP12...) its connectivity nodes in [ \a begin , \a end ).
  */
-bool MEDCouplingUMesh::Is3DExtrudedStaticCellWellOriented(const int *begin, const int *end, const double *coords)
+bool MEDCouplingUMesh::Is3DExtrudedStaticCellWellOriented(const mcIdType *begin, const mcIdType *end, const double *coords)
 {
   double vec0[3],vec1[3];
   std::size_t sz=std::distance(begin,end);
   if(sz%2!=0)
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::Is3DExtrudedStaticCellWellOriented : the length of nodal connectivity of extruded cell is not even !");
-  int nbOfNodes=(int)sz/2;
-  INTERP_KERNEL::areaVectorOfPolygon<int,INTERP_KERNEL::ALL_C_MODE>(begin,nbOfNodes,coords,vec0);
+  mcIdType nbOfNodes=ToIdType(sz/2);
+  INTERP_KERNEL::areaVectorOfPolygon<mcIdType,INTERP_KERNEL::ALL_C_MODE>(begin,nbOfNodes,coords,vec0);
   const double *pt0=coords+3*begin[0];
   const double *pt1=coords+3*begin[nbOfNodes];
   vec1[0]=pt1[0]-pt0[0]; vec1[1]=pt1[1]-pt0[1]; vec1[2]=pt1[2]-pt0[2];
   return (vec0[0]*vec1[0]+vec0[1]*vec1[1]+vec0[2]*vec1[2])<0.;
 }
 
-void MEDCouplingUMesh::CorrectExtrudedStaticCell(int *begin, int *end)
+void MEDCouplingUMesh::CorrectExtrudedStaticCell(mcIdType *begin, mcIdType *end)
 {
   std::size_t sz=std::distance(begin,end);
-  INTERP_KERNEL::AutoPtr<int> tmp=new int[sz];
+  INTERP_KERNEL::AutoPtr<mcIdType> tmp=new mcIdType[sz];
   std::size_t nbOfNodes(sz/2);
-  std::copy(begin,end,(int *)tmp);
+  std::copy(begin,end,(mcIdType *)tmp);
   for(std::size_t j=1;j<nbOfNodes;j++)
     {
       begin[j]=tmp[nbOfNodes-j];
@@ -8580,95 +7430,107 @@ void MEDCouplingUMesh::CorrectExtrudedStaticCell(int *begin, int *end)
     }
 }
 
-bool MEDCouplingUMesh::IsTetra4WellOriented(const int *begin, const int *end, const double *coords)
+bool MEDCouplingUMesh::IsTetra4WellOriented(const mcIdType *begin, const mcIdType *end, const double *coords)
 {
   std::size_t sz=std::distance(begin,end);
   if(sz!=4)
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::IsTetra4WellOriented : Tetra4 cell with not 4 nodes ! Call checkConsistency !");
   double vec0[3],vec1[3];
   const double *pt0=coords+3*begin[0],*pt1=coords+3*begin[1],*pt2=coords+3*begin[2],*pt3=coords+3*begin[3];
-  vec0[0]=pt1[0]-pt0[0]; vec0[1]=pt1[1]-pt0[1]; vec0[2]=pt1[2]-pt0[2]; vec1[0]=pt2[0]-pt0[0]; vec1[1]=pt2[1]-pt0[1]; vec1[2]=pt2[2]-pt0[2]; 
+  vec0[0]=pt1[0]-pt0[0]; vec0[1]=pt1[1]-pt0[1]; vec0[2]=pt1[2]-pt0[2]; vec1[0]=pt2[0]-pt0[0]; vec1[1]=pt2[1]-pt0[1]; vec1[2]=pt2[2]-pt0[2];
   return ((vec0[1]*vec1[2]-vec0[2]*vec1[1])*(pt3[0]-pt0[0])+(vec0[2]*vec1[0]-vec0[0]*vec1[2])*(pt3[1]-pt0[1])+(vec0[0]*vec1[1]-vec0[1]*vec1[0])*(pt3[2]-pt0[2]))<0;
 }
 
-bool MEDCouplingUMesh::IsPyra5WellOriented(const int *begin, const int *end, const double *coords)
+bool MEDCouplingUMesh::IsPyra5WellOriented(const mcIdType *begin, const mcIdType *end, const double *coords)
 {
   std::size_t sz=std::distance(begin,end);
   if(sz!=5)
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::IsPyra5WellOriented : Pyra5 cell with not 5 nodes ! Call checkConsistency !");
   double vec0[3];
-  INTERP_KERNEL::areaVectorOfPolygon<int,INTERP_KERNEL::ALL_C_MODE>(begin,4,coords,vec0);
+  INTERP_KERNEL::areaVectorOfPolygon<mcIdType,INTERP_KERNEL::ALL_C_MODE>(begin,4,coords,vec0);
   const double *pt0=coords+3*begin[0],*pt1=coords+3*begin[4];
   return (vec0[0]*(pt1[0]-pt0[0])+vec0[1]*(pt1[1]-pt0[1])+vec0[2]*(pt1[2]-pt0[2]))<0.;
 }
 
 /*!
- * This method performs a simplyfication of a single polyedron cell. To do that each face of cell whose connectivity is defined by [ \b begin , \b end ) 
+ * This method performs a simplyfication of a single polyedron cell. To do that each face of cell whose connectivity is defined by [ \b begin , \b end )
  * is compared with the others in order to find faces in the same plane (with approx of eps). If any, the cells are grouped together and projected to
  * a 2D space.
  *
  * \param [in] eps is a relative precision that allows to establish if some 3D plane are coplanar or not.
  * \param [in] coords the coordinates with nb of components exactly equal to 3
- * \param [in] begin begin of the nodal connectivity (geometric type included) of a single polyhedron cell
- * \param [in] end end of nodal connectivity of a single polyhedron cell (excluded)
+ * \param [in] index begin of the nodal connectivity (geometric type included) of a single polyhedron cell
  * \param [out] res the result is put at the end of the vector without any alteration of the data.
  */
-void MEDCouplingUMesh::SimplifyPolyhedronCell(double eps, const DataArrayDouble *coords, const int *begin, const int *end, DataArrayInt *res)
+void MEDCouplingUMesh::SimplifyPolyhedronCell(double eps, const DataArrayDouble *coords, mcIdType index, DataArrayIdType *res, MEDCouplingUMesh *faces,
+                                              DataArrayIdType *E_Fi, DataArrayIdType *E_F, DataArrayIdType *F_Ei, DataArrayIdType *F_E)
 {
-  int nbFaces=std::count(begin+1,end,-1)+1;
+  mcIdType nbFaces = E_Fi->getIJ(index + 1, 0) - E_Fi->getIJ(index, 0);
   MCAuto<DataArrayDouble> v=DataArrayDouble::New(); v->alloc(nbFaces,3);
   double *vPtr=v->getPointer();
-  MCAuto<DataArrayDouble> p=DataArrayDouble::New(); p->alloc(nbFaces,1);
+  MCAuto<DataArrayDouble> p=DataArrayDouble::New(); p->alloc(nbFaces,2);
   double *pPtr=p->getPointer();
-  const int *stFaceConn=begin+1;
-  for(int i=0;i<nbFaces;i++,vPtr+=3,pPtr++)
+  mcIdType *e_fi = E_Fi->getPointer(), *e_f = E_F->getPointer(), *f_ei = F_Ei->getPointer(), *f_e = F_E->getPointer();
+  const mcIdType *f_idx = faces->getNodalConnectivityIndex()->getPointer(), *f_cnn = faces->getNodalConnectivity()->getPointer();
+  for(mcIdType i=0;i<nbFaces;i++,vPtr+=3,pPtr++)
     {
-      const int *endFaceConn=std::find(stFaceConn,end,-1);
-      ComputeVecAndPtOfFace(eps,coords->begin(),stFaceConn,endFaceConn,vPtr,pPtr);
-      stFaceConn=endFaceConn+1;
+      mcIdType face = e_f[e_fi[index] + i];
+      ComputeVecAndPtOfFace(eps, coords->begin(), f_cnn + f_idx[face] + 1, f_cnn + f_idx[face + 1], vPtr, pPtr);
+      // to differentiate faces going to different cells:
+      pPtr++, *pPtr = 0;
+      for (mcIdType j = f_ei[face]; j < f_ei[face + 1]; j++)
+        *pPtr += FromIdType<double>(f_e[j]);
     }
   pPtr=p->getPointer(); vPtr=v->getPointer();
-  DataArrayInt *comm1=0,*commI1=0;
+  DataArrayIdType *comm1=0,*commI1=0;
   v->findCommonTuples(eps,-1,comm1,commI1);
-  MCAuto<DataArrayInt> comm1Auto(comm1),commI1Auto(commI1);
-  const int *comm1Ptr=comm1->begin();
-  const int *commI1Ptr=commI1->begin();
-  int nbOfGrps1=commI1Auto->getNumberOfTuples()-1;
-  res->pushBackSilent((int)INTERP_KERNEL::NORM_POLYHED);
-  //
-  MCAuto<MEDCouplingUMesh> mm=MEDCouplingUMesh::New("",3);
-  mm->setCoords(const_cast<DataArrayDouble *>(coords)); mm->allocateCells(1); mm->insertNextCell(INTERP_KERNEL::NORM_POLYHED,(int)std::distance(begin+1,end),begin+1);
-  mm->finishInsertingCells();
+  for (mcIdType i = 0; i < nbFaces; i++)
+    if (comm1->findIdFirstEqual(i) < 0)
+      {
+        comm1->pushBackSilent(i);
+        commI1->pushBackSilent(comm1->getNumberOfTuples());
+      }
+  MCAuto<DataArrayIdType> comm1Auto(comm1),commI1Auto(commI1);
+  const mcIdType *comm1Ptr=comm1->begin();
+  const mcIdType *commI1Ptr=commI1->begin();
+  mcIdType nbOfGrps1=commI1Auto->getNumberOfTuples()-1;
+  res->pushBackSilent(ToIdType(INTERP_KERNEL::NORM_POLYHED));
   //
-  for(int i=0;i<nbOfGrps1;i++)
+  for(mcIdType i=0;i<nbOfGrps1;i++)
     {
-      int vecId=comm1Ptr[commI1Ptr[i]];
+      mcIdType vecId=comm1Ptr[commI1Ptr[i]];
       MCAuto<DataArrayDouble> tmpgrp2=p->selectByTupleId(comm1Ptr+commI1Ptr[i],comm1Ptr+commI1Ptr[i+1]);
-      DataArrayInt *comm2=0,*commI2=0;
+      DataArrayIdType *comm2=0,*commI2=0;
       tmpgrp2->findCommonTuples(eps,-1,comm2,commI2);
-      MCAuto<DataArrayInt> comm2Auto(comm2),commI2Auto(commI2);
-      const int *comm2Ptr=comm2->begin();
-      const int *commI2Ptr=commI2->begin();
-      int nbOfGrps2=commI2Auto->getNumberOfTuples()-1;
-      for(int j=0;j<nbOfGrps2;j++)
+      for (mcIdType j = 0; j < commI1Ptr[i+1] - commI1Ptr[i]; j++)
+        if (comm2->findIdFirstEqual(j) < 0)
+          {
+            comm2->pushBackSilent(j);
+            commI2->pushBackSilent(comm2->getNumberOfTuples());
+          }
+      MCAuto<DataArrayIdType> comm2Auto(comm2),commI2Auto(commI2);
+      const mcIdType *comm2Ptr=comm2->begin();
+      const mcIdType *commI2Ptr=commI2->begin();
+      mcIdType nbOfGrps2=commI2Auto->getNumberOfTuples()-1;
+      for(mcIdType j=0;j<nbOfGrps2;j++)
         {
-          if(commI2Ptr[j+1]-commI2Ptr[j]<=1)
+          if(commI2Ptr[j+1] == commI2Ptr[j] + 1)
             {
-              res->insertAtTheEnd(begin,end);
+              mcIdType face = e_f[e_fi[index] + comm1Ptr[commI1Ptr[i] + comm2Ptr[commI2Ptr[j]]]]; //hmmm
+              res->insertAtTheEnd(f_cnn + f_idx[face] + 1, f_cnn + f_idx[face + 1]);
               res->pushBackSilent(-1);
             }
           else
             {
-              int pointId=comm1Ptr[commI1Ptr[i]+comm2Ptr[commI2Ptr[j]]];
-              MCAuto<DataArrayInt> ids2=comm2->selectByTupleIdSafeSlice(commI2Ptr[j],commI2Ptr[j+1],1);
+              mcIdType pointId=comm1Ptr[commI1Ptr[i]+comm2Ptr[commI2Ptr[j]]];
+              MCAuto<DataArrayIdType> ids2=comm2->selectByTupleIdSafeSlice(commI2Ptr[j],commI2Ptr[j+1],1);
               ids2->transformWithIndArr(comm1Ptr+commI1Ptr[i],comm1Ptr+commI1Ptr[i+1]);
-              DataArrayInt *tmp0=DataArrayInt::New(),*tmp1=DataArrayInt::New(),*tmp2=DataArrayInt::New(),*tmp3=DataArrayInt::New();
-              MCAuto<MEDCouplingUMesh> mm2=mm->buildDescendingConnectivity(tmp0,tmp1,tmp2,tmp3); tmp0->decrRef(); tmp1->decrRef(); tmp2->decrRef(); tmp3->decrRef();
-              MCAuto<MEDCouplingUMesh> mm3=static_cast<MEDCouplingUMesh *>(mm2->buildPartOfMySelf(ids2->begin(),ids2->end(),true));
-              MCAuto<DataArrayInt> idsNodeTmp=mm3->zipCoordsTraducer();
-              MCAuto<DataArrayInt> idsNode=idsNodeTmp->invertArrayO2N2N2O(mm3->getNumberOfNodes());
-              const int *idsNodePtr=idsNode->begin();
-              double center[3]; center[0]=pPtr[pointId]*vPtr[3*vecId]; center[1]=pPtr[pointId]*vPtr[3*vecId+1]; center[2]=pPtr[pointId]*vPtr[3*vecId+2];
+              ids2->transformWithIndArr(e_f + e_fi[index], e_f + e_fi[index + 1]);
+              MCAuto<MEDCouplingUMesh> mm3=static_cast<MEDCouplingUMesh *>(faces->buildPartOfMySelf(ids2->begin(),ids2->end(),true));
+              MCAuto<DataArrayIdType> idsNodeTmp=mm3->zipCoordsTraducer();
+              MCAuto<DataArrayIdType> idsNode=idsNodeTmp->invertArrayO2N2N2O(mm3->getNumberOfNodes());
+              const mcIdType *idsNodePtr=idsNode->begin();
+              double center[3]; center[0]=pPtr[2*pointId]*vPtr[3*vecId]; center[1]=pPtr[2*pointId]*vPtr[3*vecId+1]; center[2]=pPtr[2*pointId]*vPtr[3*vecId+2];
               double vec[3]; vec[0]=vPtr[3*vecId+1]; vec[1]=-vPtr[3*vecId]; vec[2]=0.;
               double norm=vec[0]*vec[0]+vec[1]*vec[1]+vec[2]*vec[2];
               if(std::abs(norm)>eps)
@@ -8678,13 +7540,13 @@ void MEDCouplingUMesh::SimplifyPolyhedronCell(double eps, const DataArrayDouble
                 }
               mm3->changeSpaceDimension(2);
               MCAuto<MEDCouplingUMesh> mm4=mm3->buildSpreadZonesWithPoly();
-              const int *conn4=mm4->getNodalConnectivity()->begin();
-              const int *connI4=mm4->getNodalConnectivityIndex()->begin();
-              int nbOfCells=mm4->getNumberOfCells();
-              for(int k=0;k<nbOfCells;k++)
+              const mcIdType *conn4=mm4->getNodalConnectivity()->begin();
+              const mcIdType *connI4=mm4->getNodalConnectivityIndex()->begin();
+              mcIdType nbOfCells=mm4->getNumberOfCells();
+              for(mcIdType k=0;k<nbOfCells;k++)
                 {
                   int l=0;
-                  for(const int *work=conn4+connI4[k]+1;work!=conn4+connI4[k+1];work++,l++)
+                  for(const mcIdType *work=conn4+connI4[k]+1;work!=conn4+connI4[k+1];work++,l++)
                     res->pushBackSilent(idsNodePtr[*work]);
                   res->pushBackSilent(-1);
                 }
@@ -8697,7 +7559,7 @@ void MEDCouplingUMesh::SimplifyPolyhedronCell(double eps, const DataArrayDouble
 /*!
  * This method computes the normalized vector of the plane and the pos of the point belonging to the plane and the line defined by the vector going
  * through origin. The plane is defined by its nodal connectivity [ \b begin, \b end ).
- * 
+ *
  * \param [in] eps below that value the dot product of 2 vectors is considered as colinears
  * \param [in] coords coordinates expected to have 3 components.
  * \param [in] begin start of the nodal connectivity of the face.
@@ -8705,7 +7567,7 @@ void MEDCouplingUMesh::SimplifyPolyhedronCell(double eps, const DataArrayDouble
  * \param [out] v the normalized vector of size 3
  * \param [out] p the pos of plane
  */
-void MEDCouplingUMesh::ComputeVecAndPtOfFace(double eps, const double *coords, const int *begin, const int *end, double *v, double *p)
+void MEDCouplingUMesh::ComputeVecAndPtOfFace(double eps, const double *coords, const mcIdType *begin, const mcIdType *end, double *v, double *p)
 {
   std::size_t nbPoints=std::distance(begin,end);
   if(nbPoints<3)
@@ -8751,15 +7613,15 @@ void MEDCouplingUMesh::ComputeVecAndPtOfFace(double eps, const double *coords, c
  * This method tries to obtain a well oriented polyhedron.
  * If the algorithm fails, an exception will be thrown.
  */
-void MEDCouplingUMesh::TryToCorrectPolyhedronOrientation(int *begin, int *end, const double *coords)
+void MEDCouplingUMesh::TryToCorrectPolyhedronOrientation(mcIdType *begin, mcIdType *end, const double *coords)
 {
-  std::list< std::pair<int,int> > edgesOK,edgesFinished;
+  std::list< std::pair<mcIdType,mcIdType> > edgesOK,edgesFinished;
   std::size_t nbOfFaces=std::count(begin,end,-1)+1;
   std::vector<bool> isPerm(nbOfFaces,false);//field on faces False: I don't know, True : oriented
   isPerm[0]=true;
-  int *bgFace=begin,*endFace=std::find(begin+1,end,-1);
+  mcIdType *bgFace=begin,*endFace=std::find(begin+1,end,-1);
   std::size_t nbOfEdgesInFace=std::distance(bgFace,endFace);
-  for(std::size_t l=0;l<nbOfEdgesInFace;l++) { std::pair<int,int> p1(bgFace[l],bgFace[(l+1)%nbOfEdgesInFace]); edgesOK.push_back(p1); }
+  for(std::size_t l=0;l<nbOfEdgesInFace;l++) { std::pair<mcIdType,mcIdType> p1(bgFace[l],bgFace[(l+1)%nbOfEdgesInFace]); edgesOK.push_back(p1); }
   //
   while(std::find(isPerm.begin(),isPerm.end(),false)!=isPerm.end())
     {
@@ -8771,28 +7633,28 @@ void MEDCouplingUMesh::TryToCorrectPolyhedronOrientation(int *begin, int *end, c
           nbOfEdgesInFace=std::distance(bgFace,endFace);
           if(!isPerm[i])
             {
-              bool b;
+              bool b=false;
               for(std::size_t j=0;j<nbOfEdgesInFace;j++)
                 {
-                  std::pair<int,int> p1(bgFace[j],bgFace[(j+1)%nbOfEdgesInFace]);
-                  std::pair<int,int> p2(p1.second,p1.first);
+                  std::pair<mcIdType,mcIdType> p1(bgFace[j],bgFace[(j+1)%nbOfEdgesInFace]);
+                  std::pair<mcIdType,mcIdType> p2(p1.second,p1.first);
                   bool b1=std::find(edgesOK.begin(),edgesOK.end(),p1)!=edgesOK.end();
                   bool b2=std::find(edgesOK.begin(),edgesOK.end(),p2)!=edgesOK.end();
                   if(b1 || b2) { b=b2; isPerm[i]=true; smthChanged++; break; }
                 }
               if(isPerm[i])
-                { 
+                {
                   if(!b)
                     std::reverse(bgFace+1,endFace);
                   for(std::size_t j=0;j<nbOfEdgesInFace;j++)
                     {
-                      std::pair<int,int> p1(bgFace[j],bgFace[(j+1)%nbOfEdgesInFace]);
-                      std::pair<int,int> p2(p1.second,p1.first);
+                      std::pair<mcIdType,mcIdType> p1(bgFace[j],bgFace[(j+1)%nbOfEdgesInFace]);
+                      std::pair<mcIdType,mcIdType> p2(p1.second,p1.first);
                       if(std::find(edgesOK.begin(),edgesOK.end(),p1)!=edgesOK.end())
                         { std::ostringstream oss; oss << "Face #" << j << " of polyhedron looks bad !"; throw INTERP_KERNEL::Exception(oss.str()); }
                       if(std::find(edgesFinished.begin(),edgesFinished.end(),p1)!=edgesFinished.end() || std::find(edgesFinished.begin(),edgesFinished.end(),p2)!=edgesFinished.end())
                         { std::ostringstream oss; oss << "Face #" << j << " of polyhedron looks bad !"; throw INTERP_KERNEL::Exception(oss.str()); }
-                      std::list< std::pair<int,int> >::iterator it=std::find(edgesOK.begin(),edgesOK.end(),p2);
+                      std::list< std::pair<mcIdType,mcIdType> >::iterator it=std::find(edgesOK.begin(),edgesOK.end(),p2);
                       if(it!=edgesOK.end())
                         {
                           edgesOK.erase(it);
@@ -8810,7 +7672,7 @@ void MEDCouplingUMesh::TryToCorrectPolyhedronOrientation(int *begin, int *end, c
     }
   if(!edgesOK.empty())
     { throw INTERP_KERNEL::Exception("The polyhedron looks too bad to be repaired : Some edges are shared only once !"); }
-  if(INTERP_KERNEL::calculateVolumeForPolyh2<int,INTERP_KERNEL::ALL_C_MODE>(begin,(int)std::distance(begin,end),coords)<-EPS_FOR_POLYH_ORIENTATION)
+  if(INTERP_KERNEL::calculateVolumeForPolyh2<mcIdType,INTERP_KERNEL::ALL_C_MODE>(begin,ToIdType(std::distance(begin,end)),coords)<-EPS_FOR_POLYH_ORIENTATION)
     {//not lucky ! The first face was not correctly oriented : reorient all faces...
       bgFace=begin;
       for(std::size_t i=0;i<nbOfFaces;i++)
@@ -8822,114 +7684,23 @@ void MEDCouplingUMesh::TryToCorrectPolyhedronOrientation(int *begin, int *end, c
     }
 }
 
-DataArrayInt *MEDCouplingUMesh::buildUnionOf2DMeshLinear(const MEDCouplingUMesh *skin, const DataArrayInt *n2o) const
-{
-  int nbOfNodesExpected(skin->getNumberOfNodes());
-  const int *n2oPtr(n2o->begin());
-  MCAuto<DataArrayInt> revNodal(DataArrayInt::New()),revNodalI(DataArrayInt::New());
-  skin->getReverseNodalConnectivity(revNodal,revNodalI);
-  const int *revNodalPtr(revNodal->begin()),*revNodalIPtr(revNodalI->begin());
-  const int *nodalPtr(skin->getNodalConnectivity()->begin());
-  const int *nodalIPtr(skin->getNodalConnectivityIndex()->begin());
-  MCAuto<DataArrayInt> ret(DataArrayInt::New()); ret->alloc(nbOfNodesExpected+1,1);
-  int *work(ret->getPointer());  *work++=INTERP_KERNEL::NORM_POLYGON;
-  if(nbOfNodesExpected<1)
-    return ret.retn();
-  int prevCell(0),prevNode(nodalPtr[nodalIPtr[0]+1]);
-  *work++=n2oPtr[prevNode];
-  for(int i=1;i<nbOfNodesExpected;i++)
-    {
-      if(nodalIPtr[prevCell+1]-nodalIPtr[prevCell]==3)
-        {
-          std::set<int> conn(nodalPtr+nodalIPtr[prevCell]+1,nodalPtr+nodalIPtr[prevCell]+3);
-          conn.erase(prevNode);
-          if(conn.size()==1)
-            {
-              int curNode(*(conn.begin()));
-              *work++=n2oPtr[curNode];
-              std::set<int> shar(revNodalPtr+revNodalIPtr[curNode],revNodalPtr+revNodalIPtr[curNode+1]);
-              shar.erase(prevCell);
-              if(shar.size()==1)
-                {
-                  prevCell=*(shar.begin());
-                  prevNode=curNode;
-                }
-              else
-                throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildUnionOf2DMeshLinear : presence of unexpected 2 !");
-            }
-          else
-            throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildUnionOf2DMeshLinear : presence of unexpected 1 !");
-        }
-      else
-        throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildUnionOf2DMeshLinear : presence of unexpected cell !");
-    }
-  return ret.retn();
-}
-
-DataArrayInt *MEDCouplingUMesh::buildUnionOf2DMeshQuadratic(const MEDCouplingUMesh *skin, const DataArrayInt *n2o) const
-{
-  int nbOfNodesExpected(skin->getNumberOfNodes());
-  int nbOfTurn(nbOfNodesExpected/2);
-  const int *n2oPtr(n2o->begin());
-  MCAuto<DataArrayInt> revNodal(DataArrayInt::New()),revNodalI(DataArrayInt::New());
-  skin->getReverseNodalConnectivity(revNodal,revNodalI);
-  const int *revNodalPtr(revNodal->begin()),*revNodalIPtr(revNodalI->begin());
-  const int *nodalPtr(skin->getNodalConnectivity()->begin());
-  const int *nodalIPtr(skin->getNodalConnectivityIndex()->begin());
-  MCAuto<DataArrayInt> ret(DataArrayInt::New()); ret->alloc(nbOfNodesExpected+1,1);
-  int *work(ret->getPointer());  *work++=INTERP_KERNEL::NORM_QPOLYG;
-  if(nbOfNodesExpected<1)
-    return ret.retn();
-  int prevCell(0),prevNode(nodalPtr[nodalIPtr[0]+1]);
-  *work=n2oPtr[prevNode]; work[nbOfTurn]=n2oPtr[nodalPtr[nodalIPtr[0]+3]]; work++;
-  for(int i=1;i<nbOfTurn;i++)
-    {
-      if(nodalIPtr[prevCell+1]-nodalIPtr[prevCell]==4)
-        {
-          std::set<int> conn(nodalPtr+nodalIPtr[prevCell]+1,nodalPtr+nodalIPtr[prevCell]+3);
-          conn.erase(prevNode);
-          if(conn.size()==1)
-            {
-              int curNode(*(conn.begin()));
-              *work=n2oPtr[curNode];
-              std::set<int> shar(revNodalPtr+revNodalIPtr[curNode],revNodalPtr+revNodalIPtr[curNode+1]);
-              shar.erase(prevCell);
-              if(shar.size()==1)
-                {
-                  int curCell(*(shar.begin()));
-                  work[nbOfTurn]=n2oPtr[nodalPtr[nodalIPtr[curCell]+3]];
-                  prevCell=curCell;
-                  prevNode=curNode;
-                  work++;
-                }
-              else
-                throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildUnionOf2DMeshQuadratic : presence of unexpected 2 !");
-            }
-          else
-            throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildUnionOf2DMeshQuadratic : presence of unexpected 1 !");
-        }
-      else
-        throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildUnionOf2DMeshQuadratic : presence of unexpected cell !");
-    }
-  return ret.retn();
-}
 
 /*!
  * This method makes the assumption spacedimension == meshdimension == 2.
  * This method works only for linear cells.
- * 
+ *
  * \return a newly allocated array containing the connectivity of a polygon type enum included (NORM_POLYGON in pos#0)
  */
-DataArrayInt *MEDCouplingUMesh::buildUnionOf2DMesh() const
+DataArrayIdType *MEDCouplingUMesh::buildUnionOf2DMesh() const
 {
   if(getMeshDimension()!=2 || getSpaceDimension()!=2)
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildUnionOf2DMesh : meshdimension, spacedimension must be equal to 2 !");
   MCAuto<MEDCouplingUMesh> skin(computeSkin());
-  int oldNbOfNodes(skin->getNumberOfNodes());
-  MCAuto<DataArrayInt> o2n(skin->zipCoordsTraducer());
-  int nbOfNodesExpected(skin->getNumberOfNodes());
-  MCAuto<DataArrayInt> n2o(o2n->invertArrayO2N2N2O(oldNbOfNodes));
-  int nbCells(skin->getNumberOfCells());
+  mcIdType oldNbOfNodes(skin->getNumberOfNodes());
+  MCAuto<DataArrayIdType> o2n(skin->zipCoordsTraducer());
+  mcIdType nbOfNodesExpected(skin->getNumberOfNodes());
+  MCAuto<DataArrayIdType> n2o(o2n->invertArrayO2N2N2O(oldNbOfNodes));
+  mcIdType nbCells=skin->getNumberOfCells();
   if(nbCells==nbOfNodesExpected)
     return buildUnionOf2DMeshLinear(skin,n2o);
   else if(2*nbCells==nbOfNodesExpected)
@@ -8941,23 +7712,23 @@ DataArrayInt *MEDCouplingUMesh::buildUnionOf2DMesh() const
 /*!
  * This method makes the assumption spacedimension == meshdimension == 3.
  * This method works only for linear cells.
- * 
+ *
  * \return a newly allocated array containing the connectivity of a polygon type enum included (NORM_POLYHED in pos#0)
  */
-DataArrayInt *MEDCouplingUMesh::buildUnionOf3DMesh() const
+DataArrayIdType *MEDCouplingUMesh::buildUnionOf3DMesh() const
 {
   if(getMeshDimension()!=3 || getSpaceDimension()!=3)
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildUnionOf3DMesh : meshdimension, spacedimension must be equal to 2 !");
   MCAuto<MEDCouplingUMesh> m=computeSkin();
-  const int *conn=m->getNodalConnectivity()->begin();
-  const int *connI=m->getNodalConnectivityIndex()->begin();
-  int nbOfCells=m->getNumberOfCells();
-  MCAuto<DataArrayInt> ret=DataArrayInt::New(); ret->alloc(m->getNodalConnectivity()->getNumberOfTuples(),1);
-  int *work=ret->getPointer();  *work++=INTERP_KERNEL::NORM_POLYHED;
+  const mcIdType *conn=m->getNodalConnectivity()->begin();
+  const mcIdType *connI=m->getNodalConnectivityIndex()->begin();
+  mcIdType nbOfCells=m->getNumberOfCells();
+  MCAuto<DataArrayIdType> ret=DataArrayIdType::New(); ret->alloc(m->getNodalConnectivity()->getNumberOfTuples(),1);
+  mcIdType *work=ret->getPointer();  *work++=INTERP_KERNEL::NORM_POLYHED;
   if(nbOfCells<1)
     return ret.retn();
   work=std::copy(conn+connI[0]+1,conn+connI[1],work);
-  for(int i=1;i<nbOfCells;i++)
+  for(mcIdType i=1;i<nbOfCells;i++)
     {
       *work++=-1;
       work=std::copy(conn+connI[i]+1,conn+connI[i+1],work);
@@ -8975,24 +7746,24 @@ DataArrayInt *MEDCouplingUMesh::buildUnionOf3DMesh() const
  *  means 6 arcs (0,1), (0,2), (0,3), (1,2), (1,3), (2,3)
  *  Arcs are not doubled but reflexive (1,1) arcs are present for each cell
  */
-MEDCouplingSkyLineArray *MEDCouplingUMesh::generateGraph() const
+MEDCouplingSkyLineArrayMEDCouplingUMesh::generateGraph() const
 {
   checkConnectivityFullyDefined();
 
   int meshDim = this->getMeshDimension();
-  MEDCoupling::DataArrayInt* indexr=MEDCoupling::DataArrayInt::New();
-  MEDCoupling::DataArrayInt* revConn=MEDCoupling::DataArrayInt::New();
+  MEDCoupling::DataArrayIdType* indexr=MEDCoupling::DataArrayIdType::New();
+  MEDCoupling::DataArrayIdType* revConn=MEDCoupling::DataArrayIdType::New();
   this->getReverseNodalConnectivity(revConn,indexr);
-  const int* indexr_ptr=indexr->begin();
-  const int* revConn_ptr=revConn->begin();
+  const mcIdType* indexr_ptr=indexr->begin();
+  const mcIdType* revConn_ptr=revConn->begin();
 
-  const MEDCoupling::DataArrayInt* index;
-  const MEDCoupling::DataArrayInt* conn;
+  const MEDCoupling::DataArrayIdType* index;
+  const MEDCoupling::DataArrayIdType* conn;
   conn=this->getNodalConnectivity(); // it includes a type as the 1st element!!!
   index=this->getNodalConnectivityIndex();
-  int nbCells=this->getNumberOfCells();
-  const int* index_ptr=index->begin();
-  const int* conn_ptr=conn->begin();
+  mcIdType nbCells=this->getNumberOfCells();
+  const mcIdType* index_ptr=index->begin();
+  const mcIdType* conn_ptr=conn->begin();
 
   //creating graph arcs (cell to cell relations)
   //arcs are stored in terms of (index,value) notation
@@ -9004,25 +7775,25 @@ MEDCouplingSkyLineArray *MEDCouplingUMesh::generateGraph() const
   //warning here one node have less than or equal effective number of cell with it
   //but cell could have more than effective nodes
   //because other equals nodes in other domain (with other global inode)
-  std::vector <int> cell2cell_index(nbCells+1,0);
-  std::vector <int> cell2cell;
+  std::vector <mcIdType> cell2cell_index(nbCells+1,0);
+  std::vector <mcIdType> cell2cell;
   cell2cell.reserve(3*nbCells);
 
-  for (int icell=0; icell<nbCells;icell++)
+  for (mcIdType icell=0; icell<nbCells;icell++)
     {
-      std::map<int,int > counter;
-      for (int iconn=index_ptr[icell]+1; iconn<index_ptr[icell+1];iconn++)
+      std::map<mcIdType,mcIdType > counter;
+      for (mcIdType iconn=index_ptr[icell]+1; iconn<index_ptr[icell+1];iconn++)
         {
-          int inode=conn_ptr[iconn];
-          for (int iconnr=indexr_ptr[inode]; iconnr<indexr_ptr[inode+1];iconnr++)
+          mcIdType inode=conn_ptr[iconn];
+          for (mcIdType iconnr=indexr_ptr[inode]; iconnr<indexr_ptr[inode+1];iconnr++)
             {
-              int icell2=revConn_ptr[iconnr];
-              std::map<int,int>::iterator iter=counter.find(icell2);
+              mcIdType icell2=revConn_ptr[iconnr];
+              std::map<mcIdType,mcIdType>::iterator iter=counter.find(icell2);
               if (iter!=counter.end()) (iter->second)++;
               else counter.insert(std::make_pair(icell2,1));
             }
         }
-      for (std::map<int,int>::const_iterator iter=counter.begin();
+      for (std::map<mcIdType,mcIdType>::const_iterator iter=counter.begin();
            iter!=counter.end(); iter++)
         if (iter->second >= meshDim)
           {
@@ -9033,39 +7804,18 @@ MEDCouplingSkyLineArray *MEDCouplingUMesh::generateGraph() const
   indexr->decrRef();
   revConn->decrRef();
   cell2cell_index[0]=0;
-  for (int icell=0; icell<nbCells;icell++)
+  for (mcIdType icell=0; icell<nbCells;icell++)
     cell2cell_index[icell+1]=cell2cell_index[icell]+cell2cell_index[icell+1];
 
   //filling up index and value to create skylinearray structure
-  MEDCouplingSkyLineArray* array=new MEDCouplingSkyLineArray(cell2cell_index,cell2cell);
+  MEDCouplingSkyLineArray * array(MEDCouplingSkyLineArray::New(cell2cell_index,cell2cell));
   return array;
 }
 
-/*!
- * This method put in zip format into parameter 'zipFrmt' in full interlace mode.
- * This format is often asked by INTERP_KERNEL algorithms to avoid many indirections into coordinates array.
- */
-void MEDCouplingUMesh::FillInCompact3DMode(int spaceDim, int nbOfNodesInCell, const int *conn, const double *coo, double *zipFrmt)
-{
-  double *w=zipFrmt;
-  if(spaceDim==3)
-    for(int i=0;i<nbOfNodesInCell;i++)
-      w=std::copy(coo+3*conn[i],coo+3*conn[i]+3,w);
-  else if(spaceDim==2)
-    {
-      for(int i=0;i<nbOfNodesInCell;i++)
-        {
-          w=std::copy(coo+2*conn[i],coo+2*conn[i]+2,w);
-          *w++=0.;
-        }
-    }
-  else
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::FillInCompact3DMode : Invalid spaceDim specified : must be 2 or 3 !");
-}
 
 void MEDCouplingUMesh::writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const
 {
-  int nbOfCells=getNumberOfCells();
+  mcIdType nbOfCells=getNumberOfCells();
   if(nbOfCells<=0)
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::writeVTK : the unstructured mesh has no cells !");
   ofs << "  <" << getVTKDataSetType() << ">\n";
@@ -9084,15 +7834,15 @@ void MEDCouplingUMesh::writeVTKLL(std::ostream& ofs, const std::string& cellData
     }
   ofs << "      </Points>\n";
   ofs << "      <Cells>\n";
-  const int *cPtr=_nodal_connec->begin();
-  const int *cIPtr=_nodal_connec_index->begin();
-  MCAuto<DataArrayInt> faceoffsets=DataArrayInt::New(); faceoffsets->alloc(nbOfCells,1);
-  MCAuto<DataArrayInt> types=DataArrayInt::New(); types->alloc(nbOfCells,1);
-  MCAuto<DataArrayInt> offsets=DataArrayInt::New(); offsets->alloc(nbOfCells,1);
-  MCAuto<DataArrayInt> connectivity=DataArrayInt::New(); connectivity->alloc(_nodal_connec->getNumberOfTuples()-nbOfCells,1);
-  int *w1=faceoffsets->getPointer(),*w2=types->getPointer(),*w3=offsets->getPointer(),*w4=connectivity->getPointer();
-  int szFaceOffsets=0,szConn=0;
-  for(int i=0;i<nbOfCells;i++,w1++,w2++,w3++)
+  const mcIdType *cPtr=_nodal_connec->begin();
+  const mcIdType *cIPtr=_nodal_connec_index->begin();
+  MCAuto<DataArrayIdType> faceoffsets=DataArrayIdType::New(); faceoffsets->alloc(nbOfCells,1);
+  MCAuto<DataArrayIdType> types=DataArrayIdType::New(); types->alloc(nbOfCells,1);
+  MCAuto<DataArrayIdType> offsets=DataArrayIdType::New(); offsets->alloc(nbOfCells,1);
+  MCAuto<DataArrayIdType> connectivity=DataArrayIdType::New(); connectivity->alloc(_nodal_connec->getNumberOfTuples()-nbOfCells,1);
+  mcIdType *w1=faceoffsets->getPointer(),*w2=types->getPointer(),*w3=offsets->getPointer(),*w4=connectivity->getPointer();
+  mcIdType szFaceOffsets=0,szConn=0;
+  for(mcIdType i=0;i<nbOfCells;i++,w1++,w2++,w3++)
     {
       *w2=cPtr[cIPtr[i]];
       if((INTERP_KERNEL::NormalizedCellType)cPtr[cIPtr[i]]!=INTERP_KERNEL::NORM_POLYHED)
@@ -9103,39 +7853,43 @@ void MEDCouplingUMesh::writeVTKLL(std::ostream& ofs, const std::string& cellData
         }
       else
         {
-          int deltaFaceOffset=cIPtr[i+1]-cIPtr[i]+1;
+          mcIdType deltaFaceOffset=cIPtr[i+1]-cIPtr[i]+1;
           *w1=szFaceOffsets+deltaFaceOffset; szFaceOffsets+=deltaFaceOffset;
-          std::set<int> c(cPtr+cIPtr[i]+1,cPtr+cIPtr[i+1]); c.erase(-1);
-          *w3=szConn+(int)c.size(); szConn+=(int)c.size();
+          std::set<mcIdType> c(cPtr+cIPtr[i]+1,cPtr+cIPtr[i+1]); c.erase(-1);
+          *w3=szConn+ToIdType(c.size()); szConn+=ToIdType(c.size());
           w4=std::copy(c.begin(),c.end(),w4);
         }
     }
-  types->transformWithIndArr(MEDCOUPLING2VTKTYPETRADUCER,MEDCOUPLING2VTKTYPETRADUCER+INTERP_KERNEL::NORM_MAXTYPE+1);
+  std::unique_ptr<mcIdType[]> medcoupling2vtkTypeTraducer_mcIdType(new mcIdType[MEDCOUPLING2VTKTYPETRADUCER_LGTH]);
+  for(auto ii = 0; ii<MEDCOUPLING2VTKTYPETRADUCER_LGTH ; ++ii)
+    medcoupling2vtkTypeTraducer_mcIdType[ii] = MEDCOUPLING2VTKTYPETRADUCER[ii]!=MEDCOUPLING2VTKTYPETRADUCER_NONE?MEDCOUPLING2VTKTYPETRADUCER[ii] : -1;
+  types->transformWithIndArr(medcoupling2vtkTypeTraducer_mcIdType.get(),medcoupling2vtkTypeTraducer_mcIdType.get()+MEDCOUPLING2VTKTYPETRADUCER_LGTH);
   types->writeVTK(ofs,8,"UInt8","types",byteData);
-  offsets->writeVTK(ofs,8,"Int32","offsets",byteData);
+  std::string vtkTypeName = Traits<mcIdType>::VTKReprStr;
+  offsets->writeVTK(ofs,8,vtkTypeName,"offsets",byteData);
   if(szFaceOffsets!=0)
     {//presence of Polyhedra
       connectivity->reAlloc(szConn);
-      faceoffsets->writeVTK(ofs,8,"Int32","faceoffsets",byteData);
-      MCAuto<DataArrayInt> faces=DataArrayInt::New(); faces->alloc(szFaceOffsets,1);
+      faceoffsets->writeVTK(ofs,8,vtkTypeName,"faceoffsets",byteData);
+      MCAuto<DataArrayIdType> faces=DataArrayIdType::New(); faces->alloc(szFaceOffsets,1);
       w1=faces->getPointer();
-      for(int i=0;i<nbOfCells;i++)
+      for(mcIdType i=0;i<nbOfCells;i++)
         if((INTERP_KERNEL::NormalizedCellType)cPtr[cIPtr[i]]==INTERP_KERNEL::NORM_POLYHED)
           {
-            int nbFaces=std::count(cPtr+cIPtr[i]+1,cPtr+cIPtr[i+1],-1)+1;
+            mcIdType nbFaces=ToIdType(std::count(cPtr+cIPtr[i]+1,cPtr+cIPtr[i+1],-1))+1;
             *w1++=nbFaces;
-            const int *w6=cPtr+cIPtr[i]+1,*w5=0;
-            for(int j=0;j<nbFaces;j++)
+            const mcIdType *w6=cPtr+cIPtr[i]+1,*w5=0;
+            for(mcIdType j=0;j<nbFaces;j++)
               {
                 w5=std::find(w6,cPtr+cIPtr[i+1],-1);
-                *w1++=(int)std::distance(w6,w5);
+                *w1++=ToIdType(std::distance(w6,w5));
                 w1=std::copy(w6,w5,w1);
                 w6=w5+1;
               }
           }
-      faces->writeVTK(ofs,8,"Int32","faces",byteData);
+      faces->writeVTK(ofs,8,vtkTypeName,"faces",byteData);
     }
-  connectivity->writeVTK(ofs,8,"Int32","connectivity",byteData);
+  connectivity->writeVTK(ofs,8,vtkTypeName,"connectivity",byteData);
   ofs << "      </Cells>\n";
   ofs << "    </Piece>\n";
   ofs << "  </" << getVTKDataSetType() << ">\n";
@@ -9159,8 +7913,8 @@ void MEDCouplingUMesh::reprQuickOverview(std::ostream& stream) const
     { stream << std::endl << "Nodal connectivity NOT set !"; return ; }
   if(!_nodal_connec_index->isAllocated())
     { stream << std::endl << "Nodal connectivity set but not allocated !"; return ; }
-  int lgth=_nodal_connec_index->getNumberOfTuples();
-  int cpt=_nodal_connec_index->getNumberOfComponents();
+  mcIdType lgth=_nodal_connec_index->getNumberOfTuples();
+  std::size_t cpt=_nodal_connec_index->getNumberOfComponents();
   if(cpt!=1 || lgth<1)
     return ;
   stream << std::endl << "Number of cells : " << lgth-1 << ".";
@@ -9176,1849 +7930,154 @@ std::string MEDCouplingUMesh::getVTKFileExtension() const
   return std::string("vtu");
 }
 
-/*!
- * Partitions the first given 2D mesh using the second given 2D mesh as a tool, and
- * returns a result mesh constituted by polygons.
- * Thus the final result contains all nodes from m1 plus new nodes. However it doesn't necessarily contains
- * all nodes from m2.
- * The meshes should be in 2D space. In
- * addition, returns two arrays mapping cells of the result mesh to cells of the input
- * meshes.
- *  \param [in] m1 - the first input mesh which is a partitioned object. The mesh must be so that each point in the space covered by \a m1
- *                      must be covered exactly by one entity, \b no \b more. If it is not the case, some tools are available to heal the mesh (conformize2D, mergeNodes)
- *  \param [in] m2 - the second input mesh which is a partition tool. The mesh must be so that each point in the space covered by \a m2
- *                      must be covered exactly by one entity, \b no \b more. If it is not the case, some tools are available to heal the mesh (conformize2D, mergeNodes)
- *  \param [in] eps - precision used to detect coincident mesh entities.
- *  \param [out] cellNb1 - a new instance of DataArrayInt holding for each result
- *         cell an id of the cell of \a m1 it comes from. The caller is to delete
- *         this array using decrRef() as it is no more needed.
- *  \param [out] cellNb2 - a new instance of DataArrayInt holding for each result
- *         cell an id of the cell of \a m2 it comes from. -1 value means that a
- *         result cell comes from a cell (or part of cell) of \a m1 not overlapped by
- *         any cell of \a m2. The caller is to delete this array using decrRef() as
- *         it is no more needed.  
- *  \return MEDCouplingUMesh * - the result 2D mesh which is a new instance of
- *         MEDCouplingUMesh. The caller is to delete this mesh using decrRef() as it
- *         is no more needed.  
- *  \throw If the coordinates array is not set in any of the meshes.
- *  \throw If the nodal connectivity of cells is not defined in any of the meshes.
- *  \throw If any of the meshes is not a 2D mesh in 2D space.
- *
- *  \sa conformize2D, mergeNodes
- */
-MEDCouplingUMesh *MEDCouplingUMesh::Intersect2DMeshes(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2,
-                                                      double eps, DataArrayInt *&cellNb1, DataArrayInt *&cellNb2)
-{
-  if(!m1 || !m2)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::Intersect2DMeshes : input meshes must be not NULL !");
-  m1->checkFullyDefined();
-  m2->checkFullyDefined();
-  if(m1->getMeshDimension()!=2 || m1->getSpaceDimension()!=2 || m2->getMeshDimension()!=2 || m2->getSpaceDimension()!=2)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::Intersect2DMeshes works on umeshes m1 AND m2  with meshdim equal to 2 and spaceDim equal to 2 too!");
-
-  // Step 1: compute all edge intersections (new nodes)
-  std::vector< std::vector<int> > intersectEdge1, colinear2, subDiv2;
-  MEDCouplingUMesh *m1Desc=0,*m2Desc=0; // descending connec. meshes
-  DataArrayInt *desc1=0,*descIndx1=0,*revDesc1=0,*revDescIndx1=0,*desc2=0,*descIndx2=0,*revDesc2=0,*revDescIndx2=0;
-  std::vector<double> addCoo,addCoordsQuadratic;  // coordinates of newly created nodes
-  IntersectDescending2DMeshes(m1,m2,eps,intersectEdge1,colinear2, subDiv2,
-                              m1Desc,desc1,descIndx1,revDesc1,revDescIndx1,
-                              addCoo, m2Desc,desc2,descIndx2,revDesc2,revDescIndx2);
-  revDesc1->decrRef(); revDescIndx1->decrRef(); revDesc2->decrRef(); revDescIndx2->decrRef();
-  MCAuto<DataArrayInt> dd1(desc1),dd2(descIndx1),dd3(desc2),dd4(descIndx2);
-  MCAuto<MEDCouplingUMesh> dd5(m1Desc),dd6(m2Desc);
-
-  // Step 2: re-order newly created nodes according to the ordering found in m2
-  std::vector< std::vector<int> > intersectEdge2;
-  BuildIntersectEdges(m1Desc,m2Desc,addCoo,subDiv2,intersectEdge2);
-  subDiv2.clear(); dd5=0; dd6=0;
-
-  // Step 3:
-  std::vector<int> cr,crI; //no DataArrayInt because interface with Geometric2D
-  std::vector<int> cNb1,cNb2; //no DataArrayInt because interface with Geometric2D
-  BuildIntersecting2DCellsFromEdges(eps,m1,desc1->begin(),descIndx1->begin(),intersectEdge1,colinear2,m2,desc2->begin(),descIndx2->begin(),intersectEdge2,addCoo,
-                                    /* outputs -> */addCoordsQuadratic,cr,crI,cNb1,cNb2);
-
-  // Step 4: Prepare final result:
-  MCAuto<DataArrayDouble> addCooDa(DataArrayDouble::New());
-  addCooDa->alloc((int)(addCoo.size())/2,2);
-  std::copy(addCoo.begin(),addCoo.end(),addCooDa->getPointer());
-  MCAuto<DataArrayDouble> addCoordsQuadraticDa(DataArrayDouble::New());
-  addCoordsQuadraticDa->alloc((int)(addCoordsQuadratic.size())/2,2);
-  std::copy(addCoordsQuadratic.begin(),addCoordsQuadratic.end(),addCoordsQuadraticDa->getPointer());
-  std::vector<const DataArrayDouble *> coordss(4);
-  coordss[0]=m1->getCoords(); coordss[1]=m2->getCoords(); coordss[2]=addCooDa; coordss[3]=addCoordsQuadraticDa;
-  MCAuto<DataArrayDouble> coo(DataArrayDouble::Aggregate(coordss));
-  MCAuto<MEDCouplingUMesh> ret(MEDCouplingUMesh::New("Intersect2D",2));
-  MCAuto<DataArrayInt> conn(DataArrayInt::New()); conn->alloc((int)cr.size(),1); std::copy(cr.begin(),cr.end(),conn->getPointer());
-  MCAuto<DataArrayInt> connI(DataArrayInt::New()); connI->alloc((int)crI.size(),1); std::copy(crI.begin(),crI.end(),connI->getPointer());
-  MCAuto<DataArrayInt> c1(DataArrayInt::New()); c1->alloc((int)cNb1.size(),1); std::copy(cNb1.begin(),cNb1.end(),c1->getPointer());
-  MCAuto<DataArrayInt> c2(DataArrayInt::New()); c2->alloc((int)cNb2.size(),1); std::copy(cNb2.begin(),cNb2.end(),c2->getPointer());
-  ret->setConnectivity(conn,connI,true);
-  ret->setCoords(coo);
-  cellNb1=c1.retn(); cellNb2=c2.retn();
-  return ret.retn();
-}
 
-/// @cond INTERNAL
 
-bool IsColinearOfACellOf(const std::vector< std::vector<int> >& intersectEdge1, const std::vector<int>& candidates, int start, int stop, int& retVal)
+/**
+ * Provides a renumbering of the cells of this (which has to be a piecewise connected 1D line), so that
+ * the segments of the line are indexed in consecutive order (i.e. cells \a i and \a i+1 are neighbors).
+ * This doesn't modify the mesh. This method only works using nodal connectivity consideration. Coordinates of nodes are ignored here.
+ * The caller is to deal with the resulting DataArrayIdType.
+ *  \throw If the coordinate array is not set.
+ *  \throw If the nodal connectivity of the cells is not defined.
+ *  \throw If m1 is not a mesh of dimension 2, or m1 is not a mesh of dimension 1
+ *  \throw If m2 is not a (piecewise) line (i.e. if a point has more than 2 adjacent segments)
+ *
+ * \sa DataArrayIdType::sortEachPairToMakeALinkedList
+ */
+DataArrayIdType *MEDCouplingUMesh::orderConsecutiveCells1D() const
 {
-  if(candidates.empty())
-    return false;
-  for(std::vector<int>::const_iterator it=candidates.begin();it!=candidates.end();it++)
+  checkFullyDefined();
+  if(getMeshDimension()!=1)
+    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::orderConsecutiveCells1D works on unstructured mesh with meshdim = 1 !");
+
+  // Check that this is a line (and not a more complex 1D mesh) - each point is used at most by 2 segments:
+  MCAuto<DataArrayIdType> _d(DataArrayIdType::New()),_dI(DataArrayIdType::New());
+  MCAuto<DataArrayIdType> _rD(DataArrayIdType::New()),_rDI(DataArrayIdType::New());
+  MCAuto<MEDCouplingUMesh> m_points(buildDescendingConnectivity(_d, _dI, _rD, _rDI));
+  const mcIdType *d(_d->begin()), *dI(_dI->begin());
+  const mcIdType *rD(_rD->begin()), *rDI(_rDI->begin());
+  MCAuto<DataArrayIdType> _dsi(_rDI->deltaShiftIndex());
+  const mcIdType * dsi(_dsi->begin());
+  MCAuto<DataArrayIdType> dsii = _dsi->findIdsNotInRange(0,3);
+  m_points=0;
+  if (dsii->getNumberOfTuples())
+    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::orderConsecutiveCells1D only work with a mesh being a (piecewise) connected line!");
+
+  mcIdType nc=getNumberOfCells();
+  MCAuto<DataArrayIdType> result(DataArrayIdType::New());
+  result->alloc(nc,1);
+
+  // set of edges not used so far
+  std::set<mcIdType> edgeSet;
+  for (mcIdType i=0; i<nc; edgeSet.insert(i), i++);
+
+  mcIdType startSeg=0;
+  mcIdType newIdx=0;
+  // while we have points with only one neighbor segments
+  do
     {
-      const std::vector<int>& pool(intersectEdge1[*it]);
-      int tmp[2]; tmp[0]=start; tmp[1]=stop;
-      if(std::search(pool.begin(),pool.end(),tmp,tmp+2)!=pool.end())
-        {
-          retVal=*it+1;
-          return true;
-        }
-      tmp[0]=stop; tmp[1]=start;
-      if(std::search(pool.begin(),pool.end(),tmp,tmp+2)!=pool.end())
-        {
-          retVal=-*it-1;
-          return true;
-        }
-    }
-  return false;
-}
-
-MEDCouplingUMesh *BuildMesh1DCutFrom(const MEDCouplingUMesh *mesh1D, const std::vector< std::vector<int> >& intersectEdge2, const DataArrayDouble *coords1, const std::vector<double>& addCoo, const std::map<int,int>& mergedNodes, const std::vector< std::vector<int> >& colinear2, const std::vector< std::vector<int> >& intersectEdge1,
-                                     MCAuto<DataArrayInt>& idsInRetColinear, MCAuto<DataArrayInt>& idsInMesh1DForIdsInRetColinear)
-{
-  idsInRetColinear=DataArrayInt::New(); idsInRetColinear->alloc(0,1);
-  idsInMesh1DForIdsInRetColinear=DataArrayInt::New(); idsInMesh1DForIdsInRetColinear->alloc(0,1);
-  int nCells(mesh1D->getNumberOfCells());
-  if(nCells!=(int)intersectEdge2.size())
-    throw INTERP_KERNEL::Exception("BuildMesh1DCutFrom : internal error # 1 !");
-  const DataArrayDouble *coo2(mesh1D->getCoords());
-  const int *c(mesh1D->getNodalConnectivity()->begin()),*ci(mesh1D->getNodalConnectivityIndex()->begin());
-  const double *coo2Ptr(coo2->begin());
-  int offset1(coords1->getNumberOfTuples());
-  int offset2(offset1+coo2->getNumberOfTuples());
-  int offset3(offset2+addCoo.size()/2);
-  std::vector<double> addCooQuad;
-  MCAuto<DataArrayInt> cOut(DataArrayInt::New()),ciOut(DataArrayInt::New()); cOut->alloc(0,1); ciOut->alloc(1,1); ciOut->setIJ(0,0,0);
-  int tmp[4],cicnt(0),kk(0);
-  for(int i=0;i<nCells;i++)
-    {
-      std::map<MCAuto<INTERP_KERNEL::Node>,int> m;
-      INTERP_KERNEL::Edge *e(MEDCouplingUMeshBuildQPFromEdge2((INTERP_KERNEL::NormalizedCellType)c[ci[i]],c+ci[i]+1,coo2Ptr,m));
-      const std::vector<int>& subEdges(intersectEdge2[i]);
-      int nbSubEdge(subEdges.size()/2);
-      for(int j=0;j<nbSubEdge;j++,kk++)
+      std::list<mcIdType> linePiece;
+      // fills a list of consecutive segment linked to startSeg. This can go forward or backward.
+      for (int direction=0;direction<2;direction++) // direction=0 --> forward, direction=1 --> backward
         {
-          MCAuto<INTERP_KERNEL::Node> n1(MEDCouplingUMeshBuildQPNode(subEdges[2*j],coords1->begin(),offset1,coo2Ptr,offset2,addCoo)),n2(MEDCouplingUMeshBuildQPNode(subEdges[2*j+1],coords1->begin(),offset1,coo2Ptr,offset2,addCoo));
-          MCAuto<INTERP_KERNEL::Edge> e2(e->buildEdgeLyingOnMe(n1,n2));
-          INTERP_KERNEL::Edge *e2Ptr(e2);
-          std::map<int,int>::const_iterator itm;
-          if(dynamic_cast<INTERP_KERNEL::EdgeArcCircle *>(e2Ptr))
-            {
-              tmp[0]=INTERP_KERNEL::NORM_SEG3;
-              itm=mergedNodes.find(subEdges[2*j]);
-              tmp[1]=itm!=mergedNodes.end()?(*itm).second:subEdges[2*j];
-              itm=mergedNodes.find(subEdges[2*j+1]);
-              tmp[2]=itm!=mergedNodes.end()?(*itm).second:subEdges[2*j+1];
-              tmp[3]=offset3+(int)addCooQuad.size()/2;
-              double tmp2[2];
-              e2->getBarycenter(tmp2); addCooQuad.insert(addCooQuad.end(),tmp2,tmp2+2);
-              cicnt+=4;
-              cOut->insertAtTheEnd(tmp,tmp+4);
-              ciOut->pushBackSilent(cicnt);
-            }
-          else
-            {
-              tmp[0]=INTERP_KERNEL::NORM_SEG2;
-              itm=mergedNodes.find(subEdges[2*j]);
-              tmp[1]=itm!=mergedNodes.end()?(*itm).second:subEdges[2*j];
-              itm=mergedNodes.find(subEdges[2*j+1]);
-              tmp[2]=itm!=mergedNodes.end()?(*itm).second:subEdges[2*j+1];
-              cicnt+=3;
-              cOut->insertAtTheEnd(tmp,tmp+3);
-              ciOut->pushBackSilent(cicnt);
-            }
-          int tmp00;
-          if(IsColinearOfACellOf(intersectEdge1,colinear2[i],tmp[1],tmp[2],tmp00))
+          // Fill the list forward (resp. backward) from the start segment:
+          mcIdType activeSeg = startSeg;
+          mcIdType prevPointId = -20;
+          mcIdType ptId;
+          while (!edgeSet.empty())
             {
-              idsInRetColinear->pushBackSilent(kk);
-              idsInMesh1DForIdsInRetColinear->pushBackSilent(tmp00);
-            }
-        }
-      e->decrRef();
-    }
-  MCAuto<MEDCouplingUMesh> ret(MEDCouplingUMesh::New(mesh1D->getName(),1));
-  ret->setConnectivity(cOut,ciOut,true);
-  MCAuto<DataArrayDouble> arr3(DataArrayDouble::New());
-  arr3->useArray(&addCoo[0],false,C_DEALLOC,(int)addCoo.size()/2,2);
-  MCAuto<DataArrayDouble> arr4(DataArrayDouble::New()); arr4->useArray(&addCooQuad[0],false,C_DEALLOC,(int)addCooQuad.size()/2,2);
-  std::vector<const DataArrayDouble *> coordss(4);
-  coordss[0]=coords1; coordss[1]=mesh1D->getCoords(); coordss[2]=arr3; coordss[3]=arr4;
-  MCAuto<DataArrayDouble> arr(DataArrayDouble::Aggregate(coordss));
-  ret->setCoords(arr);
-  return ret.retn();
-}
+              if (!(direction == 1 && prevPointId==-20)) // prevent adding twice startSeg
+                {
+                  if (direction==0)
+                    linePiece.push_back(activeSeg);
+                  else
+                    linePiece.push_front(activeSeg);
+                  edgeSet.erase(activeSeg);
+                }
 
-MEDCouplingUMesh *BuildRefined2DCellLinear(const DataArrayDouble *coords, const int *descBg, const int *descEnd, const std::vector< std::vector<int> >& intersectEdge1)
-{
-  std::vector<int> allEdges;
-  for(const int *it2(descBg);it2!=descEnd;it2++)
-    {
-      const std::vector<int>& edge1(intersectEdge1[std::abs(*it2)-1]);
-      if(*it2>0)
-        allEdges.insert(allEdges.end(),edge1.begin(),edge1.end());
-      else
-        allEdges.insert(allEdges.end(),edge1.rbegin(),edge1.rend());
-    }
-  std::size_t nb(allEdges.size());
-  if(nb%2!=0)
-    throw INTERP_KERNEL::Exception("BuildRefined2DCellLinear : internal error 1 !");
-  std::size_t nbOfEdgesOf2DCellSplit(nb/2);
-  MCAuto<MEDCouplingUMesh> ret(MEDCouplingUMesh::New("",2));
-  ret->setCoords(coords);
-  ret->allocateCells(1);
-  std::vector<int> connOut(nbOfEdgesOf2DCellSplit);
-  for(std::size_t kk=0;kk<nbOfEdgesOf2DCellSplit;kk++)
-    connOut[kk]=allEdges[2*kk];
-  ret->insertNextCell(INTERP_KERNEL::NORM_POLYGON,connOut.size(),&connOut[0]);
-  return ret.retn();
-}
+              mcIdType ptId1 = d[dI[activeSeg]], ptId2 = d[dI[activeSeg]+1];
+              ptId = direction ? (ptId1 == prevPointId ? ptId2 : ptId1) : (ptId2 == prevPointId ? ptId1 : ptId2);
+              if (dsi[ptId] == 1) // hitting the end of the line
+                break;
 
-MEDCouplingUMesh *BuildRefined2DCellQuadratic(const DataArrayDouble *coords, const MEDCouplingUMesh *mesh2D, int cellIdInMesh2D, const int *descBg, const int *descEnd, const std::vector< std::vector<int> >& intersectEdge1)
-{
-  const int *c(mesh2D->getNodalConnectivity()->begin()),*ci(mesh2D->getNodalConnectivityIndex()->begin());
-  const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)c[ci[cellIdInMesh2D]]));
-  std::size_t ii(0);
-  unsigned sz(cm.getNumberOfSons2(c+ci[cellIdInMesh2D]+1,ci[cellIdInMesh2D+1]-ci[cellIdInMesh2D]-1));
-  if(sz!=std::distance(descBg,descEnd))
-    throw INTERP_KERNEL::Exception("BuildRefined2DCellQuadratic : internal error 1 !");
-  INTERP_KERNEL::AutoPtr<int> tmpPtr(new int[ci[cellIdInMesh2D+1]-ci[cellIdInMesh2D]]);
-  std::vector<int> allEdges,centers;
-  const double *coordsPtr(coords->begin());
-  MCAuto<DataArrayDouble> addCoo(DataArrayDouble::New()); addCoo->alloc(0,1);
-  int offset(coords->getNumberOfTuples());
-  for(const int *it2(descBg);it2!=descEnd;it2++,ii++)
-    {
-      INTERP_KERNEL::NormalizedCellType typeOfSon;
-      cm.fillSonCellNodalConnectivity2(ii,c+ci[cellIdInMesh2D]+1,ci[cellIdInMesh2D+1]-ci[cellIdInMesh2D]-1,tmpPtr,typeOfSon);
-      const std::vector<int>& edge1(intersectEdge1[std::abs(*it2)-1]);
-      if(*it2>0)
-        allEdges.insert(allEdges.end(),edge1.begin(),edge1.end());
-      else
-        allEdges.insert(allEdges.end(),edge1.rbegin(),edge1.rend());
-      if(edge1.size()==2)
-        centers.push_back(tmpPtr[2]);//special case where no subsplit of edge -> reuse the original center.
-      else
-        {//the current edge has been subsplit -> create corresponding centers.
-          std::size_t nbOfCentersToAppend(edge1.size()/2);
-          std::map< MCAuto<INTERP_KERNEL::Node>,int> m;
-          MCAuto<INTERP_KERNEL::Edge> ee(MEDCouplingUMeshBuildQPFromEdge2(typeOfSon,tmpPtr,coordsPtr,m));
-          std::vector<int>::const_iterator it3(allEdges.end()-edge1.size());
-          for(std::size_t k=0;k<nbOfCentersToAppend;k++)
-            {
-              double tmpp[2];
-              const double *aa(coordsPtr+2*(*it3++));
-              const double *bb(coordsPtr+2*(*it3++));
-              ee->getMiddleOfPoints(aa,bb,tmpp);
-              addCoo->insertAtTheEnd(tmpp,tmpp+2);
-              centers.push_back(offset+k);
+              prevPointId = ptId;
+              mcIdType seg1 = rD[rDI[ptId]], seg2 = rD[rDI[ptId]+1];
+              activeSeg = (seg1 == activeSeg) ? seg2 : seg1;
+
+              //for piecewise meshes made up of closed parts
+              bool segmentAlreadyTreated = (std::find(linePiece.begin(), linePiece.end(), activeSeg) != linePiece.end());
+              if(segmentAlreadyTreated)
+                break;
             }
         }
+      // Done, save final piece into DA:
+      std::copy(linePiece.begin(), linePiece.end(), result->getPointer()+newIdx);
+      newIdx += ToIdType(linePiece.size());
+
+      // identify next valid start segment (one which is not consumed)
+      if(!edgeSet.empty())
+        startSeg = *(edgeSet.begin());
+
     }
-  std::size_t nb(allEdges.size());
-  if(nb%2!=0)
-    throw INTERP_KERNEL::Exception("BuildRefined2DCellQuadratic : internal error 2 !");
-  std::size_t nbOfEdgesOf2DCellSplit(nb/2);
-  MCAuto<MEDCouplingUMesh> ret(MEDCouplingUMesh::New("",2));
-  if(addCoo->empty())
-    ret->setCoords(coords);
-  else
-    {
-      addCoo->rearrange(2);
-      addCoo=DataArrayDouble::Aggregate(coords,addCoo);
-      ret->setCoords(addCoo);
-    }
-  ret->allocateCells(1);
-  std::vector<int> connOut(nbOfEdgesOf2DCellSplit);
-  for(std::size_t kk=0;kk<nbOfEdgesOf2DCellSplit;kk++)
-    connOut[kk]=allEdges[2*kk];
-  connOut.insert(connOut.end(),centers.begin(),centers.end());
-  ret->insertNextCell(INTERP_KERNEL::NORM_QPOLYG,connOut.size(),&connOut[0]);
-  return ret.retn();
+  while (!edgeSet.empty());
+  return result.retn();
 }
 
-/*!
- * This method creates a refinement of a cell in \a mesh2D. Those cell is defined by descending connectivity and the sorted subdivided nodal connectivity
- * of those edges.
+/**
+ * This method split some of edges of 2D cells in \a this. The edges to be split are specified in \a subNodesInSeg
+ * and in \a subNodesInSegI using \ref numbering-indirect storage mode.
+ * To do the work this method can optionally needs information about middle of subedges for quadratic cases if
+ * a minimal creation of new nodes is wanted.
+ * So this method try to reduce at most the number of new nodes. The only case that can lead this method to add
+ * nodes if a SEG3 is split without information of middle.
+ * \b WARNING : is returned value is different from 0 a call to MEDCouplingUMesh::mergeNodes is necessary to
+ * avoid to have a non conform mesh.
+ *
+ * \return mcIdType - the number of new nodes created (in most of cases 0).
  *
- * \param [in] mesh2D - The origin 2D mesh. \b Warning \b coords are not those of \a mesh2D. But mesh2D->getCoords()==coords[:mesh2D->getNumberOfNodes()]
+ * \throw If \a this is not coherent.
+ * \throw If \a this has not spaceDim equal to 2.
+ * \throw If \a this has not meshDim equal to 2.
+ * \throw If some subcells needed to be split are orphan.
+ * \sa MEDCouplingUMesh::conformize2D
  */
-MEDCouplingUMesh *BuildRefined2DCell(const DataArrayDouble *coords, const MEDCouplingUMesh *mesh2D, int cellIdInMesh2D, const int *descBg, const int *descEnd, const std::vector< std::vector<int> >& intersectEdge1)
-{
-  const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(mesh2D->getTypeOfCell(cellIdInMesh2D)));
-  if(!cm.isQuadratic())
-    return BuildRefined2DCellLinear(coords,descBg,descEnd,intersectEdge1);
-  else
-    return BuildRefined2DCellQuadratic(coords,mesh2D,cellIdInMesh2D,descBg,descEnd,intersectEdge1);
-}
-
-void AddCellInMesh2D(MEDCouplingUMesh *mesh2D, const std::vector<int>& conn, const std::vector< MCAuto<INTERP_KERNEL::Edge> >& edges)
+mcIdType MEDCouplingUMesh::split2DCells(const DataArrayIdType *desc, const DataArrayIdType *descI, const DataArrayIdType *subNodesInSeg, const DataArrayIdType *subNodesInSegI, const DataArrayIdType *midOpt, const DataArrayIdType *midOptI)
 {
-  bool isQuad(false);
-  for(std::vector< MCAuto<INTERP_KERNEL::Edge> >::const_iterator it=edges.begin();it!=edges.end();it++)
+  if(!desc || !descI || !subNodesInSeg || !subNodesInSegI)
+    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::split2DCells : the 4 first arrays must be not null !");
+  desc->checkAllocated(); descI->checkAllocated(); subNodesInSeg->checkAllocated(); subNodesInSegI->checkAllocated();
+  if(getSpaceDimension()!=2 || getMeshDimension()!=2)
+    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::split2DCells : This method only works for meshes with spaceDim=2 and meshDim=2 !");
+  if(midOpt==0 && midOptI==0)
     {
-      const INTERP_KERNEL::Edge *ee(*it);
-      if(dynamic_cast<const INTERP_KERNEL::EdgeArcCircle *>(ee))
-        isQuad=true;
+      split2DCellsLinear(desc,descI,subNodesInSeg,subNodesInSegI);
+      return 0;
     }
-  if(!isQuad)
-    mesh2D->insertNextCell(INTERP_KERNEL::NORM_POLYGON,conn.size(),&conn[0]);
+  else if(midOpt!=0 && midOptI!=0)
+    return split2DCellsQuadratic(desc,descI,subNodesInSeg,subNodesInSegI,midOpt,midOptI);
   else
-    {
-      const double *coo(mesh2D->getCoords()->begin());
-      std::size_t sz(conn.size());
-      std::vector<double> addCoo;
-      std::vector<int> conn2(conn);
-      int offset(mesh2D->getNumberOfNodes());
-      for(std::size_t i=0;i<sz;i++)
-        {
-          double tmp[2];
-          edges[(i+1)%sz]->getMiddleOfPoints(coo+2*conn[i],coo+2*conn[(i+1)%sz],tmp);// tony a chier i+1 -> i
-          addCoo.insert(addCoo.end(),tmp,tmp+2);
-          conn2.push_back(offset+(int)i);
-        }
-      mesh2D->getCoords()->rearrange(1);
-      mesh2D->getCoords()->pushBackValsSilent(&addCoo[0],&addCoo[0]+addCoo.size());
-      mesh2D->getCoords()->rearrange(2);
-      mesh2D->insertNextCell(INTERP_KERNEL::NORM_QPOLYG,conn2.size(),&conn2[0]);
-    }
+    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::split2DCells : middle parameters must be set to null for all or not null for all.");
 }
 
 /*!
- * \b WARNING edges in out1 coming from \a splitMesh1D are \b NOT oriented because only used for equation of curve.
+ * This method compute the convex hull of a single 2D cell. This method tries to conserve at maximum the given input connectivity. In particular, if the orientation of cell is not clockwise
+ * as in MED format norm. If definitely the result of Jarvis algorithm is not matchable with the input connectivity, the result will be copied into \b nodalConnecOut parameter and
+ * the geometric cell type set to INTERP_KERNEL::NORM_POLYGON.
+ * This method excepts that \b coords parameter is expected to be in dimension 2. [ \b nodalConnBg , \b nodalConnEnd ) is the nodal connectivity of the input
+ * cell (geometric cell type included at the position 0). If the meshdimension of the input cell is not equal to 2 an INTERP_KERNEL::Exception will be thrown.
  *
- * This method cuts in 2 parts the input 2D cell given using boundaries description (\a edge1Bis and \a edge1BisPtr) using
- * a set of edges defined in \a splitMesh1D.
+ * \return false if the input connectivity represents already the convex hull, true if the input cell needs to be reordered.
  */
-void BuildMesh2DCutInternal2(const MEDCouplingUMesh *splitMesh1D, const std::vector<int>& edge1Bis, const std::vector< MCAuto<INTERP_KERNEL::Edge> >& edge1BisPtr,
-                             std::vector< std::vector<int> >& out0, std::vector< std::vector< MCAuto<INTERP_KERNEL::Edge> > >& out1)
-{
-  std::size_t nb(edge1Bis.size()/2);
-  std::size_t nbOfEdgesOf2DCellSplit(nb/2);
-  int iEnd(splitMesh1D->getNumberOfCells());
-  if(iEnd==0)
-    throw INTERP_KERNEL::Exception("BuildMesh2DCutInternal2 : internal error ! input 1D mesh must have at least one cell !");
-  std::size_t ii,jj;
-  const int *cSplitPtr(splitMesh1D->getNodalConnectivity()->begin()),*ciSplitPtr(splitMesh1D->getNodalConnectivityIndex()->begin());
-  for(ii=0;ii<nb && edge1Bis[2*ii]!=cSplitPtr[ciSplitPtr[0]+1];ii++);
-  for(jj=ii;jj<nb && edge1Bis[2*jj+1]!=cSplitPtr[ciSplitPtr[iEnd-1]+2];jj++);
-  //
-  if(jj==nb)
-    {//the edges splitMesh1D[iStart:iEnd] does not fully cut the current 2D cell -> single output cell
-      out0.resize(1); out1.resize(1);
-      std::vector<int>& connOut(out0[0]);
-      connOut.resize(nbOfEdgesOf2DCellSplit);
-      std::vector< MCAuto<INTERP_KERNEL::Edge> >& edgesPtr(out1[0]);
-      edgesPtr.resize(nbOfEdgesOf2DCellSplit);
-      for(std::size_t kk=0;kk<nbOfEdgesOf2DCellSplit;kk++)
-        {
-          connOut[kk]=edge1Bis[2*kk];
-          edgesPtr[kk]=edge1BisPtr[2*kk];
-        }
-    }
-  else
-    {
-      // [i,iEnd[ contains the
-      out0.resize(2); out1.resize(2);
-      std::vector<int>& connOutLeft(out0[0]);
-      std::vector<int>& connOutRight(out0[1]);//connOutLeft should end with edge1Bis[2*ii] and connOutRight should end with edge1Bis[2*jj+1]
-      std::vector< MCAuto<INTERP_KERNEL::Edge> >& eleft(out1[0]);
-      std::vector< MCAuto<INTERP_KERNEL::Edge> >& eright(out1[1]);
-      for(std::size_t k=ii;k<jj+1;k++)
-        { connOutLeft.push_back(edge1Bis[2*k+1]); eleft.push_back(edge1BisPtr[2*k+1]); }
-      std::vector< MCAuto<INTERP_KERNEL::Edge> > ees(iEnd);
-      for(int ik=0;ik<iEnd;ik++)
-        {
-          std::map< MCAuto<INTERP_KERNEL::Node>,int> m;
-          MCAuto<INTERP_KERNEL::Edge> ee(MEDCouplingUMeshBuildQPFromEdge2((INTERP_KERNEL::NormalizedCellType)cSplitPtr[ciSplitPtr[ik]],cSplitPtr+ciSplitPtr[ik]+1,splitMesh1D->getCoords()->begin(),m));
-          ees[ik]=ee;
-        }
-      for(int ik=iEnd-1;ik>=0;ik--)
-        connOutLeft.push_back(cSplitPtr[ciSplitPtr[ik]+1]);
-      for(std::size_t k=jj+1;k<nbOfEdgesOf2DCellSplit+ii;k++)
-        { connOutRight.push_back(edge1Bis[2*k+1]); eright.push_back(edge1BisPtr[2*k+1]); }
-      eleft.insert(eleft.end(),ees.rbegin(),ees.rend());
-      for(int ik=0;ik<iEnd;ik++)
-        connOutRight.push_back(cSplitPtr[ciSplitPtr[ik]+2]);
-      eright.insert(eright.end(),ees.begin(),ees.end());
-    }
-}
-
-/// @endcond
-
-/// @cond INTERNAL
-
-struct CellInfo
-{
-public:
-  CellInfo() { }
-  CellInfo(const std::vector<int>& edges, const std::vector< MCAuto<INTERP_KERNEL::Edge> >& edgesPtr);
-public:
-  std::vector<int> _edges;
-  std::vector< MCAuto<INTERP_KERNEL::Edge> > _edges_ptr;
-};
-
-CellInfo::CellInfo(const std::vector<int>& edges, const std::vector< MCAuto<INTERP_KERNEL::Edge> >& edgesPtr)
-{
-  std::size_t nbe(edges.size());
-  std::vector<int> edges2(2*nbe); std::vector< MCAuto<INTERP_KERNEL::Edge> > edgesPtr2(2*nbe);
-  for(std::size_t i=0;i<nbe;i++)
-    {
-      edges2[2*i]=edges[i]; edges2[2*i+1]=edges[(i+1)%nbe];
-      edgesPtr2[2*i]=edgesPtr[(i+1)%nbe]; edgesPtr2[2*i+1]=edgesPtr[(i+1)%nbe];//tony a chier
-    }
-  _edges.resize(4*nbe); _edges_ptr.resize(4*nbe);
-  std::copy(edges2.begin(),edges2.end(),_edges.begin()); std::copy(edges2.begin(),edges2.end(),_edges.begin()+2*nbe);
-  std::copy(edgesPtr2.begin(),edgesPtr2.end(),_edges_ptr.begin()); std::copy(edgesPtr2.begin(),edgesPtr2.end(),_edges_ptr.begin()+2*nbe);
-}
-
-class EdgeInfo
-{
-public:
-  EdgeInfo(int istart, int iend, const MCAuto<MEDCouplingUMesh>& mesh):_istart(istart),_iend(iend),_mesh(mesh),_left(-7),_right(-7) { }
-  EdgeInfo(int istart, int iend, int pos, const MCAuto<INTERP_KERNEL::Edge>& edge):_istart(istart),_iend(iend),_edge(edge),_left(pos),_right(pos+1) { }
-  bool isInMyRange(int pos) const { return pos>=_istart && pos<_iend; }
-  void somethingHappendAt(int pos, const std::vector< MCAuto<INTERP_KERNEL::Edge> >& newLeft, const std::vector< MCAuto<INTERP_KERNEL::Edge> >& newRight);
-  void feedEdgeInfoAt(double eps, const MEDCouplingUMesh *mesh2D, int offset, int neighbors[2]) const;
-private:
-  int _istart;
-  int _iend;
-  MCAuto<MEDCouplingUMesh> _mesh;
-  MCAuto<INTERP_KERNEL::Edge> _edge;
-  int _left;
-  int _right;
-};
-
-void EdgeInfo::somethingHappendAt(int pos, const std::vector< MCAuto<INTERP_KERNEL::Edge> >& newLeft, const std::vector< MCAuto<INTERP_KERNEL::Edge> >& newRight)
-{
-  const MEDCouplingUMesh *mesh(_mesh);
-  if(mesh)
-    return ;
-  if(_right<pos)
-    return ;
-  if(_left>pos)
-    { _left++; _right++; return ; }
-  if(_right==pos)
-    {
-      bool isLeft(std::find(newLeft.begin(),newLeft.end(),_edge)!=newLeft.end()),isRight(std::find(newRight.begin(),newRight.end(),_edge)!=newRight.end());
-      if((isLeft && isRight) || (!isLeft && !isRight))
-        throw INTERP_KERNEL::Exception("EdgeInfo::somethingHappendAt : internal error # 1 !");
-      if(isLeft)
-        return ;
-      if(isRight)
-        {
-          _right++;
-          return ;
-        }
-    }
-  if(_left==pos)
-    {
-      bool isLeft(std::find(newLeft.begin(),newLeft.end(),_edge)!=newLeft.end()),isRight(std::find(newRight.begin(),newRight.end(),_edge)!=newRight.end());
-      if((isLeft && isRight) || (!isLeft && !isRight))
-        throw INTERP_KERNEL::Exception("EdgeInfo::somethingHappendAt : internal error # 2 !");
-      if(isLeft)
-        {
-          _right++;
-          return ;
-        }
-      if(isRight)
-        {
-          _left++;
-          _right++;
-          return ;
-        }
-    }
-}
-
-void EdgeInfo::feedEdgeInfoAt(double eps, const MEDCouplingUMesh *mesh2D, int offset, int neighbors[2]) const
+bool MEDCouplingUMesh::BuildConvexEnvelopOf2DCellJarvis(const double *coords, const mcIdType *nodalConnBg, const mcIdType *nodalConnEnd, DataArrayIdType *nodalConnecOut)
 {
-  const MEDCouplingUMesh *mesh(_mesh);
-  if(!mesh)
+  std::size_t sz=std::distance(nodalConnBg,nodalConnEnd);
+  if(sz>=4)
     {
-      neighbors[0]=offset+_left; neighbors[1]=offset+_right;
-    }
-  else
-    {// not fully splitting cell case
-      if(mesh2D->getNumberOfCells()==1)
-        {//little optimization. 1 cell no need to find in which cell mesh is !
-          neighbors[0]=offset; neighbors[1]=offset;
-          return;
-        }
-      else
+      const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)*nodalConnBg);
+      if(cm.getDimension()==2)
         {
-          MCAuto<DataArrayDouble> barys(mesh->computeCellCenterOfMass());
-          int cellId(mesh2D->getCellContainingPoint(barys->begin(),eps));
-          if(cellId==-1)
-            throw INTERP_KERNEL::Exception("EdgeInfo::feedEdgeInfoAt : internal error !");
-          neighbors[0]=offset+cellId; neighbors[1]=offset+cellId;
-        }
-    }
-}
-
-class VectorOfCellInfo
-{
-public:
-  VectorOfCellInfo(const std::vector<int>& edges, const std::vector< MCAuto<INTERP_KERNEL::Edge> >& edgesPtr);
-  std::size_t size() const { return _pool.size(); }
-  int getPositionOf(double eps, const MEDCouplingUMesh *mesh) const;
-  void setMeshAt(int pos, const MCAuto<MEDCouplingUMesh>& mesh, int istart, int iend, const MCAuto<MEDCouplingUMesh>& mesh1DInCase, const std::vector< std::vector<int> >& edges, const std::vector< std::vector< MCAuto<INTERP_KERNEL::Edge> > >& edgePtrs);
-  const std::vector<int>& getConnOf(int pos) const { return get(pos)._edges; }
-  const std::vector< MCAuto<INTERP_KERNEL::Edge> >& getEdgePtrOf(int pos) const { return get(pos)._edges_ptr; }
-  MCAuto<MEDCouplingUMesh> getZeMesh() const { return _ze_mesh; }
-  void feedEdgeInfoAt(double eps, int pos, int offset, int neighbors[2]) const;
-private:
-  int getZePosOfEdgeGivenItsGlobalId(int pos) const;
-  void updateEdgeInfo(int pos, const std::vector< MCAuto<INTERP_KERNEL::Edge> >& newLeft, const std::vector< MCAuto<INTERP_KERNEL::Edge> >& newRight);
-  const CellInfo& get(int pos) const;
-  CellInfo& get(int pos);
-private:
-  std::vector<CellInfo> _pool;
-  MCAuto<MEDCouplingUMesh> _ze_mesh;
-  std::vector<EdgeInfo> _edge_info;
-};
-
-VectorOfCellInfo::VectorOfCellInfo(const std::vector<int>& edges, const std::vector< MCAuto<INTERP_KERNEL::Edge> >& edgesPtr):_pool(1)
-{
-  _pool[0]._edges=edges;
-  _pool[0]._edges_ptr=edgesPtr;
-}
-
-int VectorOfCellInfo::getPositionOf(double eps, const MEDCouplingUMesh *mesh) const
-{
-  if(_pool.empty())
-    throw INTERP_KERNEL::Exception("VectorOfCellSplitter::getPositionOf : empty !");
-  if(_pool.size()==1)
-    return 0;
-  const MEDCouplingUMesh *zeMesh(_ze_mesh);
-  if(!zeMesh)
-    throw INTERP_KERNEL::Exception("VectorOfCellSplitter::getPositionOf : null aggregated mesh !");
-  MCAuto<DataArrayDouble> barys(mesh->computeCellCenterOfMass());
-  return zeMesh->getCellContainingPoint(barys->begin(),eps);
-}
-
-void VectorOfCellInfo::setMeshAt(int pos, const MCAuto<MEDCouplingUMesh>& mesh, int istart, int iend, const MCAuto<MEDCouplingUMesh>& mesh1DInCase, const std::vector< std::vector<int> >& edges, const std::vector< std::vector< MCAuto<INTERP_KERNEL::Edge> > >& edgePtrs)
-{
-  get(pos);//to check pos
-  bool isFast(pos==0 && _pool.size()==1);
-  std::size_t sz(edges.size());
-  // dealing with edges
-  if(sz==1)
-    _edge_info.push_back(EdgeInfo(istart,iend,mesh1DInCase));
-  else
-    _edge_info.push_back(EdgeInfo(istart,iend,pos,edgePtrs[0].back()));
-  //
-  std::vector<CellInfo> pool(_pool.size()-1+sz);
-  for(int i=0;i<pos;i++)
-    pool[i]=_pool[i];
-  for(std::size_t j=0;j<sz;j++)
-    pool[pos+j]=CellInfo(edges[j],edgePtrs[j]);
-  for(int i=pos+1;i<(int)_pool.size();i++)
-    pool[i+sz-1]=_pool[i];
-  _pool=pool;
-  //
-  if(sz==2)
-    updateEdgeInfo(pos,edgePtrs[0],edgePtrs[1]);
-  //
-  if(isFast)
-    {
-      _ze_mesh=mesh;
-      return ;
-    }
-  //
-  std::vector< MCAuto<MEDCouplingUMesh> > ms;
-  if(pos>0)
-    {
-      MCAuto<MEDCouplingUMesh> elt(static_cast<MEDCouplingUMesh *>(_ze_mesh->buildPartOfMySelfSlice(0,pos,true)));
-      ms.push_back(elt);
-    }
-  ms.push_back(mesh);
-  if(pos<_ze_mesh->getNumberOfCells()-1)
-  {
-    MCAuto<MEDCouplingUMesh> elt(static_cast<MEDCouplingUMesh *>(_ze_mesh->buildPartOfMySelfSlice(pos+1,_ze_mesh->getNumberOfCells(),true)));
-    ms.push_back(elt);
-  }
-  std::vector< const MEDCouplingUMesh *> ms2(ms.size());
-  for(std::size_t j=0;j<ms2.size();j++)
-    ms2[j]=ms[j];
-  _ze_mesh=MEDCouplingUMesh::MergeUMeshesOnSameCoords(ms2);
-}
-
-void VectorOfCellInfo::feedEdgeInfoAt(double eps, int pos, int offset, int neighbors[2]) const
-{
-  _edge_info[getZePosOfEdgeGivenItsGlobalId(pos)].feedEdgeInfoAt(eps,_ze_mesh,offset,neighbors);
-}
-
-int VectorOfCellInfo::getZePosOfEdgeGivenItsGlobalId(int pos) const
-{
-  if(pos<0)
-    throw INTERP_KERNEL::Exception("VectorOfCellInfo::getZePosOfEdgeGivenItsGlobalId : invalid id ! Must be >=0 !");
-  int ret(0);
-  for(std::vector<EdgeInfo>::const_iterator it=_edge_info.begin();it!=_edge_info.end();it++,ret++)
-    {
-      if((*it).isInMyRange(pos))
-        return ret;
-    }
-  throw INTERP_KERNEL::Exception("VectorOfCellInfo::getZePosOfEdgeGivenItsGlobalId : invalid id !");
-}
-
-void VectorOfCellInfo::updateEdgeInfo(int pos, const std::vector< MCAuto<INTERP_KERNEL::Edge> >& newLeft, const std::vector< MCAuto<INTERP_KERNEL::Edge> >& newRight)
-{
-  get(pos);//to check;
-  if(_edge_info.empty())
-    return ;
-  std::size_t sz(_edge_info.size()-1);
-  for(std::size_t i=0;i<sz;i++)
-    _edge_info[i].somethingHappendAt(pos,newLeft,newRight);
-}
-
-const CellInfo& VectorOfCellInfo::get(int pos) const
-{
-  if(pos<0 || pos>=(int)_pool.size())
-    throw INTERP_KERNEL::Exception("VectorOfCellSplitter::get const : invalid pos !");
-  return _pool[pos];
-}
-
-CellInfo& VectorOfCellInfo::get(int pos)
-{
-  if(pos<0 || pos>=(int)_pool.size())
-    throw INTERP_KERNEL::Exception("VectorOfCellSplitter::get : invalid pos !");
-  return _pool[pos];
-}
-
-/*!
- * Given :
- * - a \b closed set of edges ( \a allEdges and \a allEdgesPtr ) that defines the split descending 2D cell.
- * - \a splitMesh1D a split 2D curve mesh contained into 2D cell defined above.
- *
- * This method returns the 2D mesh and feeds \a idsLeftRight using offset.
- *
- * Algorithm : \a splitMesh1D is cut into contiguous parts. Each contiguous parts will build incrementally the output 2D cells.
- *
- * \param [in] allEdges a list of pairs (beginNode, endNode). Linked with \a allEdgesPtr to get the equation of edge.
- */
-MEDCouplingUMesh *BuildMesh2DCutInternal(double eps, const MEDCouplingUMesh *splitMesh1D, const std::vector<int>& allEdges, const std::vector< MCAuto<INTERP_KERNEL::Edge> >& allEdgesPtr, int offset,
-                                         MCAuto<DataArrayInt>& idsLeftRight)
-{
-  int nbCellsInSplitMesh1D(splitMesh1D->getNumberOfCells());
-  if(nbCellsInSplitMesh1D==0)
-    throw INTERP_KERNEL::Exception("BuildMesh2DCutInternal : internal error ! input 1D mesh must have at least one cell !");
-  const int *cSplitPtr(splitMesh1D->getNodalConnectivity()->begin()),*ciSplitPtr(splitMesh1D->getNodalConnectivityIndex()->begin());
-  std::size_t nb(allEdges.size()),jj;
-  if(nb%2!=0)
-    throw INTERP_KERNEL::Exception("BuildMesh2DCutFrom : internal error 2 !");
-  std::vector<int> edge1Bis(nb*2);
-  std::vector< MCAuto<INTERP_KERNEL::Edge> > edge1BisPtr(nb*2);
-  std::copy(allEdges.begin(),allEdges.end(),edge1Bis.begin());
-  std::copy(allEdges.begin(),allEdges.end(),edge1Bis.begin()+nb);
-  std::copy(allEdgesPtr.begin(),allEdgesPtr.end(),edge1BisPtr.begin());
-  std::copy(allEdgesPtr.begin(),allEdgesPtr.end(),edge1BisPtr.begin()+nb);
-  //
-  idsLeftRight=DataArrayInt::New(); idsLeftRight->alloc(nbCellsInSplitMesh1D*2); idsLeftRight->fillWithValue(-2); idsLeftRight->rearrange(2);
-  int *idsLeftRightPtr(idsLeftRight->getPointer());
-  VectorOfCellInfo pool(edge1Bis,edge1BisPtr);
-  for(int iStart=0;iStart<nbCellsInSplitMesh1D;)
-    {// split [0:nbCellsInSplitMesh1D) in contiguous parts [iStart:iEnd)
-      int iEnd(iStart);
-      for(;iEnd<nbCellsInSplitMesh1D;)
-        {
-          for(jj=0;jj<nb && edge1Bis[2*jj+1]!=cSplitPtr[ciSplitPtr[iEnd]+2];jj++);
-          if(jj!=nb)
-            break;
-          else
-            iEnd++;
-        }
-      if(iEnd<nbCellsInSplitMesh1D)
-        iEnd++;
-      //
-      MCAuto<MEDCouplingUMesh> partOfSplitMesh1D(static_cast<MEDCouplingUMesh *>(splitMesh1D->buildPartOfMySelfSlice(iStart,iEnd,1,true)));
-      int pos(pool.getPositionOf(eps,partOfSplitMesh1D));
-      //
-      MCAuto<MEDCouplingUMesh>retTmp(MEDCouplingUMesh::New("",2));
-      retTmp->setCoords(splitMesh1D->getCoords());
-      retTmp->allocateCells();
-
-      std::vector< std::vector<int> > out0;
-      std::vector< std::vector< MCAuto<INTERP_KERNEL::Edge> > > out1;
-
-      BuildMesh2DCutInternal2(partOfSplitMesh1D,pool.getConnOf(pos),pool.getEdgePtrOf(pos),out0,out1);
-      for(std::size_t cnt=0;cnt<out0.size();cnt++)
-        AddCellInMesh2D(retTmp,out0[cnt],out1[cnt]);
-      pool.setMeshAt(pos,retTmp,iStart,iEnd,partOfSplitMesh1D,out0,out1);
-      //
-      iStart=iEnd;
-    }
-  for(int mm=0;mm<nbCellsInSplitMesh1D;mm++)
-    pool.feedEdgeInfoAt(eps,mm,offset,idsLeftRightPtr+2*mm);
-  return pool.getZeMesh().retn();
-}
-
-MEDCouplingUMesh *BuildMesh2DCutFrom(double eps, int cellIdInMesh2D, const MEDCouplingUMesh *mesh2DDesc, const MEDCouplingUMesh *splitMesh1D,
-                                     const int *descBg, const int *descEnd, const std::vector< std::vector<int> >& intersectEdge1, int offset,
-                                     MCAuto<DataArrayInt>& idsLeftRight)
-{
-  const int *cdescPtr(mesh2DDesc->getNodalConnectivity()->begin()),*cidescPtr(mesh2DDesc->getNodalConnectivityIndex()->begin());
-  //
-  std::vector<int> allEdges;
-  std::vector< MCAuto<INTERP_KERNEL::Edge> > allEdgesPtr; // for each sub edge in splitMesh2D the uncut Edge object of the original mesh2D
-  for(const int *it(descBg);it!=descEnd;it++) // for all edges in the descending connectivity of the 2D mesh in relative Fortran mode
-    {
-      int edgeId(std::abs(*it)-1);
-      std::map< MCAuto<INTERP_KERNEL::Node>,int> m;
-      MCAuto<INTERP_KERNEL::Edge> ee(MEDCouplingUMeshBuildQPFromEdge2((INTERP_KERNEL::NormalizedCellType)cdescPtr[cidescPtr[edgeId]],cdescPtr+cidescPtr[edgeId]+1,mesh2DDesc->getCoords()->begin(),m));
-      const std::vector<int>& edge1(intersectEdge1[edgeId]);
-      if(*it>0)
-        allEdges.insert(allEdges.end(),edge1.begin(),edge1.end());
-      else
-        allEdges.insert(allEdges.end(),edge1.rbegin(),edge1.rend());
-      std::size_t sz(edge1.size());
-      for(std::size_t cnt=0;cnt<sz;cnt++)
-        allEdgesPtr.push_back(ee);
-    }
-  //
-  return BuildMesh2DCutInternal(eps,splitMesh1D,allEdges,allEdgesPtr,offset,idsLeftRight);
-}
-
-bool AreEdgeEqual(const double *coo2D, const INTERP_KERNEL::CellModel& typ1, const int *conn1, const INTERP_KERNEL::CellModel& typ2, const int *conn2, double eps)
-{
-  if(!typ1.isQuadratic() && !typ2.isQuadratic())
-    {//easy case comparison not
-      return conn1[0]==conn2[0] && conn1[1]==conn2[1];
-    }
-  else if(typ1.isQuadratic() && typ2.isQuadratic())
-    {
-      bool status0(conn1[0]==conn2[0] && conn1[1]==conn2[1]);
-      if(!status0)
-        return false;
-      if(conn1[2]==conn2[2])
-        return true;
-      const double *a(coo2D+2*conn1[2]),*b(coo2D+2*conn2[2]);
-      double dist(sqrt((a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1])));
-      return dist<eps;
-    }
-  else
-    {//only one is quadratic
-      bool status0(conn1[0]==conn2[0] && conn1[1]==conn2[1]);
-      if(!status0)
-        return false;
-      const double *a(0),*bb(0),*be(0);
-      if(typ1.isQuadratic())
-        {
-          a=coo2D+2*conn1[2]; bb=coo2D+2*conn2[0]; be=coo2D+2*conn2[1];
-        }
-      else
-        {
-          a=coo2D+2*conn2[2]; bb=coo2D+2*conn1[0]; be=coo2D+2*conn1[1];
-        }
-      double b[2]; b[0]=(be[0]+bb[0])/2.; b[1]=(be[1]+bb[1])/2.;
-      double dist(sqrt((a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1])));
-      return dist<eps;
-    }
-}
-
-/*!
- * This method returns among the cellIds [ \a candidatesIn2DBg , \a candidatesIn2DEnd ) in \a mesh2DSplit those exactly sharing \a cellIdInMesh1DSplitRelative in \a mesh1DSplit.
- * \a mesh2DSplit and \a mesh1DSplit are expected to share the coordinates array.
- *
- * \param [in] cellIdInMesh1DSplitRelative is in Fortran mode using sign to specify direction.
- */
-int FindRightCandidateAmong(const MEDCouplingUMesh *mesh2DSplit, const int *candidatesIn2DBg, const int *candidatesIn2DEnd, const MEDCouplingUMesh *mesh1DSplit, int cellIdInMesh1DSplitRelative, double eps)
-{
-  if(candidatesIn2DEnd==candidatesIn2DBg)
-    throw INTERP_KERNEL::Exception("FindRightCandidateAmong : internal error 1 !");
-  const double *coo(mesh2DSplit->getCoords()->begin());
-  if(std::distance(candidatesIn2DBg,candidatesIn2DEnd)==1)
-    return *candidatesIn2DBg;
-  int edgeId(std::abs(cellIdInMesh1DSplitRelative)-1);
-  MCAuto<MEDCouplingUMesh> cur1D(static_cast<MEDCouplingUMesh *>(mesh1DSplit->buildPartOfMySelf(&edgeId,&edgeId+1,true)));
-  if(cellIdInMesh1DSplitRelative<0)
-    cur1D->changeOrientationOfCells();
-  const int *c1D(cur1D->getNodalConnectivity()->begin());
-  const INTERP_KERNEL::CellModel& ref1DType(INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)c1D[0]));
-  for(const int *it=candidatesIn2DBg;it!=candidatesIn2DEnd;it++)
-    {
-      MCAuto<MEDCouplingUMesh> cur2D(static_cast<MEDCouplingUMesh *>(mesh2DSplit->buildPartOfMySelf(it,it+1,true)));
-      const int *c(cur2D->getNodalConnectivity()->begin()),*ci(cur2D->getNodalConnectivityIndex()->begin());
-      const INTERP_KERNEL::CellModel &cm(INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)c[ci[0]]));
-      unsigned sz(cm.getNumberOfSons2(c+ci[0]+1,ci[1]-ci[0]-1));
-      INTERP_KERNEL::AutoPtr<int> tmpPtr(new int[ci[1]-ci[0]]);
-      for(unsigned it2=0;it2<sz;it2++)
-        {
-          INTERP_KERNEL::NormalizedCellType typeOfSon;
-          cm.fillSonCellNodalConnectivity2(it2,c+ci[0]+1,ci[1]-ci[0]-1,tmpPtr,typeOfSon);
-          const INTERP_KERNEL::CellModel &curCM(INTERP_KERNEL::CellModel::GetCellModel(typeOfSon));
-          if(AreEdgeEqual(coo,ref1DType,c1D+1,curCM,tmpPtr,eps))
-            return *it;
-        }
-    }
-  throw INTERP_KERNEL::Exception("FindRightCandidateAmong : internal error 2 ! Unable to find the edge among split cell !");
-}
-
-/// @endcond
-
-/*!
- * Partitions the first given 2D mesh using the second given 1D mesh as a tool.
- * Thus the final result contains the aggregation of nodes of \a mesh2D, then nodes of \a mesh1D, then new nodes that are the result of the intersection
- * and finaly, in case of quadratic polygon the centers of edges new nodes.
- * The meshes should be in 2D space. In addition, returns two arrays mapping cells of the resulting mesh to cells of the input.
- *
- * \param [in] mesh2D - the 2D mesh (spacedim=meshdim=2) to be intersected using \a mesh1D tool. The mesh must be so that each point in the space covered by \a mesh2D
- *                      must be covered exactly by one entity, \b no \b more. If it is not the case, some tools are available to heal the mesh (conformize2D, mergeNodes)
- * \param [in] mesh1D - the 1D mesh (spacedim=2 meshdim=1) the is the tool that will be used to intersect \a mesh2D. \a mesh1D must be ordered consecutively. If it is not the case
- *                      you can invoke orderConsecutiveCells1D on \a mesh1D.
- * \param [in] eps - precision used to perform intersections and localization operations.
- * \param [out] splitMesh2D - the result of the split of \a mesh2D mesh.
- * \param [out] splitMesh1D - the result of the split of \a mesh1D mesh.
- * \param [out] cellIdInMesh2D - the array that gives for each cell id \a i in \a splitMesh2D the id in \a mesh2D it comes from.
- *                               So this array has a number of tuples equal to the number of cells of \a splitMesh2D and a number of component equal to 1.
- * \param [out] cellIdInMesh1D - the array of pair that gives for each cell id \a i in \a splitMesh1D the cell in \a splitMesh2D on the left for the 1st component
- *                               and the cell in \a splitMesh2D on the right for the 2nt component. -1 means no cell.
- *                               So this array has a number of tuples equal to the number of cells of \a splitMesh1D and a number of components equal to 2.
- *
- * \sa Intersect2DMeshes, orderConsecutiveCells1D, conformize2D, mergeNodes
- */
-void MEDCouplingUMesh::Intersect2DMeshWith1DLine(const MEDCouplingUMesh *mesh2D, const MEDCouplingUMesh *mesh1D, double eps, MEDCouplingUMesh *&splitMesh2D, MEDCouplingUMesh *&splitMesh1D, DataArrayInt *&cellIdInMesh2D, DataArrayInt *&cellIdInMesh1D)
-{
-  if(!mesh2D || !mesh1D)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::Intersect2DMeshWith1DLine : input meshes must be not NULL !");
-  mesh2D->checkFullyDefined();
-  mesh1D->checkFullyDefined();
-  const std::vector<std::string>& compNames(mesh2D->getCoords()->getInfoOnComponents());
-  if(mesh2D->getMeshDimension()!=2 || mesh2D->getSpaceDimension()!=2 || mesh1D->getMeshDimension()!=1 || mesh1D->getSpaceDimension()!=2)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::Intersect2DMeshWith1DLine works with mesh2D with spacedim=meshdim=2 and mesh1D with meshdim=1 spaceDim=2 !");
-  // Step 1: compute all edge intersections (new nodes)
-  std::vector< std::vector<int> > intersectEdge1, colinear2, subDiv2;
-  std::vector<double> addCoo,addCoordsQuadratic;  // coordinates of newly created nodes
-  INTERP_KERNEL::QUADRATIC_PLANAR::_precision=eps;
-  INTERP_KERNEL::QUADRATIC_PLANAR::_arc_detection_precision=eps;
-  //
-  // Build desc connectivity
-  DataArrayInt *desc1(DataArrayInt::New()),*descIndx1(DataArrayInt::New()),*revDesc1(DataArrayInt::New()),*revDescIndx1(DataArrayInt::New());
-  MCAuto<DataArrayInt> dd1(desc1),dd2(descIndx1),dd3(revDesc1),dd4(revDescIndx1);
-  MCAuto<MEDCouplingUMesh> m1Desc(mesh2D->buildDescendingConnectivity2(desc1,descIndx1,revDesc1,revDescIndx1));
-  std::map<int,int> mergedNodes;
-  Intersect1DMeshes(m1Desc,mesh1D,eps,intersectEdge1,colinear2,subDiv2,addCoo,mergedNodes);
-  // use mergeNodes to fix intersectEdge1
-  for(std::vector< std::vector<int> >::iterator it0=intersectEdge1.begin();it0!=intersectEdge1.end();it0++)
-    {
-      std::size_t n((*it0).size()/2);
-      int eltStart((*it0)[0]),eltEnd((*it0)[2*n-1]);
-      std::map<int,int>::const_iterator it1;
-      it1=mergedNodes.find(eltStart);
-      if(it1!=mergedNodes.end())
-        (*it0)[0]=(*it1).second;
-      it1=mergedNodes.find(eltEnd);
-      if(it1!=mergedNodes.end())
-        (*it0)[2*n-1]=(*it1).second;
-    }
-  //
-  MCAuto<DataArrayDouble> addCooDa(DataArrayDouble::New());
-  addCooDa->useArray(&addCoo[0],false,C_DEALLOC,(int)addCoo.size()/2,2);
-  // Step 2: re-order newly created nodes according to the ordering found in m2
-  std::vector< std::vector<int> > intersectEdge2;
-  BuildIntersectEdges(m1Desc,mesh1D,addCoo,subDiv2,intersectEdge2);
-  subDiv2.clear();
-  // Step 3: compute splitMesh1D
-  MCAuto<DataArrayInt> idsInRet1Colinear,idsInDescMesh2DForIdsInRetColinear;
-  MCAuto<DataArrayInt> ret2(DataArrayInt::New()); ret2->alloc(0,1);
-  MCAuto<MEDCouplingUMesh> ret1(BuildMesh1DCutFrom(mesh1D,intersectEdge2,mesh2D->getCoords(),addCoo,mergedNodes,colinear2,intersectEdge1,
-      idsInRet1Colinear,idsInDescMesh2DForIdsInRetColinear));
-  MCAuto<DataArrayInt> ret3(DataArrayInt::New()); ret3->alloc(ret1->getNumberOfCells()*2,1); ret3->fillWithValue(std::numeric_limits<int>::max()); ret3->rearrange(2);
-  MCAuto<DataArrayInt> idsInRet1NotColinear(idsInRet1Colinear->buildComplement(ret1->getNumberOfCells()));
-  // deal with cells in mesh2D that are not cut but only some of their edges are
-  MCAuto<DataArrayInt> idsInDesc2DToBeRefined(idsInDescMesh2DForIdsInRetColinear->deepCopy());
-  idsInDesc2DToBeRefined->abs(); idsInDesc2DToBeRefined->applyLin(1,-1);
-  idsInDesc2DToBeRefined=idsInDesc2DToBeRefined->buildUnique();
-  MCAuto<DataArrayInt> out0s;//ids in mesh2D that are impacted by the fact that some edges of \a mesh1D are part of the edges of those cells
-  if(!idsInDesc2DToBeRefined->empty())
-    {
-      DataArrayInt *out0(0),*outi0(0);
-      MEDCouplingUMesh::ExtractFromIndexedArrays(idsInDesc2DToBeRefined->begin(),idsInDesc2DToBeRefined->end(),dd3,dd4,out0,outi0);
-      MCAuto<DataArrayInt> outi0s(outi0);
-      out0s=out0;
-      out0s=out0s->buildUnique();
-      out0s->sort(true);
-    }
-  //
-  MCAuto<MEDCouplingUMesh> ret1NonCol(static_cast<MEDCouplingUMesh *>(ret1->buildPartOfMySelf(idsInRet1NotColinear->begin(),idsInRet1NotColinear->end())));
-  MCAuto<DataArrayDouble> baryRet1(ret1NonCol->computeCellCenterOfMass());
-  MCAuto<DataArrayInt> elts,eltsIndex;
-  mesh2D->getCellsContainingPoints(baryRet1->begin(),baryRet1->getNumberOfTuples(),eps,elts,eltsIndex);
-  MCAuto<DataArrayInt> eltsIndex2(eltsIndex->deltaShiftIndex());
-  MCAuto<DataArrayInt> eltsIndex3(eltsIndex2->findIdsEqual(1));
-  if(eltsIndex2->count(0)+eltsIndex3->getNumberOfTuples()!=ret1NonCol->getNumberOfCells())
-    throw INTERP_KERNEL::Exception("Intersect2DMeshWith1DLine : internal error 1 !");
-  MCAuto<DataArrayInt> cellsToBeModified(elts->buildUnique());
-  MCAuto<DataArrayInt> untouchedCells(cellsToBeModified->buildComplement(mesh2D->getNumberOfCells()));
-  if((DataArrayInt *)out0s)
-    untouchedCells=untouchedCells->buildSubstraction(out0s);//if some edges in ret1 are colinear to descending mesh of mesh2D remove cells from untouched one
-  std::vector< MCAuto<MEDCouplingUMesh> > outMesh2DSplit;
-  // OK all is ready to insert in ret2 mesh
-  if(!untouchedCells->empty())
-    {// the most easy part, cells in mesh2D not impacted at all
-      outMesh2DSplit.push_back(static_cast<MEDCouplingUMesh *>(mesh2D->buildPartOfMySelf(untouchedCells->begin(),untouchedCells->end())));
-      outMesh2DSplit.back()->setCoords(ret1->getCoords());
-      ret2->pushBackValsSilent(untouchedCells->begin(),untouchedCells->end());
-    }
-  if((DataArrayInt *)out0s)
-    {// here dealing with cells in out0s but not in cellsToBeModified
-      MCAuto<DataArrayInt> fewModifiedCells(out0s->buildSubstraction(cellsToBeModified));
-      const int *rdptr(dd3->begin()),*rdiptr(dd4->begin()),*dptr(dd1->begin()),*diptr(dd2->begin());
-      for(const int *it=fewModifiedCells->begin();it!=fewModifiedCells->end();it++)
-        {
-          outMesh2DSplit.push_back(BuildRefined2DCell(ret1->getCoords(),mesh2D,*it,dptr+diptr[*it],dptr+diptr[*it+1],intersectEdge1));
-          ret1->setCoords(outMesh2DSplit.back()->getCoords());
-        }
-      int offset(ret2->getNumberOfTuples());
-      ret2->pushBackValsSilent(fewModifiedCells->begin(),fewModifiedCells->end());
-      MCAuto<DataArrayInt> partOfRet3(DataArrayInt::New()); partOfRet3->alloc(2*idsInRet1Colinear->getNumberOfTuples(),1);
-      partOfRet3->fillWithValue(std::numeric_limits<int>::max()); partOfRet3->rearrange(2);
-      int kk(0),*ret3ptr(partOfRet3->getPointer());
-      for(const int *it=idsInDescMesh2DForIdsInRetColinear->begin();it!=idsInDescMesh2DForIdsInRetColinear->end();it++,kk++)
-        {
-          int faceId(std::abs(*it)-1);
-          for(const int *it2=rdptr+rdiptr[faceId];it2!=rdptr+rdiptr[faceId+1];it2++)
-            {
-              int tmp(fewModifiedCells->findIdFirstEqual(*it2));
-              if(tmp!=-1)
-                {
-                  if(std::find(dptr+diptr[*it2],dptr+diptr[*it2+1],-(*it))!=dptr+diptr[*it2+1])
-                    ret3ptr[2*kk]=tmp+offset;
-                  if(std::find(dptr+diptr[*it2],dptr+diptr[*it2+1],(*it))!=dptr+diptr[*it2+1])
-                    ret3ptr[2*kk+1]=tmp+offset;
-                }
-              else
-                {//the current edge is shared by a 2D cell that will be split just after
-                  if(std::find(dptr+diptr[*it2],dptr+diptr[*it2+1],-(*it))!=dptr+diptr[*it2+1])
-                    ret3ptr[2*kk]=-(*it2+1);
-                  if(std::find(dptr+diptr[*it2],dptr+diptr[*it2+1],(*it))!=dptr+diptr[*it2+1])
-                    ret3ptr[2*kk+1]=-(*it2+1);
-                }
-            }
-        }
-      m1Desc->setCoords(ret1->getCoords());
-      ret1NonCol->setCoords(ret1->getCoords());
-      ret3->setPartOfValues3(partOfRet3,idsInRet1Colinear->begin(),idsInRet1Colinear->end(),0,2,1,true);
-      if(!outMesh2DSplit.empty())
-        {
-          DataArrayDouble *da(outMesh2DSplit.back()->getCoords());
-          for(std::vector< MCAuto<MEDCouplingUMesh> >::iterator itt=outMesh2DSplit.begin();itt!=outMesh2DSplit.end();itt++)
-            (*itt)->setCoords(da);
-        }
-    }
-  cellsToBeModified=cellsToBeModified->buildUniqueNotSorted();
-  for(const int *it=cellsToBeModified->begin();it!=cellsToBeModified->end();it++)
-    {
-      MCAuto<DataArrayInt> idsNonColPerCell(elts->findIdsEqual(*it));
-      idsNonColPerCell->transformWithIndArr(eltsIndex3->begin(),eltsIndex3->end());
-      MCAuto<DataArrayInt> idsNonColPerCell2(idsInRet1NotColinear->selectByTupleId(idsNonColPerCell->begin(),idsNonColPerCell->end()));
-      MCAuto<MEDCouplingUMesh> partOfMesh1CuttingCur2DCell(static_cast<MEDCouplingUMesh *>(ret1NonCol->buildPartOfMySelf(idsNonColPerCell->begin(),idsNonColPerCell->end())));
-      MCAuto<DataArrayInt> partOfRet3;
-      MCAuto<MEDCouplingUMesh> splitOfOneCell(BuildMesh2DCutFrom(eps,*it,m1Desc,partOfMesh1CuttingCur2DCell,dd1->begin()+dd2->getIJ(*it,0),dd1->begin()+dd2->getIJ((*it)+1,0),intersectEdge1,ret2->getNumberOfTuples(),partOfRet3));
-      ret3->setPartOfValues3(partOfRet3,idsNonColPerCell2->begin(),idsNonColPerCell2->end(),0,2,1,true);
-      outMesh2DSplit.push_back(splitOfOneCell);
-      for(int i=0;i<splitOfOneCell->getNumberOfCells();i++)
-        ret2->pushBackSilent(*it);
-    }
-  //
-  std::size_t nbOfMeshes(outMesh2DSplit.size());
-  std::vector<const MEDCouplingUMesh *> tmp(nbOfMeshes);
-  for(std::size_t i=0;i<nbOfMeshes;i++)
-    tmp[i]=outMesh2DSplit[i];
-  //
-  ret1->getCoords()->setInfoOnComponents(compNames);
-  MCAuto<MEDCouplingUMesh> ret2D(MEDCouplingUMesh::MergeUMeshesOnSameCoords(tmp));
-  // To finish - filter ret3 - std::numeric_limits<int>::max() -> -1 - negate values must be resolved.
-  ret3->rearrange(1);
-  MCAuto<DataArrayInt> edgesToDealWith(ret3->findIdsStricltyNegative());
-  for(const int *it=edgesToDealWith->begin();it!=edgesToDealWith->end();it++)
-    {
-      int old2DCellId(-ret3->getIJ(*it,0)-1);
-      MCAuto<DataArrayInt> candidates(ret2->findIdsEqual(old2DCellId));
-      ret3->setIJ(*it,0,FindRightCandidateAmong(ret2D,candidates->begin(),candidates->end(),ret1,*it%2==0?-((*it)/2+1):(*it)/2+1,eps));// div by 2 because 2 components natively in ret3
-    }
-  ret3->changeValue(std::numeric_limits<int>::max(),-1);
-  ret3->rearrange(2);
-  //
-  splitMesh1D=ret1.retn();
-  splitMesh2D=ret2D.retn();
-  cellIdInMesh2D=ret2.retn();
-  cellIdInMesh1D=ret3.retn();
-}
-
-/**
- * Private. Third step of the partitioning algorithm (Intersect2DMeshes): reconstruct full 2D cells from the
- * (newly created) nodes corresponding to the edge intersections.
- * Output params:
- * @param[out] cr, crI connectivity of the resulting mesh
- * @param[out] cNb1, cNb2 correspondance arrays giving for the merged mesh the initial cells IDs in m1 / m2
- * TODO: describe input parameters
- */
-void MEDCouplingUMesh::BuildIntersecting2DCellsFromEdges(double eps, const MEDCouplingUMesh *m1, const int *desc1, const int *descIndx1,
-                                                         const std::vector<std::vector<int> >& intesctEdges1, const std::vector< std::vector<int> >& colinear2,
-                                                         const MEDCouplingUMesh *m2, const int *desc2, const int *descIndx2, const std::vector<std::vector<int> >& intesctEdges2,
-                                                         const std::vector<double>& addCoords,
-                                                         std::vector<double>& addCoordsQuadratic, std::vector<int>& cr, std::vector<int>& crI, std::vector<int>& cNb1, std::vector<int>& cNb2)
-{
-  static const int SPACEDIM=2;
-  const double *coo1(m1->getCoords()->begin());
-  const int *conn1(m1->getNodalConnectivity()->begin()),*connI1(m1->getNodalConnectivityIndex()->begin());
-  int offset1(m1->getNumberOfNodes());
-  const double *coo2(m2->getCoords()->begin());
-  const int *conn2(m2->getNodalConnectivity()->begin()),*connI2(m2->getNodalConnectivityIndex()->begin());
-  int offset2(offset1+m2->getNumberOfNodes());
-  int offset3(offset2+((int)addCoords.size())/2);
-  MCAuto<DataArrayDouble> bbox1Arr(m1->getBoundingBoxForBBTree()),bbox2Arr(m2->getBoundingBoxForBBTree());
-  const double *bbox1(bbox1Arr->begin()),*bbox2(bbox2Arr->begin());
-  // Here a BBTree on 2D-cells, not on segments:
-  BBTree<SPACEDIM,int> myTree(bbox2,0,0,m2->getNumberOfCells(),eps);
-  int ncell1(m1->getNumberOfCells());
-  crI.push_back(0);
-  for(int i=0;i<ncell1;i++)
-    {
-      std::vector<int> candidates2;
-      myTree.getIntersectingElems(bbox1+i*2*SPACEDIM,candidates2);
-      std::map<INTERP_KERNEL::Node *,int> mapp;
-      std::map<int,INTERP_KERNEL::Node *> mappRev;
-      INTERP_KERNEL::QuadraticPolygon pol1;
-      INTERP_KERNEL::NormalizedCellType typ=(INTERP_KERNEL::NormalizedCellType)conn1[connI1[i]];
-      const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
-      // Populate mapp and mappRev with nodes from the current cell (i) from mesh1 - this also builds the Node* objects:
-      MEDCouplingUMeshBuildQPFromMesh3(coo1,offset1,coo2,offset2,addCoords,desc1+descIndx1[i],desc1+descIndx1[i+1],intesctEdges1,/* output */mapp,mappRev);
-      // pol1 is the full cell from mesh2, in QP format, with all the additional intersecting nodes.
-      pol1.buildFromCrudeDataArray(mappRev,cm.isQuadratic(),conn1+connI1[i]+1,coo1,
-          desc1+descIndx1[i],desc1+descIndx1[i+1],intesctEdges1);
-      //
-      std::set<INTERP_KERNEL::Edge *> edges1;// store all edges of pol1 that are NOT consumed by intersect cells. If any after iteration over candidates2 -> a part of pol1 should appear in result
-      std::set<INTERP_KERNEL::Edge *> edgesBoundary2;// store all edges that are on boundary of (pol2 intersect pol1) minus edges on pol1.
-      INTERP_KERNEL::IteratorOnComposedEdge it1(&pol1);
-      for(it1.first();!it1.finished();it1.next())
-        edges1.insert(it1.current()->getPtr());
-      //
-      std::map<int,std::vector<INTERP_KERNEL::ElementaryEdge *> > edgesIn2ForShare; // common edges
-      std::vector<INTERP_KERNEL::QuadraticPolygon> pol2s(candidates2.size());
-      int ii=0;
-      for(std::vector<int>::const_iterator it2=candidates2.begin();it2!=candidates2.end();it2++,ii++)
-        {
-          INTERP_KERNEL::NormalizedCellType typ2=(INTERP_KERNEL::NormalizedCellType)conn2[connI2[*it2]];
-          const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel(typ2);
-          // Complete mapping with elements coming from the current cell it2 in mesh2:
-          MEDCouplingUMeshBuildQPFromMesh3(coo1,offset1,coo2,offset2,addCoords,desc2+descIndx2[*it2],desc2+descIndx2[*it2+1],intesctEdges2,/* output */mapp,mappRev);
-          // pol2 is the new QP in the final merged result.
-          pol2s[ii].buildFromCrudeDataArray2(mappRev,cm2.isQuadratic(),conn2+connI2[*it2]+1,coo2,desc2+descIndx2[*it2],desc2+descIndx2[*it2+1],intesctEdges2,
-              pol1,desc1+descIndx1[i],desc1+descIndx1[i+1],intesctEdges1,colinear2, /* output */ edgesIn2ForShare);
-        }
-      ii=0;
-      for(std::vector<int>::const_iterator it2=candidates2.begin();it2!=candidates2.end();it2++,ii++)
-        {
-          INTERP_KERNEL::ComposedEdge::InitLocationsWithOther(pol1,pol2s[ii]);
-          pol2s[ii].updateLocOfEdgeFromCrudeDataArray2(desc2+descIndx2[*it2],desc2+descIndx2[*it2+1],intesctEdges2,pol1,desc1+descIndx1[i],desc1+descIndx1[i+1],intesctEdges1,colinear2);
-          //MEDCouplingUMeshAssignOnLoc(pol1,pol2,desc1+descIndx1[i],desc1+descIndx1[i+1],intesctEdges1,desc2+descIndx2[*it2],desc2+descIndx2[*it2+1],intesctEdges2,colinear2);
-          pol1.buildPartitionsAbs(pol2s[ii],edges1,edgesBoundary2,mapp,i,*it2,offset3,addCoordsQuadratic,cr,crI,cNb1,cNb2);
-        }
-      // Deals with remaining (non-consumed) edges from m1: these are the edges that were never touched
-      // by m2 but that we still want to keep in the final result.
-      if(!edges1.empty())
-        {
-          try
-          {
-              INTERP_KERNEL::QuadraticPolygon::ComputeResidual(pol1,edges1,edgesBoundary2,mapp,offset3,i,addCoordsQuadratic,cr,crI,cNb1,cNb2);
-          }
-          catch(INTERP_KERNEL::Exception& e)
-          {
-              std::ostringstream oss; oss << "Error when computing residual of cell #" << i << " in source/m1 mesh ! Maybe the neighbours of this cell in mesh are not well connected !\n" << "The deep reason is the following : " << e.what();
-              throw INTERP_KERNEL::Exception(oss.str());
-          }
-        }
-      for(std::map<int,INTERP_KERNEL::Node *>::const_iterator it=mappRev.begin();it!=mappRev.end();it++)
-        (*it).second->decrRef();
-    }
-}
-
-/**
- * Provides a renumbering of the cells of this (which has to be a piecewise connected 1D line), so that
- * the segments of the line are indexed in consecutive order (i.e. cells \a i and \a i+1 are neighbors).
- * This doesn't modify the mesh. This method only works using nodal connectivity consideration. Coordinates of nodes are ignored here.
- * The caller is to deal with the resulting DataArrayInt.
- *  \throw If the coordinate array is not set.
- *  \throw If the nodal connectivity of the cells is not defined.
- *  \throw If m1 is not a mesh of dimension 2, or m1 is not a mesh of dimension 1
- *  \throw If m2 is not a (piecewise) line (i.e. if a point has more than 2 adjacent segments)
- *
- * \sa DataArrayInt::sortEachPairToMakeALinkedList
- */
-DataArrayInt *MEDCouplingUMesh::orderConsecutiveCells1D() const
-{
-  checkFullyDefined();
-  if(getMeshDimension()!=1)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::orderConsecutiveCells1D works on unstructured mesh with meshdim = 1 !");
-
-  // Check that this is a line (and not a more complex 1D mesh) - each point is used at most by 2 segments:
-  MCAuto<DataArrayInt> _d(DataArrayInt::New()),_dI(DataArrayInt::New());
-  MCAuto<DataArrayInt> _rD(DataArrayInt::New()),_rDI(DataArrayInt::New());
-  MCAuto<MEDCouplingUMesh> m_points(buildDescendingConnectivity(_d, _dI, _rD, _rDI));
-  const int *d(_d->begin()), *dI(_dI->begin());
-  const int *rD(_rD->begin()), *rDI(_rDI->begin());
-  MCAuto<DataArrayInt> _dsi(_rDI->deltaShiftIndex());
-  const int * dsi(_dsi->begin());
-  MCAuto<DataArrayInt> dsii = _dsi->findIdsNotInRange(0,3);
-  m_points=0;
-  if (dsii->getNumberOfTuples())
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::orderConsecutiveCells1D only work with a mesh being a (piecewise) connected line!");
-
-  int nc(getNumberOfCells());
-  MCAuto<DataArrayInt> result(DataArrayInt::New());
-  result->alloc(nc,1);
-
-  // set of edges not used so far
-  std::set<int> edgeSet;
-  for (int i=0; i<nc; edgeSet.insert(i), i++);
-
-  int startSeg=0;
-  int newIdx=0;
-  // while we have points with only one neighbor segments
-  do
-    {
-      std::list<int> linePiece;
-      // fills a list of consecutive segment linked to startSeg. This can go forward or backward.
-      for (int direction=0;direction<2;direction++) // direction=0 --> forward, direction=1 --> backward
-        {
-          // Fill the list forward (resp. backward) from the start segment:
-          int activeSeg = startSeg;
-          int prevPointId = -20;
-          int ptId;
-          while (!edgeSet.empty())
-            {
-              if (!(direction == 1 && prevPointId==-20)) // prevent adding twice startSeg
-                {
-                  if (direction==0)
-                    linePiece.push_back(activeSeg);
-                  else
-                    linePiece.push_front(activeSeg);
-                  edgeSet.erase(activeSeg);
-                }
-
-              int ptId1 = d[dI[activeSeg]], ptId2 = d[dI[activeSeg]+1];
-              ptId = direction ? (ptId1 == prevPointId ? ptId2 : ptId1) : (ptId2 == prevPointId ? ptId1 : ptId2);
-              if (dsi[ptId] == 1) // hitting the end of the line
-                break;
-              prevPointId = ptId;
-              int seg1 = rD[rDI[ptId]], seg2 = rD[rDI[ptId]+1];
-              activeSeg = (seg1 == activeSeg) ? seg2 : seg1;
-            }
-        }
-      // Done, save final piece into DA:
-      std::copy(linePiece.begin(), linePiece.end(), result->getPointer()+newIdx);
-      newIdx += linePiece.size();
-
-      // identify next valid start segment (one which is not consumed)
-      if(!edgeSet.empty())
-        startSeg = *(edgeSet.begin());
-    }
-  while (!edgeSet.empty());
-  return result.retn();
-}
-
-/// @cond INTERNAL
-
-void IKGeo2DInternalMapper2(INTERP_KERNEL::Node *n, const std::map<MCAuto<INTERP_KERNEL::Node>,int>& m, int forbVal0, int forbVal1, std::vector<int>& isect)
-{
-  MCAuto<INTERP_KERNEL::Node> nTmp(n); nTmp->incrRef();
-  std::map<MCAuto<INTERP_KERNEL::Node>,int>::const_iterator it(m.find(nTmp));
-  if(it==m.end())
-    throw INTERP_KERNEL::Exception("Internal error in remapping !");
-  int v((*it).second);
-  if(v==forbVal0 || v==forbVal1)
-    return ;
-  if(std::find(isect.begin(),isect.end(),v)==isect.end())
-    isect.push_back(v);
-}
-
-bool IKGeo2DInternalMapper(const INTERP_KERNEL::ComposedEdge& c, const std::map<MCAuto<INTERP_KERNEL::Node>,int>& m, int forbVal0, int forbVal1, std::vector<int>& isect)
-{
-  int sz(c.size());
-  if(sz<=1)
-    return false;
-  bool presenceOfOn(false);
-  for(int i=0;i<sz;i++)
-    {
-      INTERP_KERNEL::ElementaryEdge *e(c[i]);
-      if(e->getLoc()!=INTERP_KERNEL::FULL_ON_1)
-        continue ;
-      IKGeo2DInternalMapper2(e->getStartNode(),m,forbVal0,forbVal1,isect);
-      IKGeo2DInternalMapper2(e->getEndNode(),m,forbVal0,forbVal1,isect);
-    }
-  return presenceOfOn;
-}
-
-/// @endcond
-
-/**
- * This method split some of edges of 2D cells in \a this. The edges to be split are specified in \a subNodesInSeg
- * and in \a subNodesInSegI using \ref numbering-indirect storage mode.
- * To do the work this method can optionally needs information about middle of subedges for quadratic cases if
- * a minimal creation of new nodes is wanted.
- * So this method try to reduce at most the number of new nodes. The only case that can lead this method to add
- * nodes if a SEG3 is split without information of middle.
- * \b WARNING : is returned value is different from 0 a call to MEDCouplingUMesh::mergeNodes is necessary to
- * avoid to have a non conform mesh.
- *
- * \return int - the number of new nodes created (in most of cases 0).
- * 
- * \throw If \a this is not coherent.
- * \throw If \a this has not spaceDim equal to 2.
- * \throw If \a this has not meshDim equal to 2.
- * \throw If some subcells needed to be split are orphan.
- * \sa MEDCouplingUMesh::conformize2D
- */
-int MEDCouplingUMesh::split2DCells(const DataArrayInt *desc, const DataArrayInt *descI, const DataArrayInt *subNodesInSeg, const DataArrayInt *subNodesInSegI, const DataArrayInt *midOpt, const DataArrayInt *midOptI)
-{
-  if(!desc || !descI || !subNodesInSeg || !subNodesInSegI)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::split2DCells : the 4 first arrays must be not null !");
-  desc->checkAllocated(); descI->checkAllocated(); subNodesInSeg->checkAllocated(); subNodesInSegI->checkAllocated();
-  if(getSpaceDimension()!=2 || getMeshDimension()!=2)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::split2DCells : This method only works for meshes with spaceDim=2 and meshDim=2 !");
-  if(midOpt==0 && midOptI==0)
-    {
-      split2DCellsLinear(desc,descI,subNodesInSeg,subNodesInSegI);
-      return 0;
-    }
-  else if(midOpt!=0 && midOptI!=0)
-    return split2DCellsQuadratic(desc,descI,subNodesInSeg,subNodesInSegI,midOpt,midOptI);
-  else
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::split2DCells : middle parameters must be set to null for all or not null for all.");
-}
-
-/*!
- * \b WARNING this method is \b potentially \b non \b const (if returned array is empty).
- * \b WARNING this method lead to have a non geometric type sorted mesh (for MED file users) !
- * This method performs a conformization of \b this. So if a edge in \a this can be split into entire edges in \a this this method
- * will suppress such edges to use sub edges in \a this. So this method does not add nodes in \a this if merged edges are both linear (INTERP_KERNEL::NORM_SEG2).
- * In the other cases new nodes can be created. If any are created, they will be appended at the end of the coordinates object before the invokation of this method.
- * 
- * Whatever the returned value, this method does not alter the order of cells in \a this neither the orientation of cells.
- * The modified cells, if any, are systematically declared as NORM_POLYGON or NORM_QPOLYG depending on the initial quadraticness of geometric type.
- *
- * This method expects that \b this has a meshDim equal 2 and spaceDim equal to 2 too.
- * This method expects that all nodes in \a this are not closer than \a eps.
- * If it is not the case you can invoke MEDCouplingUMesh::mergeNodes before calling this method.
- * 
- * \param [in] eps the relative error to detect merged edges.
- * \return DataArrayInt  * - The list of cellIds in \a this that have been subdivided. If empty, nothing changed in \a this (as if it were a const method). The array is a newly allocated array
- *                           that the user is expected to deal with.
- *
- * \throw If \a this is not coherent.
- * \throw If \a this has not spaceDim equal to 2.
- * \throw If \a this has not meshDim equal to 2.
- * \sa MEDCouplingUMesh::mergeNodes, MEDCouplingUMesh::split2DCells
- */
-DataArrayInt *MEDCouplingUMesh::conformize2D(double eps)
-{
-  static const int SPACEDIM=2;
-  checkConsistencyLight();
-  if(getSpaceDimension()!=2 || getMeshDimension()!=2)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::conformize2D : This method only works for meshes with spaceDim=2 and meshDim=2 !");
-  MCAuto<DataArrayInt> desc1(DataArrayInt::New()),descIndx1(DataArrayInt::New()),revDesc1(DataArrayInt::New()),revDescIndx1(DataArrayInt::New());
-  MCAuto<MEDCouplingUMesh> mDesc(buildDescendingConnectivity(desc1,descIndx1,revDesc1,revDescIndx1));
-  const int *c(mDesc->getNodalConnectivity()->begin()),*ci(mDesc->getNodalConnectivityIndex()->begin()),*rd(revDesc1->begin()),*rdi(revDescIndx1->begin());
-  MCAuto<DataArrayDouble> bboxArr(mDesc->getBoundingBoxForBBTree());
-  const double *bbox(bboxArr->begin()),*coords(getCoords()->begin());
-  int nCell(getNumberOfCells()),nDescCell(mDesc->getNumberOfCells());
-  std::vector< std::vector<int> > intersectEdge(nDescCell),overlapEdge(nDescCell);
-  std::vector<double> addCoo;
-  BBTree<SPACEDIM,int> myTree(bbox,0,0,nDescCell,-eps);
-  INTERP_KERNEL::QUADRATIC_PLANAR::_precision=eps;
-  INTERP_KERNEL::QUADRATIC_PLANAR::_arc_detection_precision=eps;
-  for(int i=0;i<nDescCell;i++)
-    {
-      std::vector<int> candidates;
-      myTree.getIntersectingElems(bbox+i*2*SPACEDIM,candidates);
-      for(std::vector<int>::const_iterator it=candidates.begin();it!=candidates.end();it++)
-        if(*it>i)
-          {
-            std::map<MCAuto<INTERP_KERNEL::Node>,int> m;
-            INTERP_KERNEL::Edge *e1(MEDCouplingUMeshBuildQPFromEdge2((INTERP_KERNEL::NormalizedCellType)c[ci[i]],c+ci[i]+1,coords,m)),
-                *e2(MEDCouplingUMeshBuildQPFromEdge2((INTERP_KERNEL::NormalizedCellType)c[ci[*it]],c+ci[*it]+1,coords,m));
-            INTERP_KERNEL::MergePoints merge;
-            INTERP_KERNEL::QuadraticPolygon c1,c2;
-            e1->intersectWith(e2,merge,c1,c2);
-            e1->decrRef(); e2->decrRef();
-            if(IKGeo2DInternalMapper(c1,m,c[ci[i]+1],c[ci[i]+2],intersectEdge[i]))
-              overlapEdge[i].push_back(*it);
-            if(IKGeo2DInternalMapper(c2,m,c[ci[*it]+1],c[ci[*it]+2],intersectEdge[*it]))
-              overlapEdge[*it].push_back(i);
-          }
-    }
-  // splitting done. sort intersect point in intersectEdge.
-  std::vector< std::vector<int> > middle(nDescCell);
-  int nbOf2DCellsToBeSplit(0);
-  bool middleNeedsToBeUsed(false);
-  std::vector<bool> cells2DToTreat(nDescCell,false);
-  for(int i=0;i<nDescCell;i++)
-    {
-      std::vector<int>& isect(intersectEdge[i]);
-      int sz((int)isect.size());
-      if(sz>1)
-        {
-          std::map<MCAuto<INTERP_KERNEL::Node>,int> m;
-          INTERP_KERNEL::Edge *e(MEDCouplingUMeshBuildQPFromEdge2((INTERP_KERNEL::NormalizedCellType)c[ci[i]],c+ci[i]+1,coords,m));
-          e->sortSubNodesAbs(coords,isect);
-          e->decrRef();
-        }
-      if(sz!=0)
-        {
-          int idx0(rdi[i]),idx1(rdi[i+1]);
-          if(idx1-idx0!=1)
-            throw INTERP_KERNEL::Exception("MEDCouplingUMesh::conformize2D : internal error #0 !");
-          if(!cells2DToTreat[rd[idx0]])
-            {
-              cells2DToTreat[rd[idx0]]=true;
-              nbOf2DCellsToBeSplit++;
-            }
-          // try to reuse at most eventual 'middle' of SEG3
-          std::vector<int>& mid(middle[i]);
-          mid.resize(sz+1,-1);
-          if((INTERP_KERNEL::NormalizedCellType)c[ci[i]]==INTERP_KERNEL::NORM_SEG3)
-            {
-              middleNeedsToBeUsed=true;
-              const std::vector<int>& candidates(overlapEdge[i]);
-              std::vector<int> trueCandidates;
-              for(std::vector<int>::const_iterator itc=candidates.begin();itc!=candidates.end();itc++)
-                if((INTERP_KERNEL::NormalizedCellType)c[ci[*itc]]==INTERP_KERNEL::NORM_SEG3)
-                  trueCandidates.push_back(*itc);
-              int stNode(c[ci[i]+1]),endNode(isect[0]);
-              for(int j=0;j<sz+1;j++)
-                {
-                  for(std::vector<int>::const_iterator itc=trueCandidates.begin();itc!=trueCandidates.end();itc++)
-                    {
-                      int tmpSt(c[ci[*itc]+1]),tmpEnd(c[ci[*itc]+2]);
-                      if((tmpSt==stNode && tmpEnd==endNode) || (tmpSt==endNode && tmpEnd==stNode))
-                        { mid[j]=*itc; break; }
-                    }
-                  stNode=endNode;
-                  endNode=j<sz-1?isect[j+1]:c[ci[i]+2];
-                }
-            }
-        }
-    }
-  MCAuto<DataArrayInt> ret(DataArrayInt::New()),notRet(DataArrayInt::New()); ret->alloc(nbOf2DCellsToBeSplit,1);
-  if(nbOf2DCellsToBeSplit==0)
-    return ret.retn();
-  //
-  int *retPtr(ret->getPointer());
-  for(int i=0;i<nCell;i++)
-    if(cells2DToTreat[i])
-      *retPtr++=i;
-  //
-  MCAuto<DataArrayInt> mSafe,nSafe,oSafe,pSafe,qSafe,rSafe;
-  DataArrayInt *m(0),*n(0),*o(0),*p(0),*q(0),*r(0);
-  MEDCouplingUMesh::ExtractFromIndexedArrays(ret->begin(),ret->end(),desc1,descIndx1,m,n); mSafe=m; nSafe=n;
-  DataArrayInt::PutIntoToSkylineFrmt(intersectEdge,o,p); oSafe=o; pSafe=p;
-  if(middleNeedsToBeUsed)
-    { DataArrayInt::PutIntoToSkylineFrmt(middle,q,r); qSafe=q; rSafe=r; }
-  MCAuto<MEDCouplingUMesh> modif(static_cast<MEDCouplingUMesh *>(buildPartOfMySelf(ret->begin(),ret->end(),true)));
-  int nbOfNodesCreated(modif->split2DCells(mSafe,nSafe,oSafe,pSafe,qSafe,rSafe));
-  setCoords(modif->getCoords());//if nbOfNodesCreated==0 modif and this have the same coordinates pointer so this line has no effect. But for quadratic cases this line is important.
-  setPartOfMySelf(ret->begin(),ret->end(),*modif);
-  {
-    bool areNodesMerged; int newNbOfNodes;
-    if(nbOfNodesCreated!=0)
-      MCAuto<DataArrayInt> tmp(mergeNodes(eps,areNodesMerged,newNbOfNodes));
-  }
-  return ret.retn();
-}
-
-/*!
- * This non const method works on 2D mesh. This method scans every cell in \a this and look if each edge constituting this cell is not mergeable with neighbors edges of that cell.
- * If yes, the cell is "repaired" to minimize at most its number of edges. So this method do not change the overall shape of cells in \a this (with eps precision).
- * This method do not take care of shared edges between cells, so this method can lead to a non conform mesh (\a this). If a conform mesh is required you're expected
- * to invoke MEDCouplingUMesh::mergeNodes and MEDCouplingUMesh::conformize2D right after this call.
- * This method works on any 2D geometric types of cell (even static one). If a cell is touched its type becomes dynamic automaticaly. For 2D "repaired" quadratic cells
- * new nodes for center of merged edges is are systematically created and appended at the end of the previously existing nodes.
- *
- * If the returned array is empty it means that nothing has changed in \a this (as if it were a const method). If the array is not empty the connectivity of \a this is modified
- * using new instance, idem for coordinates.
- *
- * If \a this is constituted by only linear 2D cells, this method is close to the computation of the convex hull of each cells in \a this.
- * 
- * \return DataArrayInt  * - The list of cellIds in \a this that have at least one edge colinearized.
- *
- * \throw If \a this is not coherent.
- * \throw If \a this has not spaceDim equal to 2.
- * \throw If \a this has not meshDim equal to 2.
- * 
- * \sa MEDCouplingUMesh::conformize2D, MEDCouplingUMesh::mergeNodes, MEDCouplingUMesh::convexEnvelop2D.
- */
-DataArrayInt *MEDCouplingUMesh::colinearize2D(double eps)
-{
-  MCAuto<DataArrayInt> ret(DataArrayInt::New()); ret->alloc(0,1);
-  checkConsistencyLight();
-  if(getSpaceDimension()!=2 || getMeshDimension()!=2)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::colinearize2D : This method only works for meshes with spaceDim=2 and meshDim=2 !");
-  INTERP_KERNEL::QUADRATIC_PLANAR::_arc_detection_precision=eps;
-  INTERP_KERNEL::QUADRATIC_PLANAR::_precision=eps;
-  int nbOfCells(getNumberOfCells()),nbOfNodes(getNumberOfNodes());
-  const int *cptr(_nodal_connec->begin()),*ciptr(_nodal_connec_index->begin());
-  MCAuto<DataArrayInt> newc(DataArrayInt::New()),newci(DataArrayInt::New()); newci->alloc(nbOfCells+1,1); newc->alloc(0,1); newci->setIJ(0,0,0);
-  MCAuto<DataArrayDouble> appendedCoords(DataArrayDouble::New()); appendedCoords->alloc(0,1);//1 not 2 it is not a bug.
-  const double *coords(_coords->begin());
-  int *newciptr(newci->getPointer());
-  for(int i=0;i<nbOfCells;i++,newciptr++,ciptr++)
-    {
-      if(Colinearize2DCell(coords,cptr+ciptr[0],cptr+ciptr[1],nbOfNodes,newc,appendedCoords))
-        ret->pushBackSilent(i);
-      newciptr[1]=newc->getNumberOfTuples();
-    }
-  //
-  if(ret->empty())
-    return ret.retn();
-  if(!appendedCoords->empty())
-    {
-      appendedCoords->rearrange(2);
-      MCAuto<DataArrayDouble> newCoords(DataArrayDouble::Aggregate(getCoords(),appendedCoords));//treat info on components
-      //non const part
-      setCoords(newCoords);
-    }
-  //non const part
-  setConnectivity(newc,newci,true);
-  return ret.retn();
-}
-
-/*!
- * \param [out] intersectEdge1 - for each cell in \a m1Desc returns the result of the split. The result is given using pair of int given resp start and stop.
- *                               So for all edge \a i in \a m1Desc \a  intersectEdge1[i] is of length 2*n where n is the number of sub edges.
- *                               And for each j in [1,n) intersect[i][2*(j-1)+1]==intersect[i][2*j].
- * \param [out] subDiv2 - for each cell in \a m2Desc returns nodes that split it using convention \a m1Desc first, then \a m2Desc, then addCoo
- * \param [out] colinear2 - for each cell in \a m2Desc returns the edges in \a m1Desc that are colinear to it.
- * \param [out] addCoo - nodes to be append at the end
- * \param [out] mergedNodes - gives all pair of nodes of \a m2Desc that have same location than some nodes in \a m1Desc. key is id in \a m2Desc offseted and value is id in \a m1Desc.
- */
-void MEDCouplingUMesh::Intersect1DMeshes(const MEDCouplingUMesh *m1Desc, const MEDCouplingUMesh *m2Desc, double eps,
-                                         std::vector< std::vector<int> >& intersectEdge1, std::vector< std::vector<int> >& colinear2, std::vector< std::vector<int> >& subDiv2, std::vector<double>& addCoo, std::map<int,int>& mergedNodes)
-{
-  static const int SPACEDIM=2;
-  INTERP_KERNEL::QUADRATIC_PLANAR::_precision=eps;
-  INTERP_KERNEL::QUADRATIC_PLANAR::_arc_detection_precision=eps;
-  const int *c1(m1Desc->getNodalConnectivity()->begin()),*ci1(m1Desc->getNodalConnectivityIndex()->begin());
-  // Build BB tree of all edges in the tool mesh (second mesh)
-  MCAuto<DataArrayDouble> bbox1Arr(m1Desc->getBoundingBoxForBBTree()),bbox2Arr(m2Desc->getBoundingBoxForBBTree());
-  const double *bbox1(bbox1Arr->begin()),*bbox2(bbox2Arr->begin());
-  int nDescCell1(m1Desc->getNumberOfCells()),nDescCell2(m2Desc->getNumberOfCells());
-  intersectEdge1.resize(nDescCell1);
-  colinear2.resize(nDescCell2);
-  subDiv2.resize(nDescCell2);
-  BBTree<SPACEDIM,int> myTree(bbox2,0,0,m2Desc->getNumberOfCells(),-eps);
-
-  std::vector<int> candidates1(1);
-  int offset1(m1Desc->getNumberOfNodes());
-  int offset2(offset1+m2Desc->getNumberOfNodes());
-  for(int i=0;i<nDescCell1;i++)  // for all edges in the first mesh
-    {
-      std::vector<int> candidates2; // edges of mesh2 candidate for intersection
-      myTree.getIntersectingElems(bbox1+i*2*SPACEDIM,candidates2);
-      if(!candidates2.empty()) // candidates2 holds edges from the second mesh potentially intersecting current edge i in mesh1
-        {
-          std::map<INTERP_KERNEL::Node *,int> map1,map2;
-          // pol2 is not necessarily a closed polygon: just a set of (quadratic) edges (same as candidates2) in the Geometric DS format
-          INTERP_KERNEL::QuadraticPolygon *pol2=MEDCouplingUMeshBuildQPFromMesh(m2Desc,candidates2,map2);
-          candidates1[0]=i;
-          INTERP_KERNEL::QuadraticPolygon *pol1=MEDCouplingUMeshBuildQPFromMesh(m1Desc,candidates1,map1);
-          // This following part is to avoid that some removed nodes (for example due to a merge between pol1 and pol2) are replaced by a newly created one
-          // This trick guarantees that Node * are discriminant (i.e. form a unique identifier)
-          std::set<INTERP_KERNEL::Node *> nodes;
-          pol1->getAllNodes(nodes); pol2->getAllNodes(nodes);
-          std::size_t szz(nodes.size());
-          std::vector< MCAuto<INTERP_KERNEL::Node> > nodesSafe(szz);
-          std::set<INTERP_KERNEL::Node *>::const_iterator itt(nodes.begin());
-          for(std::size_t iii=0;iii<szz;iii++,itt++)
-            { (*itt)->incrRef(); nodesSafe[iii]=*itt; }
-          // end of protection
-          // Performs egde cutting:
-          pol1->splitAbs(*pol2,map1,map2,offset1,offset2,candidates2,intersectEdge1[i],i,colinear2,subDiv2,addCoo,mergedNodes);
-          delete pol2;
-          delete pol1;
-        }
-      else
-        // Copy the edge (take only the two first points, ie discard quadratic point at this stage)
-        intersectEdge1[i].insert(intersectEdge1[i].end(),c1+ci1[i]+1,c1+ci1[i]+3);
-    }
-}
-
-/*!
- * This method is private and is the first step of Partition of 2D mesh (spaceDim==2 and meshDim==2).
- * It builds the descending connectivity of the two meshes, and then using a binary tree
- * it computes the edge intersections. This results in new points being created : they're stored in addCoo.
- * Documentation about parameters  colinear2 and subDiv2 can be found in method QuadraticPolygon::splitAbs().
- */
-void MEDCouplingUMesh::IntersectDescending2DMeshes(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2, double eps,
-                                                   std::vector< std::vector<int> >& intersectEdge1, std::vector< std::vector<int> >& colinear2, std::vector< std::vector<int> >& subDiv2,
-                                                   MEDCouplingUMesh *& m1Desc, DataArrayInt *&desc1, DataArrayInt *&descIndx1, DataArrayInt *&revDesc1, DataArrayInt *&revDescIndx1,
-                                                   std::vector<double>& addCoo,
-                                                   MEDCouplingUMesh *& m2Desc, DataArrayInt *&desc2, DataArrayInt *&descIndx2, DataArrayInt *&revDesc2, DataArrayInt *&revDescIndx2)
-{
-  // Build desc connectivity
-  desc1=DataArrayInt::New(); descIndx1=DataArrayInt::New(); revDesc1=DataArrayInt::New(); revDescIndx1=DataArrayInt::New();
-  desc2=DataArrayInt::New();
-  descIndx2=DataArrayInt::New();
-  revDesc2=DataArrayInt::New();
-  revDescIndx2=DataArrayInt::New();
-  MCAuto<DataArrayInt> dd1(desc1),dd2(descIndx1),dd3(revDesc1),dd4(revDescIndx1);
-  MCAuto<DataArrayInt> dd5(desc2),dd6(descIndx2),dd7(revDesc2),dd8(revDescIndx2);
-  m1Desc=m1->buildDescendingConnectivity2(desc1,descIndx1,revDesc1,revDescIndx1);
-  m2Desc=m2->buildDescendingConnectivity2(desc2,descIndx2,revDesc2,revDescIndx2);
-  MCAuto<MEDCouplingUMesh> dd9(m1Desc),dd10(m2Desc);
-  std::map<int,int> notUsedMap;
-  Intersect1DMeshes(m1Desc,m2Desc,eps,intersectEdge1,colinear2,subDiv2,addCoo,notUsedMap);
-  m1Desc->incrRef(); desc1->incrRef(); descIndx1->incrRef(); revDesc1->incrRef(); revDescIndx1->incrRef();
-  m2Desc->incrRef(); desc2->incrRef(); descIndx2->incrRef(); revDesc2->incrRef(); revDescIndx2->incrRef();
-}
-
-/*!
- * This method performs the 2nd step of Partition of 2D mesh.
- * This method has 4 inputs :
- *  - a mesh 'm1' with meshDim==1 and a SpaceDim==2
- *  - a mesh 'm2' with meshDim==1 and a SpaceDim==2
- *  - subDiv of size 'm2->getNumberOfCells()' that lists for each seg cell in 'm' the splitting node ids randomly sorted.
- * The aim of this method is to sort the splitting nodes, if any, and to put them in 'intersectEdge' output parameter based on edges of mesh 'm2'
- * Nodes end up lying consecutively on a cutted edge.
- * \param m1 is expected to be a mesh of meshDimension equal to 1 and spaceDim equal to 2. No check of that is performed by this method.
- * (Only present for its coords in case of 'subDiv' shares some nodes of 'm1')
- * \param m2 is expected to be a mesh of meshDimension equal to 1 and spaceDim equal to 2. No check of that is performed by this method.
- * \param addCoo input parameter with additional nodes linked to intersection of the 2 meshes.
- * \param[out] intersectEdge the same content as subDiv, but correclty oriented.
- */
-void MEDCouplingUMesh::BuildIntersectEdges(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2,
-                                           const std::vector<double>& addCoo,
-                                           const std::vector< std::vector<int> >& subDiv, std::vector< std::vector<int> >& intersectEdge)
-{
-  int offset1=m1->getNumberOfNodes();
-  int ncell=m2->getNumberOfCells();
-  const int *c=m2->getNodalConnectivity()->begin();
-  const int *cI=m2->getNodalConnectivityIndex()->begin();
-  const double *coo=m2->getCoords()->begin();
-  const double *cooBis=m1->getCoords()->begin();
-  int offset2=offset1+m2->getNumberOfNodes();
-  intersectEdge.resize(ncell);
-  for(int i=0;i<ncell;i++,cI++)
-    {
-      const std::vector<int>& divs=subDiv[i];
-      int nnode=cI[1]-cI[0]-1;
-      std::map<int, std::pair<INTERP_KERNEL::Node *,bool> > mapp2;
-      std::map<INTERP_KERNEL::Node *, int> mapp22;
-      for(int j=0;j<nnode;j++)
-        {
-          INTERP_KERNEL::Node *nn=new INTERP_KERNEL::Node(coo[2*c[(*cI)+j+1]],coo[2*c[(*cI)+j+1]+1]);
-          int nnid=c[(*cI)+j+1];
-          mapp2[nnid]=std::pair<INTERP_KERNEL::Node *,bool>(nn,true);
-          mapp22[nn]=nnid+offset1;
-        }
-      INTERP_KERNEL::Edge *e=MEDCouplingUMeshBuildQPFromEdge((INTERP_KERNEL::NormalizedCellType)c[*cI],mapp2,c+(*cI)+1);
-      for(std::map<int, std::pair<INTERP_KERNEL::Node *,bool> >::const_iterator it=mapp2.begin();it!=mapp2.end();it++)
-        ((*it).second.first)->decrRef();
-      std::vector<INTERP_KERNEL::Node *> addNodes(divs.size());
-      std::map<INTERP_KERNEL::Node *,int> mapp3;
-      for(std::size_t j=0;j<divs.size();j++)
-        {
-          int id=divs[j];
-          INTERP_KERNEL::Node *tmp=0;
-          if(id<offset1)
-            tmp=new INTERP_KERNEL::Node(cooBis[2*id],cooBis[2*id+1]);
-          else if(id<offset2)
-            tmp=new INTERP_KERNEL::Node(coo[2*(id-offset1)],coo[2*(id-offset1)+1]);//if it happens, bad news mesh 'm2' is non conform.
-          else
-            tmp=new INTERP_KERNEL::Node(addCoo[2*(id-offset2)],addCoo[2*(id-offset2)+1]);
-          addNodes[j]=tmp;
-          mapp3[tmp]=id;
-        }
-      e->sortIdsAbs(addNodes,mapp22,mapp3,intersectEdge[i]);
-      for(std::vector<INTERP_KERNEL::Node *>::const_iterator it=addNodes.begin();it!=addNodes.end();it++)
-        (*it)->decrRef();
-      e->decrRef();
-    }
-}
-
-/*!
- * This method is part of the Slice3D algorithm. It is the first step of assembly process, ones coordinates have been computed (by MEDCouplingUMesh::split3DCurveWithPlane method).
- * This method allows to compute given the status of 3D curve cells and the descending connectivity 3DSurf->3DCurve to deduce the intersection of each 3D surf cells
- * with a plane. The result will be put in 'cut3DSuf' out parameter.
- * \param [in] cut3DCurve  input paramter that gives for each 3DCurve cell if it owns fully to the plane or partially.
- * \param [out] nodesOnPlane, returns all the nodes that are on the plane.
- * \param [in] nodal3DSurf is the nodal connectivity of 3D surf mesh.
- * \param [in] nodalIndx3DSurf is the nodal connectivity index of 3D surf mesh.
- * \param [in] nodal3DCurve is the nodal connectivity of 3D curve mesh.
- * \param [in] nodal3DIndxCurve is the nodal connectivity index of 3D curve mesh.
- * \param [in] desc is the descending connectivity 3DSurf->3DCurve
- * \param [in] descIndx is the descending connectivity index 3DSurf->3DCurve
- * \param [out] cut3DSuf input/output param.
- */
-void MEDCouplingUMesh::AssemblyForSplitFrom3DCurve(const std::vector<int>& cut3DCurve, std::vector<int>& nodesOnPlane, const int *nodal3DSurf, const int *nodalIndx3DSurf,
-                                                   const int *nodal3DCurve, const int *nodalIndx3DCurve,
-                                                   const int *desc, const int *descIndx, 
-                                                   std::vector< std::pair<int,int> >& cut3DSurf)
-{
-  std::set<int> nodesOnP(nodesOnPlane.begin(),nodesOnPlane.end());
-  int nbOf3DSurfCell=(int)cut3DSurf.size();
-  for(int i=0;i<nbOf3DSurfCell;i++)
-    {
-      std::vector<int> res;
-      int offset=descIndx[i];
-      int nbOfSeg=descIndx[i+1]-offset;
-      for(int j=0;j<nbOfSeg;j++)
-        {
-          int edgeId=desc[offset+j];
-          int status=cut3DCurve[edgeId];
-          if(status!=-2)
-            {
-              if(status>-1)
-                res.push_back(status);
-              else
-                {
-                  res.push_back(nodal3DCurve[nodalIndx3DCurve[edgeId]+1]);
-                  res.push_back(nodal3DCurve[nodalIndx3DCurve[edgeId]+2]);
-                }
-            }
-        }
-      switch(res.size())
-      {
-        case 2:
-          {
-            cut3DSurf[i].first=res[0]; cut3DSurf[i].second=res[1];
-            break;
-          }
-        case 1:
-        case 0:
-          {
-            std::set<int> s1(nodal3DSurf+nodalIndx3DSurf[i]+1,nodal3DSurf+nodalIndx3DSurf[i+1]);
-            std::set_intersection(nodesOnP.begin(),nodesOnP.end(),s1.begin(),s1.end(),std::back_insert_iterator< std::vector<int> >(res));
-            if(res.size()==2)
-              {
-                cut3DSurf[i].first=res[0]; cut3DSurf[i].second=res[1];
-              }
-            else
-              {
-                cut3DSurf[i].first=-1; cut3DSurf[i].second=-1;
-              }
-            break;
-          }
-        default:
-          {// case when plane is on a multi colinear edge of a polyhedron
-            if((int)res.size()==2*nbOfSeg)
-              {
-                cut3DSurf[i].first=-2; cut3DSurf[i].second=i;
-              }
-            else
-              throw INTERP_KERNEL::Exception("MEDCouplingUMesh::AssemblyPointsFrom3DCurve : unexpected situation !");
-          }
-      }
-    }
-}
-
-/*!
- * \a this is expected to be a mesh with spaceDim==3 and meshDim==3. If not an exception will be thrown.
- * This method is part of the Slice3D algorithm. It is the second step of assembly process, ones coordinates have been computed (by MEDCouplingUMesh::split3DCurveWithPlane method).
- * This method allows to compute given the result of 3D surf cells with plane and the descending connectivity 3D->3DSurf to deduce the intersection of each 3D cells
- * with a plane. The result will be put in 'nodalRes' 'nodalResIndx' and 'cellIds' out parameters.
- * \param cut3DSurf  input paramter that gives for each 3DSurf its intersection with plane (result of MEDCouplingUMesh::AssemblyForSplitFrom3DCurve).
- * \param desc is the descending connectivity 3D->3DSurf
- * \param descIndx is the descending connectivity index 3D->3DSurf
- */
-void MEDCouplingUMesh::assemblyForSplitFrom3DSurf(const std::vector< std::pair<int,int> >& cut3DSurf,
-                                                  const int *desc, const int *descIndx,
-                                                  DataArrayInt *nodalRes, DataArrayInt *nodalResIndx, DataArrayInt *cellIds) const
-{
-  checkFullyDefined();
-  if(getMeshDimension()!=3 || getSpaceDimension()!=3)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::assemblyForSplitFrom3DSurf works on umeshes with meshdim equal to 3 and spaceDim equal to 3 too!");
-  const int *nodal3D(_nodal_connec->begin()),*nodalIndx3D(_nodal_connec_index->begin());
-  int nbOfCells(getNumberOfCells());
-  for(int i=0;i<nbOfCells;i++)
-    {
-      std::map<int, std::set<int> > m;
-      int offset=descIndx[i];
-      int nbOfFaces=descIndx[i+1]-offset;
-      int start=-1;
-      int end=-1;
-      for(int j=0;j<nbOfFaces;j++)
-        {
-          const std::pair<int,int>& p=cut3DSurf[desc[offset+j]];
-          if(p.first!=-1 && p.second!=-1)
-            {
-              if(p.first!=-2)
-                {
-                  start=p.first; end=p.second;
-                  m[p.first].insert(p.second);
-                  m[p.second].insert(p.first);
-                }
-              else
-                {
-                  const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)nodal3D[nodalIndx3D[i]]);
-                  int sz=nodalIndx3D[i+1]-nodalIndx3D[i]-1;
-                  INTERP_KERNEL::AutoPtr<int> tmp=new int[sz];
-                  INTERP_KERNEL::NormalizedCellType cmsId;
-                  unsigned nbOfNodesSon=cm.fillSonCellNodalConnectivity2(j,nodal3D+nodalIndx3D[i]+1,sz,tmp,cmsId);
-                  start=tmp[0]; end=tmp[nbOfNodesSon-1];
-                  for(unsigned k=0;k<nbOfNodesSon;k++)
-                    {
-                      m[tmp[k]].insert(tmp[(k+1)%nbOfNodesSon]);
-                      m[tmp[(k+1)%nbOfNodesSon]].insert(tmp[k]);
-                    }
-                }
-            }
-        }
-      if(m.empty())
-        continue;
-      std::vector<int> conn(1,(int)INTERP_KERNEL::NORM_POLYGON);
-      int prev=end;
-      while(end!=start)
-        {
-          std::map<int, std::set<int> >::const_iterator it=m.find(start);
-          const std::set<int>& s=(*it).second;
-          std::set<int> s2; s2.insert(prev);
-          std::set<int> s3;
-          std::set_difference(s.begin(),s.end(),s2.begin(),s2.end(),inserter(s3,s3.begin()));
-          if(s3.size()==1)
-            {
-              int val=*s3.begin();
-              conn.push_back(start);
-              prev=start;
-              start=val;
-            }
-          else
-            start=end;
-        }
-      conn.push_back(end);
-      if(conn.size()>3)
-        {
-          nodalRes->insertAtTheEnd(conn.begin(),conn.end());
-          nodalResIndx->pushBackSilent(nodalRes->getNumberOfTuples());
-          cellIds->pushBackSilent(i);
-        }
-    }
-}
-
-void InsertNodeInConnIfNecessary(int nodeIdToInsert, std::vector<int>& conn, const double *coords, double eps)
-{
-  std::vector<int>::iterator it(std::find(conn.begin(),conn.end(),nodeIdToInsert));
-  if(it!=conn.end())
-    return ;
-  std::size_t sz(conn.size());
-  std::size_t found(std::numeric_limits<std::size_t>::max());
-  for(std::size_t i=0;i<sz;i++)
-    {
-      int pt0(conn[i]),pt1(conn[(i+1)%sz]);
-      double v1[3]={coords[3*pt1+0]-coords[3*pt0+0],coords[3*pt1+1]-coords[3*pt0+1],coords[3*pt1+2]-coords[3*pt0+2]},v2[3]={coords[3*nodeIdToInsert+0]-coords[3*pt0+0],coords[3*nodeIdToInsert+1]-coords[3*pt0+1],coords[3*nodeIdToInsert+2]-coords[3*pt0+2]};
-      double normm(sqrt(v1[0]*v1[0]+v1[1]*v1[1]+v1[2]*v1[2]));
-      std::transform(v1,v1+3,v1,std::bind2nd(std::multiplies<double>(),1./normm));
-      std::transform(v2,v2+3,v2,std::bind2nd(std::multiplies<double>(),1./normm));
-      double v3[3];
-      v3[0]=v1[1]*v2[2]-v1[2]*v2[1]; v3[1]=v1[2]*v2[0]-v1[0]*v2[2]; v3[2]=v1[0]*v2[1]-v1[1]*v2[0];
-      double normm2(sqrt(v3[0]*v3[0]+v3[1]*v3[1]+v3[2]*v3[2])),dotTest(v1[0]*v2[0]+v1[1]*v2[1]+v1[2]*v2[2]);
-      if(normm2<eps)
-        if(dotTest>eps && dotTest<1.-eps)
-          {
-            found=i;
-            break;
-          }
-    }
-  if(found==std::numeric_limits<std::size_t>::max())
-    throw INTERP_KERNEL::Exception("InsertNodeInConnIfNecessary : not found point !");
-  conn.insert(conn.begin()+(found+1)%sz,nodeIdToInsert);
-}
-
-void SplitIntoToPart(const std::vector<int>& conn, int pt0, int pt1, std::vector<int>& part0, std::vector<int>& part1)
-{
-  std::size_t sz(conn.size());
-  std::vector<int> *curPart(&part0);
-  for(std::size_t i=0;i<sz;i++)
-    {
-      int nextt(conn[(i+1)%sz]);
-      (*curPart).push_back(nextt);
-      if(nextt==pt0 || nextt==pt1)
-        {
-          if(curPart==&part0)
-            curPart=&part1;
-          else
-            curPart=&part0;
-          (*curPart).push_back(nextt);
-        }
-    }
-}
-
-/*!
- * this method method splits cur cells 3D Surf in sub cells 3DSurf using the previous subsplit. This method is the last one used to clip.
- */
-void MEDCouplingUMesh::buildSubCellsFromCut(const std::vector< std::pair<int,int> >& cut3DSurf,
-                                            const int *desc, const int *descIndx, const double *coords, double eps,
-                                            std::vector<std::vector<int> >& res) const
-{
-  checkFullyDefined();
-  if(getMeshDimension()!=3 || getSpaceDimension()!=3)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildSubCellsFromCut works on umeshes with meshdim equal to 3 and spaceDim equal to 3 too!");
-  const int *nodal3D(_nodal_connec->begin()),*nodalIndx3D(_nodal_connec_index->begin());
-  int nbOfCells(getNumberOfCells());
-  if(nbOfCells!=1)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildSubCellsFromCut works only with single cell presently !");
-  for(int i=0;i<nbOfCells;i++)
-    {
-      int offset(descIndx[i]),nbOfFaces(descIndx[i+1]-offset),start(-1),end(-1);
-      for(int j=0;j<nbOfFaces;j++)
-        {
-          const std::pair<int,int>& p=cut3DSurf[desc[offset+j]];
-          const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)nodal3D[nodalIndx3D[i]]));
-          int sz=nodalIndx3D[i+1]-nodalIndx3D[i]-1;
-          INTERP_KERNEL::AutoPtr<int> tmp(new int[sz]);
-          INTERP_KERNEL::NormalizedCellType cmsId;
-          unsigned nbOfNodesSon(cm.fillSonCellNodalConnectivity2(j,nodal3D+nodalIndx3D[i]+1,sz,tmp,cmsId));
-          std::vector<int> elt((int *)tmp,(int *)tmp+nbOfNodesSon);
-          if(p.first!=-1 && p.second!=-1)
-            {
-              if(p.first!=-2)
-                {
-                  InsertNodeInConnIfNecessary(p.first,elt,coords,eps);
-                  InsertNodeInConnIfNecessary(p.second,elt,coords,eps);
-                  std::vector<int> elt1,elt2;
-                  SplitIntoToPart(elt,p.first,p.second,elt1,elt2);
-                  res.push_back(elt1);
-                  res.push_back(elt2);
-                }
-              else
-                res.push_back(elt);
-            }
-          else
-            res.push_back(elt);
-        }
-    }
-}
-
-/*!
- * This method compute the convex hull of a single 2D cell. This method tries to conserve at maximum the given input connectivity. In particular, if the orientation of cell is not clockwise
- * as in MED format norm. If definitely the result of Jarvis algorithm is not matchable with the input connectivity, the result will be copied into \b nodalConnecOut parameter and
- * the geometric cell type set to INTERP_KERNEL::NORM_POLYGON.
- * This method excepts that \b coords parameter is expected to be in dimension 2. [ \b nodalConnBg , \b nodalConnEnd ) is the nodal connectivity of the input
- * cell (geometric cell type included at the position 0). If the meshdimension of the input cell is not equal to 2 an INTERP_KERNEL::Exception will be thrown.
- * 
- * \return false if the input connectivity represents already the convex hull, true if the input cell needs to be reordered.
- */
-bool MEDCouplingUMesh::BuildConvexEnvelopOf2DCellJarvis(const double *coords, const int *nodalConnBg, const int *nodalConnEnd, DataArrayInt *nodalConnecOut)
-{
-  std::size_t sz=std::distance(nodalConnBg,nodalConnEnd);
-  if(sz>=4)
-    {
-      const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)*nodalConnBg);
-      if(cm.getDimension()==2)
-        {
-          const int *node=nodalConnBg+1;
-          int startNode=*node++;
+          const mcIdType *node=nodalConnBg+1;
+          mcIdType startNode=*node++;
           double refX=coords[2*startNode];
           for(;node!=nodalConnEnd;node++)
             {
@@ -11028,14 +8087,14 @@ bool MEDCouplingUMesh::BuildConvexEnvelopOf2DCellJarvis(const double *coords, co
                   refX=coords[2*startNode];
                 }
             }
-          std::vector<int> tmpOut; tmpOut.reserve(sz); tmpOut.push_back(startNode);
+          std::vector<mcIdType> tmpOut; tmpOut.reserve(sz); tmpOut.push_back(startNode);
           refX=1e300;
           double tmp1;
           double tmp2[2];
           double angle0=-M_PI/2;
           //
-          int nextNode=-1;
-          int prevNode=-1;
+          mcIdType nextNode=-1;
+          mcIdType prevNode=-1;
           double resRef;
           double angleNext=0.;
           while(nextNode!=startNode)
@@ -11070,8 +8129,8 @@ bool MEDCouplingUMesh::BuildConvexEnvelopOf2DCellJarvis(const double *coords, co
                   tmpOut.push_back(nextNode);
                 }
             }
-          std::vector<int> tmp3(2*(sz-1));
-          std::vector<int>::iterator it=std::copy(nodalConnBg+1,nodalConnEnd,tmp3.begin());
+          std::vector<mcIdType> tmp3(2*(sz-1));
+          std::vector<mcIdType>::iterator it=std::copy(nodalConnBg+1,nodalConnEnd,tmp3.begin());
           std::copy(nodalConnBg+1,nodalConnEnd,it);
           if(std::search(tmp3.begin(),tmp3.end(),tmpOut.begin(),tmpOut.end())!=tmp3.end())
             {
@@ -11085,7 +8144,7 @@ bool MEDCouplingUMesh::BuildConvexEnvelopOf2DCellJarvis(const double *coords, co
             }
           else
             {
-              nodalConnecOut->pushBackSilent((int)INTERP_KERNEL::NORM_POLYGON);
+              nodalConnecOut->pushBackSilent(ToIdType(INTERP_KERNEL::NORM_POLYGON));
               nodalConnecOut->insertAtTheEnd(tmpOut.begin(),tmpOut.end());
               return true;
             }
@@ -11097,521 +8156,66 @@ bool MEDCouplingUMesh::BuildConvexEnvelopOf2DCellJarvis(const double *coords, co
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::BuildConvexEnvelopOf2DCellJarvis : invalid 2D cell connectivity !");
 }
 
-/*!
- * This method works on an input pair (\b arr, \b arrIndx) where \b arr indexes is in \b arrIndx.
- * This method will not impact the size of inout parameter \b arrIndx but the size of \b arr will be modified in case of suppression.
- * 
- * \param [in] idsToRemoveBg begin of set of ids to remove in \b arr (included)
- * \param [in] idsToRemoveEnd end of set of ids to remove in \b arr (excluded)
- * \param [in,out] arr array in which the remove operation will be done.
- * \param [in,out] arrIndx array in the remove operation will modify
- * \param [in] offsetForRemoval (by default 0) offset so that for each i in [0,arrIndx->getNumberOfTuples()-1) removal process will be performed in the following range [arr+arrIndx[i]+offsetForRemoval,arr+arr[i+1])
- * \return true if \b arr and \b arrIndx have been modified, false if not.
- */
-bool MEDCouplingUMesh::RemoveIdsFromIndexedArrays(const int *idsToRemoveBg, const int *idsToRemoveEnd, DataArrayInt *arr, DataArrayInt *arrIndx, int offsetForRemoval)
-{
-  if(!arrIndx || !arr)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::RemoveIdsFromIndexedArrays : some input arrays are empty !");
-  if(offsetForRemoval<0)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::RemoveIdsFromIndexedArrays : offsetForRemoval should be >=0 !");
-  std::set<int> s(idsToRemoveBg,idsToRemoveEnd);
-  int nbOfGrps=arrIndx->getNumberOfTuples()-1;
-  int *arrIPtr=arrIndx->getPointer();
-  *arrIPtr++=0;
-  int previousArrI=0;
-  const int *arrPtr=arr->begin();
-  std::vector<int> arrOut;//no utility to switch to DataArrayInt because copy always needed
-  for(int i=0;i<nbOfGrps;i++,arrIPtr++)
-    {
-      if(*arrIPtr-previousArrI>offsetForRemoval)
-        {
-          for(const int *work=arrPtr+previousArrI+offsetForRemoval;work!=arrPtr+*arrIPtr;work++)
-            {
-              if(s.find(*work)==s.end())
-                arrOut.push_back(*work);
-            }
-        }
-      previousArrI=*arrIPtr;
-      *arrIPtr=(int)arrOut.size();
-    }
-  if(arr->getNumberOfTuples()==(int)arrOut.size())
-    return false;
-  arr->alloc((int)arrOut.size(),1);
-  std::copy(arrOut.begin(),arrOut.end(),arr->getPointer());
-  return true;
-}
-
-/*!
- * This method works on a pair input (\b arrIn, \b arrIndxIn) where \b arrIn indexes is in \b arrIndxIn
- * (\ref numbering-indirect).
- * This method returns the result of the extraction ( specified by a set of ids in [\b idsOfSelectBg , \b idsOfSelectEnd ) ).
- * The selection of extraction is done standardly in new2old format.
- * This method returns indexed arrays (\ref numbering-indirect) using 2 arrays (arrOut,arrIndexOut).
- *
- * \param [in] idsOfSelectBg begin of set of ids of the input extraction (included)
- * \param [in] idsOfSelectEnd end of set of ids of the input extraction (excluded)
- * \param [in] arrIn arr origin array from which the extraction will be done.
- * \param [in] arrIndxIn is the input index array allowing to walk into \b arrIn
- * \param [out] arrOut the resulting array
- * \param [out] arrIndexOut the index array of the resulting array \b arrOut
- * \sa MEDCouplingUMesh::ExtractFromIndexedArraysSlice
- */
-void MEDCouplingUMesh::ExtractFromIndexedArrays(const int *idsOfSelectBg, const int *idsOfSelectEnd, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn,
-                                                DataArrayInt* &arrOut, DataArrayInt* &arrIndexOut)
-{
-  if(!arrIn || !arrIndxIn)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ExtractFromIndexedArrays : input pointer is NULL !");
-  arrIn->checkAllocated(); arrIndxIn->checkAllocated();
-  if(arrIn->getNumberOfComponents()!=1 || arrIndxIn->getNumberOfComponents()!=1)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ExtractFromIndexedArrays : input arrays must have exactly one component !");
-  std::size_t sz=std::distance(idsOfSelectBg,idsOfSelectEnd);
-  const int *arrInPtr=arrIn->begin();
-  const int *arrIndxPtr=arrIndxIn->begin();
-  int nbOfGrps=arrIndxIn->getNumberOfTuples()-1;
-  if(nbOfGrps<0)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ExtractFromIndexedArrays : The format of \"arrIndxIn\" is invalid ! Its nb of tuples should be >=1 !");
-  int maxSizeOfArr=arrIn->getNumberOfTuples();
-  MCAuto<DataArrayInt> arro=DataArrayInt::New();
-  MCAuto<DataArrayInt> arrIo=DataArrayInt::New();
-  arrIo->alloc((int)(sz+1),1);
-  const int *idsIt=idsOfSelectBg;
-  int *work=arrIo->getPointer();
-  *work++=0;
-  int lgth=0;
-  for(std::size_t i=0;i<sz;i++,work++,idsIt++)
-    {
-      if(*idsIt>=0 && *idsIt<nbOfGrps)
-        lgth+=arrIndxPtr[*idsIt+1]-arrIndxPtr[*idsIt];
-      else
-        {
-          std::ostringstream oss; oss << "MEDCouplingUMesh::ExtractFromIndexedArrays : id located on pos #" << i << " value is " << *idsIt << " ! Must be in [0," << nbOfGrps << ") !";
-          throw INTERP_KERNEL::Exception(oss.str());
-        }
-      if(lgth>=work[-1])
-        *work=lgth;
-      else
-        {
-          std::ostringstream oss; oss << "MEDCouplingUMesh::ExtractFromIndexedArrays : id located on pos #" << i << " value is " << *idsIt << " and at this pos arrIndxIn[" << *idsIt;
-          oss << "+1]-arrIndxIn[" << *idsIt << "] < 0 ! The input index array is bugged !";
-          throw INTERP_KERNEL::Exception(oss.str());
-        }
-    }
-  arro->alloc(lgth,1);
-  work=arro->getPointer();
-  idsIt=idsOfSelectBg;
-  for(std::size_t i=0;i<sz;i++,idsIt++)
-    {
-      if(arrIndxPtr[*idsIt]>=0 && arrIndxPtr[*idsIt+1]<=maxSizeOfArr)
-        work=std::copy(arrInPtr+arrIndxPtr[*idsIt],arrInPtr+arrIndxPtr[*idsIt+1],work);
-      else
-        {
-          std::ostringstream oss; oss << "MEDCouplingUMesh::ExtractFromIndexedArrays : id located on pos #" << i << " value is " << *idsIt << " arrIndx[" << *idsIt << "] must be >= 0 and arrIndx[";
-          oss << *idsIt << "+1] <= " << maxSizeOfArr << " (the size of arrIn)!";
-          throw INTERP_KERNEL::Exception(oss.str());
-        }
-    }
-  arrOut=arro.retn();
-  arrIndexOut=arrIo.retn();
-}
-
-/*!
- * This method works on a pair input (\b arrIn, \b arrIndxIn) where \b arrIn indexes is in \b arrIndxIn
- * (\ref numbering-indirect).
- * This method returns the result of the extraction ( specified by a set of ids with a slice given by \a idsOfSelectStart, \a idsOfSelectStop and \a idsOfSelectStep ).
- * The selection of extraction is done standardly in new2old format.
- * This method returns indexed arrays (\ref numbering-indirect) using 2 arrays (arrOut,arrIndexOut).
- *
- * \param [in] idsOfSelectStart begin of set of ids of the input extraction (included)
- * \param [in] idsOfSelectStop end of set of ids of the input extraction (excluded)
- * \param [in] idsOfSelectStep
- * \param [in] arrIn arr origin array from which the extraction will be done.
- * \param [in] arrIndxIn is the input index array allowing to walk into \b arrIn
- * \param [out] arrOut the resulting array
- * \param [out] arrIndexOut the index array of the resulting array \b arrOut
- * \sa MEDCouplingUMesh::ExtractFromIndexedArrays
- */
-void MEDCouplingUMesh::ExtractFromIndexedArraysSlice(int idsOfSelectStart, int idsOfSelectStop, int idsOfSelectStep, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn,
-                                                 DataArrayInt* &arrOut, DataArrayInt* &arrIndexOut)
-{
-  if(!arrIn || !arrIndxIn)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ExtractFromIndexedArraysSlice : input pointer is NULL !");
-  arrIn->checkAllocated(); arrIndxIn->checkAllocated();
-  if(arrIn->getNumberOfComponents()!=1 || arrIndxIn->getNumberOfComponents()!=1)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ExtractFromIndexedArraysSlice : input arrays must have exactly one component !");
-  int sz=DataArrayInt::GetNumberOfItemGivenBESRelative(idsOfSelectStart,idsOfSelectStop,idsOfSelectStep,"MEDCouplingUMesh::ExtractFromIndexedArraysSlice : Input slice ");
-  const int *arrInPtr=arrIn->begin();
-  const int *arrIndxPtr=arrIndxIn->begin();
-  int nbOfGrps=arrIndxIn->getNumberOfTuples()-1;
-  if(nbOfGrps<0)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ExtractFromIndexedArraysSlice : The format of \"arrIndxIn\" is invalid ! Its nb of tuples should be >=1 !");
-  int maxSizeOfArr=arrIn->getNumberOfTuples();
-  MCAuto<DataArrayInt> arro=DataArrayInt::New();
-  MCAuto<DataArrayInt> arrIo=DataArrayInt::New();
-  arrIo->alloc((int)(sz+1),1);
-  int idsIt=idsOfSelectStart;
-  int *work=arrIo->getPointer();
-  *work++=0;
-  int lgth=0;
-  for(int i=0;i<sz;i++,work++,idsIt+=idsOfSelectStep)
-    {
-      if(idsIt>=0 && idsIt<nbOfGrps)
-        lgth+=arrIndxPtr[idsIt+1]-arrIndxPtr[idsIt];
-      else
-        {
-          std::ostringstream oss; oss << "MEDCouplingUMesh::ExtractFromIndexedArraysSlice : id located on pos #" << i << " value is " << idsIt << " ! Must be in [0," << nbOfGrps << ") !";
-          throw INTERP_KERNEL::Exception(oss.str());
-        }
-      if(lgth>=work[-1])
-        *work=lgth;
-      else
-        {
-          std::ostringstream oss; oss << "MEDCouplingUMesh::ExtractFromIndexedArraysSlice : id located on pos #" << i << " value is " << idsIt << " and at this pos arrIndxIn[" << idsIt;
-          oss << "+1]-arrIndxIn[" << idsIt << "] < 0 ! The input index array is bugged !";
-          throw INTERP_KERNEL::Exception(oss.str());
-        }
-    }
-  arro->alloc(lgth,1);
-  work=arro->getPointer();
-  idsIt=idsOfSelectStart;
-  for(int i=0;i<sz;i++,idsIt+=idsOfSelectStep)
-    {
-      if(arrIndxPtr[idsIt]>=0 && arrIndxPtr[idsIt+1]<=maxSizeOfArr)
-        work=std::copy(arrInPtr+arrIndxPtr[idsIt],arrInPtr+arrIndxPtr[idsIt+1],work);
-      else
-        {
-          std::ostringstream oss; oss << "MEDCouplingUMesh::ExtractFromIndexedArraysSlice : id located on pos #" << i << " value is " << idsIt << " arrIndx[" << idsIt << "] must be >= 0 and arrIndx[";
-          oss << idsIt << "+1] <= " << maxSizeOfArr << " (the size of arrIn)!";
-          throw INTERP_KERNEL::Exception(oss.str());
-        }
-    }
-  arrOut=arro.retn();
-  arrIndexOut=arrIo.retn();
-}
-
-/*!
- * This method works on an input pair (\b arrIn, \b arrIndxIn) where \b arrIn indexes is in \b arrIndxIn.
- * This method builds an output pair (\b arrOut,\b arrIndexOut) that is a copy from \b arrIn for all cell ids \b not \b in [ \b idsOfSelectBg , \b idsOfSelectEnd ) and for
- * cellIds \b in [ \b idsOfSelectBg , \b idsOfSelectEnd ) a copy coming from the corresponding values in input pair (\b srcArr, \b srcArrIndex).
- * This method is an generalization of MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx that performs the same thing but by without building explicitely a result output arrays.
- *
- * \param [in] idsOfSelectBg begin of set of ids of the input extraction (included)
- * \param [in] idsOfSelectEnd end of set of ids of the input extraction (excluded)
- * \param [in] arrIn arr origin array from which the extraction will be done.
- * \param [in] arrIndxIn is the input index array allowing to walk into \b arrIn
- * \param [in] srcArr input array that will be used as source of copy for ids in [ \b idsOfSelectBg, \b idsOfSelectEnd )
- * \param [in] srcArrIndex index array of \b srcArr
- * \param [out] arrOut the resulting array
- * \param [out] arrIndexOut the index array of the resulting array \b arrOut
- * 
- * \sa MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx
- */
-void MEDCouplingUMesh::SetPartOfIndexedArrays(const int *idsOfSelectBg, const int *idsOfSelectEnd, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn,
-                                              const DataArrayInt *srcArr, const DataArrayInt *srcArrIndex,
-                                              DataArrayInt* &arrOut, DataArrayInt* &arrIndexOut)
-{
-  if(arrIn==0 || arrIndxIn==0 || srcArr==0 || srcArrIndex==0)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::SetPartOfIndexedArrays : presence of null pointer in input parameter !");
-  MCAuto<DataArrayInt> arro=DataArrayInt::New();
-  MCAuto<DataArrayInt> arrIo=DataArrayInt::New();
-  int nbOfTuples=arrIndxIn->getNumberOfTuples()-1;
-  std::vector<bool> v(nbOfTuples,true);
-  int offset=0;
-  const int *arrIndxInPtr=arrIndxIn->begin();
-  const int *srcArrIndexPtr=srcArrIndex->begin();
-  for(const int *it=idsOfSelectBg;it!=idsOfSelectEnd;it++,srcArrIndexPtr++)
-    {
-      if(*it>=0 && *it<nbOfTuples)
-        {
-          v[*it]=false;
-          offset+=(srcArrIndexPtr[1]-srcArrIndexPtr[0])-(arrIndxInPtr[*it+1]-arrIndxInPtr[*it]);
-        }
-      else
-        {
-          std::ostringstream oss; oss << "MEDCouplingUMesh::SetPartOfIndexedArrays : On pos #" << std::distance(idsOfSelectBg,it) << " value is " << *it << " not in [0," << nbOfTuples << ") !";
-          throw INTERP_KERNEL::Exception(oss.str());
-        }
-    }
-  srcArrIndexPtr=srcArrIndex->begin();
-  arrIo->alloc(nbOfTuples+1,1);
-  arro->alloc(arrIn->getNumberOfTuples()+offset,1);
-  const int *arrInPtr=arrIn->begin();
-  const int *srcArrPtr=srcArr->begin();
-  int *arrIoPtr=arrIo->getPointer(); *arrIoPtr++=0;
-  int *arroPtr=arro->getPointer();
-  for(int ii=0;ii<nbOfTuples;ii++,arrIoPtr++)
-    {
-      if(v[ii])
-        {
-          arroPtr=std::copy(arrInPtr+arrIndxInPtr[ii],arrInPtr+arrIndxInPtr[ii+1],arroPtr);
-          *arrIoPtr=arrIoPtr[-1]+(arrIndxInPtr[ii+1]-arrIndxInPtr[ii]);
-        }
-      else
-        {
-          std::size_t pos=std::distance(idsOfSelectBg,std::find(idsOfSelectBg,idsOfSelectEnd,ii));
-          arroPtr=std::copy(srcArrPtr+srcArrIndexPtr[pos],srcArrPtr+srcArrIndexPtr[pos+1],arroPtr);
-          *arrIoPtr=arrIoPtr[-1]+(srcArrIndexPtr[pos+1]-srcArrIndexPtr[pos]);
-        }
-    }
-  arrOut=arro.retn();
-  arrIndexOut=arrIo.retn();
-}
-
-/*!
- * This method works on an input pair (\b arrIn, \b arrIndxIn) where \b arrIn indexes is in \b arrIndxIn.
- * This method is an specialization of MEDCouplingUMesh::SetPartOfIndexedArrays in the case of assignement do not modify the index in \b arrIndxIn.
- *
- * \param [in] idsOfSelectBg begin of set of ids of the input extraction (included)
- * \param [in] idsOfSelectEnd end of set of ids of the input extraction (excluded)
- * \param [in,out] arrInOut arr origin array from which the extraction will be done.
- * \param [in] arrIndxIn is the input index array allowing to walk into \b arrIn
- * \param [in] srcArr input array that will be used as source of copy for ids in [ \b idsOfSelectBg , \b idsOfSelectEnd )
- * \param [in] srcArrIndex index array of \b srcArr
- * 
- * \sa MEDCouplingUMesh::SetPartOfIndexedArrays
- */
-void MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx(const int *idsOfSelectBg, const int *idsOfSelectEnd, DataArrayInt *arrInOut, const DataArrayInt *arrIndxIn,
-                                                     const DataArrayInt *srcArr, const DataArrayInt *srcArrIndex)
-{
-  if(arrInOut==0 || arrIndxIn==0 || srcArr==0 || srcArrIndex==0)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx : presence of null pointer in input parameter !");
-  int nbOfTuples=arrIndxIn->getNumberOfTuples()-1;
-  const int *arrIndxInPtr=arrIndxIn->begin();
-  const int *srcArrIndexPtr=srcArrIndex->begin();
-  int *arrInOutPtr=arrInOut->getPointer();
-  const int *srcArrPtr=srcArr->begin();
-  for(const int *it=idsOfSelectBg;it!=idsOfSelectEnd;it++,srcArrIndexPtr++)
-    {
-      if(*it>=0 && *it<nbOfTuples)
-        {
-          if(srcArrIndexPtr[1]-srcArrIndexPtr[0]==arrIndxInPtr[*it+1]-arrIndxInPtr[*it])
-            std::copy(srcArrPtr+srcArrIndexPtr[0],srcArrPtr+srcArrIndexPtr[1],arrInOutPtr+arrIndxInPtr[*it]);
-          else
-            {
-              std::ostringstream oss; oss << "MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx : On pos #" << std::distance(idsOfSelectBg,it) << " id (idsOfSelectBg[" << std::distance(idsOfSelectBg,it)<< "]) is " << *it << " arrIndxIn[id+1]-arrIndxIn[id]!=srcArrIndex[pos+1]-srcArrIndex[pos] !";
-              throw INTERP_KERNEL::Exception(oss.str());
-            }
-        }
-      else
-        {
-          std::ostringstream oss; oss << "MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx : On pos #" << std::distance(idsOfSelectBg,it) << " value is " << *it << " not in [0," << nbOfTuples << ") !";
-          throw INTERP_KERNEL::Exception(oss.str());
-        }
-    }
-}
-
 /*!
  * This method works on a pair input (\b arrIn, \b arrIndxIn) where \b arr indexes is in \b arrIndxIn.
  * This method expects that these two input arrays come from the output of MEDCouplingUMesh::computeNeighborsOfCells method.
- * This method start from id 0 that will be contained in output DataArrayInt. It searches then all neighbors of id0 looking at arrIn[arrIndxIn[0]:arrIndxIn[0+1]].
+ * This method start from id 0 that will be contained in output DataArrayIdType. It searches then all neighbors of id0 looking at arrIn[arrIndxIn[0]:arrIndxIn[0+1]].
  * Then it is repeated recursively until either all ids are fetched or no more ids are reachable step by step.
  * A negative value in \b arrIn means that it is ignored.
  * This method is useful to see if a mesh is contiguous regarding its connectivity. If it is not the case the size of returned array is different from arrIndxIn->getNumberOfTuples()-1.
- * 
+ *
  * \param [in] arrIn arr origin array from which the extraction will be done.
  * \param [in] arrIndxIn is the input index array allowing to walk into \b arrIn
  * \return a newly allocated DataArray that stores all ids fetched by the gradually spread process.
  * \sa MEDCouplingUMesh::ComputeSpreadZoneGraduallyFromSeed, MEDCouplingUMesh::partitionBySpreadZone
  */
-DataArrayInt *MEDCouplingUMesh::ComputeSpreadZoneGradually(const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn)
+DataArrayIdType *MEDCouplingUMesh::ComputeSpreadZoneGradually(const DataArrayIdType *arrIn, const DataArrayIdType *arrIndxIn)
 {
-  int seed=0,nbOfDepthPeelingPerformed=0;
+  mcIdType seed=0,nbOfDepthPeelingPerformed=0;
   return ComputeSpreadZoneGraduallyFromSeed(&seed,&seed+1,arrIn,arrIndxIn,-1,nbOfDepthPeelingPerformed);
 }
 
 /*!
  * This method works on a pair input (\b arrIn, \b arrIndxIn) where \b arr indexes is in \b arrIndxIn.
  * This method expects that these two input arrays come from the output of MEDCouplingUMesh::computeNeighborsOfCells method.
- * This method start from id 0 that will be contained in output DataArrayInt. It searches then all neighbors of id0 regarding arrIn[arrIndxIn[0]:arrIndxIn[0+1]].
+ * This method start from id 0 that will be contained in output DataArrayIdType. It searches then all neighbors of id0 regarding arrIn[arrIndxIn[0]:arrIndxIn[0+1]].
  * Then it is repeated recursively until either all ids are fetched or no more ids are reachable step by step.
  * A negative value in \b arrIn means that it is ignored.
  * This method is useful to see if a mesh is contiguous regarding its connectivity. If it is not the case the size of returned array is different from arrIndxIn->getNumberOfTuples()-1.
  * \param [in] seedBg the begin pointer (included) of an array containing the seed of the search zone
  * \param [in] seedEnd the end pointer (not included) of an array containing the seed of the search zone
- * \param [in] arrIn arr origin array from which the extraction will be done.
- * \param [in] arrIndxIn is the input index array allowing to walk into \b arrIn
- * \param [in] nbOfDepthPeeling the max number of peels requested in search. By default -1, that is to say, no limit.
- * \param [out] nbOfDepthPeelingPerformed the number of peels effectively performed. May be different from \a nbOfDepthPeeling
- * \return a newly allocated DataArray that stores all ids fetched by the gradually spread process.
- * \sa MEDCouplingUMesh::partitionBySpreadZone
- */
-DataArrayInt *MEDCouplingUMesh::ComputeSpreadZoneGraduallyFromSeed(const int *seedBg, const int *seedEnd, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn, int nbOfDepthPeeling, int& nbOfDepthPeelingPerformed)
-{
-  nbOfDepthPeelingPerformed=0;
-  if(!arrIndxIn)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ComputeSpreadZoneGraduallyFromSeed : arrIndxIn input pointer is NULL !");
-  int nbOfTuples=arrIndxIn->getNumberOfTuples()-1;
-  if(nbOfTuples<=0)
-    {
-      DataArrayInt *ret=DataArrayInt::New(); ret->alloc(0,1);
-      return ret;
-    }
-  //
-  std::vector<bool> fetched(nbOfTuples,false);
-  return ComputeSpreadZoneGraduallyFromSeedAlg(fetched,seedBg,seedEnd,arrIn,arrIndxIn,nbOfDepthPeeling,nbOfDepthPeelingPerformed);
-}
-
-DataArrayInt *MEDCouplingUMesh::ComputeSpreadZoneGraduallyFromSeedAlg(std::vector<bool>& fetched, const int *seedBg, const int *seedEnd, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn, int nbOfDepthPeeling, int& nbOfDepthPeelingPerformed)
-{
-  nbOfDepthPeelingPerformed=0;
-  if(!seedBg || !seedEnd || !arrIn || !arrIndxIn)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ComputeSpreadZoneGraduallyFromSeedAlg : some input pointer is NULL !");
-  int nbOfTuples=arrIndxIn->getNumberOfTuples()-1;
-  std::vector<bool> fetched2(nbOfTuples,false);
-  int i=0;
-  for(const int *seedElt=seedBg;seedElt!=seedEnd;seedElt++,i++)
-    {
-      if(*seedElt>=0 && *seedElt<nbOfTuples)
-        { fetched[*seedElt]=true; fetched2[*seedElt]=true; }
-      else
-        { std::ostringstream oss; oss << "MEDCouplingUMesh::ComputeSpreadZoneGraduallyFromSeedAlg : At pos #" << i << " of seeds value is " << *seedElt << "! Should be in [0," << nbOfTuples << ") !"; throw INTERP_KERNEL::Exception(oss.str()); }
-    }
-  const int *arrInPtr=arrIn->begin();
-  const int *arrIndxPtr=arrIndxIn->begin();
-  int targetNbOfDepthPeeling=nbOfDepthPeeling!=-1?nbOfDepthPeeling:std::numeric_limits<int>::max();
-  std::vector<int> idsToFetch1(seedBg,seedEnd);
-  std::vector<int> idsToFetch2;
-  std::vector<int> *idsToFetch=&idsToFetch1;
-  std::vector<int> *idsToFetchOther=&idsToFetch2;
-  while(!idsToFetch->empty() && nbOfDepthPeelingPerformed<targetNbOfDepthPeeling)
-    {
-      for(std::vector<int>::const_iterator it=idsToFetch->begin();it!=idsToFetch->end();it++)
-        for(const int *it2=arrInPtr+arrIndxPtr[*it];it2!=arrInPtr+arrIndxPtr[*it+1];it2++)
-          if(!fetched[*it2])
-            { fetched[*it2]=true; fetched2[*it2]=true; idsToFetchOther->push_back(*it2); }
-      std::swap(idsToFetch,idsToFetchOther);
-      idsToFetchOther->clear();
-      nbOfDepthPeelingPerformed++;
-    }
-  int lgth=(int)std::count(fetched2.begin(),fetched2.end(),true);
-  i=0;
-  MCAuto<DataArrayInt> ret=DataArrayInt::New(); ret->alloc(lgth,1);
-  int *retPtr=ret->getPointer();
-  for(std::vector<bool>::const_iterator it=fetched2.begin();it!=fetched2.end();it++,i++)
-    if(*it)
-      *retPtr++=i;
-  return ret.retn();
-}
-
-/*!
- * This method works on an input pair (\b arrIn, \b arrIndxIn) where \b arrIn indexes is in \b arrIndxIn.
- * This method builds an output pair (\b arrOut,\b arrIndexOut) that is a copy from \b arrIn for all cell ids \b not \b in [ \b idsOfSelectBg , \b idsOfSelectEnd ) and for
- * cellIds \b in [\b idsOfSelectBg, \b idsOfSelectEnd) a copy coming from the corresponding values in input pair (\b srcArr, \b srcArrIndex).
- * This method is an generalization of MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx that performs the same thing but by without building explicitely a result output arrays.
- *
- * \param [in] start begin of set of ids of the input extraction (included)
- * \param [in] end end of set of ids of the input extraction (excluded)
- * \param [in] step step of the set of ids in range mode.
- * \param [in] arrIn arr origin array from which the extraction will be done.
- * \param [in] arrIndxIn is the input index array allowing to walk into \b arrIn
- * \param [in] srcArr input array that will be used as source of copy for ids in [\b idsOfSelectBg, \b idsOfSelectEnd)
- * \param [in] srcArrIndex index array of \b srcArr
- * \param [out] arrOut the resulting array
- * \param [out] arrIndexOut the index array of the resulting array \b arrOut
- * 
- * \sa MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx MEDCouplingUMesh::SetPartOfIndexedArrays
- */
-void MEDCouplingUMesh::SetPartOfIndexedArraysSlice(int start, int end, int step, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn,
-                                               const DataArrayInt *srcArr, const DataArrayInt *srcArrIndex,
-                                               DataArrayInt* &arrOut, DataArrayInt* &arrIndexOut)
-{
-  if(arrIn==0 || arrIndxIn==0 || srcArr==0 || srcArrIndex==0)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::SetPartOfIndexedArraysSlice : presence of null pointer in input parameter !");
-  MCAuto<DataArrayInt> arro=DataArrayInt::New();
-  MCAuto<DataArrayInt> arrIo=DataArrayInt::New();
-  int nbOfTuples=arrIndxIn->getNumberOfTuples()-1;
-  int offset=0;
-  const int *arrIndxInPtr=arrIndxIn->begin();
-  const int *srcArrIndexPtr=srcArrIndex->begin();
-  int nbOfElemsToSet=DataArray::GetNumberOfItemGivenBESRelative(start,end,step,"MEDCouplingUMesh::SetPartOfIndexedArraysSlice : ");
-  int it=start;
-  for(int i=0;i<nbOfElemsToSet;i++,srcArrIndexPtr++,it+=step)
-    {
-      if(it>=0 && it<nbOfTuples)
-        offset+=(srcArrIndexPtr[1]-srcArrIndexPtr[0])-(arrIndxInPtr[it+1]-arrIndxInPtr[it]);
-      else
-        {
-          std::ostringstream oss; oss << "MEDCouplingUMesh::SetPartOfIndexedArraysSlice : On pos #" << i << " value is " << it << " not in [0," << nbOfTuples << ") !";
-          throw INTERP_KERNEL::Exception(oss.str());
-        }
-    }
-  srcArrIndexPtr=srcArrIndex->begin();
-  arrIo->alloc(nbOfTuples+1,1);
-  arro->alloc(arrIn->getNumberOfTuples()+offset,1);
-  const int *arrInPtr=arrIn->begin();
-  const int *srcArrPtr=srcArr->begin();
-  int *arrIoPtr=arrIo->getPointer(); *arrIoPtr++=0;
-  int *arroPtr=arro->getPointer();
-  for(int ii=0;ii<nbOfTuples;ii++,arrIoPtr++)
-    {
-      int pos=DataArray::GetPosOfItemGivenBESRelativeNoThrow(ii,start,end,step);
-      if(pos<0)
-        {
-          arroPtr=std::copy(arrInPtr+arrIndxInPtr[ii],arrInPtr+arrIndxInPtr[ii+1],arroPtr);
-          *arrIoPtr=arrIoPtr[-1]+(arrIndxInPtr[ii+1]-arrIndxInPtr[ii]);
-        }
-      else
-        {
-          arroPtr=std::copy(srcArrPtr+srcArrIndexPtr[pos],srcArrPtr+srcArrIndexPtr[pos+1],arroPtr);
-          *arrIoPtr=arrIoPtr[-1]+(srcArrIndexPtr[pos+1]-srcArrIndexPtr[pos]);
-        }
-    }
-  arrOut=arro.retn();
-  arrIndexOut=arrIo.retn();
-}
-
-/*!
- * This method works on an input pair (\b arrIn, \b arrIndxIn) where \b arrIn indexes is in \b arrIndxIn.
- * This method is an specialization of MEDCouplingUMesh::SetPartOfIndexedArrays in the case of assignement do not modify the index in \b arrIndxIn.
- *
- * \param [in] start begin of set of ids of the input extraction (included)
- * \param [in] end end of set of ids of the input extraction (excluded)
- * \param [in] step step of the set of ids in range mode.
- * \param [in,out] arrInOut arr origin array from which the extraction will be done.
+ * \param [in] arrIn arr origin array from which the extraction will be done.
  * \param [in] arrIndxIn is the input index array allowing to walk into \b arrIn
- * \param [in] srcArr input array that will be used as source of copy for ids in [\b idsOfSelectBg, \b idsOfSelectEnd)
- * \param [in] srcArrIndex index array of \b srcArr
- * 
- * \sa MEDCouplingUMesh::SetPartOfIndexedArraysSlice MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx
- */
-void MEDCouplingUMesh::SetPartOfIndexedArraysSameIdxSlice(int start, int end, int step, DataArrayInt *arrInOut, const DataArrayInt *arrIndxIn,
-                                                      const DataArrayInt *srcArr, const DataArrayInt *srcArrIndex)
-{
-  if(arrInOut==0 || arrIndxIn==0 || srcArr==0 || srcArrIndex==0)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::SetPartOfIndexedArraysSameIdxSlice : presence of null pointer in input parameter !");
-  int nbOfTuples=arrIndxIn->getNumberOfTuples()-1;
-  const int *arrIndxInPtr=arrIndxIn->begin();
-  const int *srcArrIndexPtr=srcArrIndex->begin();
-  int *arrInOutPtr=arrInOut->getPointer();
-  const int *srcArrPtr=srcArr->begin();
-  int nbOfElemsToSet=DataArray::GetNumberOfItemGivenBESRelative(start,end,step,"MEDCouplingUMesh::SetPartOfIndexedArraysSameIdxSlice : ");
-  int it=start;
-  for(int i=0;i<nbOfElemsToSet;i++,srcArrIndexPtr++,it+=step)
-    {
-      if(it>=0 && it<nbOfTuples)
-        {
-          if(srcArrIndexPtr[1]-srcArrIndexPtr[0]==arrIndxInPtr[it+1]-arrIndxInPtr[it])
-            std::copy(srcArrPtr+srcArrIndexPtr[0],srcArrPtr+srcArrIndexPtr[1],arrInOutPtr+arrIndxInPtr[it]);
-          else
-            {
-              std::ostringstream oss; oss << "MEDCouplingUMesh::SetPartOfIndexedArraysSameIdxSlice : On pos #" << i << " id (idsOfSelectBg[" << i << "]) is " << it << " arrIndxIn[id+1]-arrIndxIn[id]!=srcArrIndex[pos+1]-srcArrIndex[pos] !";
-              throw INTERP_KERNEL::Exception(oss.str());
-            }
-        }
-      else
-        {
-          std::ostringstream oss; oss << "MEDCouplingUMesh::SetPartOfIndexedArraysSameIdxSlice : On pos #" << i << " value is " << it << " not in [0," << nbOfTuples << ") !";
-          throw INTERP_KERNEL::Exception(oss.str());
-        }
+ * \param [in] nbOfDepthPeeling the max number of peels requested in search. By default -1, that is to say, no limit.
+ * \param [out] nbOfDepthPeelingPerformed the number of peels effectively performed. May be different from \a nbOfDepthPeeling
+ * \return a newly allocated DataArray that stores all ids fetched by the gradually spread process.
+ * \sa MEDCouplingUMesh::partitionBySpreadZone
+ */
+DataArrayIdType *MEDCouplingUMesh::ComputeSpreadZoneGraduallyFromSeed(const mcIdType *seedBg, const mcIdType *seedEnd, const DataArrayIdType *arrIn, const DataArrayIdType *arrIndxIn, mcIdType nbOfDepthPeeling, mcIdType& nbOfDepthPeelingPerformed)
+{
+  nbOfDepthPeelingPerformed=0;
+  if(!arrIndxIn)
+    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ComputeSpreadZoneGraduallyFromSeed : arrIndxIn input pointer is NULL !");
+  mcIdType nbOfTuples=arrIndxIn->getNumberOfTuples()-1;
+  if(nbOfTuples<=0)
+    {
+      DataArrayIdType *ret=DataArrayIdType::New(); ret->alloc(0,1);
+      return ret;
     }
+  //
+  std::vector<bool> fetched(nbOfTuples,false);
+  return ComputeSpreadZoneGraduallyFromSeedAlg(fetched,seedBg,seedEnd,arrIn,arrIndxIn,nbOfDepthPeeling,nbOfDepthPeelingPerformed);
 }
 
+
+
 /*!
  * \b this is expected to be a mesh fully defined whose spaceDim==meshDim.
  * It returns a new allocated mesh having the same mesh dimension and lying on same coordinates.
  * The returned mesh contains as poly cells as number of contiguous zone (regarding connectivity).
  * A spread contiguous zone is built using poly cells (polyhedra in 3D, polygons in 2D and polyline in 1D).
  * The sum of measure field of returned mesh is equal to the sum of measure field of this.
- * 
+ *
  * \return a newly allocated mesh lying on the same coords than \b this with same meshdimension than \b this.
  */
 MEDCouplingUMesh *MEDCouplingUMesh::buildSpreadZonesWithPoly() const
@@ -11621,17 +8225,17 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildSpreadZonesWithPoly() const
   int spaceDim=getSpaceDimension();
   if(mdim!=spaceDim)
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildSpreadZonesWithPoly : meshdimension and spacedimension do not match !");
-  std::vector<DataArrayInt *> partition=partitionBySpreadZone();
-  std::vector< MCAuto<DataArrayInt> > partitionAuto; partitionAuto.reserve(partition.size());
-  std::copy(partition.begin(),partition.end(),std::back_insert_iterator<std::vector< MCAuto<DataArrayInt> > >(partitionAuto));
+  std::vector<DataArrayIdType *> partition=partitionBySpreadZone();
+  std::vector< MCAuto<DataArrayIdType> > partitionAuto; partitionAuto.reserve(partition.size());
+  std::copy(partition.begin(),partition.end(),std::back_insert_iterator<std::vector< MCAuto<DataArrayIdType> > >(partitionAuto));
   MCAuto<MEDCouplingUMesh> ret=MEDCouplingUMesh::New(getName(),mdim);
   ret->setCoords(getCoords());
-  ret->allocateCells((int)partition.size());
+  ret->allocateCells(ToIdType(partition.size()));
   //
-  for(std::vector<DataArrayInt *>::const_iterator it=partition.begin();it!=partition.end();it++)
+  for(std::vector<DataArrayIdType *>::const_iterator it=partition.begin();it!=partition.end();it++)
     {
       MCAuto<MEDCouplingUMesh> tmp=static_cast<MEDCouplingUMesh *>(buildPartOfMySelf((*it)->begin(),(*it)->end(),true));
-      MCAuto<DataArrayInt> cell;
+      MCAuto<DataArrayIdType> cell;
       switch(mdim)
       {
         case 2:
@@ -11656,45 +8260,56 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildSpreadZonesWithPoly() const
  * This method only needs a well defined connectivity. Coordinates are not considered here.
  * This method returns a vector of \b newly allocated arrays that the caller has to deal with.
  */
-std::vector<DataArrayInt *> MEDCouplingUMesh::partitionBySpreadZone() const
+std::vector<DataArrayIdType *> MEDCouplingUMesh::partitionBySpreadZone() const
+{
+  DataArrayIdType *neigh=0,*neighI=0;
+  computeNeighborsOfCells(neigh,neighI);
+  MCAuto<DataArrayIdType> neighAuto(neigh),neighIAuto(neighI);
+  return PartitionBySpreadZone(neighAuto,neighIAuto);
+}
+
+std::vector<DataArrayIdType *> MEDCouplingUMesh::PartitionBySpreadZone(const DataArrayIdType *arrIn, const DataArrayIdType *arrIndxIn)
 {
-  int nbOfCellsCur=getNumberOfCells();
-  std::vector<DataArrayInt *> ret;
+  if(!arrIn || !arrIndxIn)
+    throw INTERP_KERNEL::Exception("PartitionBySpreadZone : null input pointers !");
+  arrIn->checkAllocated(); arrIndxIn->checkAllocated();
+  mcIdType nbOfTuples(arrIndxIn->getNumberOfTuples());
+  if(arrIn->getNumberOfComponents()!=1 || arrIndxIn->getNumberOfComponents()!=1 || nbOfTuples<1)
+    throw INTERP_KERNEL::Exception("PartitionBySpreadZone : invalid arrays in input !");
+  mcIdType nbOfCellsCur(nbOfTuples-1);
+  std::vector<DataArrayIdType *> ret;
   if(nbOfCellsCur<=0)
     return ret;
-  DataArrayInt *neigh=0,*neighI=0;
-  computeNeighborsOfCells(neigh,neighI);
-  MCAuto<DataArrayInt> neighAuto(neigh),neighIAuto(neighI);
   std::vector<bool> fetchedCells(nbOfCellsCur,false);
-  std::vector< MCAuto<DataArrayInt> > ret2;
-  int seed=0;
+  std::vector< MCAuto<DataArrayIdType> > ret2;
+  mcIdType seed=0;
   while(seed<nbOfCellsCur)
     {
-      int nbOfPeelPerformed=0;
-      ret2.push_back(ComputeSpreadZoneGraduallyFromSeedAlg(fetchedCells,&seed,&seed+1,neigh,neighI,-1,nbOfPeelPerformed));
-      seed=(int)std::distance(fetchedCells.begin(),std::find(fetchedCells.begin()+seed,fetchedCells.end(),false));
+      mcIdType nbOfPeelPerformed=0;
+      ret2.push_back(ComputeSpreadZoneGraduallyFromSeedAlg(fetchedCells,&seed,&seed+1,arrIn,arrIndxIn,-1,nbOfPeelPerformed));
+      seed=ToIdType(std::distance(fetchedCells.begin(),std::find(fetchedCells.begin()+seed,fetchedCells.end(),false)));
     }
-  for(std::vector< MCAuto<DataArrayInt> >::iterator it=ret2.begin();it!=ret2.end();it++)
+  for(std::vector< MCAuto<DataArrayIdType> >::iterator it=ret2.begin();it!=ret2.end();it++)
     ret.push_back((*it).retn());
   return ret;
 }
 
 /*!
  * This method returns given a distribution of cell type (returned for example by MEDCouplingUMesh::getDistributionOfTypes method and customized after) a
- * newly allocated DataArrayInt instance with 2 components ready to be interpreted as input of DataArrayInt::findRangeIdForEachTuple method.
+ * newly allocated DataArrayIdType instance with 2 components ready to be interpreted as input of DataArrayIdType::findRangeIdForEachTuple method.
  *
  * \param [in] code a code with the same format than those returned by MEDCouplingUMesh::getDistributionOfTypes except for the code[3*k+2] that should contain start id of chunck.
- * \return a newly allocated DataArrayInt to be managed by the caller.
+ * \return a newly allocated DataArrayIdType to be managed by the caller.
  * \throw In case of \a code has not the right format (typically of size 3*n)
  */
-DataArrayInt *MEDCouplingUMesh::ComputeRangesFromTypeDistribution(const std::vector<int>& code)
+DataArrayIdType *MEDCouplingUMesh::ComputeRangesFromTypeDistribution(const std::vector<mcIdType>& code)
 {
-  MCAuto<DataArrayInt> ret=DataArrayInt::New();
+  MCAuto<DataArrayIdType> ret=DataArrayIdType::New();
   std::size_t nb=code.size()/3;
   if(code.size()%3!=0)
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ComputeRangesFromTypeDistribution : invalid input code !");
-  ret->alloc((int)nb,2);
-  int *retPtr=ret->getPointer();
+  ret->alloc(nb,2);
+  mcIdType *retPtr=ret->getPointer();
   for(std::size_t i=0;i<nb;i++,retPtr+=2)
     {
       retPtr[0]=code[3*i+2];
@@ -11709,52 +8324,53 @@ DataArrayInt *MEDCouplingUMesh::ComputeRangesFromTypeDistribution(const std::vec
  * This method will split **all** 3D cells in \a this into INTERP_KERNEL::NORM_TETRA4 cells and put them in the returned mesh.
  * It leads to an increase to number of cells.
  * This method contrary to MEDCouplingUMesh::simplexize can append coordinates in \a this to perform its work.
- * The \a nbOfAdditionalPoints returned value informs about it. If > 0, the coordinates array in returned mesh will have \a nbOfAdditionalPoints 
+ * The \a nbOfAdditionalPoints returned value informs about it. If > 0, the coordinates array in returned mesh will have \a nbOfAdditionalPoints
  * more tuples (nodes) than in \a this. Anyway, all the nodes in \a this (with the same order) will be in the returned mesh.
  *
  * \param [in] policy - the policy of splitting that must be in (PLANAR_FACE_5, PLANAR_FACE_6, GENERAL_24, GENERAL_48). The policy will be used only for INTERP_KERNEL::NORM_HEXA8 cells.
  *                      For all other cells, the splitting policy will be ignored. See INTERP_KERNEL::SplittingPolicy for the images.
- * \param [out] nbOfAdditionalPoints - number of nodes added to \c this->_coords. If > 0 a new coordinates object will be constructed result of the aggregation of the old one and the new points added. 
- * \param [out] n2oCells - A new instance of DataArrayInt holding, for each new cell,
+ * \param [out] nbOfAdditionalPoints - number of nodes added to \c this->_coords. If > 0 a new coordinates object will be constructed result of the aggregation of the old one and the new points added.
+ * \param [out] n2oCells - A new instance of DataArrayIdType holding, for each new cell,
  *          an id of old cell producing it. The caller is to delete this array using
  *         decrRef() as it is no more needed.
  * \return MEDCoupling1SGTUMesh * - the mesh containing only INTERP_KERNEL::NORM_TETRA4 cells.
  *
- * \warning This method operates on each cells in this independantly ! So it can leads to non conform mesh in returned value ! If you expect to have a conform mesh in output
+ * \warning This method operates on each cells in this independently ! So it can leads to non conform mesh in returned value ! If you expect to have a conform mesh in output
  * the policy PLANAR_FACE_6 should be used on a mesh sorted with MEDCoupling1SGTUMesh::sortHexa8EachOther.
- * 
+ *
  * \throw If \a this is not a 3D mesh (spaceDim==3 and meshDim==3).
  * \throw If \a this is not fully constituted with linear 3D cells.
  * \sa MEDCouplingUMesh::simplexize, MEDCoupling1SGTUMesh::sortHexa8EachOther
  */
-MEDCoupling1SGTUMesh *MEDCouplingUMesh::tetrahedrize(int policy, DataArrayInt *& n2oCells, int& nbOfAdditionalPoints) const
+MEDCoupling1SGTUMesh *MEDCouplingUMesh::tetrahedrize(int policy, DataArrayIdType *& n2oCells, mcIdType& nbOfAdditionalPoints) const
 {
   INTERP_KERNEL::SplittingPolicy pol((INTERP_KERNEL::SplittingPolicy)policy);
   checkConnectivityFullyDefined();
   if(getMeshDimension()!=3 || getSpaceDimension()!=3)
     throw INTERP_KERNEL::Exception("MEDCouplingUMesh::tetrahedrize : only available for mesh with meshdim == 3 and spacedim == 3 !");
-  int nbOfCells(getNumberOfCells()),nbNodes(getNumberOfNodes());
+  mcIdType nbOfCells=getNumberOfCells();
+  mcIdType nbNodes(getNumberOfNodes());
   MCAuto<MEDCoupling1SGTUMesh> ret0(MEDCoupling1SGTUMesh::New(getName(),INTERP_KERNEL::NORM_TETRA4));
-  MCAuto<DataArrayInt> ret(DataArrayInt::New()); ret->alloc(nbOfCells,1);
-  int *retPt(ret->getPointer());
-  MCAuto<DataArrayInt> newConn(DataArrayInt::New()); newConn->alloc(0,1);
+  MCAuto<DataArrayIdType> ret(DataArrayIdType::New()); ret->alloc(nbOfCells,1);
+  mcIdType *retPt(ret->getPointer());
+  MCAuto<DataArrayIdType> newConn(DataArrayIdType::New()); newConn->alloc(0,1);
   MCAuto<DataArrayDouble> addPts(DataArrayDouble::New()); addPts->alloc(0,1);
-  const int *oldc(_nodal_connec->begin());
-  const int *oldci(_nodal_connec_index->begin());
+  const mcIdType *oldc(_nodal_connec->begin());
+  const mcIdType *oldci(_nodal_connec_index->begin());
   const double *coords(_coords->begin());
-  for(int i=0;i<nbOfCells;i++,oldci++,retPt++)
+  for(mcIdType i=0;i<nbOfCells;i++,oldci++,retPt++)
     {
-      std::vector<int> a; std::vector<double> b;
+      std::vector<mcIdType> a; std::vector<double> b;
       INTERP_KERNEL::SplitIntoTetras(pol,(INTERP_KERNEL::NormalizedCellType)oldc[oldci[0]],oldc+oldci[0]+1,oldc+oldci[1],coords,a,b);
-      std::size_t nbOfTet(a.size()/4); *retPt=(int)nbOfTet;
-      const int *aa(&a[0]);
+      std::size_t nbOfTet(a.size()/4); *retPt=ToIdType(nbOfTet);
+      const mcIdType *aa(&a[0]);
       if(!b.empty())
         {
-          for(std::vector<int>::iterator it=a.begin();it!=a.end();it++)
+          for(std::vector<mcIdType>::iterator it=a.begin();it!=a.end();it++)
             if(*it<0)
               *it=(-(*(it))-1+nbNodes);
           addPts->insertAtTheEnd(b.begin(),b.end());
-          nbNodes+=(int)b.size()/3;
+          nbNodes+=ToIdType(b.size()/3);
         }
       for(std::size_t j=0;j<nbOfTet;j++,aa+=4)
         newConn->insertAtTheEnd(aa,aa+4);
@@ -11778,287 +8394,6 @@ MEDCoupling1SGTUMesh *MEDCouplingUMesh::tetrahedrize(int policy, DataArrayInt *&
   return ret0.retn();
 }
 
-/*!
- * It is the linear part of MEDCouplingUMesh::split2DCells. Here no additionnal nodes will be added in \b this. So coordinates pointer remain unchanged (is not even touch). 
- *
- * \sa MEDCouplingUMesh::split2DCells
- */
-void MEDCouplingUMesh::split2DCellsLinear(const DataArrayInt *desc, const DataArrayInt *descI, const DataArrayInt *subNodesInSeg, const DataArrayInt *subNodesInSegI)
-{
-  checkConnectivityFullyDefined();
-  int ncells(getNumberOfCells()),lgthToReach(getNodalConnectivityArrayLen()+subNodesInSeg->getNumberOfTuples());
-  MCAuto<DataArrayInt> c(DataArrayInt::New()); c->alloc((std::size_t)lgthToReach);
-  const int *subPtr(subNodesInSeg->begin()),*subIPtr(subNodesInSegI->begin()),*descPtr(desc->begin()),*descIPtr(descI->begin()),*oldConn(getNodalConnectivity()->begin());
-  int *cPtr(c->getPointer()),*ciPtr(getNodalConnectivityIndex()->getPointer());
-  int prevPosOfCi(ciPtr[0]);
-  for(int i=0;i<ncells;i++,ciPtr++,descIPtr++)
-    {
-      int offset(descIPtr[0]),sz(descIPtr[1]-descIPtr[0]),deltaSz(0);
-      *cPtr++=(int)INTERP_KERNEL::NORM_POLYGON; *cPtr++=oldConn[prevPosOfCi+1];
-      for(int j=0;j<sz;j++)
-        {
-          int offset2(subIPtr[descPtr[offset+j]]),sz2(subIPtr[descPtr[offset+j]+1]-subIPtr[descPtr[offset+j]]);
-          for(int k=0;k<sz2;k++)
-            *cPtr++=subPtr[offset2+k];
-          if(j!=sz-1)
-            *cPtr++=oldConn[prevPosOfCi+j+2];
-          deltaSz+=sz2;
-        }
-      prevPosOfCi=ciPtr[1];
-      ciPtr[1]=ciPtr[0]+1+sz+deltaSz;//sz==old nb of nodes because (nb of subedges=nb of nodes for polygons)
-    }
-  if(c->end()!=cPtr)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::split2DCellsLinear : Some of edges to be split are orphan !");
-  _nodal_connec->decrRef();
-  _nodal_connec=c.retn(); _types.clear(); _types.insert(INTERP_KERNEL::NORM_POLYGON);
-}
-
-int InternalAddPoint(const INTERP_KERNEL::Edge *e, int id, const double *coo, int startId, int endId, DataArrayDouble& addCoo, int& nodesCnter)
-{
-  if(id!=-1)
-    return id;
-  else
-    {
-      int ret(nodesCnter++);
-      double newPt[2];
-      e->getMiddleOfPoints(coo+2*startId,coo+2*endId,newPt);
-      addCoo.insertAtTheEnd(newPt,newPt+2);
-      return ret;
-    }
-}
-
-int InternalAddPointOriented(const INTERP_KERNEL::Edge *e, int id, const double *coo, int startId, int endId, DataArrayDouble& addCoo, int& nodesCnter)
-{
-  if(id!=-1)
-    return id;
-  else
-    {
-      int ret(nodesCnter++);
-      double newPt[2];
-      e->getMiddleOfPointsOriented(coo+2*startId,coo+2*endId,newPt);
-      addCoo.insertAtTheEnd(newPt,newPt+2);
-      return ret;
-    }
-}
-
-
-/// @cond INTERNAL
-
-void EnterTheResultOf2DCellFirst(const INTERP_KERNEL::Edge *e, int start, int stp, int nbOfEdges, bool linOrArc, const double *coords, const int *connBg, int offset, DataArrayInt *newConnOfCell, DataArrayDouble *appendedCoords, std::vector<int>& middles)
-{
-  int tmp[3];
-  int trueStart(start>=0?start:nbOfEdges+start);
-  tmp[0]=linOrArc?(int)INTERP_KERNEL::NORM_QPOLYG:(int)INTERP_KERNEL::NORM_POLYGON; tmp[1]=connBg[trueStart]; tmp[2]=connBg[stp];
-  newConnOfCell->insertAtTheEnd(tmp,tmp+3);
-  if(linOrArc)
-    {
-      if(stp-start>1)
-        {
-          int tmp2(0),tmp3(appendedCoords->getNumberOfTuples()/2);
-          InternalAddPointOriented(e,-1,coords,tmp[1],tmp[2],*appendedCoords,tmp2);
-          middles.push_back(tmp3+offset);
-        }
-      else
-        middles.push_back(connBg[trueStart+nbOfEdges]);
-    }
-}
-
-void EnterTheResultOf2DCellMiddle(const INTERP_KERNEL::Edge *e, int start, int stp, int nbOfEdges, bool linOrArc, const double *coords, const int *connBg, int offset, DataArrayInt *newConnOfCell, DataArrayDouble *appendedCoords, std::vector<int>& middles)
-{
-  int tmpSrt(newConnOfCell->back()),tmpEnd(connBg[stp]);
-  newConnOfCell->pushBackSilent(tmpEnd);
-  if(linOrArc)
-    {
-      if(stp-start>1)
-        {
-          int tmp2(0),tmp3(appendedCoords->getNumberOfTuples()/2);
-          InternalAddPointOriented(e,-1,coords,tmpSrt,tmpEnd,*appendedCoords,tmp2);
-          middles.push_back(tmp3+offset);
-        }
-      else
-        middles.push_back(connBg[start+nbOfEdges]);
-    }
-}
-
-void EnterTheResultOf2DCellEnd(const INTERP_KERNEL::Edge *e, int start, int stp, int nbOfEdges, bool linOrArc, const double *coords, const int *connBg, int offset, DataArrayInt *newConnOfCell, DataArrayDouble *appendedCoords, std::vector<int>& middles)
-{
-  // only the quadratic point to deal with:
-  if(linOrArc)
-    {
-      if(stp-start>1)
-        {
-          int tmpSrt(connBg[start]),tmpEnd(connBg[stp]);
-          int tmp2(0),tmp3(appendedCoords->getNumberOfTuples()/2);
-          InternalAddPointOriented(e,-1,coords,tmpSrt,tmpEnd,*appendedCoords,tmp2);
-          middles.push_back(tmp3+offset);
-        }
-      else
-        middles.push_back(connBg[start+nbOfEdges]);
-    }
-}
-
-/// @endcond
-
-/*!
- * Returns true if a colinearization has been found in the given cell. If false is returned the content pushed in \a newConnOfCell is equal to [ \a connBg , \a connEnd ) .
- * \a appendedCoords is a DataArrayDouble instance with number of components equal to one (even if the items are pushed by pair).
- */
-bool MEDCouplingUMesh::Colinearize2DCell(const double *coords, const int *connBg, const int *connEnd, int offset, DataArrayInt *newConnOfCell, DataArrayDouble *appendedCoords)
-{
-  std::size_t sz(std::distance(connBg,connEnd));
-  if(sz<3)//3 because 2+1(for the cell type) and 2 is the minimal number of edges of 2D cell.
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::Colinearize2DCell : the input cell has invalid format !");
-  sz--;
-  INTERP_KERNEL::AutoPtr<int> tmpConn(new int[sz]);
-  const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)connBg[0]));
-  unsigned nbs(cm.getNumberOfSons2(connBg+1,sz));
-  unsigned nbOfHit(0); // number of fusions operated
-  int posBaseElt(0),posEndElt(0),nbOfTurn(0);
-  const unsigned int maxNbOfHit = cm.isQuadratic() ? nbs-2 : nbs-3;  // a quad cell is authorized to end up with only two edges, a linear one has to keep 3 at least
-  INTERP_KERNEL::NormalizedCellType typeOfSon;
-  std::vector<int> middles;
-  bool ret(false);
-  for(;(nbOfTurn+nbOfHit)<nbs;nbOfTurn++)
-    {
-      cm.fillSonCellNodalConnectivity2(posBaseElt,connBg+1,sz,tmpConn,typeOfSon);
-      std::map<MCAuto<INTERP_KERNEL::Node>,int> m;
-      INTERP_KERNEL::Edge *e(MEDCouplingUMeshBuildQPFromEdge2(typeOfSon,tmpConn,coords,m));
-      posEndElt = posBaseElt+1;
-
-      // Look backward first: are the final edges of the cells colinear with the first ones?
-      // This initializes posBaseElt.
-      if(nbOfTurn==0)
-        {
-          for(unsigned i=1;i<nbs && nbOfHit<maxNbOfHit;i++) // 2nd condition is to avoid ending with a cell wih one single edge
-            {
-              cm.fillSonCellNodalConnectivity2(nbs-i,connBg+1,sz,tmpConn,typeOfSon);
-              INTERP_KERNEL::Edge *eCand(MEDCouplingUMeshBuildQPFromEdge2(typeOfSon,tmpConn,coords,m));
-              INTERP_KERNEL::EdgeIntersector *eint(INTERP_KERNEL::Edge::BuildIntersectorWith(e,eCand));
-              bool isColinear=eint->areColinears();
-              if(isColinear)
-                {
-                  nbOfHit++;
-                  posBaseElt--;
-                  ret=true;
-                }
-              delete eint;
-              eCand->decrRef();
-              if(!isColinear)
-                break;
-            }
-        }
-      // Now move forward:
-      const unsigned fwdStart = (nbOfTurn == 0 ? 0 : posBaseElt);  // the first element to be inspected going forward
-      for(unsigned j=fwdStart+1;j<nbs && nbOfHit<maxNbOfHit;j++)  // 2nd condition is to avoid ending with a cell wih one single edge
-        {
-          cm.fillSonCellNodalConnectivity2((int)j,connBg+1,sz,tmpConn,typeOfSon); // get edge #j's connectivity
-          INTERP_KERNEL::Edge *eCand(MEDCouplingUMeshBuildQPFromEdge2(typeOfSon,tmpConn,coords,m));
-          INTERP_KERNEL::EdgeIntersector *eint(INTERP_KERNEL::Edge::BuildIntersectorWith(e,eCand));
-          bool isColinear(eint->areColinears());
-          if(isColinear)
-            {
-              nbOfHit++;
-              posEndElt++;
-              ret=true;
-            }
-          delete eint;
-          eCand->decrRef();
-          if(!isColinear)
-              break;
-        }
-      //push [posBaseElt,posEndElt) in newConnOfCell using e
-      // The if clauses below are (volontary) not mutually exclusive: on a quad cell with 2 edges, the end of the connectivity is also its begining!
-      if(nbOfTurn==0)
-        // at the begining of the connectivity (insert type)
-        EnterTheResultOf2DCellFirst(e,posBaseElt,posEndElt,(int)nbs,cm.isQuadratic(),coords,connBg+1,offset,newConnOfCell,appendedCoords,middles);
-      else if((nbOfHit+nbOfTurn) != (nbs-1))
-        // in the middle
-        EnterTheResultOf2DCellMiddle(e,posBaseElt,posEndElt,(int)nbs,cm.isQuadratic(),coords,connBg+1,offset,newConnOfCell,appendedCoords,middles);
-      if ((nbOfHit+nbOfTurn) == (nbs-1))
-        // at the end (only quad points to deal with)
-        EnterTheResultOf2DCellEnd(e,posBaseElt,posEndElt,(int)nbs,cm.isQuadratic(),coords,connBg+1,offset,newConnOfCell,appendedCoords,middles);
-      posBaseElt=posEndElt;
-      e->decrRef();
-    }
-  if(!middles.empty())
-    newConnOfCell->insertAtTheEnd(middles.begin(),middles.end());
-  return ret;
-}
-
-/*!
- * It is the quadratic part of MEDCouplingUMesh::split2DCells. Here some additionnal nodes can be added at the end of coordinates array object.
- *
- * \return  int - the number of new nodes created.
- * \sa MEDCouplingUMesh::split2DCells
- */
-int MEDCouplingUMesh::split2DCellsQuadratic(const DataArrayInt *desc, const DataArrayInt *descI, const DataArrayInt *subNodesInSeg, const DataArrayInt *subNodesInSegI, const DataArrayInt *mid, const DataArrayInt *midI)
-{
-  checkConsistencyLight();
-  int ncells(getNumberOfCells()),lgthToReach(getNodalConnectivityArrayLen()+2*subNodesInSeg->getNumberOfTuples()),nodesCnt(getNumberOfNodes());
-  MCAuto<DataArrayInt> c(DataArrayInt::New()); c->alloc((std::size_t)lgthToReach);
-  MCAuto<DataArrayDouble> addCoo(DataArrayDouble::New()); addCoo->alloc(0,1);
-  const int *subPtr(subNodesInSeg->begin()),*subIPtr(subNodesInSegI->begin()),*descPtr(desc->begin()),*descIPtr(descI->begin()),*oldConn(getNodalConnectivity()->begin());
-  const int *midPtr(mid->begin()),*midIPtr(midI->begin());
-  const double *oldCoordsPtr(getCoords()->begin());
-  int *cPtr(c->getPointer()),*ciPtr(getNodalConnectivityIndex()->getPointer());
-  int prevPosOfCi(ciPtr[0]);
-  for(int i=0;i<ncells;i++,ciPtr++,descIPtr++)
-    {
-      int offset(descIPtr[0]),sz(descIPtr[1]-descIPtr[0]),deltaSz(sz);
-      for(int j=0;j<sz;j++)
-        { int sz2(subIPtr[descPtr[offset+j]+1]-subIPtr[descPtr[offset+j]]); deltaSz+=sz2; }
-      *cPtr++=(int)INTERP_KERNEL::NORM_QPOLYG; cPtr[0]=oldConn[prevPosOfCi+1];
-      for(int j=0;j<sz;j++)//loop over subedges of oldConn
-        {
-          int offset2(subIPtr[descPtr[offset+j]]),sz2(subIPtr[descPtr[offset+j]+1]-subIPtr[descPtr[offset+j]]),offset3(midIPtr[descPtr[offset+j]]);
-          if(sz2==0)
-            {
-              if(j<sz-1)
-                cPtr[1]=oldConn[prevPosOfCi+2+j];
-              cPtr[deltaSz]=oldConn[prevPosOfCi+1+j+sz]; cPtr++;
-              continue;
-            }
-          std::vector<INTERP_KERNEL::Node *> ns(3);
-          ns[0]=new INTERP_KERNEL::Node(oldCoordsPtr[2*oldConn[prevPosOfCi+1+j]],oldCoordsPtr[2*oldConn[prevPosOfCi+1+j]+1]);
-          ns[1]=new INTERP_KERNEL::Node(oldCoordsPtr[2*oldConn[prevPosOfCi+1+(1+j)%sz]],oldCoordsPtr[2*oldConn[prevPosOfCi+1+(1+j)%sz]+1]);
-          ns[2]=new INTERP_KERNEL::Node(oldCoordsPtr[2*oldConn[prevPosOfCi+1+sz+j]],oldCoordsPtr[2*oldConn[prevPosOfCi+1+sz+j]+1]);
-          MCAuto<INTERP_KERNEL::Edge> e(INTERP_KERNEL::QuadraticPolygon::BuildArcCircleEdge(ns));
-          for(int k=0;k<sz2;k++)//loop over subsplit of current subedge
-            {
-              cPtr[1]=subPtr[offset2+k];
-              cPtr[deltaSz]=InternalAddPoint(e,midPtr[offset3+k],oldCoordsPtr,cPtr[0],cPtr[1],*addCoo,nodesCnt); cPtr++;
-            }
-          int tmpEnd(oldConn[prevPosOfCi+1+(j+1)%sz]);
-          if(j!=sz-1)
-            { cPtr[1]=tmpEnd; }
-          cPtr[deltaSz]=InternalAddPoint(e,midPtr[offset3+sz2],oldCoordsPtr,cPtr[0],tmpEnd,*addCoo,nodesCnt); cPtr++;
-        }
-      prevPosOfCi=ciPtr[1]; cPtr+=deltaSz;
-      ciPtr[1]=ciPtr[0]+1+2*deltaSz;//sz==old nb of nodes because (nb of subedges=nb of nodes for polygons)
-    }
-  if(c->end()!=cPtr)
-    throw INTERP_KERNEL::Exception("MEDCouplingUMesh::split2DCellsQuadratic : Some of edges to be split are orphan !");
-  _nodal_connec->decrRef();
-  _nodal_connec=c.retn(); _types.clear(); _types.insert(INTERP_KERNEL::NORM_QPOLYG);
-  addCoo->rearrange(2);
-  MCAuto<DataArrayDouble> coo(DataArrayDouble::Aggregate(getCoords(),addCoo));//info are copied from getCoords() by using Aggregate
-  setCoords(coo);
-  return addCoo->getNumberOfTuples();
-}
-
-void MEDCouplingUMesh::ComputeAllTypesInternal(std::set<INTERP_KERNEL::NormalizedCellType>& types, const DataArrayInt *nodalConnec, const DataArrayInt *nodalConnecIndex)
-{
-  if(nodalConnec && nodalConnecIndex)
-    {
-      types.clear();
-      const int *conn(nodalConnec->begin()),*connIndex(nodalConnecIndex->begin());
-      int nbOfElem(nodalConnecIndex->getNbOfElems()-1);
-      if(nbOfElem>0)
-        for(const int *pt=connIndex;pt!=connIndex+nbOfElem;pt++)
-          types.insert((INTERP_KERNEL::NormalizedCellType)conn[*pt]);
-    }
-}
-
 MEDCouplingUMeshCellIterator::MEDCouplingUMeshCellIterator(MEDCouplingUMesh *mesh):_mesh(mesh),_cell(new MEDCouplingUMeshCell(mesh)),
     _own_cell(true),_cell_id(-1),_nb_cell(0)
 {
@@ -12077,7 +8412,7 @@ MEDCouplingUMeshCellIterator::~MEDCouplingUMeshCellIterator()
     delete _cell;
 }
 
-MEDCouplingUMeshCellIterator::MEDCouplingUMeshCellIterator(MEDCouplingUMesh *mesh, MEDCouplingUMeshCell *itc, int bg, int end):_mesh(mesh),_cell(itc),
+MEDCouplingUMeshCellIterator::MEDCouplingUMeshCellIterator(MEDCouplingUMesh *mesh, MEDCouplingUMeshCell *itc, mcIdType bg, mcIdType end):_mesh(mesh),_cell(itc),
     _own_cell(false),_cell_id(bg-1),
     _nb_cell(end)
 {
@@ -12114,7 +8449,7 @@ MEDCouplingUMeshCellByTypeEntry::~MEDCouplingUMeshCellByTypeEntry()
     _mesh->decrRef();
 }
 
-MEDCouplingUMeshCellEntry::MEDCouplingUMeshCellEntry(MEDCouplingUMesh *mesh,  INTERP_KERNEL::NormalizedCellType type, MEDCouplingUMeshCell *itc, int bg, int end):_mesh(mesh),_type(type),
+MEDCouplingUMeshCellEntry::MEDCouplingUMeshCellEntry(MEDCouplingUMesh *mesh,  INTERP_KERNEL::NormalizedCellType type, MEDCouplingUMeshCell *itc, mcIdType bg, mcIdType end):_mesh(mesh),_type(type),
     _itc(itc),
     _bg(bg),_end(end)
 {
@@ -12133,7 +8468,7 @@ INTERP_KERNEL::NormalizedCellType MEDCouplingUMeshCellEntry::getType() const
   return _type;
 }
 
-int MEDCouplingUMeshCellEntry::getNumberOfElems() const
+mcIdType MEDCouplingUMeshCellEntry::getNumberOfElems() const
 {
   return _end-_bg;
 }
@@ -12161,13 +8496,13 @@ MEDCouplingUMeshCellByTypeIterator::~MEDCouplingUMeshCellByTypeIterator()
 
 MEDCouplingUMeshCellEntry *MEDCouplingUMeshCellByTypeIterator::nextt()
 {
-  const int *c=_mesh->getNodalConnectivity()->begin();
-  const int *ci=_mesh->getNodalConnectivityIndex()->begin();
+  const mcIdType *c=_mesh->getNodalConnectivity()->begin();
+  const mcIdType *ci=_mesh->getNodalConnectivityIndex()->begin();
   if(_cell_id<_nb_cell)
     {
       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)c[ci[_cell_id]];
-      int nbOfElems=(int)std::distance(ci+_cell_id,std::find_if(ci+_cell_id,ci+_nb_cell,MEDCouplingImpl::ConnReader(c,type)));
-      int startId=_cell_id;
+      mcIdType nbOfElems=ToIdType(std::distance(ci+_cell_id,std::find_if(ci+_cell_id,ci+_nb_cell,MEDCouplingImpl::ConnReader(c,type))));
+      mcIdType startId=_cell_id;
       _cell_id+=nbOfElems;
       return new MEDCouplingUMeshCellEntry(_mesh,type,_cell,startId,_cell_id);
     }
@@ -12200,7 +8535,7 @@ std::string MEDCouplingUMeshCell::repr() const
     {
       std::ostringstream oss; oss << "Cell Type " << INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)_conn[0]).getRepr();
       oss << " : ";
-      std::copy(_conn+1,_conn+_conn_lgth,std::ostream_iterator<int>(oss," "));
+      std::copy(_conn+1,_conn+_conn_lgth,std::ostream_iterator<mcIdType>(oss," "));
       return oss.str();
     }
   else
@@ -12215,7 +8550,7 @@ INTERP_KERNEL::NormalizedCellType MEDCouplingUMeshCell::getType() const
     return INTERP_KERNEL::NORM_ERROR;
 }
 
-const int *MEDCouplingUMeshCell::getAllConn(int& lgth) const
+const mcIdType *MEDCouplingUMeshCell::getAllConn(mcIdType& lgth) const
 {
   lgth=_conn_lgth;
   if(_conn_lgth!=NOTICABLE_FIRST_VAL)
@@ -12223,3 +8558,411 @@ const int *MEDCouplingUMeshCell::getAllConn(int& lgth) const
   else
     return 0;
 }
+
+/// @cond INTERNAL
+
+namespace MEDCouplingImpl
+{
+  const mcIdType theUndefID = std::numeric_limits< mcIdType >::max(); //!< undefined cell id
+
+  //================================================================================
+  /*!
+   * \brief Encode a cell id and a mesh index into a code
+   *  \param [in] id - cell id
+   *  \param [in] iMesh - mesh index [0,1]
+   *  \return mcIdType - code
+   */
+  //================================================================================
+
+  mcIdType encodeID( mcIdType id, int iMesh )
+  {
+    return ( id + 1 ) * ( iMesh ? -1 : 1 );
+  }
+  //================================================================================
+  /*!
+   * \brief Return cell id and mesh index by a given id
+   *  \param [in] id - code of a cell in a mesh
+   *  \param [out] iMesh - returned mesh index
+   *  \return mcIdType - cell id
+   */
+  //================================================================================
+
+  mcIdType decodeID( mcIdType id, int& iMesh )
+  {
+    iMesh = ( id < 0 );
+    return std::abs( id ) - 1;
+  }
+
+  //================================================================================
+  /*!
+   * \brief return another face sharing two given nodes of a face edge
+   *  \param [in] n0 - 1st node of the edge
+   *  \param [in] n1 - 2nd node of the edge
+   *  \param [in] inputFaceID - face including \a n0 andf \a n2
+   *  \param [in] mesh - object and reference meshes
+   *  \param [in] revNodal - reverse nodal connectivity of the two meshes
+   *  \param [in] revNodalIndx - index of reverse nodal connectivity of the two meshes
+   *  \param [out] facesByEdge - return another face including \a n0 andf \a n2
+   *  \param [out] equalFaces - return faces equal to facesByEdge
+   */
+  //================================================================================
+
+  void getFacesOfEdge( mcIdType n0,
+                       mcIdType n1,
+                       mcIdType inputFaceID,
+                       MEDCouplingUMesh* mesh[],
+                       MCAuto<DataArrayIdType> revNodal[],
+                       MCAuto<DataArrayIdType> revNodalIndx[],
+                       std::vector< mcIdType >& facesByEdge,
+                       std::vector< mcIdType >& equalFaces)
+  {
+    // find faces sharing the both nodes of edge
+
+    facesByEdge.clear();
+    size_t prevNbF; // nb faces found in 0-th mesh
+    for ( int iM = 0; iM < 2; ++iM )
+      {
+        const mcIdType * revInd = revNodalIndx[ iM ]->begin();
+        const mcIdType * rev    = revNodal    [ iM ]->begin();
+
+        mcIdType nbRevFaces0 = revInd[ n0 + 1 ] - revInd[ n0 ];
+        mcIdType nbRevFaces1 = revInd[ n1 + 1 ] - revInd[ n1 ];
+
+        prevNbF = facesByEdge.size();
+        facesByEdge.resize( prevNbF + std::max( nbRevFaces0, nbRevFaces1 ));
+
+        auto it = std::set_intersection( rev + revInd[ n0 ],
+                                         rev + revInd[ n0 ] + nbRevFaces0,
+                                         rev + revInd[ n1 ],
+                                         rev + revInd[ n1 ] + nbRevFaces1,
+                                         facesByEdge.begin() + prevNbF );
+        facesByEdge.resize( it - facesByEdge.begin() );
+      }
+
+    // facesByEdge now contains at least the 'inputFaceID'
+    // check if there are other faces
+
+    size_t nbF = facesByEdge.size();
+    if ( nbF > 1 )
+      {
+        if ( prevNbF > 0 && prevNbF < nbF ) // faces found in both meshes
+          {
+            // remove from facesByEdge equal faces in different meshes
+            const mcIdType *conn [2] = { mesh[0]->getNodalConnectivity()->getConstPointer(),
+                                         mesh[1]->getNodalConnectivity()->getConstPointer() };
+            const mcIdType *connI[2] = { mesh[0]->getNodalConnectivityIndex()->getConstPointer(),
+                                         mesh[1]->getNodalConnectivityIndex()->getConstPointer() };
+            for ( size_t i0 = 0; i0 < prevNbF; ++i0 )
+              {
+                if ( facesByEdge[ i0 ] == theUndefID )
+                  continue;
+                mcIdType objFaceID = MEDCouplingImpl::encodeID( facesByEdge[ i0 ], 0 );
+                bool   isInputFace = ( objFaceID == inputFaceID );
+
+                for ( size_t i1 = prevNbF; i1 < facesByEdge.size(); ++i1 )
+                  {
+                    if ( facesByEdge[ i1 ] == theUndefID )
+                      continue;
+
+                    mcIdType f0 = facesByEdge[ i0 ];
+                    mcIdType f1 = facesByEdge[ i1 ];
+                    size_t nbNodes0 = connI[0][ f0 + 1 ] - connI[0][ f0 ] - 1;
+                    size_t nbNodes1 = connI[1][ f1 + 1 ] - connI[1][ f1 ] - 1;
+                    if ( nbNodes0 != nbNodes1 )
+                      continue;
+
+                    const mcIdType * fConn0 = conn[0] + connI[0][ f0 ] + 1;
+                    const mcIdType * fConn1 = conn[1] + connI[1][ f1 ] + 1;
+                    if ( std::equal( fConn0, fConn0 + nbNodes0, fConn1 ))
+                      {
+                        // equal faces; remove an object one
+                        mcIdType refFaceID = MEDCouplingImpl::encodeID( facesByEdge[ i1 ], 1 );
+                        if ( refFaceID == inputFaceID )
+                          isInputFace = true;
+
+                        if ( std::find( equalFaces.begin(),
+                                        equalFaces.end(), objFaceID ) == equalFaces.end() )
+                          equalFaces.push_back( objFaceID );
+
+                        facesByEdge[ i0 ] = theUndefID;
+                        if ( isInputFace )
+                          facesByEdge[ i1 ] = theUndefID;
+                        break;
+                      }
+                  }
+                if ( isInputFace )
+                  facesByEdge[ i0 ] = theUndefID;
+              }
+          }
+      }
+
+    nbF = facesByEdge.size();
+    for ( size_t i = 0; i < facesByEdge.size(); ++i )
+      {
+        if ( facesByEdge[ i ] != theUndefID )
+          {
+            facesByEdge[ i ] = MEDCouplingImpl::encodeID( facesByEdge[ i ], i >= prevNbF );
+            if ( facesByEdge[ i ] == inputFaceID )
+              facesByEdge[ i ] = theUndefID;
+          }
+        nbF -= ( facesByEdge[ i ] == theUndefID );
+      }
+
+    if ( nbF > 1 )
+      return; // non-manifold
+
+    if ( nbF < 1 )
+      {
+        facesByEdge.clear();
+      }
+    else // nbF == 1, set a found face first
+      {
+        if ( facesByEdge[ 0 ] == theUndefID )
+          {
+            for ( size_t i = 1; i < facesByEdge.size(); ++i )
+              if ( facesByEdge[ i ] != theUndefID )
+                {
+                  facesByEdge[ 0 ] = facesByEdge[ i ];
+                  break;
+                }
+          }
+        facesByEdge.resize( 1 );
+      }
+    return;
+  }
+
+  //================================================================================
+  /*!
+   * \brief Remove a face from nodal reversed connectivity
+   *  \param [in] node - a node of the face
+   *  \param [in] face - the face
+   *  \param [in.out] revNodal - reverse nodal connectivity
+   *  \param [in,out] revNodalIndx - reverse nodal connectivity index
+   */
+  //================================================================================
+
+  void removeFromRevNodal( mcIdType node,
+                           mcIdType face,
+                           MCAuto<DataArrayIdType>& revNodal,
+                           MCAuto<DataArrayIdType>& revNodalIndx)
+  {
+    mcIdType* fBeg = revNodal->getPointer() + revNodalIndx->getIJ( node, 0 );
+    mcIdType* fEnd = revNodal->getPointer() + revNodalIndx->getIJ( node + 1, 0);
+    auto it = std::find( fBeg, fEnd, face );
+    if ( it != fEnd )
+      {
+        for ( auto it2 = it + 1; it2 < fEnd; ++it2 ) // keep faces sorted
+          *( it2 - 1 ) = *it2;
+
+        *( fEnd - 1 ) = theUndefID;
+      }
+  }
+
+  //================================================================================
+  /*!
+   * \brief Check order of two nodes in a given face
+   *  \param [inout] n0 - node 1
+   *  \param [inout] n1 - node 2
+   *  \param [inout] iFEnc - face
+   *  \param [inout] mesh - mesh
+   *  \return bool - true if the nodes are in [ .., n1, n0, ..] order in face
+   */
+  //================================================================================
+
+  bool isReverseOrder( mcIdType n0,
+                       mcIdType n1,
+                       mcIdType iFEnc,
+                       MEDCouplingUMesh* mesh[] )
+  {
+    int iMesh;
+    mcIdType iF = decodeID( iFEnc, iMesh );
+
+    const mcIdType *conn  = mesh[ iMesh ]->getNodalConnectivity()->getConstPointer();
+    const mcIdType *connI = mesh[ iMesh ]->getNodalConnectivityIndex()->getConstPointer();
+
+    auto it0 = std::find( conn + connI[ iF ] + 1,
+                          conn + connI[ iF + 1 ],
+                          n0 );
+    auto it1 = std::find( conn + connI[ iF ] + 1,
+                          conn + connI[ iF + 1 ],
+                          n1 );
+    long i0 = it0 - conn;
+    long i1 = it1 - conn;
+
+    bool isRev = ( std::abs( i1 - i0 ) == 1 ) ?  i1 < i0 :  i0 < i1;
+    return isRev;
+  }
+
+  //================================================================================
+  /*!
+   * \brief Change orientation of a face in one of given meshes
+   *  \param [in] iFEnc - face ID also encoding a mesh index
+   *  \param [in,out] mesh - object and reference meshes
+   */
+  //================================================================================
+
+  void reverseFace( mcIdType iFEnc, MEDCouplingUMesh* mesh[] )
+  {
+    int iMesh;
+    mcIdType face = decodeID( iFEnc, iMesh );
+
+    mcIdType *conn  = mesh[ iMesh ]->getNodalConnectivity()->getPointer();
+    mcIdType *connI = mesh[ iMesh ]->getNodalConnectivityIndex()->getPointer();
+
+    const INTERP_KERNEL::CellModel& cm =
+      INTERP_KERNEL::CellModel::GetCellModel( mesh[iMesh]->getTypeOfCell( face ));
+
+    cm.changeOrientationOf2D( conn + connI[ face ] + 1,
+                              (unsigned int)( connI[ face + 1 ] - connI[ face ] - 1 ));
+    return;
+  }
+}
+
+/// @endcond
+
+//================================================================================
+/*!
+ * \brief Orient cells of \a this 2D mesh equally to \a refFaces
+ *  \param [in] refFaces - 2D mesh containing correctly oriented faces. It is optional.
+ *              If there are no cells in \a refFaces or it is nullptr, then any face
+ *              in \a this mesh is used as a reference
+ *  \throw If \a this mesh is not well defined.
+ *  \throw If \a this mesh or \refFaces are not 2D.
+ *  \throw If \a this mesh and \refFaces do not share nodes.
+ *  \throw If \a refFaces are not equally oriented.
+ *  \throw If \a this mesh plus \a refFaces together form a non-manifold mesh.
+ *
+ *  \if ENABLE_EXAMPLES
+ *  \ref cpp_mcumesh_are2DCellsNotCorrectlyOriented "Here is a C++ example".<br>
+ *  \ref  py_mcumesh_are2DCellsNotCorrectlyOriented "Here is a Python example".
+ *  \endif
+ */
+//================================================================================
+
+void MEDCouplingUMesh::orientCorrectly2DCells(const MEDCouplingUMesh* refFaces)
+{
+  checkConsistencyLight();
+  if ( getMeshDimension() != 2 )
+    throw INTERP_KERNEL::Exception("The mesh dimension must be 2");
+  if ( refFaces )
+    {
+      refFaces->checkConsistencyLight();
+      if ( refFaces->getMeshDimension() != 2 )
+        throw INTERP_KERNEL::Exception("The reference mesh dimension must be 2");
+      if ( getCoords() != refFaces->getCoords() )
+        throw INTERP_KERNEL::Exception("Object and reference meshes must share nodes ");
+      if ( refFaces->getNumberOfCells() == 0 )
+        refFaces = nullptr;
+    }
+  if ( getNumberOfCells() == 0 )
+    return;
+
+  enum { _OBJ, _REF };
+  MEDCouplingUMesh* mesh[2] = { this, const_cast< MEDCouplingUMesh* >( refFaces ) };
+  MCAuto<MEDCouplingUMesh> meshPtr;
+  if ( !mesh[_REF] )
+    {
+      meshPtr = mesh[_REF] = MEDCouplingUMesh::New();
+      mesh[_REF]->setCoords( mesh[_OBJ]->getCoords() );
+      mesh[_REF]->allocateCells(0);
+      mesh[_REF]->finishInsertingCells();
+    }
+  mcIdType nbFacesToCheck[2] = { mesh[_OBJ]->getNumberOfCells(),
+                                 mesh[_REF]->getNumberOfCells() };
+  std::vector< bool > isFaceQueued[ 2 ]; // enqueued faces of 2 meshes
+  isFaceQueued[_OBJ].resize( nbFacesToCheck[_OBJ] );
+  isFaceQueued[_REF].resize( nbFacesToCheck[_REF] );
+
+  MCAuto<DataArrayIdType> revNodal    [2] = { DataArrayIdType::New(), DataArrayIdType::New() };
+  MCAuto<DataArrayIdType> revNodalIndx[2] = { DataArrayIdType::New(), DataArrayIdType::New() };
+  mesh[_OBJ]->getReverseNodalConnectivity( revNodal[_OBJ], revNodalIndx[_OBJ] );
+  mesh[_REF]->getReverseNodalConnectivity( revNodal[_REF], revNodalIndx[_REF] );
+
+  std::vector< mcIdType > faceNodes(4);
+  std::vector< mcIdType > facesByEdge(4), equalFaces;
+  std::vector< mcIdType > faceQueue; // starting faces with IDs counted from 1; negative ID mean a face in ref mesh
+
+  while ( nbFacesToCheck[_OBJ] + nbFacesToCheck[_REF] > 0 ) // until all faces checked
+    {
+      if ( faceQueue.empty() ) // all neighbors checked, find more faces to check
+        {
+          for ( int iMesh = 1; iMesh >= 0; --iMesh ) // on [ _REF, _OBJ ]
+            if ( nbFacesToCheck[iMesh] > 0 )
+              for ( mcIdType f = 0, nbF = mesh[iMesh]->getNumberOfCells(); f < nbF; ++f )
+                if ( !isFaceQueued[iMesh][f] )
+                  {
+                    faceQueue.push_back( MEDCouplingImpl::encodeID( f, iMesh ));
+                    isFaceQueued[ iMesh ][ f ] = true;
+                    iMesh = 0;
+                    break;
+                  }
+          if ( faceQueue.empty() )
+            break;
+        }
+
+      mcIdType fID = faceQueue.back();
+      faceQueue.pop_back();
+
+      int iMesh, iMesh2;
+      mcIdType refFace = MEDCouplingImpl::decodeID( fID, iMesh );
+
+      nbFacesToCheck[iMesh]--;
+
+      equalFaces.clear();
+      faceNodes.clear();
+      mesh[iMesh]->getNodeIdsOfCell( refFace, faceNodes );
+      const INTERP_KERNEL::CellModel& cm = INTERP_KERNEL::CellModel::GetCellModel( mesh[iMesh]->getTypeOfCell( refFace ));
+      const int nbEdges = cm.getNumberOfSons();
+
+      // loop on edges of the refFace
+      mcIdType n0 = faceNodes[ nbEdges - 1 ]; // 1st node of edge
+      for ( int edge = 0; edge < nbEdges; ++edge )
+        {
+          mcIdType n1 = faceNodes[ edge ]; // 2nd node of edge
+
+          // get faces sharing the edge
+          MEDCouplingImpl::getFacesOfEdge( n0, n1, fID, mesh, revNodal, revNodalIndx,
+                                           facesByEdge, equalFaces );
+
+          if ( facesByEdge.size() > 1 )
+            THROW_IK_EXCEPTION("Non-manifold mesh at edge " << n0+1 << " - " << n1+1);
+
+          if ( facesByEdge.size() == 1 )
+            {
+              // compare orientation of two faces
+              //
+              if ( !MEDCouplingImpl::isReverseOrder( n0, n1, facesByEdge[0], mesh ))
+                {
+                  if ( facesByEdge[0] < 0 ) // in the ref mesh
+                    throw INTERP_KERNEL::Exception("Different orientation of reference faces");
+
+                  MEDCouplingImpl::reverseFace( facesByEdge[0], mesh );
+                }
+              mcIdType face2 = MEDCouplingImpl::decodeID( facesByEdge[0], iMesh2 );
+              if ( !isFaceQueued[iMesh2][face2] )
+                {
+                  isFaceQueued[iMesh2][face2] = true;
+                  faceQueue.push_back( facesByEdge[0] );
+                }
+            }
+          n0 = n1;
+        }
+
+      // remove face and equalFaces from revNodal in order not to treat them again
+      equalFaces.push_back( fID );
+      for ( mcIdType face : equalFaces )
+        {
+          mcIdType f            = MEDCouplingImpl::decodeID( face, iMesh2 );
+          const mcIdType *conn  = mesh[iMesh2]->getNodalConnectivity()->getConstPointer();
+          const mcIdType *connI = mesh[iMesh2]->getNodalConnectivityIndex()->getConstPointer();
+          mcIdType nbNodes      = connI[ f + 1 ] - connI[ f ] - 1;
+          for ( const mcIdType* n = conn + connI[ f ] + 1, *nEnd = n + nbNodes; n < nEnd; ++n )
+
+            MEDCouplingImpl::removeFromRevNodal( *n, f,  // not to treat f again
+                                                 revNodal[ iMesh2 ], revNodalIndx[ iMesh2 ] );
+        }
+
+    } // while() until all faces checked
+
+  return;
+}