From 6aba7c32093365f72ccee02166b0850a9d66dc77 Mon Sep 17 00:00:00 2001 From: ageay Date: Fri, 20 Jan 2012 14:04:13 +0000 Subject: [PATCH] Addition of MEDCouplingUMesh::getNodeIdsInUse method. --- src/MEDCoupling/MEDCouplingUMesh.cxx | 36 ++++++++++++++++++---------- src/MEDCoupling/MEDCouplingUMesh.hxx | 1 + 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index 151849e87..00adbbf7c 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -887,13 +887,16 @@ void MEDCouplingUMesh::unPolyze() } /*! - * Array returned is the correspondance old to new. - * The maximum value stored in returned array is the number of nodes of 'this' minus 1 after call of this method. - * The size of returned array is the number of nodes of the old (previous to the call of this method) number of nodes. - * -1 values in returned array means that the corresponding old node is no more used. + * Array returned is the correspondance in \b old \b to \b new format (that's why 'nbrOfNodesInUse' is returned too). + * The returned array is newly created and should be dealt by the caller. + * To retrieve the new to old format the user can use DataArrayInt::invertArrayO2N2N2O method. + * The size of returned array is the number of nodes of 'this'. + * -1 values in returned array means that the corresponding node never appear in any nodal connectivity of cells constituting 'this'. + * @param nbrOfNodesInUse out parameter that specifies how many of nodes in 'this' is really used in nodal connectivity. */ -DataArrayInt *MEDCouplingUMesh::zipCoordsTraducer() throw(INTERP_KERNEL::Exception) +DataArrayInt *MEDCouplingUMesh::getNodeIdsInUse(int& nbrOfNodesInUse) const throw(INTERP_KERNEL::Exception) { + nbrOfNodesInUse=-1; int nbOfNodes=getNumberOfNodes(); DataArrayInt *ret=DataArrayInt::New(); ret->alloc(nbOfNodes,1); @@ -906,18 +909,25 @@ DataArrayInt *MEDCouplingUMesh::zipCoordsTraducer() throw(INTERP_KERNEL::Excepti for(int j=connIndex[i]+1;j=0) traducer[conn[j]]=1; - int newNbOfNodes=std::count(traducer,traducer+nbOfNodes,1); + nbrOfNodesInUse=std::count(traducer,traducer+nbOfNodes,1); std::transform(traducer,traducer+nbOfNodes,traducer,MEDCouplingAccVisit()); - for(int i=0;i=0) - conn[j]=traducer[conn[j]]; - DataArrayDouble *newCoords=_coords->renumberAndReduce(traducer,newNbOfNodes); - setCoords(newCoords); - newCoords->decrRef(); return ret; } +/*! + * Array returned is the correspondance in \b old \b to \b new format. The returned array is newly created and should be dealt by the caller. + * The maximum value stored in returned array is the number of nodes of 'this' minus 1 after call of this method. + * The size of returned array is the number of nodes of the old (previous to the call of this method) number of nodes. + * -1 values in returned array means that the corresponding old node is no more used. + */ +DataArrayInt *MEDCouplingUMesh::zipCoordsTraducer() throw(INTERP_KERNEL::Exception) +{ + int newNbOfNodes=-1; + DataArrayInt *traducer=getNodeIdsInUse(newNbOfNodes); + renumberNodes(traducer->getConstPointer(),newNbOfNodes); + return traducer; +} + /*! * This method stands if 'cell1' and 'cell2' are equals regarding 'compType' policy. * The semantic of 'compType' is specified in MEDCouplingUMesh::zipConnectivityTraducer method. diff --git a/src/MEDCoupling/MEDCouplingUMesh.hxx b/src/MEDCoupling/MEDCouplingUMesh.hxx index b1a440496..a8ec97fb6 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.hxx +++ b/src/MEDCoupling/MEDCouplingUMesh.hxx @@ -99,6 +99,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT void convertAllToPoly(); MEDCOUPLING_EXPORT void convertExtrudedPolyhedra() throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void unPolyze(); + MEDCOUPLING_EXPORT DataArrayInt *getNodeIdsInUse(int& nbrOfNodesInUse) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayInt *zipCoordsTraducer() throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayInt *zipConnectivityTraducer(int compType) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT bool areCellsIncludedIn(const MEDCouplingUMesh *other, int compType, DataArrayInt *& arr) const throw(INTERP_KERNEL::Exception); -- 2.39.2