From b8b159f191fa8bbf835a98b6dd13fc81fa18bc75 Mon Sep 17 00:00:00 2001 From: ageay Date: Fri, 15 Oct 2010 10:42:43 +0000 Subject: [PATCH] *** empty log message *** --- src/MEDCoupling/MEDCouplingMesh.cxx | 4 +- src/MEDCoupling/MEDCouplingPointSet.cxx | 2 +- src/MEDCoupling/MEDCouplingUMesh.cxx | 76 +++++++++++++++++-------- src/MEDCoupling/MEDCouplingUMesh.hxx | 10 ++-- 4 files changed, 60 insertions(+), 32 deletions(-) diff --git a/src/MEDCoupling/MEDCouplingMesh.cxx b/src/MEDCoupling/MEDCouplingMesh.cxx index 1f60dc669..5ad1928d3 100644 --- a/src/MEDCoupling/MEDCouplingMesh.cxx +++ b/src/MEDCoupling/MEDCouplingMesh.cxx @@ -105,8 +105,8 @@ void MEDCouplingMesh::checkGeoEquivalWith(const MEDCouplingMesh *other, int levO } /*! - * Given a nodeIds range ['partBg','partEnd'), this method returns the set of cell ids in ascendant order that are \b fully whose connectivity of - * these cells are fully included in the range. As a consequence the returned set of cell ids does not \b always fit the nodes in ['partBg','partEnd') + * Given a nodeIds range ['partBg','partEnd'), this method returns the set of cell ids in ascendant order whose connectivity of + * these cells are fully included in the range. As a consequence the returned set of cell ids does \b not \b always fit the nodes in ['partBg','partEnd') * This method returns the corresponding cells in a newly created array that the caller has the responsability. */ DataArrayInt *MEDCouplingMesh::getCellIdsFullyIncludedInNodeIds(const int *partBg, const int *partEnd) const diff --git a/src/MEDCoupling/MEDCouplingPointSet.cxx b/src/MEDCoupling/MEDCouplingPointSet.cxx index 5bb444122..87964cbdf 100644 --- a/src/MEDCoupling/MEDCouplingPointSet.cxx +++ b/src/MEDCoupling/MEDCouplingPointSet.cxx @@ -693,7 +693,7 @@ MEDCouplingMesh *MEDCouplingPointSet::buildPart(const int *start, const int *end /*! * This method implements pure virtual method MEDCouplingMesh::buildPartAndReduceNodes. * This method build a part of 'this' by simply keeping cells whose ids are in ['start','end') \b and potentially reduces the nodes set - * behind returned mesh. This cause an overhead but it is more little in memory. + * behind returned mesh. This cause an overhead but it is lesser in memory. * This method returns an array too. This array allows to the caller to know the mapping between nodeids in 'this' and nodeids in * returned mesh. This is quite usefull for MEDCouplingFieldDouble on nodes for example... * The returned mesh has to be managed by the caller. diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index 1c2ba401f..ce0461314 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -893,44 +893,58 @@ void MEDCouplingUMesh::tryToShareSameCoordsPermute(const MEDCouplingPointSet& ot } /*! - * build a sub part of 'this'. This sub part is defined by the cell ids contained in the array in [start,end). - * @param start start of array containing the cell ids to keep. + * build a sub part of 'this'. This sub part is defined by the cell ids contained in the array in [begin,end). + * @param begin begin of array containing the cell ids to keep. * @param end end of array of cell ids to keep. \b WARNING end param is \b not included ! Idem STL standard definitions. * @param keepCoords that specifies if you want or not to keep coords as this or zip it (see zipCoords) */ -MEDCouplingPointSet *MEDCouplingUMesh::buildPartOfMySelf(const int *start, const int *end, bool keepCoords) const +MEDCouplingPointSet *MEDCouplingUMesh::buildPartOfMySelf(const int *begin, const int *end, bool keepCoords) const { if(getMeshDimension()!=-1) { - MEDCouplingUMesh *ret=buildPartOfMySelfKeepCoords(start,end); + MEDCouplingUMesh *ret=buildPartOfMySelfKeepCoords(begin,end); if(!keepCoords) ret->zipCoords(); return ret; } else { - if(end-start!=1) + if(end-begin!=1) throw INTERP_KERNEL::Exception("-1D mesh has only one cell !"); - if(start[0]!=0) + if(begin[0]!=0) throw INTERP_KERNEL::Exception("-1D mesh has only one cell : 0 !"); incrRef(); return (MEDCouplingUMesh *)this; } } +DataArrayInt *MEDCouplingUMesh::getCellIdsFullyIncludedInNodeIds(const int *partBg, const int *partEnd) const +{ + std::vector cellIdsKept; + fillCellIdsToKeepFromNodeIds(partBg,partEnd,true,cellIdsKept); + DataArrayInt *ret=DataArrayInt::New(); + ret->alloc(cellIdsKept.size(),1); + std::copy(cellIdsKept.begin(),cellIdsKept.end(),ret->getPointer()); + return ret; +} + /*! - * Keeps from 'this' only cells which constituing point id are in the ids specified by ['start','end'). - * The return newly allocated mesh will share the same coordinates as 'this'. + * Keeps from 'this' only cells which constituing point id are in the ids specified by ['begin','end'). + * The resulting cell ids are stored at the end of the 'cellIdsKept' parameter. * Parameter 'fullyIn' specifies if a cell that has part of its nodes in ids array is kept or not. - * If 'fullyIn' is true only cells whose ids are \b fully contained in ['start','end') tab will be kept. + * If 'fullyIn' is true only cells whose ids are \b fully contained in ['begin','end') tab will be kept. + * + * @param begin input start of array of node ids. + * @param end input end of array of node ids. + * @param fullyIn input that specifies if all node ids must be in ['begin','end') array to consider cell to be in. + * @param cellIdsKept in/out array where all candidate cell ids are put at the end. */ -MEDCouplingPointSet *MEDCouplingUMesh::buildPartOfMySelfNode(const int *start, const int *end, bool fullyIn) const +void MEDCouplingUMesh::fillCellIdsToKeepFromNodeIds(const int *begin, const int *end, bool fullyIn, std::vector& cellIdsKept) const { - std::set fastFinder(start,end); + std::set fastFinder(begin,end); + int nbOfCells=getNumberOfCells(); const int *conn=getNodalConnectivity()->getConstPointer(); const int *connIndex=getNodalConnectivityIndex()->getConstPointer(); - int nbOfCells=getNumberOfCells(); - std::vector cellIdsKept; for(int i=0;i connOfCell(conn+connIndex[i]+1,conn+connIndex[i+1]); @@ -942,22 +956,34 @@ MEDCouplingPointSet *MEDCouplingUMesh::buildPartOfMySelfNode(const int *start, c if(((int)locMerge.size()==refLgth && fullyIn) || (locMerge.size()!=0 && !fullyIn)) cellIdsKept.push_back(i); } +} + +/*! + * Keeps from 'this' only cells which constituing point id are in the ids specified by ['begin','end'). + * The return newly allocated mesh will share the same coordinates as 'this'. + * Parameter 'fullyIn' specifies if a cell that has part of its nodes in ids array is kept or not. + * If 'fullyIn' is true only cells whose ids are \b fully contained in ['begin','end') tab will be kept. + */ +MEDCouplingPointSet *MEDCouplingUMesh::buildPartOfMySelfNode(const int *begin, const int *end, bool fullyIn) const +{ + std::vector cellIdsKept; + fillCellIdsToKeepFromNodeIds(begin,end,fullyIn,cellIdsKept); return buildPartOfMySelf(&cellIdsKept[0],&cellIdsKept[0]+cellIdsKept.size(),true); } /*! - * Contrary to MEDCouplingUMesh::buildPartOfMySelfNode method this method a mesh with a meshDimension equal to + * Contrary to MEDCouplingUMesh::buildPartOfMySelfNode method this method builds a mesh with a meshDimension equal to * this->getMeshDimension()-1. The return newly allocated mesh will share the same coordinates as 'this'. * Parameter 'fullyIn' specifies if a face that has part of its nodes in ids array is kept or not. - * If 'fullyIn' is true only faces whose ids are \b fully contained in ['start','end') tab will be kept. + * If 'fullyIn' is true only faces whose ids are \b fully contained in ['begin','end') tab will be kept. */ -MEDCouplingPointSet *MEDCouplingUMesh::buildFacePartOfMySelfNode(const int *start, const int *end, bool fullyIn) const +MEDCouplingPointSet *MEDCouplingUMesh::buildFacePartOfMySelfNode(const int *begin, const int *end, bool fullyIn) const { DataArrayInt *desc,*descIndx,*revDesc,*revDescIndx; desc=DataArrayInt::New(); descIndx=DataArrayInt::New(); revDesc=DataArrayInt::New(); revDescIndx=DataArrayInt::New(); MEDCouplingUMesh *subMesh=buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx); desc->decrRef(); descIndx->decrRef(); revDesc->decrRef(); revDescIndx->decrRef(); - MEDCouplingUMesh *ret=(MEDCouplingUMesh *)subMesh->buildPartOfMySelfNode(start,end,fullyIn); + MEDCouplingUMesh *ret=(MEDCouplingUMesh *)subMesh->buildPartOfMySelfNode(begin,end,fullyIn); subMesh->decrRef(); return ret; } @@ -1512,10 +1538,10 @@ void MEDCouplingUMesh::unserialization(const std::vector& tinyInfo, const D /*! * This is the low algorithm of buildPartOfMySelf. - * Keeps from 'this' only cells which constituing point id are in the ids specified by ['start','end'). + * Keeps from 'this' only cells which constituing point id are in the ids specified by ['begin','end'). * The return newly allocated mesh will share the same coordinates as 'this'. */ -MEDCouplingUMesh *MEDCouplingUMesh::buildPartOfMySelfKeepCoords(const int *start, const int *end) const +MEDCouplingUMesh *MEDCouplingUMesh::buildPartOfMySelfKeepCoords(const int *begin, const int *end) const { checkFullyDefined(); MEDCouplingUMesh *ret=MEDCouplingUMesh::New(); @@ -1532,18 +1558,18 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildPartOfMySelfKeepCoords(const int *start ret->setName(getName()); ret->_mesh_dim=_mesh_dim; ret->setCoords(_coords); - int nbOfElemsRet=end-start; + int nbOfElemsRet=end-begin; int *connIndexRet=new int[nbOfElemsRet+1]; connIndexRet[0]=0; const int *conn=_nodal_connec->getConstPointer(); const int *connIndex=_nodal_connec_index->getConstPointer(); int newNbring=0; - for(const int *work=start;work!=end;work++,newNbring++) + for(const int *work=begin;work!=end;work++,newNbring++) connIndexRet[newNbring+1]=connIndexRet[newNbring]+connIndex[*work+1]-connIndex[*work]; int *connRet=new int[connIndexRet[nbOfElemsRet]]; int *connRetWork=connRet; std::set types; - for(const int *work=start;work!=end;work++) + 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); @@ -2446,13 +2472,13 @@ std::vector MEDCouplingUMesh::splitByType() const for(const int *i=connI;i!=connI+nbOfCells;) { INTERP_KERNEL::NormalizedCellType curType=(INTERP_KERNEL::NormalizedCellType)conn[*i]; - int startCellId=std::distance(connI,i); + int beginCellId=std::distance(connI,i); i=std::find_if(i+1,connI+nbOfCells,ParaMEDMEMImpl::ConnReader(conn,(int)curType)); int endCellId=std::distance(connI,i); - int sz=endCellId-startCellId; + int sz=endCellId-beginCellId; int *cells=new int[sz]; for(int j=0;j& conn) const; + MEDCOUPLING_EXPORT DataArrayInt *getCellIdsFullyIncludedInNodeIds(const int *partBg, const int *partEnd) const; MEDCOUPLING_EXPORT void getCoordinatesOfNode(int nodeId, std::vector& coo) const; MEDCOUPLING_EXPORT std::string simpleRepr() const; MEDCOUPLING_EXPORT std::string advancedRepr() const; @@ -84,9 +85,9 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT MEDCouplingUMesh *buildDescendingConnectivity(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const; MEDCOUPLING_EXPORT DataArrayInt *mergeNodes(double precision, bool& areNodesMerged, int& newNbOfNodes); MEDCOUPLING_EXPORT void tryToShareSameCoordsPermute(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelf(const int *start, const int *end, bool keepCoords) const; - MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelfNode(const int *start, const int *end, bool fullyIn) const; - MEDCOUPLING_EXPORT MEDCouplingPointSet *buildFacePartOfMySelfNode(const int *start, const int *end, bool fullyIn) const; + MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelf(const int *begin, const int *end, bool keepCoords) const; + MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelfNode(const int *begin, const int *end, bool fullyIn) const; + MEDCOUPLING_EXPORT MEDCouplingPointSet *buildFacePartOfMySelfNode(const int *begin, const int *end, bool fullyIn) const; MEDCOUPLING_EXPORT void findBoundaryNodes(std::vector& nodes) const; MEDCOUPLING_EXPORT MEDCouplingPointSet *buildBoundaryMesh(bool keepCoords) const; MEDCOUPLING_EXPORT void renumberNodes(const int *newNodeNumbers, int newNbOfNodes); @@ -137,12 +138,13 @@ namespace ParaMEDMEM void reprConnectivityOfThisLL(std::ostringstream& stream) const; //tools void renumberNodesInConn(const int *newNodeNumbers); + void fillCellIdsToKeepFromNodeIds(const int *begin, const int *end, bool fullyIn, std::vector& cellIdsKept) const; MEDCouplingUMesh *buildExtrudedMeshFromThisLowLev(int nbOfNodesOf1Lev, bool isQuad) const; DataArrayDouble *fillExtCoordsUsingTranslation(const MEDCouplingUMesh *mesh1D, bool isQuad) const; template void findCommonCellsBase(int compType, std::vector& res, std::vector& resI) const; bool areCellsEqualInPool(const std::vector& candidates, int compType, std::vector& result) const; - MEDCouplingUMesh *buildPartOfMySelfKeepCoords(const int *start, const int *end) const; + MEDCouplingUMesh *buildPartOfMySelfKeepCoords(const int *begin, const int *end) const; template void getCellsContainingPointsAlg(const double *coords, const double *pos, int nbOfPoints, double eps, std::vector& elts, std::vector& eltsIndex) const; -- 2.39.2