Salome HOME
54355: 'Compute' button is absent for 'Number of the double nodes' value in 'Mesh...
[modules/smesh.git] / src / SMESH_I / SMESH_subMesh_i.cxx
index 48ed4a1341b4a358838be88de1bfb8d7a1f33f47..4737a7b0e8eb28a7a8060d80a29beea5b64750e8 100644 (file)
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
-//  SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
+//  SMESH SMESH_I : idl implementation based on 'SMESH' unit's classes
 //  File   : SMESH_subMesh_i.cxx
 //  Author : Paul RASCLE, EDF
 //  Module : SMESH
 //
 #include "SMESH_subMesh_i.hxx"
 
+#include "SMESHDS_Mesh.hxx"
 #include "SMESHDS_SubMesh.hxx"
 #include "SMESH_Gen_i.hxx"
 #include "SMESH_Mesh_i.hxx"
@@ -484,14 +485,19 @@ SMESH::long_array* SMESH_subMesh_i::GetNbElementsByType()
     aRes[ SMESH::NODE ] = GetNumberOfNodes(true);
 
     ::SMESH_subMesh* aSubMesh = _mesh_i->_mapSubMesh[_localId];
-    if ( SMESHDS_SubMesh* smDS = aSubMesh->GetSubMeshDS() )
+    TListOfSubMeshes smList;
+    if ( getSubMeshes( aSubMesh, smList ))
     {
-      SMDS_ElemIteratorPtr eIt = smDS->GetElements();
-      if ( eIt->more() )
-        aRes[ eIt->next()->GetType() ] = smDS->NbElements();
+      TListOfSubMeshes::iterator smDS = smList.begin();
+      for ( ; smDS != smList.end(); ++smDS )
+      {
+        SMDS_ElemIteratorPtr eIt = (*smDS)->GetElements();
+        if ( eIt->more() )
+          aRes[ eIt->next()->GetType() ] = (*smDS)->NbElements();
+      }
     }
   }
-  return aRes._retn();  
+  return aRes._retn();
 }
 
 
@@ -508,26 +514,37 @@ SMESH::array_of_ElementType* SMESH_subMesh_i::GetTypes()
   SMESH::array_of_ElementType_var types = new SMESH::array_of_ElementType;
 
   ::SMESH_subMesh* aSubMesh = _mesh_i->_mapSubMesh[_localId];
-  if ( SMESHDS_SubMesh* smDS = aSubMesh->GetSubMeshDS() )
+
+  TListOfSubMeshes smList;
+  if ( getSubMeshes( aSubMesh, smList ))
   {
-    SMDS_ElemIteratorPtr eIt = smDS->GetElements();
-    if ( eIt->more() )
-    {
-      types->length( 1 );
-      types[0] = SMESH::ElementType( eIt->next()->GetType());
-    }
-    else if ( smDS->GetNodes()->more() )
+    TListOfSubMeshes::iterator smDS = smList.begin();
+    for ( ; smDS != smList.end(); ++smDS )
     {
-      TopoDS_Shape shape = aSubMesh->GetSubShape();
-      while ( !shape.IsNull() && shape.ShapeType() == TopAbs_COMPOUND )
+      SMDS_ElemIteratorPtr eIt = (*smDS)->GetElements();
+      if ( eIt->more() )
       {
-        TopoDS_Iterator it( shape );
-        shape = it.More() ? it.Value() : TopoDS_Shape();
+        types->length( 1 );
+        types[0] = SMESH::ElementType( eIt->next()->GetType());
+        break;
       }
-      if ( !shape.IsNull() && shape.ShapeType() == TopAbs_VERTEX )
+    }
+
+    if ( types->length() == 0 )
+    {
+      for ( smDS = smList.begin(); smDS != smList.end(); ++smDS )
       {
-        types->length( 1 );
-        types[0] = SMESH::NODE;
+        if ( (*smDS)->GetNodes()->more() )
+        {
+          int smID = (*smDS)->GetID();
+          TopoDS_Shape shape = (*smDS)->GetParent()->IndexToShape( smID );
+          if ( !shape.IsNull() && shape.ShapeType() == TopAbs_VERTEX )
+          {
+            types->length( 1 );
+            types[0] = SMESH::NODE;
+            break;
+          }
+        }
       }
     }
   }