+/*!
+ * 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
+ */
+void MEDCouplingUMesh::computeEnlargedNeighborsOfNodes(MCAuto<DataArrayInt> &neighbors, MCAuto<DataArrayInt>& neighborsIdx) const
+{
+ checkFullyDefined();
+ int nbOfNodes(getNumberOfNodes());
+ const int *conn(_nodal_connec->begin()),*connIndex(_nodal_connec_index->begin());
+ int nbOfCells(getNumberOfCells());
+ std::vector< std::set<int> > st0(nbOfNodes);
+ for(int eltId=0;eltId<nbOfCells;eltId++)
+ {
+ const int *strtNdlConnOfCurCell(conn+connIndex[eltId]+1),*endNdlConnOfCurCell(conn+connIndex[eltId+1]);
+ std::set<int> s(strtNdlConnOfCurCell,endNdlConnOfCurCell); s.erase(-1); //for polyhedrons
+ for(std::set<int>::const_iterator iter2=s.begin();iter2!=s.end();iter2++)
+ st0[*iter2].insert(s.begin(),s.end());
+ }
+ neighborsIdx=DataArrayInt::New(); neighborsIdx->alloc(nbOfNodes+1,1); neighborsIdx->setIJ(0,0,0);
+ {
+ int *neighIdx(neighborsIdx->getPointer());
+ for(std::vector< std::set<int> >::const_iterator it=st0.begin();it!=st0.end();it++,neighIdx++)
+ {
+ if ((*it).empty())
+ neighIdx[1]=neighIdx[0];
+ else
+ neighIdx[1]=neighIdx[0]+(*it).size()-1;
+ }
+ }
+ neighbors=DataArrayInt::New(); neighbors->alloc(neighborsIdx->back(),1);
+ {
+ const int *neighIdx(neighborsIdx->begin());
+ int *neigh(neighbors->getPointer()),nodeId(0);
+ for(std::vector< std::set<int> >::const_iterator it=st0.begin();it!=st0.end();it++,neighIdx++,nodeId++)
+ {
+ std::set<int> s(*it); s.erase(nodeId);
+ std::copy(s.begin(),s.end(),neigh+*neighIdx);
+ }
+ }
+}
+