- SMESH::long_array_var anIds;
- SMESH::SMESH_GroupBase_var group = SMESH::SMESH_GroupBase::_narrow(theSource);
- SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow(theSource);
- SMESH::SMESH_subMesh_var submesh = SMESH::SMESH_subMesh::_narrow(theSource);
- SMESH::Filter_var filter = SMESH::Filter::_narrow(theSource);
- if ( !group->_is_nil())
- anIds = group->GetType()==GetType() ? theSource->GetIDs() : new SMESH::long_array();
- else if ( !mesh->_is_nil() )
- anIds = mesh->GetElementsByType( GetType() );
- else if ( !submesh->_is_nil())
- anIds = submesh->GetElementsByType( GetType() );
- else if ( !filter->_is_nil() ) {
- filter->SetMesh( GetMeshServant()->_this() );
- anIds = filter->GetElementType()==GetType() ? theSource->GetIDs() : new SMESH::long_array();
- }
- else
- anIds = theSource->GetIDs();
- for ( int i = 0, total = anIds->length(); i < total; i++ ) {
- if ( aGroupDS->Add((int)anIds[i]) ) nbAdd++;
- }
+ SMDS_ElemIteratorPtr elemIt = SMESH_Mesh_i::GetElements( theSource, GetType() );
+ while ( elemIt->more() )
+ aGroupDS->SMDSGroup().Add( elemIt->next() );