Salome HOME
Mantis issue 0020508: EDF 1059 GEOM : Selection of a group in Suppress Faces.
authorjfa <jfa@opencascade.com>
Thu, 14 Jan 2010 11:33:46 +0000 (11:33 +0000)
committerjfa <jfa@opencascade.com>
Thu, 14 Jan 2010 11:33:46 +0000 (11:33 +0000)
src/RepairGUI/RepairGUI_SuppressFacesDlg.cxx

index a517685406f6ff0744c8d5fa7af6729a56360eed..0253027fcb2270a602ca41fe6e949b4777368689 100644 (file)
 #include <SUIT_Session.h>
 #include <SUIT_ResourceMgr.h>
 #include <SalomeApp_Application.h>
+#include <SalomeApp_Study.h>
 #include <LightApp_SelectionMgr.h>
 
 // OCCT Includes
 #include <TopAbs.hxx>
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
 #include <TColStd_MapOfInteger.hxx>
 #include <TColStd_IndexedMapOfInteger.hxx>
 
@@ -192,6 +196,35 @@ void RepairGUI_SuppressFacesDlg::SelectionIntoArgument()
     else if (myEditCurrentArgument == GroupArgs->LineEdit2) {
       TColStd_IndexedMapOfInteger aMap;
       aSelMgr->GetIndexes(anIO, aMap);
+
+      if (aMap.IsEmpty()) { // try to detect selected published sub-shape
+        QString anEntry = anIO->getEntry();
+
+        SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(myGeomGUI->getApp()->activeStudy());
+        if (!appStudy) return;
+        _PTR(Study) aStudy = appStudy->studyDS();
+        _PTR(SObject) aSObj (aStudy->FindObjectID(anEntry.toLatin1().constData()));
+        GEOM::GEOM_Object_var aGeomObj =
+          GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aSObj));
+        TopoDS_Shape aShape;
+        if (GEOMBase::GetShape(aGeomObj, aShape)) {
+          if (aGeomObj->GetType() == GEOM_GROUP || aShape.ShapeType() == TopAbs_FACE) {
+            TopTools_IndexedMapOfShape aMainMap;
+            TopoDS_Shape aMainShape = GEOM_Client().GetShape(GeometryGUI::GetGeomGen(), myObject);
+            TopExp::MapShapes(aMainShape, aMainMap);
+
+            TopExp_Explorer anExp (aShape, TopAbs_FACE);
+            for (; anExp.More(); anExp.Next()) {
+              TopoDS_Shape aSubShape = anExp.Current();
+              int anIndex = aMainMap.FindIndex(aSubShape);
+              if (anIndex >= 0) {
+                aMap.Add(anIndex);
+              }
+            }
+          }
+        }
+      }
+
       const int n = aMap.Extent();
       myFacesInd->length(n);
       for (int i = 1; i <= n; i++)