neighborsIdx=descIndx.retn();
}
+/*!
+ * 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);
+ }
+ }
+}
+
/*!
* 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
MEDCOUPLING_EXPORT static void ComputeNeighborsOfCellsAdv(const DataArrayInt *desc, const DataArrayInt *descI, const DataArrayInt *revDesc, const DataArrayInt *revDescI,
DataArrayInt *&neighbors, DataArrayInt *&neighborsIdx);
MEDCOUPLING_EXPORT void computeNeighborsOfNodes(DataArrayInt *&neighbors, DataArrayInt *&neighborsIdx) const;
+ MEDCOUPLING_EXPORT void computeEnlargedNeighborsOfNodes(MCAuto<DataArrayInt> &neighbors, MCAuto<DataArrayInt>& neighborsIdx) const;
MEDCOUPLING_EXPORT MEDCouplingUMesh *mergeMyselfWithOnSameCoords(const MEDCouplingPointSet *other) const;
MEDCOUPLING_EXPORT MEDCouplingUMesh *buildPartOfMySelf(const int *begin, const int *end, bool keepCoords=true) const;
MEDCOUPLING_EXPORT MEDCouplingUMesh *buildPartOfMySelfSlice(int start, int end, int step, bool keepCoords=true) const;
PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(neighborsIdx),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
return ret;
}
+
+ PyObject *computeEnlargedNeighborsOfNodes() const throw(INTERP_KERNEL::Exception)
+ {
+ MCAuto<DataArrayInt> neighbors,neighborsIdx;
+ self->computeEnlargedNeighborsOfNodes(neighbors,neighborsIdx);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(neighbors.retn()),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(neighborsIdx.retn()),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
PyObject *computeCellNeighborhoodFromNodesOne(const DataArrayInt *nodeNeigh, const DataArrayInt *nodeNeighI) const throw(INTERP_KERNEL::Exception)
{