Salome HOME
http://www.salome-platform.org/forum/forum_10/881672547
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_MeshOp.cxx
index 8c1813f5636753b9da8cf4fa6521e4c69c2edf31..bed7c25fda6dc159638fb18e57d4e00ba54d7c87 100644 (file)
@@ -363,15 +363,36 @@ bool SMESHGUI_MeshOp::isSubshapeOk() const
       // skl for NPAL14695 - implementation of searching of mainObj
       GEOM::GEOM_Object_var mainObj = op->GetMainShape(aSubGeomVar); /* _var not _wrap as
                                                                         mainObj already exists! */
-      while(1) {
-        if (mainObj->_is_nil())
-          return false;
+      while( !mainObj->_is_nil()) {
         CORBA::String_var entry1 = mainObj->GetEntry();
         CORBA::String_var entry2 = mainGeom->GetEntry();
         if (std::string( entry1.in() ) == entry2.in() )
           return true;
         mainObj = op->GetMainShape(mainObj);
       }
+      if ( aSubGeomVar->GetShapeType() == GEOM::COMPOUND )
+      {
+        // is aSubGeomVar a compound of sub-shapes?
+        GEOM::GEOM_IShapesOperations_wrap sop = geomGen->GetIShapesOperations(aStudy->StudyId());
+        if (sop->_is_nil()) return false;
+        GEOM::ListOfLong_var ids = sop->GetAllSubShapesIDs( aSubGeomVar,
+                                                            GEOM::SHAPE,/*sorted=*/false);
+        if ( ids->length() > 0 )
+        {
+          ids->length( 1 );
+          GEOM::GEOM_Object_var compSub = geomGen->AddSubShape( aSubGeomVar, ids );
+          if ( !compSub->_is_nil() )
+          {
+            GEOM::ListOfGO_var shared = sop->GetSharedShapes( mainGeom,
+                                                              compSub,
+                                                              compSub->GetShapeType() );
+            geomGen->RemoveObject( compSub );
+            if ( shared->length() > 0 )
+              geomGen->RemoveObject( shared[0] );
+            return ( shared->length() > 0 );
+          }
+        }
+      }
     }
   }