Salome HOME
untabify
[modules/smesh.git] / src / SMESH_I / SMESH_Group_i.cxx
index 1c7ff6a51fe8378e164da5362e3e60a33d841730..d6f2d4ee477f1f5d5c97d6421e2e1db60db2deb8 100644 (file)
@@ -1,4 +1,4 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -19,6 +19,7 @@
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 //  SMESH SMESH_I : idl implementation based on 'SMESH' unit's classes
 //  File   : SMESH_Group_i.cxx
 //  Author : Sergey ANIKIN, OCC
@@ -346,6 +347,36 @@ RemoveByPredicate( SMESH::Predicate_ptr thePredicate )
   return 0;
 }
 
+CORBA::Long SMESH_Group_i::AddFrom( SMESH::SMESH_IDSource_ptr theSource )
+{
+  long nbAdd = 0;
+  SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( GetGroupDS() );
+  if (aGroupDS) {
+    SMESH::long_array_var anIds;
+    if ( !CORBA::is_nil(SMESH::SMESH_GroupBase::_narrow(theSource)) &&
+         SMESH::SMESH_GroupBase::_narrow(theSource)->GetType() == GetType() ) {
+      anIds = theSource->GetIDs();
+    }
+    else if ( !CORBA::is_nil(SMESH::SMESH_Mesh::_narrow(theSource)) ) {
+      anIds = SMESH::SMESH_Mesh::_narrow(theSource)->GetElementsByType( GetType() );
+    }
+    else if ( !CORBA::is_nil(SMESH::SMESH_subMesh::_narrow(theSource)) ) {
+      anIds = SMESH::SMESH_subMesh::_narrow(theSource)->GetElementsByType( GetType() );
+    }
+    else {
+      anIds->length( 0 );
+    }
+    for ( int i = 0, total = anIds->length(); i < total; i++ ) {
+      if ( aGroupDS->Add((int)anIds[i]) ) nbAdd++;
+    }
+  }
+
+  // Update Python script
+  TPythonDump() << "nbAdd = " << _this() << ".AddFrom( " << theSource << " )";
+
+  return nbAdd;
+}
+
 //=============================================================================
 /*!
  *