X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FSMESH_I%2FSMESH_Group_i.cxx;h=7a75b310be55a430c394341c1e546a0483eb31c0;hb=c63ee099ad2b149bd70136839c973e8910137bc5;hp=78ca5289810b95a4fb690ab38ca20f4365136ebf;hpb=7dbc79c51dcd1dce59ae05bc8766b2576a3c40ed;p=modules%2Fsmesh.git diff --git a/src/SMESH_I/SMESH_Group_i.cxx b/src/SMESH_I/SMESH_Group_i.cxx index 78ca52898..7a75b310b 100644 --- a/src/SMESH_I/SMESH_Group_i.cxx +++ b/src/SMESH_I/SMESH_Group_i.cxx @@ -16,7 +16,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -33,8 +33,14 @@ #include "SMESHDS_Group.hxx" #include "SMESHDS_GroupOnGeom.hxx" #include "SMDSAbs_ElementType.hxx" + +#include "SMESH_Filter_i.hxx" +#include "SMESH_PythonDump.hxx" + #include "utilities.h" +using namespace SMESH; + //============================================================================= /*! * @@ -113,6 +119,10 @@ SMESHDS_GroupBase* SMESH_GroupBase_i::GetGroupDS() const void SMESH_GroupBase_i::SetName( const char* theName ) { + // Update Python script + TPythonDump() << _this() << ".SetName( '" << theName << "' )"; + + // Perform renaming ::SMESH_Group* aGroup = GetSmeshGroup(); if (aGroup) { aGroup->SetName(theName); @@ -204,6 +214,10 @@ CORBA::Boolean SMESH_GroupBase_i::IsEmpty() void SMESH_Group_i::Clear() { + // Update Python script + TPythonDump() << _this() << ".Clear()"; + + // Clear the group SMESHDS_Group* aGroupDS = dynamic_cast( GetGroupDS() ); if (aGroupDS) { aGroupDS->Clear(); @@ -235,6 +249,10 @@ CORBA::Boolean SMESH_GroupBase_i::Contains( CORBA::Long theID ) CORBA::Long SMESH_Group_i::Add( const SMESH::long_array& theIDs ) { + // Update Python script + TPythonDump() << "nbAdd = " << _this() << ".Add( " << theIDs << " )"; + + // Add elements to the group SMESHDS_Group* aGroupDS = dynamic_cast( GetGroupDS() ); if (aGroupDS) { int nbAdd = 0; @@ -255,6 +273,82 @@ CORBA::Long SMESH_Group_i::Add( const SMESH::long_array& theIDs ) */ //============================================================================= +CORBA::Long SMESH_Group_i::Remove( const SMESH::long_array& theIDs ) +{ + // Update Python script + TPythonDump() << "nbDel = " << _this() << ".Remove( " << theIDs << " )"; + + // Remove elements from the group + SMESHDS_Group* aGroupDS = dynamic_cast( GetGroupDS() ); + if (aGroupDS) { + int nbDel = 0; + for (int i = 0; i < theIDs.length(); i++) { + int anID = (int) theIDs[i]; + if (aGroupDS->Remove(anID)) + nbDel++; + } + return nbDel; + } + MESSAGE("attempt to remove elements from a vague group"); + return 0; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +typedef bool (SMESHDS_Group::*TFunChangeGroup)(const int); + +CORBA::Long +ChangeByPredicate( SMESH::Predicate_i* thePredicate, + SMESHDS_GroupBase* theGroupBase, + TFunChangeGroup theFun) +{ + CORBA::Long aNb = 0; + if(SMESHDS_Group* aGroupDS = dynamic_cast(theGroupBase)){ + SMESH::Controls::Filter::TIdSequence aSequence; + const SMDS_Mesh* aMesh = theGroupBase->GetMesh(); + SMESH::Filter_i::GetElementsId(thePredicate,aMesh,aSequence); + + CORBA::Long i = 0, iEnd = aSequence.size(); + for(; i < iEnd; i++) + if((aGroupDS->*theFun)(aSequence[i])) + aNb++; + return aNb; + } + return aNb; +} + +CORBA::Long +SMESH_Group_i:: +AddByPredicate( SMESH::Predicate_ptr thePredicate ) +{ + if(SMESH::Predicate_i* aPredicate = SMESH::GetPredicate(thePredicate)){ + TPythonDump()<<_this()<<".AddByPredicate("<( GetGroupDS() ); - if (aGroupDS) { - int nbDel = 0; - for (int i = 0; i < theIDs.length(); i++) { - int anID = (int) theIDs[i]; - if (aGroupDS->Remove(anID)) - nbDel++; - } - return nbDel; - } - MESSAGE("attempt to remove elements from a vague group"); - return 0; -} - //============================================================================= /*! * @@ -347,3 +419,33 @@ GEOM::GEOM_Object_ptr SMESH_GroupOnGeom_i::GetShape() return aGeomObj._retn(); } +//============================================================================= +/*! + * + */ +//============================================================================= +CORBA::Long SMESH_GroupBase_i::GetColorNumber() +{ + SMESHDS_GroupBase* aGroupDS = GetGroupDS(); + if (aGroupDS) + return aGroupDS->GetColorGroup(); + MESSAGE("get color number of a vague group"); + return 0; +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESH_GroupBase_i::SetColorNumber(CORBA::Long color) +{ + SMESHDS_GroupBase* aGroupDS = GetGroupDS(); + if (aGroupDS) + return aGroupDS->SetColorGroup(color); + MESSAGE("set color number of a vague group"); + return ; +} + + +