]> SALOME platform Git repositories - tools/medcoupling.git/blobdiff - src/MEDCoupling/MEDCoupling1GTUMesh.cxx
Salome HOME
Tests again and again
[tools/medcoupling.git] / src / MEDCoupling / MEDCoupling1GTUMesh.cxx
index 87f1ebe29463c3648dc3b1b42561453408084d8f..193b34f2fac44a4789f240039801c6a0c9bfbff2 100644 (file)
@@ -46,6 +46,20 @@ MEDCoupling1GTUMesh *MEDCoupling1GTUMesh::New(const char *name, INTERP_KERNEL::N
     return MEDCoupling1DGTUMesh::New(name,type);
 }
 
+MEDCoupling1GTUMesh *MEDCoupling1GTUMesh::New(const MEDCouplingUMesh *m) throw(INTERP_KERNEL::Exception)
+{
+  if(!m)
+    throw INTERP_KERNEL::Exception("MEDCoupling1GTUMesh::New : input mesh is null !");
+  std::set<INTERP_KERNEL::NormalizedCellType> gts(m->getAllGeoTypes());
+  if(gts.size()!=1)
+    throw INTERP_KERNEL::Exception("MEDCoupling1GTUMesh::New : input mesh must have exactly one geometric type !");
+  const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*gts.begin());
+  if(!cm.isDynamic())
+    return MEDCoupling1SGTUMesh::New(m);
+  else
+    return MEDCoupling1DGTUMesh::New(m);
+}
+
 const INTERP_KERNEL::CellModel& MEDCoupling1GTUMesh::getCellModel() const throw(INTERP_KERNEL::Exception)
 {
   return *_cm;
@@ -120,13 +134,13 @@ std::set<INTERP_KERNEL::NormalizedCellType> MEDCoupling1GTUMesh::getAllGeoTypes(
  * 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]==0 because it has no sense here. 
+ * 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.
  */
 std::vector<int> MEDCoupling1GTUMesh::getDistributionOfTypes() const throw(INTERP_KERNEL::Exception)
 {
   std::vector<int> ret(3);
-  ret[0]=(int)getCellModelEnum(); ret[1]=getNumberOfCells(); ret[2]=0;
+  ret[0]=(int)getCellModelEnum(); ret[1]=getNumberOfCells(); ret[2]=-1;
   return ret;
 }
 
@@ -350,6 +364,91 @@ void MEDCoupling1GTUMesh::findCommonCells(int compType, int startCellId, DataArr
   m->findCommonCells(compType,startCellId,commonCellsArr,commonCellsIArr);
 }
 
+int MEDCoupling1GTUMesh::getNodalConnectivityLength() const throw(INTERP_KERNEL::Exception)
+{
+  const DataArrayInt *c1(getNodalConnectivity());
+  if(!c1)
+    throw INTERP_KERNEL::Exception("MEDCoupling1GTUMesh::getNodalConnectivityLength : no connectivity set !");
+  if(c1->getNumberOfComponents()!=1)
+    throw INTERP_KERNEL::Exception("MEDCoupling1GTUMesh::getNodalConnectivityLength : Nodal connectivity array set must have exactly one component !");
+  if(!c1->isAllocated())
+    throw INTERP_KERNEL::Exception("MEDCoupling1GTUMesh::getNodalConnectivityLength : Nodal connectivity array must be allocated !");
+  return c1->getNumberOfTuples();
+}
+
+/*!
+ * This method aggregates all the meshes in \a parts to put them in a single unstructured mesh (those returned).
+ * The order of cells is the returned instance is those in the order of instances in \a parts.
+ *
+ * \param [in] parts - all not null parts of single geo type meshes to be aggreagated having the same mesh dimension and same coordinates.
+ * \return MEDCouplingUMesh * - new object to be dealt by the caller.
+ *
+ * \throw If one element is null in \a parts.
+ * \throw If not all the parts do not have the same mesh dimension.
+ * \throw If not all the parts do not share the same coordinates.
+ * \throw If not all the parts have their connectivity set properly.
+ * \throw If \a parts is empty.
+ */
+MEDCouplingUMesh *MEDCoupling1GTUMesh::AggregateOnSameCoordsToUMesh(const std::vector< const MEDCoupling1GTUMesh *>& parts) throw(INTERP_KERNEL::Exception)
+{
+  if(parts.empty())
+    throw INTERP_KERNEL::Exception("MEDCoupling1GTUMesh::AggregateOnSameCoordsToUMesh : input parts vector is empty !");
+  const MEDCoupling1GTUMesh *firstPart(parts[0]);
+  if(!firstPart)
+    throw INTERP_KERNEL::Exception("MEDCoupling1GTUMesh::AggregateOnSameCoordsToUMesh : the first instance in input parts is null !");
+  const DataArrayDouble *coords(firstPart->getCoords());
+  int meshDim(firstPart->getMeshDimension());
+  MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret(MEDCouplingUMesh::New(firstPart->getName().c_str(),meshDim)); ret->setDescription(firstPart->getDescription().c_str());
+  ret->setCoords(coords);
+  int nbOfCells(0),connSize(0);
+  for(std::vector< const MEDCoupling1GTUMesh *>::const_iterator it=parts.begin();it!=parts.end();it++)
+    {
+      if(!(*it))
+        throw INTERP_KERNEL::Exception("MEDCoupling1GTUMesh::AggregateOnSameCoordsToUMesh : presence of null pointer in input vector !");
+      if((*it)->getMeshDimension()!=meshDim)
+        throw INTERP_KERNEL::Exception("MEDCoupling1GTUMesh::AggregateOnSameCoordsToUMesh : all the instances in input vector must have same mesh dimension !");
+      if((*it)->getCoords()!=coords)
+        throw INTERP_KERNEL::Exception("MEDCoupling1GTUMesh::AggregateOnSameCoordsToUMesh : all the instances must share the same coordinates pointer !");
+      nbOfCells+=(*it)->getNumberOfCells();
+      connSize+=(*it)->getNodalConnectivityLength();
+    }
+  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> conn(DataArrayInt::New()),connI(DataArrayInt::New());
+  connI->alloc(nbOfCells+1,1); conn->alloc(connSize+nbOfCells,1);
+  int *c(conn->getPointer()),*ci(connI->getPointer()); *ci=0;
+  for(std::vector< const MEDCoupling1GTUMesh *>::const_iterator it=parts.begin();it!=parts.end();it++)
+    {
+      int curNbCells((*it)->getNumberOfCells());
+      int geoType((int)(*it)->getCellModelEnum());
+      const int *cinPtr((*it)->getNodalConnectivity()->begin());
+      const MEDCoupling1SGTUMesh *ps(dynamic_cast<const MEDCoupling1SGTUMesh *>(*it));
+      const MEDCoupling1DGTUMesh *pd(dynamic_cast<const MEDCoupling1DGTUMesh *>(*it));
+      if(ps && !pd)
+        {
+          int nNodesPerCell(ps->getNumberOfNodesPerCell());
+          for(int i=0;i<curNbCells;i++,ci++,cinPtr+=nNodesPerCell)
+            {
+              *c++=geoType;
+              c=std::copy(cinPtr,cinPtr+nNodesPerCell,c);
+              ci[1]=ci[0]+nNodesPerCell+1;
+            }
+        }
+      else if(!ps && pd)
+        {
+          const int *ciinPtr(pd->getNodalConnectivityIndex()->begin());
+          for(int i=0;i<curNbCells;i++,ci++,ciinPtr++)
+            {
+              *c++=geoType;
+              c=std::copy(cinPtr+ciinPtr[0],cinPtr+ciinPtr[1],c);
+              ci[1]=ci[0]+ciinPtr[1]-ciinPtr[0]+1;
+            }
+        }
+      else
+        throw INTERP_KERNEL::Exception("MEDCoupling1GTUMesh::AggregateOnSameCoordsToUMesh : presence of instance which type is not in [MEDCoupling1SGTUMesh,MEDCoupling1DGTUMesh] !");
+    }
+  ret->setConnectivity(conn,connI,true);
+  return ret.retn();
+}
+
 //==
 
 MEDCoupling1SGTUMesh::MEDCoupling1SGTUMesh(const MEDCoupling1SGTUMesh& other, bool recDeepCpy):MEDCoupling1GTUMesh(other,recDeepCpy),_conn(other._conn)
@@ -379,11 +478,64 @@ MEDCoupling1SGTUMesh *MEDCoupling1SGTUMesh::New(const char *name, INTERP_KERNEL:
   return new MEDCoupling1SGTUMesh(name,cm);
 }
 
+MEDCoupling1SGTUMesh *MEDCoupling1SGTUMesh::New(const MEDCouplingUMesh *m) throw(INTERP_KERNEL::Exception)
+{
+  if(!m)
+    throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::New : input mesh is null !");
+  std::set<INTERP_KERNEL::NormalizedCellType> gts(m->getAllGeoTypes());
+  if(gts.size()!=1)
+    throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::New : input mesh must have exactly one geometric type !");
+  int geoType((int)*gts.begin());
+  MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> ret(MEDCoupling1SGTUMesh::New(m->getName().c_str(),*gts.begin()));
+  ret->setCoords(m->getCoords()); ret->setDescription(m->getDescription().c_str());
+  int nbCells(m->getNumberOfCells());
+  int nbOfNodesPerCell(ret->getNumberOfNodesPerCell());
+  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> conn(DataArrayInt::New()); conn->alloc(nbCells*nbOfNodesPerCell,1);
+  int *c(conn->getPointer());
+  const int *cin(m->getNodalConnectivity()->begin()),*ciin(m->getNodalConnectivityIndex()->begin());
+  for(int i=0;i<nbCells;i++,ciin++)
+    {
+      if(cin[ciin[0]]==geoType)
+        {
+          if(ciin[1]-ciin[0]==nbOfNodesPerCell+1)
+            c=std::copy(cin+ciin[0]+1,cin+ciin[1],c);
+          else
+            {
+              std::ostringstream oss; oss << "MEDCoupling1SGTUMesh::New(const MEDCouplingUMesh *m) : something is wrong in the input mesh at cell #" << i << " ! The size of cell is not those expected (" << nbOfNodesPerCell << ") !";
+              throw INTERP_KERNEL::Exception(oss.str().c_str());
+            }
+        }
+      else
+        {
+          std::ostringstream oss; oss << "MEDCoupling1SGTUMesh::New(const MEDCouplingUMesh *m) : something is wrong in the input mesh at cell #" << i << " ! The geometric type is not those expected !";
+          throw INTERP_KERNEL::Exception(oss.str().c_str());
+        }
+    }
+  ret->setNodalConnectivity(conn);
+  return ret.retn();
+}
+
 MEDCoupling1SGTUMesh *MEDCoupling1SGTUMesh::clone(bool recDeepCpy) const
 {
   return new MEDCoupling1SGTUMesh(*this,recDeepCpy);
 }
 
+/*!
+ * This method behaves mostly like MEDCoupling1SGTUMesh::deepCpy 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 MEDCoupling1SGTUMesh::deepCpy
+ */
+MEDCouplingPointSet *MEDCoupling1SGTUMesh::deepCpyConnectivityOnly() const throw(INTERP_KERNEL::Exception)
+{
+  checkCoherency();
+  MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> ret(clone(false));
+  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> c(_conn->deepCpy());
+  ret->setNodalConnectivity(c);
+  return ret.retn();
+}
+
 void MEDCoupling1SGTUMesh::shallowCopyConnectivityFrom(const MEDCouplingPointSet *other) throw(INTERP_KERNEL::Exception)
 {
   if(!other)
@@ -464,9 +616,8 @@ bool MEDCoupling1SGTUMesh::isEqualWithoutConsideringStr(const MEDCouplingMesh *o
   return true;
 }
 
-void MEDCoupling1SGTUMesh::checkCoherency() const throw(INTERP_KERNEL::Exception)
+void MEDCoupling1SGTUMesh::checkCoherencyOfConnectivity() const throw(INTERP_KERNEL::Exception)
 {
-  MEDCouplingPointSet::checkCoherency();
   const DataArrayInt *c1(_conn);
   if(c1)
     {
@@ -480,6 +631,12 @@ void MEDCoupling1SGTUMesh::checkCoherency() const throw(INTERP_KERNEL::Exception
     throw INTERP_KERNEL::Exception("Nodal connectivity array not defined !");
 }
 
+void MEDCoupling1SGTUMesh::checkCoherency() const throw(INTERP_KERNEL::Exception)
+{
+  MEDCouplingPointSet::checkCoherency();
+  checkCoherencyOfConnectivity();
+}
+
 void MEDCoupling1SGTUMesh::checkCoherency1(double eps) const throw(INTERP_KERNEL::Exception)
 {
   checkCoherency();
@@ -528,18 +685,6 @@ int MEDCoupling1SGTUMesh::getNumberOfNodesPerCell() const throw(INTERP_KERNEL::E
   return (int)_cm->getNumberOfNodes();
 }
 
-int MEDCoupling1SGTUMesh::getNodalConnectivityLength() const throw(INTERP_KERNEL::Exception)
-{
-  const DataArrayInt *c1(_conn);
-  if(!c1)
-    throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::getNodalConnectivityLength : no connectivity set !");
-  if(c1->getNumberOfComponents()!=1)
-    throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::getNodalConnectivityLength : Nodal connectivity array set must have exactly one component !");
-  if(!c1->isAllocated())
-    throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::getNodalConnectivityLength : Nodal connectivity array must be allocated !");
-  return c1->getNumberOfTuples();
-}
-
 DataArrayInt *MEDCoupling1SGTUMesh::computeNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception)
 {
   checkNonDynamicGeoType();
@@ -558,6 +703,23 @@ DataArrayInt *MEDCoupling1SGTUMesh::computeNbOfFacesPerCell() const throw(INTERP
   return ret.retn();
 }
 
+DataArrayInt *MEDCoupling1SGTUMesh::computeEffectiveNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception)
+{
+  checkNonDynamicGeoType();
+  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
+  int nbCells(getNumberOfCells());
+  ret->alloc(nbCells,1);
+  int *retPtr(ret->getPointer());
+  int nbNodesPerCell(getNumberOfNodesPerCell());
+  const int *conn(_conn->begin());
+  for(int i=0;i<nbCells;i++,conn+=nbNodesPerCell,retPtr++)
+    {
+      std::set<int> s(conn,conn+nbNodesPerCell);
+      *retPtr=(int)s.size();
+    }
+  return ret.retn();
+}
+
 void MEDCoupling1SGTUMesh::getNodeIdsOfCell(int cellId, std::vector<int>& conn) const
 {
   int sz=getNumberOfNodesPerCell();
@@ -762,7 +924,7 @@ MEDCouplingMesh *MEDCoupling1SGTUMesh::mergeMyselfWith(const MEDCouplingMesh *ot
 
 MEDCouplingUMesh *MEDCoupling1SGTUMesh::buildUnstructured() const throw(INTERP_KERNEL::Exception)
 {
-  MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret=MEDCouplingUMesh::New(getName(),getMeshDimension());
+  MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret=MEDCouplingUMesh::New(getName().c_str(),getMeshDimension());
   ret->setCoords(getCoords());
   const int *nodalConn=_conn->begin();
   int nbCells=getNumberOfCells();
@@ -905,13 +1067,17 @@ MEDCoupling1SGTUMesh *MEDCoupling1SGTUMesh::Merge1SGTUMeshes(std::vector<const M
   return Merge1SGTUMeshesLL(aa);
 }
 
+/*!
+ * \throw If presence of a null instance in the input vector \a a.
+ * \throw If a is empty
+ */
 MEDCoupling1SGTUMesh *MEDCoupling1SGTUMesh::Merge1SGTUMeshesOnSameCoords(std::vector<const MEDCoupling1SGTUMesh *>& a) throw(INTERP_KERNEL::Exception)
 {
   if(a.empty())
     throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::Merge1SGTUMeshesOnSameCoords : input array must be NON EMPTY !");
   std::vector<const MEDCoupling1SGTUMesh *>::const_iterator it=a.begin();
   if(!(*it))
-    throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::Merge1SGTUMeshesOnSameCoords : presence of null instance !");
+    throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::Merge1SGTUMeshesOnSameCoords : null instance in the first element of input vector !");
   std::vector<const DataArrayInt *> ncs(a.size());
   int nbOfCells=(*it)->getNumberOfCells();
   const DataArrayDouble *coords=(*it)->getCoords();
@@ -921,6 +1087,8 @@ MEDCoupling1SGTUMesh *MEDCoupling1SGTUMesh::Merge1SGTUMeshesOnSameCoords(std::ve
   it++;
   for(int i=1;it!=a.end();i++,it++)
     {
+      if(!(*it))
+        throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::Merge1SGTUMeshesOnSameCoords : presence of a null instance in the input vector !");
       if(cm!=&((*it)->getCellModel()))
         throw INTERP_KERNEL::Exception("Geometric types mismatches, Merge1SGTUMeshes impossible !");
       (*it)->getNumberOfCells();//to check that all is OK
@@ -934,6 +1102,9 @@ MEDCoupling1SGTUMesh *MEDCoupling1SGTUMesh::Merge1SGTUMeshesOnSameCoords(std::ve
   return ret.retn();
 }
 
+/*!
+ * Assume that all instances in \a a are non null. If null it leads to a crash. That's why this method is assigned to be low level (LL)
+ */
 MEDCoupling1SGTUMesh *MEDCoupling1SGTUMesh::Merge1SGTUMeshesLL(std::vector<const MEDCoupling1SGTUMesh *>& a) throw(INTERP_KERNEL::Exception)
 {
   if(a.empty())
@@ -973,7 +1144,7 @@ MEDCoupling1SGTUMesh *MEDCoupling1SGTUMesh::Merge1SGTUMeshesLL(std::vector<const
 MEDCouplingPointSet *MEDCoupling1SGTUMesh::buildPartOfMySelfKeepCoords(const int *begin, const int *end) const
 {
   int ncell=getNumberOfCells();
-  MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> ret(new MEDCoupling1SGTUMesh(getName(),*_cm));
+  MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> ret(new MEDCoupling1SGTUMesh(getName().c_str(),*_cm));
   ret->setCoords(_coords);
   std::size_t nbOfElemsRet=std::distance(begin,end);
   const int *inConn=_conn->getConstPointer();
@@ -999,7 +1170,7 @@ MEDCouplingPointSet *MEDCoupling1SGTUMesh::buildPartOfMySelfKeepCoords2(int star
 {
   int ncell=getNumberOfCells();
   int nbOfElemsRet=DataArray::GetNumberOfItemGivenBESRelative(start,end,step,"MEDCoupling1SGTUMesh::buildPartOfMySelfKeepCoords2 : ");
-  MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> ret(new MEDCoupling1SGTUMesh(getName(),*_cm));
+  MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> ret(new MEDCoupling1SGTUMesh(getName().c_str(),*_cm));
   ret->setCoords(_coords);
   const int *inConn=_conn->getConstPointer();
   int sz=getNumberOfNodesPerCell();
@@ -1021,9 +1192,28 @@ MEDCouplingPointSet *MEDCoupling1SGTUMesh::buildPartOfMySelfKeepCoords2(int star
   return ret.retn();
 }
 
+void MEDCoupling1SGTUMesh::computeNodeIdsAlg(std::vector<bool>& nodeIdsInUse) const throw(INTERP_KERNEL::Exception)
+{
+  int sz((int)nodeIdsInUse.size());
+  int nbCells(getNumberOfCells());
+  int nbOfNodesPerCell(getNumberOfNodesPerCell());
+  const int *w(_conn->begin());
+  for(int i=0;i<nbCells;i++)
+    for(int j=0;j<nbOfNodesPerCell;j++,w++)
+      {
+        if(*w>=0 && *w<sz)
+          nodeIdsInUse[*w]=true;
+        else
+          {
+            std::ostringstream oss; oss << "MEDCoupling1SGTUMesh::computeNodeIdsAlg : At cell #" << i << " presence of node id #" << *w << " should be in [0," << sz << ") !";
+            throw INTERP_KERNEL::Exception(oss.str().c_str());
+          }
+      }
+}
+
 MEDCoupling1SGTUMesh *MEDCoupling1SGTUMesh::buildSetInstanceFromThis(int spaceDim) const throw(INTERP_KERNEL::Exception)
 {
-  MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> ret(new MEDCoupling1SGTUMesh(getName(),*_cm));
+  MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> ret(new MEDCoupling1SGTUMesh(getName().c_str(),*_cm));
   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp1;
   const DataArrayInt *nodalConn(_conn);
   if(!nodalConn)
@@ -1175,7 +1365,7 @@ void MEDCoupling1SGTUMesh::checkFastEquivalWith(const MEDCouplingMesh *other, do
   MEDCouplingPointSet::checkFastEquivalWith(other,prec);
   const MEDCoupling1SGTUMesh *otherC=dynamic_cast<const MEDCoupling1SGTUMesh *>(other);
   if(!otherC)
-    throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::checkFastEquivalWith : Two meshes are not not unstructured with single static geometric type !");
+    throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::checkFastEquivalWith : Two meshes are not unstructured with single static geometric type !");
   const DataArrayInt *c1(_conn),*c2(otherC->_conn);
   if(c1==c2)
     return;
@@ -1308,7 +1498,7 @@ void MEDCoupling1SGTUMesh::insertNextCell(const int *nodalConnOfCellBg, const in
     }
 }
 
-//== find static tony
+//== 
 
 MEDCoupling1DGTUMesh *MEDCoupling1DGTUMesh::New(const char *name, INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception)
 {
@@ -1345,6 +1535,22 @@ MEDCoupling1DGTUMesh *MEDCoupling1DGTUMesh::clone(bool recDeepCpy) const
   return new MEDCoupling1DGTUMesh(*this,recDeepCpy);
 }
 
+/*!
+ * This method behaves mostly like MEDCoupling1DGTUMesh::deepCpy 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 MEDCoupling1DGTUMesh::deepCpy
+ */
+MEDCouplingPointSet *MEDCoupling1DGTUMesh::deepCpyConnectivityOnly() const throw(INTERP_KERNEL::Exception)
+{
+  checkCoherency();
+  MEDCouplingAutoRefCountObjectPtr<MEDCoupling1DGTUMesh> ret(clone(false));
+  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> c(_conn->deepCpy()),ci(_conn_indx->deepCpy());
+  ret->setNodalConnectivity(c,ci);
+  return ret.retn();
+}
+
 void MEDCoupling1DGTUMesh::updateTime() const
 {
   MEDCoupling1GTUMesh::updateTime();
@@ -1457,7 +1663,7 @@ void MEDCoupling1DGTUMesh::checkFastEquivalWith(const MEDCouplingMesh *other, do
   MEDCouplingPointSet::checkFastEquivalWith(other,prec);
   const MEDCoupling1DGTUMesh *otherC=dynamic_cast<const MEDCoupling1DGTUMesh *>(other);
   if(!otherC)
-    throw INTERP_KERNEL::Exception("MEDCoupling1DGTUMesh::checkFastEquivalWith : Two meshes are not not unstructured with single static geometric type !");
+    throw INTERP_KERNEL::Exception("MEDCoupling1DGTUMesh::checkFastEquivalWith : Two meshes are not unstructured with single dynamic geometric type !");
   const DataArrayInt *c1(_conn),*c2(otherC->_conn);
   if(c1!=c2)
     {
@@ -1484,14 +1690,8 @@ void MEDCoupling1DGTUMesh::checkFastEquivalWith(const MEDCouplingMesh *other, do
     }
 }
 
-/*!
- * If \a this pass this method, you are sure that connectivity arrays are not null, with exactly one component, no name, no component name, allocated.
- * In addition you are sure that the length of nodal connectivity index array is bigger than or equal to one.
- * In addition you are also sure that length of nodal connectivity is coherent with the content of the last value in the index array.
- */
-void MEDCoupling1DGTUMesh::checkCoherency() const throw(INTERP_KERNEL::Exception)
+void MEDCoupling1DGTUMesh::checkCoherencyOfConnectivity() const throw(INTERP_KERNEL::Exception)
 {
-  MEDCouplingPointSet::checkCoherency();
   const DataArrayInt *c1(_conn);
   if(c1)
     {
@@ -1537,11 +1737,22 @@ void MEDCoupling1DGTUMesh::checkCoherency() const throw(INTERP_KERNEL::Exception
   int szOfC1Exp=_conn_indx->back();
   if(sz2<szOfC1Exp)
     {
-      std::ostringstream oss; oss << "MEDCoupling1DGTUMesh::checkCoherency : The expected length of nodal connectivity array regarding index is " << szOfC1Exp << " but the actual size of it is " << c1->getNumberOfTuples() << " !";
+      std::ostringstream oss; oss << "MEDCoupling1DGTUMesh::checkCoherencyOfConnectivity : The expected length of nodal connectivity array regarding index is " << szOfC1Exp << " but the actual size of it is " << c1->getNumberOfTuples() << " !";
       throw INTERP_KERNEL::Exception(oss.str().c_str());
     }
 }
 
+/*!
+ * If \a this pass this method, you are sure that connectivity arrays are not null, with exactly one component, no name, no component name, allocated.
+ * In addition you are sure that the length of nodal connectivity index array is bigger than or equal to one.
+ * In addition you are also sure that length of nodal connectivity is coherent with the content of the last value in the index array.
+ */
+void MEDCoupling1DGTUMesh::checkCoherency() const throw(INTERP_KERNEL::Exception)
+{
+  MEDCouplingPointSet::checkCoherency();
+  checkCoherencyOfConnectivity();
+}
+
 void MEDCoupling1DGTUMesh::checkCoherency1(double eps) const throw(INTERP_KERNEL::Exception)
 {
   checkCoherency();
@@ -1570,7 +1781,7 @@ void MEDCoupling1DGTUMesh::checkCoherency2(double eps) const throw(INTERP_KERNEL
 
 int MEDCoupling1DGTUMesh::getNumberOfCells() const
 {
-  checkCoherency();//do not remove
+  checkCoherencyOfConnectivity();//do not remove
   return _conn_indx->getNumberOfTuples()-1;
 }
 
@@ -1628,6 +1839,41 @@ DataArrayInt *MEDCoupling1DGTUMesh::computeNbOfFacesPerCell() const throw(INTERP
   return ret.retn();
 }
 
+/*!
+ * 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 MEDCoupling1DGTUMesh::computeNbOfNodesPerCell method.
+ *
+ * \return DataArrayInt * - new object to be deallocated by the caller.
+ * \sa MEDCoupling1DGTUMesh::computeNbOfNodesPerCell
+ */
+DataArrayInt *MEDCoupling1DGTUMesh::computeEffectiveNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception)
+{
+  checkCoherency();
+  _conn_indx->checkMonotonic(true);
+  int nbOfCells(_conn_indx->getNumberOfTuples()-1);
+  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
+  ret->alloc(nbOfCells,1);
+  int *retPtr(ret->getPointer());
+  const int *ci(_conn_indx->begin()),*c(_conn->begin());
+  if(getCellModelEnum()!=INTERP_KERNEL::NORM_POLYHED)
+    {
+      for(int i=0;i<nbOfCells;i++,retPtr++,ci++)
+        {
+          std::set<int> s(c+ci[0],c+ci[1]);
+          *retPtr=(int)s.size();
+        }
+    }
+  else
+    {
+      for(int i=0;i<nbOfCells;i++,retPtr++,ci++)
+        {
+          std::set<int> s(c+ci[0],c+ci[1]); s.erase(-1);
+          *retPtr=(int)s.size();
+        }
+    }
+  return ret.retn();
+}
+
 void MEDCoupling1DGTUMesh::getNodeIdsOfCell(int cellId, std::vector<int>& conn) const
 {
   int nbOfCells=getNumberOfCells();//performs checks
@@ -1732,7 +1978,7 @@ DataArrayDouble *MEDCoupling1DGTUMesh::computeIsoBarycenterOfNodesPerCell() cons
       for(int i=0;i<nbOfCells;i++,ptToFill+=spaceDim,nodali++)
         {
           std::fill(ptToFill,ptToFill+spaceDim,0.);
-          if(nodali[0]>=nodali[1])// >= to avoid division by 0.
+          if(nodali[0]<nodali[1])// >= to avoid division by 0.
             {
               for(int j=nodali[0];j<nodali[1];j++,nodal++)
                 {
@@ -1758,7 +2004,7 @@ DataArrayDouble *MEDCoupling1DGTUMesh::computeIsoBarycenterOfNodesPerCell() cons
       for(int i=0;i<nbOfCells;i++,ptToFill+=spaceDim,nodali++)
         {
           std::fill(ptToFill,ptToFill+spaceDim,0.);
-          if(nodali[0]>=nodali[1])// >= to avoid division by 0.
+          if(nodali[0]<nodali[1])// >= to avoid division by 0.
             {
               int nbOfNod=0;
               for(int j=nodali[0];j<nodali[1];j++,nodal++)
@@ -1801,9 +2047,8 @@ void MEDCoupling1DGTUMesh::renumberCells(const int *old2NewBg, bool check) throw
   if(check)
     o2n=o2n->checkAndPreparePermutation();
   //
+  const int *o2nPtr=o2n->getPointer();
   const int *conn=_conn->begin(),*conni=_conn_indx->begin();
-  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> n2o=o2n->invertArrayO2N2N2O(nbCells);
-  const int *n2oPtr=n2o->begin();
   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newConn=DataArrayInt::New();
   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newConnI=DataArrayInt::New();
   newConn->alloc(_conn->getNumberOfTuples(),1); newConnI->alloc(nbCells,1);
@@ -1812,9 +2057,10 @@ void MEDCoupling1DGTUMesh::renumberCells(const int *old2NewBg, bool check) throw
   int *newC=newConn->getPointer(),*newCI=newConnI->getPointer();
   for(int i=0;i<nbCells;i++)
     {
+      int newPos=o2nPtr[i];
       int sz=conni[i+1]-conni[i];
       if(sz>=0)
-        newCI[n2oPtr[i]]=sz;
+        newCI[newPos]=sz;
       else
         {
           std::ostringstream oss; oss << "MEDCoupling1DGTUMesh::renumberCells : the index nodal array is invalid for cell #" << i << " !";
@@ -1826,10 +2072,11 @@ void MEDCoupling1DGTUMesh::renumberCells(const int *old2NewBg, bool check) throw
   for(int i=0;i<nbCells;i++,conni++)
     {
       int sz=conni[1]-conni[0];
-      int newp=n2oPtr[i];
+      int newp=o2nPtr[i];
       std::copy(conn+conni[0],conn+conni[1],newC+newCI[newp]);
     }
   _conn=newConn;
+  _conn_indx=newConnI;
 }
 
 MEDCouplingMesh *MEDCoupling1DGTUMesh::mergeMyselfWith(const MEDCouplingMesh *other) const
@@ -1842,7 +2089,7 @@ MEDCouplingMesh *MEDCoupling1DGTUMesh::mergeMyselfWith(const MEDCouplingMesh *ot
 
 MEDCouplingUMesh *MEDCoupling1DGTUMesh::buildUnstructured() const throw(INTERP_KERNEL::Exception)
 {
-  MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret=MEDCouplingUMesh::New(getName(),getMeshDimension());
+  MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret=MEDCouplingUMesh::New(getName().c_str(),getMeshDimension());
   ret->setCoords(getCoords());
   const int *nodalConn=_conn->begin(),*nodalConnI=_conn_indx->begin();
   int nbCells=getNumberOfCells();//checkCoherency
@@ -1928,7 +2175,7 @@ MEDCouplingPointSet *MEDCoupling1DGTUMesh::mergeMyselfWithOnSameCoords(const MED
 MEDCouplingPointSet *MEDCoupling1DGTUMesh::buildPartOfMySelfKeepCoords(const int *begin, const int *end) const
 {
   checkCoherency();
-  MEDCouplingAutoRefCountObjectPtr<MEDCoupling1DGTUMesh> ret(new MEDCoupling1DGTUMesh(getName(),*_cm));
+  MEDCouplingAutoRefCountObjectPtr<MEDCoupling1DGTUMesh> ret(new MEDCoupling1DGTUMesh(getName().c_str(),*_cm));
   ret->setCoords(_coords);
   DataArrayInt *c=0,*ci=0;
   MEDCouplingUMesh::ExtractFromIndexedArrays(begin,end,_conn,_conn_indx,c,ci);
@@ -1940,7 +2187,7 @@ MEDCouplingPointSet *MEDCoupling1DGTUMesh::buildPartOfMySelfKeepCoords(const int
 MEDCouplingPointSet *MEDCoupling1DGTUMesh::buildPartOfMySelfKeepCoords2(int start, int end, int step) const
 {
   checkCoherency();
-  MEDCouplingAutoRefCountObjectPtr<MEDCoupling1DGTUMesh> ret(new MEDCoupling1DGTUMesh(getName(),*_cm));
+  MEDCouplingAutoRefCountObjectPtr<MEDCoupling1DGTUMesh> ret(new MEDCoupling1DGTUMesh(getName().c_str(),*_cm));
   ret->setCoords(_coords);
   DataArrayInt *c=0,*ci=0;
   MEDCouplingUMesh::ExtractFromIndexedArrays2(start,end,step,_conn,_conn_indx,c,ci);
@@ -1949,6 +2196,25 @@ MEDCouplingPointSet *MEDCoupling1DGTUMesh::buildPartOfMySelfKeepCoords2(int star
   return ret.retn();
 }
 
+void MEDCoupling1DGTUMesh::computeNodeIdsAlg(std::vector<bool>& nodeIdsInUse) const throw(INTERP_KERNEL::Exception)
+{
+  int sz((int)nodeIdsInUse.size());
+  int nbCells(getNumberOfCells());
+  const int *w(_conn->begin()),*wi(_conn_indx->begin());
+  for(int i=0;i<nbCells;i++,wi++)
+    for(const int *pt=w+wi[0];pt!=w+wi[1];pt++)
+      if(*pt!=-1)
+        {
+          if(*pt>=0 && *pt<sz)
+            nodeIdsInUse[*pt]=true;
+          else
+            {
+              std::ostringstream oss; oss << "MEDCoupling1DGTUMesh::computeNodeIdsAlg : At cell #" << i << " presence of node id #" << *pt << " should be in [0," << sz << ") !";
+              throw INTERP_KERNEL::Exception(oss.str().c_str());
+            }
+        }
+}
+
 void MEDCoupling1DGTUMesh::getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const throw(INTERP_KERNEL::Exception)
 {
   checkFullyDefined();
@@ -2227,7 +2493,7 @@ DataArrayInt *MEDCoupling1DGTUMesh::getNodalConnectivityIndex() const throw(INTE
  */
 MEDCoupling1DGTUMesh *MEDCoupling1DGTUMesh::copyWithNodalConnectivityPacked(bool& isShallowCpyOfNodalConnn) const throw(INTERP_KERNEL::Exception)
 {
-  MEDCouplingAutoRefCountObjectPtr<MEDCoupling1DGTUMesh> ret(new MEDCoupling1DGTUMesh(getName(),*_cm));
+  MEDCouplingAutoRefCountObjectPtr<MEDCoupling1DGTUMesh> ret(new MEDCoupling1DGTUMesh(getName().c_str(),*_cm));
   DataArrayInt *nc=0,*nci=0;
   isShallowCpyOfNodalConnn=retrievePackedNodalConnectivity(nc,nci);
   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ncs(nc),ncis(nci);
@@ -2330,13 +2596,17 @@ MEDCoupling1DGTUMesh *MEDCoupling1DGTUMesh::Merge1DGTUMeshes(std::vector<const M
   return Merge1DGTUMeshesLL(aa);
 }
 
+/*!
+ * \throw If presence of a null instance in the input vector \a a.
+ * \throw If a is empty
+ */
 MEDCoupling1DGTUMesh *MEDCoupling1DGTUMesh::Merge1DGTUMeshesOnSameCoords(std::vector<const MEDCoupling1DGTUMesh *>& a) throw(INTERP_KERNEL::Exception)
 {
   if(a.empty())
     throw INTERP_KERNEL::Exception("MEDCoupling1DGTUMesh::Merge1DGTUMeshesOnSameCoords : input array must be NON EMPTY !");
   std::vector<const MEDCoupling1DGTUMesh *>::const_iterator it=a.begin();
   if(!(*it))
-    throw INTERP_KERNEL::Exception("MEDCoupling1DGTUMesh::Merge1DGTUMeshesOnSameCoords : presence of null instance !");
+    throw INTERP_KERNEL::Exception("MEDCoupling1DGTUMesh::Merge1DGTUMeshesOnSameCoords : null instance in the first element of input vector !");
   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1DGTUMesh> > objs(a.size());
   std::vector<const DataArrayInt *> ncs(a.size()),ncis(a.size());
   int nbOfCells=(*it)->getNumberOfCells();
@@ -2348,6 +2618,8 @@ MEDCoupling1DGTUMesh *MEDCoupling1DGTUMesh::Merge1DGTUMeshesOnSameCoords(std::ve
   it++;
   for(int i=1;it!=a.end();i++,it++)
     {
+      if(!(*it))
+        throw INTERP_KERNEL::Exception("MEDCoupling1DGTUMesh::Merge1DGTUMeshesOnSameCoords : presence of null instance !");
       if(cm!=&((*it)->getCellModel()))
         throw INTERP_KERNEL::Exception("Geometric types mismatches, Merge1DGTUMeshes impossible !");
       (*it)->getNumberOfCells();//to check that all is OK
@@ -2363,14 +2635,48 @@ MEDCoupling1DGTUMesh *MEDCoupling1DGTUMesh::Merge1DGTUMeshesOnSameCoords(std::ve
   return ret.retn();
 }
 
+/*!
+ * Assume that all instances in \a a are non null. If null it leads to a crash. That's why this method is assigned to be low level (LL)
+ */
 MEDCoupling1DGTUMesh *MEDCoupling1DGTUMesh::Merge1DGTUMeshesLL(std::vector<const MEDCoupling1DGTUMesh *>& a) throw(INTERP_KERNEL::Exception)
 {
-  //tony
+  if(a.empty())
+    throw INTERP_KERNEL::Exception("MEDCoupling1DGTUMesh::Merge1DGTUMeshes : input array must be NON EMPTY !");
+  std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1DGTUMesh> > objs(a.size());
+  std::vector<const DataArrayInt *> ncs(a.size()),ncis(a.size());
+  std::vector<const MEDCoupling1DGTUMesh *>::const_iterator it=a.begin();
+  std::vector<int> nbNodesPerElt(a.size());
+  int nbOfCells=(*it)->getNumberOfCells();
+  bool tmp;
+  objs[0]=(*it)->copyWithNodalConnectivityPacked(tmp);
+  ncs[0]=objs[0]->getNodalConnectivity(); ncis[0]=objs[0]->getNodalConnectivityIndex();
+  nbNodesPerElt[0]=0;
+  int prevNbOfNodes=(*it)->getNumberOfNodes();
+  const INTERP_KERNEL::CellModel *cm=&((*it)->getCellModel());
+  it++;
+  for(int i=1;it!=a.end();i++,it++)
+    {
+      if(cm!=&((*it)->getCellModel()))
+        throw INTERP_KERNEL::Exception("Geometric types mismatches, Merge1DGTUMeshes impossible !");
+      objs[i]=(*it)->copyWithNodalConnectivityPacked(tmp);
+      ncs[i]=objs[i]->getNodalConnectivity(); ncis[i]=objs[i]->getNodalConnectivityIndex();
+      nbOfCells+=(*it)->getNumberOfCells();
+      nbNodesPerElt[i]=nbNodesPerElt[i-1]+prevNbOfNodes;
+      prevNbOfNodes=(*it)->getNumberOfNodes();
+    }
+  std::vector<const MEDCouplingPointSet *> aps(a.size());
+  std::copy(a.begin(),a.end(),aps.begin());
+  MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> pts=MergeNodesArray(aps);
+  MEDCouplingAutoRefCountObjectPtr<MEDCoupling1DGTUMesh> ret(new MEDCoupling1DGTUMesh("merge",*cm));
+  ret->setCoords(pts);
+  ret->_conn=AggregateNodalConnAndShiftNodeIds(ncs,nbNodesPerElt);
+  ret->_conn_indx=DataArrayInt::AggregateIndexes(ncis);
+  return ret.retn();
 }
 
 MEDCoupling1DGTUMesh *MEDCoupling1DGTUMesh::buildSetInstanceFromThis(int spaceDim) const throw(INTERP_KERNEL::Exception)
 {
-  MEDCouplingAutoRefCountObjectPtr<MEDCoupling1DGTUMesh> ret(new MEDCoupling1DGTUMesh(getName(),*_cm));
+  MEDCouplingAutoRefCountObjectPtr<MEDCoupling1DGTUMesh> ret(new MEDCoupling1DGTUMesh(getName().c_str(),*_cm));
   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp1,tmp2;
   const DataArrayInt *nodalConn(_conn),*nodalConnI(_conn_indx);
   if(!nodalConn)
@@ -2398,3 +2704,93 @@ MEDCoupling1DGTUMesh *MEDCoupling1DGTUMesh::buildSetInstanceFromThis(int spaceDi
     ret->setCoords(_coords);
   return ret.retn();
 }
+
+/*!
+ * This method performs an aggregation of \a nodalConns (as DataArrayInt::Aggregate does) but in addition of that a shift is applied on the 
+ * values contained in \a nodalConns using corresponding offset specified in input \a offsetInNodeIdsPerElt.
+ * But it also manage the values -1, that have a semantic in MEDCoupling1DGTUMesh class (separator for polyhedron).
+ *
+ * \param [in] nodalConns - a list of nodal connectivity arrays same size than \a offsetInNodeIdsPerElt.
+ * \param [in] offsetInNodeIdsPerElt - a list of offsets to apply.
+ * \return DataArrayInt * - A new object (to be managed by the caller) that is the result of the aggregation.
+ * \throw If \a nodalConns or \a offsetInNodeIdsPerElt are empty.
+ * \throw If \a nodalConns and \a offsetInNodeIdsPerElt have not the same size.
+ * \throw If presence of null pointer in \a nodalConns.
+ * \throw If presence of not allocated or array with not exactly one component in \a nodalConns.
+ */
+DataArrayInt *MEDCoupling1DGTUMesh::AggregateNodalConnAndShiftNodeIds(const std::vector<const DataArrayInt *>& nodalConns, const std::vector<int>& offsetInNodeIdsPerElt) throw(INTERP_KERNEL::Exception)
+{
+  std::size_t sz1(nodalConns.size()),sz2(offsetInNodeIdsPerElt.size());
+  if(sz1!=sz2)
+    throw INTERP_KERNEL::Exception("MEDCoupling1DGTUMesh::AggregateNodalConnAndShiftNodeIds : input vectors do not have the same size !");
+  if(sz1==0)
+    throw INTERP_KERNEL::Exception("MEDCoupling1DGTUMesh::AggregateNodalConnAndShiftNodeIds : empty vectors in input !");
+  int nbOfTuples=0;
+  for(std::vector<const DataArrayInt *>::const_iterator it=nodalConns.begin();it!=nodalConns.end();it++)
+    {
+      if(!(*it))
+        throw INTERP_KERNEL::Exception("MEDCoupling1DGTUMesh::AggregateNodalConnAndShiftNodeIds : presence of null pointer in input vector !");
+      if(!(*it)->isAllocated())
+        throw INTERP_KERNEL::Exception("MEDCoupling1DGTUMesh::AggregateNodalConnAndShiftNodeIds : presence of non allocated array in input vector !");
+      if((*it)->getNumberOfComponents()!=1)
+        throw INTERP_KERNEL::Exception("MEDCoupling1DGTUMesh::AggregateNodalConnAndShiftNodeIds : presence of array with not exactly one component !");
+      nbOfTuples+=(*it)->getNumberOfTuples();
+    }
+  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New(); ret->alloc(nbOfTuples,1);
+  int *pt=ret->getPointer();
+  int i=0;
+  for(std::vector<const DataArrayInt *>::const_iterator it=nodalConns.begin();it!=nodalConns.end();it++,i++)
+    {
+      int curNbt=(*it)->getNumberOfTuples();
+      const int *inPt=(*it)->begin();
+      int offset=offsetInNodeIdsPerElt[i];
+      for(int j=0;j<curNbt;j++,pt++)
+        {
+          if(inPt[j]!=-1)
+            *pt=inPt[j]+offset;
+          else
+            *pt=-1;
+        }
+    }
+  return ret.retn();
+}
+
+MEDCoupling1DGTUMesh *MEDCoupling1DGTUMesh::New(const MEDCouplingUMesh *m) throw(INTERP_KERNEL::Exception)
+{
+  if(!m)
+    throw INTERP_KERNEL::Exception("MEDCoupling1DGTUMesh::New : input mesh is null !");
+  std::set<INTERP_KERNEL::NormalizedCellType> gts(m->getAllGeoTypes());
+  if(gts.size()!=1)
+    throw INTERP_KERNEL::Exception("MEDCoupling1DGTUMesh::New : input mesh must have exactly one geometric type !");
+  int geoType((int)*gts.begin());
+  MEDCouplingAutoRefCountObjectPtr<MEDCoupling1DGTUMesh> ret(MEDCoupling1DGTUMesh::New(m->getName().c_str(),*gts.begin()));
+  ret->setCoords(m->getCoords()); ret->setDescription(m->getDescription().c_str());
+  int nbCells(m->getNumberOfCells());
+  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> conn(DataArrayInt::New()),connI(DataArrayInt::New());
+  conn->alloc(m->getMeshLength()-nbCells,1); connI->alloc(nbCells+1,1);
+  int *c(conn->getPointer()),*ci(connI->getPointer()); *ci=0;
+  const int *cin(m->getNodalConnectivity()->begin()),*ciin(m->getNodalConnectivityIndex()->begin());
+  for(int i=0;i<nbCells;i++,ciin++,ci++)
+    {
+      if(cin[ciin[0]]==geoType)
+        {
+          if(ciin[1]-ciin[0]>=1)
+            {
+              c=std::copy(cin+ciin[0]+1,cin+ciin[1],c);
+              ci[1]=ci[0]+ciin[1]-ciin[0]-1;
+            }
+          else
+            {
+              std::ostringstream oss; oss << "MEDCoupling1DGTUMesh::New(const MEDCouplingUMesh *m) : something is wrong in the input mesh at cell #" << i << " ! The size of cell is not >=0 !";
+              throw INTERP_KERNEL::Exception(oss.str().c_str());
+            }
+        }
+      else
+        {
+          std::ostringstream oss; oss << "MEDCoupling1DGTUMesh::New(const MEDCouplingUMesh *m) : something is wrong in the input mesh at cell #" << i << " ! The geometric type is not those expected !";
+          throw INTERP_KERNEL::Exception(oss.str().c_str());
+        }
+    }
+  ret->setNodalConnectivity(conn,connI);
+  return ret.retn();
+}