Salome HOME
Merge branch 'csgroup_IS2'
[modules/shaper.git] / src / ExchangePlugin / ExchangePlugin_ImportFeature.cpp
index e6bd0d82f32fb57ec69d6fe5fdd3af933fb36fbc..65045f2283880243a962b3b394532cf6ce527949 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2020  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2021  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -36,6 +36,7 @@
 #include <GeomAPI_Shape.h>
 #include <GeomAPI_Face.h>
 #include <GeomAPI_ShapeExplorer.h>
+#include <GeomAPI_ShapeIterator.h>
 
 #include <Locale_Convert.h>
 
@@ -289,8 +290,16 @@ void ExchangePlugin_ImportFeature::setColorGroup(
 
     if (!aColor.empty()){
       if (aRes->get() &&  aColor == theColor) {
-        aSelectionList->setSelectionType(aShape->shapeTypeStr());
-        aSelectionList->append(theResultBody,aShape);
+        if (aShape->isCompound() || aShape->isCompSolid()) {
+          GeomAPI_ShapeIterator anIt(aShape);
+          for (; anIt.more(); anIt.next()) {
+            aSelectionList->setSelectionType(anIt.current()->shapeTypeStr());
+            aSelectionList->append(theResultBody,anIt.current());
+          }
+        } else {
+          aSelectionList->setSelectionType(aShape->shapeTypeStr());
+          aSelectionList->append(theResultBody,aShape);
+        }
       }
     }
   }
@@ -329,8 +338,16 @@ void ExchangePlugin_ImportFeature::setMaterielGroup(
                                  aResMat != anIt->second.end(); ++aResMat) {
         if (aRes->get() && ((*aRes)->data()->name() == (*aResMat)))
         {
-          aSelectionList->append(theResultBody,aShape);
-          aSelectionList->setSelectionType(aShape->shapeTypeStr());
+          if (aShape->isCompound() || aShape->isCompSolid()) {
+            GeomAPI_ShapeIterator anIt(aShape);
+            for (; anIt.more(); anIt.next()) {
+              aSelectionList->setSelectionType(anIt.current()->shapeTypeStr());
+              aSelectionList->append(theResultBody,anIt.current());
+            }
+          } else {
+            aSelectionList->setSelectionType(aShape->shapeTypeStr());
+            aSelectionList->append(theResultBody,aShape);
+          }
           break;
         }
       }