]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
[EDF26238] : fix performance on MEDFileMesh::getGroupsOnSpecifiedLev method
authorAnthony Geay <anthony.geay@edf.fr>
Fri, 7 Oct 2022 12:17:11 +0000 (14:17 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Fri, 7 Oct 2022 12:17:11 +0000 (14:17 +0200)
src/MEDLoader/MEDFileMesh.cxx

index f712e2abdbab3b86661d5c40d3e03d593400d0a3..09bd0ad0dbe26b83d5e6dfa91b27d8a13703d8f3 100644 (file)
@@ -534,12 +534,24 @@ std::vector<std::string> MEDFileMesh::getGroupsOnSpecifiedLev(int meshDimRelToMa
 {
   std::vector<std::string> ret;
   std::vector<std::string> allGrps(getGroupsNames());
-  for(std::vector<std::string>::const_iterator it=allGrps.begin();it!=allGrps.end();it++)
+  const DataArrayIdType *arr=getFamilyFieldAtLevel(meshDimRelToMaxExt);
+  if(!arr)
+    return ret;
+  std::set<mcIdType> famIdsInUse(arr->begin(),arr->end());
+  //
+  for(auto it : _groups)
+  {
+    for(auto it2 : it.second)
     {
-      std::vector<mcIdType> levs(getGrpNonEmptyLevelsExt((*it)));
-      if(std::find(levs.begin(),levs.end(),meshDimRelToMaxExt)!=levs.end())
-        ret.push_back(*it);
+      auto it3 = _families.find( it2 );
+      mcIdType famIdToTest = (*it3).second;
+      if( famIdsInUse.find(famIdToTest) != famIdsInUse.end() )
+      {
+        ret.push_back( it.first );
+        break ;
+      }
     }
+  }
   return ret;
 }