Salome HOME
0021439: EDF 2004 GEOM, SMESH: Dump of study gives bad geom group and stops with...
[modules/smesh.git] / src / SMESH_I / SMESH_Gen_i_1.cxx
index ef41b4c6f2311154c60ac85e38ec29c393929952..900534d11c705f957bfaa7a9726ccbebdd4d42e2 100644 (file)
@@ -632,7 +632,10 @@ SALOMEDS::SObject_ptr SMESH_Gen_i::PublishSubMesh (SALOMEDS::Study_ptr      theS
     SetName( aRootSO, aRootName );
 
     // Add new submesh to corresponding sub-tree
-    aSubMeshSO = publish (theStudy, theSubMesh, aRootSO, 0, "ICON_SMESH_TREE_MESH_WARN");
+    SMESH::array_of_ElementType_var elemTypes = theSubMesh->GetTypes();
+    const int isEmpty = ( elemTypes->length() == 0 );
+    const char* pm[2] = { "ICON_SMESH_TREE_MESH", "ICON_SMESH_TREE_MESH_WARN" };
+    aSubMeshSO = publish (theStudy, theSubMesh, aRootSO, 0, pm[isEmpty] );
     if ( aSubMeshSO->_is_nil() )
       return aSubMeshSO._retn();
   }
@@ -695,10 +698,18 @@ SALOMEDS::SObject_ptr SMESH_Gen_i::PublishGroup (SALOMEDS::Study_ptr    theStudy
 
       // Add new group to corresponding sub-tree
       SMESH::array_of_ElementType_var elemTypes = theGroup->GetTypes();
-      const int isEmpty = ( elemTypes->length() == 0 );
+      int isEmpty = ( elemTypes->length() == 0 );
       std::string pm[2] = { "ICON_SMESH_TREE_GROUP", "ICON_SMESH_TREE_MESH_WARN" };
       if ( SMESH::DownCast< SMESH_GroupOnFilter_i* > ( theGroup ))
+      {
         pm[0] = "ICON_SMESH_TREE_GROUP_ON_FILTER";
+      }
+      else if ( SMESH::DownCast< SMESH_Group_i* > ( theGroup ))
+      {
+        SMESH::array_of_ElementType_var allElemTypes = theMesh->GetTypes();
+        for ( size_t i =0; i < allElemTypes->length() && isEmpty; ++i )
+          isEmpty = ( allElemTypes[i] != theGroup->GetType() );
+      }
       aGroupSO = publish (theStudy, theGroup, aRootSO, 0, pm[isEmpty].c_str() );
     }
     if ( aGroupSO->_is_nil() )