From: ageay Date: Thu, 7 Mar 2013 15:09:35 +0000 (+0000) Subject: API modification of DataArrayInt::getDifferentValues X-Git-Tag: V6_main_FINAL~318 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=89490c41741d587a54a5e384d1c9deb0d469e3ab;p=tools%2Fmedcoupling.git API modification of DataArrayInt::getDifferentValues --- diff --git a/src/MEDLoader/MEDFileField.cxx b/src/MEDLoader/MEDFileField.cxx index e0bb931f4..d1da7a2b8 100644 --- a/src/MEDLoader/MEDFileField.cxx +++ b/src/MEDLoader/MEDFileField.cxx @@ -831,7 +831,7 @@ bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::ve } MEDCouplingAutoRefCountObjectPtr newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear(); MEDCouplingAutoRefCountObjectPtr newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear(); - std::set diffVals=newGeoTypesEltIdsAllGather->getDifferentValues(); + MEDCouplingAutoRefCountObjectPtr diffVals=newGeoTypesEltIdsAllGather->getDifferentValues(); MEDCouplingAutoRefCountObjectPtr renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel(); // MEDCouplingAutoRefCountObjectPtr renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel(); @@ -840,10 +840,10 @@ bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::ve arrPart->renumberInPlace(renumTupleIds->begin()); arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1); bool ret=false; - std::set::const_iterator idIt=diffVals.begin(); + const int *idIt=diffVals->begin(); std::list li(entriesOnSameDisc.begin(),entriesOnSameDisc.end()); int offset2=0; - for(std::size_t i=0;igetNumberOfTuples();i++,idIt++) { MEDCouplingAutoRefCountObjectPtr ids=newGeoTypesEltIdsAllGather->getIdsEqual(*idIt); MEDCouplingAutoRefCountObjectPtr subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end()); @@ -1064,10 +1064,10 @@ std::vector MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const M throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !"); const DataArrayInt *da=disc2->getArrayOfDiscIds(); MEDCouplingAutoRefCountObjectPtr da2=da->selectByTupleId2(offset,offset+nbOfCells,1); - std::set retTmp=da2->getDifferentValues(); - if(retTmp.find(-1)!=retTmp.end()) + MEDCouplingAutoRefCountObjectPtr retTmp=da2->getDifferentValues(); + if(retTmp->presenceOfValue(-1)) throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !"); - std::vector ret(retTmp.begin(),retTmp.end()); + std::vector ret(retTmp->begin(),retTmp->end()); return ret; } @@ -1134,10 +1134,10 @@ std::vector MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const M throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !"); const DataArrayInt *da=disc2->getArrayOfDiscIds(); MEDCouplingAutoRefCountObjectPtr da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples()); - std::set retTmp=da2->getDifferentValues(); - if(retTmp.find(-1)!=retTmp.end()) + MEDCouplingAutoRefCountObjectPtr retTmp=da2->getDifferentValues(); + if(retTmp->presenceOfValue(-1)) throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !"); - std::vector ret(retTmp.begin(),retTmp.end()); + std::vector ret(retTmp->begin(),retTmp->end()); return ret; } diff --git a/src/MEDLoader/MEDFileMesh.cxx b/src/MEDLoader/MEDFileMesh.cxx index 987e61bd0..fe3be7088 100644 --- a/src/MEDLoader/MEDFileMesh.cxx +++ b/src/MEDLoader/MEDFileMesh.cxx @@ -660,9 +660,9 @@ void MEDFileMesh::createGroupOnAll(int meshDimRelToMaxExt, const char *groupName const DataArrayInt *fieldFamIds=getFamilyFieldAtLevel(meshDimRelToMaxExt); if(fieldFamIds==0) throw INTERP_KERNEL::Exception("MEDFileMesh::createGroupOnAll : Family field arr ids is not defined for this level !"); - std::set famIds=fieldFamIds->getDifferentValues(); + MEDCouplingAutoRefCountObjectPtr famIds=fieldFamIds->getDifferentValues(); std::vector familiesOnWholeGroup; - for(std::set::const_iterator it=famIds.begin();it!=famIds.end();it++) + for(const int *it=famIds->begin();it!=famIds->end();it++) { bool tmp; familiesOnWholeGroup.push_back(findOrCreateAndGiveFamilyWithId(*it,tmp)); @@ -694,9 +694,9 @@ bool MEDFileMesh::keepFamIdsOnlyOnLevs(const std::vector& famIds, const std const DataArrayInt *fieldFamIds=getFamilyFieldAtLevel(*it); if(fieldFamIds) { - std::set famIds3=fieldFamIds->getDifferentValues(); + MEDCouplingAutoRefCountObjectPtr famIds3=fieldFamIds->getDifferentValues(); std::vector tmp; - std::set_intersection(famIds3.begin(),famIds3.end(),famIds2.begin(),famIds2.end(),std::back_insert_iterator< std::vector >(tmp)); + std::set_intersection(famIds3->begin(),famIds3->end(),famIds2.begin(),famIds2.end(),std::back_insert_iterator< std::vector >(tmp)); for(std::vector::const_iterator it2=tmp.begin();it2!=tmp.end();it2++) { ret=false; @@ -940,13 +940,13 @@ bool MEDFileMesh::ensureDifferentFamIdsPerLevel() throw(INTERP_KERNEL::Exception const DataArrayInt *fam=getFamilyFieldAtLevel(*it); if(fam) { - std::set tmp=fam->getDifferentValues(); + MEDCouplingAutoRefCountObjectPtr tmp=fam->getDifferentValues(); std::set r2; - std::set_intersection(tmp.begin(),tmp.end(),allFamIds.begin(),allFamIds.end(),std::inserter(r2,r2.end())); + std::set_intersection(tmp->begin(),tmp->end(),allFamIds.begin(),allFamIds.end(),std::inserter(r2,r2.end())); if(!r2.empty()) famIdsToRenum[*it].insert(famIdsToRenum[*it].end(),r2.begin(),r2.end()); std::set r3; - std::set_union(tmp.begin(),tmp.end(),allFamIds.begin(),allFamIds.end(),std::inserter(r3,r3.end())); + std::set_union(tmp->begin(),tmp->end(),allFamIds.begin(),allFamIds.end(),std::inserter(r3,r3.end())); } } if(famIdsToRenum.empty()) @@ -999,15 +999,15 @@ void MEDFileMesh::normalizeFamIdsTrio() throw(INTERP_KERNEL::Exception) if(fam) { int refId=1; - std::set tmp=fam->getDifferentValues(); + MEDCouplingAutoRefCountObjectPtr tmp=fam->getDifferentValues(); std::map ren; - for(std::set::const_iterator it=tmp.begin();it!=tmp.end();it++,refId++) + for(const int *it=tmp->begin();it!=tmp->end();it++,refId++) ren[*it]=refId; int nbOfTuples=fam->getNumberOfTuples(); int *start=const_cast(fam)->getPointer(); for(int *w=start;w!=start+nbOfTuples;w++) *w=ren[*w]; - for(std::set::const_iterator it=tmp.begin();it!=tmp.end();it++) + for(const int *it=tmp->begin();it!=tmp->end();it++) { if(allIds->presenceOfValue(*it)) { @@ -1025,15 +1025,15 @@ void MEDFileMesh::normalizeFamIdsTrio() throw(INTERP_KERNEL::Exception) if(fam) { int refId=-1; - std::set tmp=fam->getDifferentValues(); + MEDCouplingAutoRefCountObjectPtr tmp=fam->getDifferentValues(); std::map ren; - for(std::set::const_iterator it=tmp.begin();it!=tmp.end();it++,refId--) + for(const int *it=tmp->begin();it!=tmp->end();it++,refId--) ren[*it]=refId; int nbOfTuples=fam->getNumberOfTuples(); int *start=const_cast(fam)->getPointer(); for(int *w=start;w!=start+nbOfTuples;w++) *w=ren[*w]; - for(std::set::const_iterator it=tmp.begin();it!=tmp.end();it++) + for(const int *it=tmp->begin();it!=tmp->end();it++) { if(allIds->presenceOfValue(*it)) { @@ -1049,9 +1049,9 @@ void MEDFileMesh::normalizeFamIdsTrio() throw(INTERP_KERNEL::Exception) DataArrayInt *fam=const_cast(getFamilyFieldAtLevel(*it2)); if(fam) { - std::set tmp=fam->getDifferentValues(); + MEDCouplingAutoRefCountObjectPtr tmp=fam->getDifferentValues(); fam->fillWithZero(); - for(std::set::const_iterator it3=tmp.begin();it3!=tmp.end();it3++) + for(const int *it3=tmp->begin();it3!=tmp->end();it3++) if(allIds->presenceOfValue(*it3)) { std::string famName=getFamilyNameGivenId(*it3); @@ -1091,15 +1091,15 @@ void MEDFileMesh::normalizeFamIdsMEDFile() throw(INTERP_KERNEL::Exception) const DataArrayInt *fam=getFamilyFieldAtLevel(1); if(fam) { - std::set tmp=fam->getDifferentValues(); + MEDCouplingAutoRefCountObjectPtr tmp=fam->getDifferentValues(); std::map ren; - for(std::set::const_iterator it=tmp.begin();it!=tmp.end();it++,refId++) + for(const int *it=tmp->begin();it!=tmp->end();it++,refId++) ren[*it]=refId; int nbOfTuples=fam->getNumberOfTuples(); int *start=const_cast(fam)->getPointer(); for(int *w=start;w!=start+nbOfTuples;w++) *w=ren[*w]; - for(std::set::const_iterator it=tmp.begin();it!=tmp.end();it++) + for(const int *it=tmp->begin();it!=tmp->end();it++) { if(allIds->presenceOfValue(*it)) { @@ -1116,15 +1116,15 @@ void MEDFileMesh::normalizeFamIdsMEDFile() throw(INTERP_KERNEL::Exception) const DataArrayInt *fam=getFamilyFieldAtLevel(1); if(fam) { - std::set tmp=fam->getDifferentValues(); + MEDCouplingAutoRefCountObjectPtr tmp=fam->getDifferentValues(); std::map ren; - for(std::set::const_iterator it=tmp.begin();it!=tmp.end();it++,refId--) + for(const int *it=tmp->begin();it!=tmp->end();it++,refId--) ren[*it]=refId; int nbOfTuples=fam->getNumberOfTuples(); int *start=const_cast(fam)->getPointer(); for(int *w=start;w!=start+nbOfTuples;w++) *w=ren[*w]; - for(std::set::const_iterator it=tmp.begin();it!=tmp.end();it++) + for(const int *it=tmp->begin();it!=tmp->end();it++) { if(allIds->presenceOfValue(*it)) { @@ -1257,7 +1257,7 @@ void MEDFileMesh::setGroupsAtLevel(int meshDimRelToMaxExt, const std::vector ids=fam->getDifferentValues(); + MEDCouplingAutoRefCountObjectPtr ids=fam->getDifferentValues(); appendFamilyEntries(ids,fidsOfGroups,grpsName2); setFamilyFieldArr(meshDimRelToMaxExt,fam); } @@ -1267,10 +1267,10 @@ void MEDFileMesh::setGroupsAtLevel(int meshDimRelToMaxExt, const std::vector& famIds, const std::vector< std::vector >& fidsOfGrps, const std::vector& grpNames) +void MEDFileMesh::appendFamilyEntries(const DataArrayInt *famIds, const std::vector< std::vector >& fidsOfGrps, const std::vector& grpNames) { std::map famInv; - for(std::set::const_iterator it=famIds.begin();it!=famIds.end();it++) + for(const int *it=famIds->begin();it!=famIds->end();it++) { std::ostringstream oss; oss << "Family_" << (*it); @@ -2175,9 +2175,9 @@ void MEDFileUMesh::optimizeFamilies() throw(INTERP_KERNEL::Exception) for(std::vector::const_iterator it=levs.begin();it!=levs.end();it++) { const DataArrayInt *ffield=getFamilyFieldAtLevel(*it); - std::set ids=ffield->getDifferentValues(); + MEDCouplingAutoRefCountObjectPtr ids=ffield->getDifferentValues(); std::set res; - std::set_union(ids.begin(),ids.end(),allFamsIds.begin(),allFamsIds.end(),std::inserter(res,res.begin())); + std::set_union(ids->begin(),ids->end(),allFamsIds.begin(),allFamsIds.end(),std::inserter(res,res.begin())); allFamsIds=res; } std::set famNamesToKill; @@ -2474,7 +2474,7 @@ void MEDFileUMesh::addGroupUnderground(const DataArrayInt *ids, DataArrayInt *fa std::list< MEDCouplingAutoRefCountObjectPtr > allFamIds=getAllNonNullFamilyIds(); allFamIds.erase(std::find(allFamIds.begin(),allFamIds.end(),famArrTmp)); MEDCouplingAutoRefCountObjectPtr famIds=famArr->selectByTupleIdSafe(ids->begin(),ids->end()); - std::set diffFamIds=famIds->getDifferentValues(); + MEDCouplingAutoRefCountObjectPtr diffFamIds=famIds->getDifferentValues(); std::vector familyIds; std::vector< MEDCouplingAutoRefCountObjectPtr > idsPerfamiliyIds; int maxVal=getTheMaxFamilyId()+1; @@ -2482,7 +2482,7 @@ void MEDFileUMesh::addGroupUnderground(const DataArrayInt *ids, DataArrayInt *fa std::map > groups(_groups); std::vector fams; bool created(false); - for(std::set::const_iterator famId=diffFamIds.begin();famId!=diffFamIds.end();famId++) + for(const int *famId=diffFamIds->begin();famId!=diffFamIds->end();famId++) { MEDCouplingAutoRefCountObjectPtr ids2Tmp=famIds->getIdsEqual(*famId); MEDCouplingAutoRefCountObjectPtr ids2=ids->selectByTupleId(ids2Tmp->begin(),ids2Tmp->end()); diff --git a/src/MEDLoader/MEDFileMesh.hxx b/src/MEDLoader/MEDFileMesh.hxx index eb1e5bb37..b8656a6b7 100644 --- a/src/MEDLoader/MEDFileMesh.hxx +++ b/src/MEDLoader/MEDFileMesh.hxx @@ -138,7 +138,7 @@ namespace ParaMEDMEM void dealWithTinyInfo(const MEDCouplingMesh *m) throw(INTERP_KERNEL::Exception); virtual void synchronizeTinyInfoOnLeaves() const = 0; void getFamilyRepr(std::ostream& oss) const; - virtual void appendFamilyEntries(const std::set& famIds, const std::vector< std::vector >& fidsOfGrps, const std::vector& grpNames); + virtual void appendFamilyEntries(const DataArrayInt *famIds, const std::vector< std::vector >& fidsOfGrps, const std::vector& grpNames); virtual void changeFamilyIdArr(int oldId, int newId) throw(INTERP_KERNEL::Exception) = 0; static void TranslateFamilyIds(int offset, DataArrayInt *famArr, std::vector< std::vector >& famIdsPerGrp); static void ChangeAllGroupsContainingFamily(std::map >& groups, const char *familyNameToChange, const std::vector& newFamiliesNames) throw(INTERP_KERNEL::Exception);