X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling%2FMEDCouplingUMesh.cxx;h=c22552bae39dff82cae00b8db7b5903495102537;hb=8f2a28585bcf231a8f976f36b7fb1d2eed8801c2;hp=939c45c34955c9afca0ea0760515c6dd31b85f69;hpb=ffb8188e28b2b60ee207a8644286821bc4e8fcdc;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index 939c45c34..c22552bae 100755 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -1695,9 +1695,11 @@ int MEDCouplingUMesh::AreCellsEqualPolicy7(const mcIdType *conn, const mcIdType /*! - * This method find cells that are equal (regarding \a compType) in \a this. The comparison is specified - * by \a compType. - * This method keeps the coordiantes of \a this. This method is time consuming. + * This method find cells that are equal (regarding \a compType) in \a this. The comparison is specified by \a compType (see zipConnectivityTraducer). + * This method keeps the coordinates of \a this. The comparison starts at rank \a startCellId cell id (included). + * If \a startCellId is equal to 0 algorithm starts at cell #0 and for each cell candidates being searched have cell id higher than current cellId. + * If \a startCellId is greater than 0 algorithm starts at cell #startCellId but for each cell all candidates are considered. + * This method is time consuming. * * \param [in] compType input specifying the technique used to compare cells each other. * - 0 : exactly. A cell is detected to be the same if and only if the connectivity is exactly the same without permutation and types same too. This is the strongest policy. @@ -1729,7 +1731,7 @@ void MEDCouplingUMesh::FindCommonCellsAlg(int compType, mcIdType startCellId, co std::vector isFetched(nbOfCells,false); if(startCellId==0) { - for(mcIdType i=0;i(),-1)); + // v2 contains the result of successive intersections using rev nodal on on each node of cell #i std::vector v,v2; if(connOfNode!=connPtr+connIPtr[i+1]) { @@ -1782,12 +1785,20 @@ void MEDCouplingUMesh::FindCommonCellsAlg(int compType, mcIdType startCellId, co std::vector::iterator it=std::set_intersection(v.begin(),v.end(),revNodalPtr+revNodalIPtr[*connOfNode],revNodalPtr+revNodalIPtr[*connOfNode+1],v2.begin()); v2.resize(std::distance(v2.begin(),it)); } + // v2 contains now candidates. Problem candidates are sorted using id rank. if(v2.size()>1) { + if(v2[0]!=i) + { + auto it(std::find(v2.begin(),v2.end(),i)); + std::swap(*v2.begin(),*it); + } if(AreCellsEqualInPool(v2,compType,connPtr,connIPtr,commonCells)) { - mcIdType pos=commonCellsI->back(); - commonCellsI->pushBackSilent(commonCells->getNumberOfTuples()); + mcIdType newPos(commonCells->getNumberOfTuples()); + mcIdType pos(commonCellsI->back()); + std::sort(commonCells->getPointerSilent()+pos,commonCells->getPointerSilent()+newPos); + commonCellsI->pushBackSilent(newPos); for(const mcIdType *it=commonCells->begin()+pos;it!=commonCells->end();it++) isFetched[*it]=true; } @@ -1835,13 +1846,30 @@ bool MEDCouplingUMesh::areCellsIncludedIn(const MEDCouplingUMesh *other, int com oss << " !"; throw INTERP_KERNEL::Exception(oss.str()); } - MCAuto o2n=mesh->zipConnectivityTraducer(compType,nbOfCells); - arr=o2n->subArray(nbOfCells); - arr->setName(other->getName()); - mcIdType tmp; + // if(other->getNumberOfCells()==0) + { + MCAuto dftRet(DataArrayIdType::New()); dftRet->alloc(0,1); arr=dftRet.retn(); arr->setName(other->getName()); return true; - return arr->getMaxValue(tmp)findCommonCells(compType,nbOfCells,commonCells,commonCellsI); + MCAuto commonCellsTmp(commonCells),commonCellsITmp(commonCellsI); + mcIdType newNbOfCells=-1; + MCAuto o2n = DataArrayIdType::ConvertIndexArrayToO2N(ToIdType(mesh->getNumberOfCells()),commonCells->begin(),commonCellsI->begin(),commonCellsI->end(),newNbOfCells); + MCAuto p0(o2n->selectByTupleIdSafeSlice(0,nbOfCells,1)); + mcIdType maxPart(p0->getMaxValueInArray()); + bool ret(maxPart==newNbOfCells-1); + MCAuto p1(p0->invertArrayO2N2N2O(newNbOfCells)); + // fill p1 array in case of presence of cells in other not in this + mcIdType *pt(p1->getPointer()); + for(mcIdType i = maxPart ; i < newNbOfCells-1 ; ++i ) + pt[i+1] = i+1; + // + MCAuto p2(o2n->subArray(nbOfCells)); + p2->transformWithIndArr(p1->begin(),p1->end()); p2->setName(other->getName()); + arr = p2.retn(); + return ret; } /*!