Back to index

salome-smesh  6.5.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
_pyGroup Class Reference

To convert creation of a group by filter. More...

#include <SMESH_2smeshpy.hxx>

Inheritance diagram for _pyGroup:
Inheritance graph
[legend]
Collaboration diagram for _pyGroup:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 _pyGroup (const Handle(_pyCommand)&theCreationCmd, const _pyID &id=_pyID())
 Creates _pyGroup.
virtual void Process (const Handle(_pyCommand)&theCommand)
 To convert creation of a group by filter.
virtual void Flush ()
 Prevent clearing "DoubleNode...() command if a group created by it is removed.
virtual void Free ()
virtual Handle (_pyMesh) GetMesh()
void SetCreator (const Handle(_pyObject)&theCreator)
const _pyIDGetID ()
int GetNbCalls () const
bool IsInStudy () const
virtual void SetRemovedFromStudy (const bool isRemoved)
void SetCreationCmd (Handle(_pyCommand) cmd)
int GetCommandNb ()
void AddProcessedCmd (const Handle(_pyCommand)&cmd)
std::list< Handle(_pyCommand) > & GetProcessedCmds ()
virtual const char * AccessorMethod () const
 Return method name giving access to an interaface object wrapped by python class.
virtual bool CanClear ()
virtual void ClearCommands ()
 Clear myCreationCmd and myProcessedCmds.

Static Public Member Functions

static _pyID FatherID (const _pyID &childID)
 Return ID of a father.

Protected Member Functions

 Handle (_pyCommand) myCreationCmd
void setID (const _pyID &theID)
 Set up myID and myIsPublished.

Protected Attributes

_pyID myID
std::list< Handle(_pyCommand) > myProcessedCmds
bool myIsPublished

Private Member Functions

 Handle (_pyFilter) myFilter

Private Attributes

bool myCanClearCreationCmd

Detailed Description

To convert creation of a group by filter.

Definition at line 579 of file SMESH_2smeshpy.hxx.


Constructor & Destructor Documentation

_pyGroup::_pyGroup ( const Handle(_pyCommand)&  theCreationCmd,
const _pyID id = _pyID() 
)

Creates _pyGroup.

Definition at line 3698 of file SMESH_2smeshpy.cxx.

  :_pySubMesh(theCreationCmd)
{
  if ( !id.IsEmpty() )
    setID( id );

  myCanClearCreationCmd = true;

  const _AString& method = theCreationCmd->GetMethod();
  if ( method == "CreateGroup" ) // CreateGroup() --> CreateEmptyGroup()
  {
    theCreationCmd->SetMethod( "CreateEmptyGroup" );
  }
  // ----------------------------------------------------------------------
  else if ( method == "CreateGroupFromGEOM" ) // (type, name, grp)
  {
    _pyID geom = theCreationCmd->GetArg( 3 );
    // VSR 24/12/2010. PAL21106: always use GroupOnGeom() function on dump
    // next if(){...} section is commented
    //if ( sameGroupType( geom, theCreationCmd->GetArg( 1 )) ) { // --> Group(geom)
    //  theCreationCmd->SetMethod( "Group" );
    //  theCreationCmd->RemoveArgs();
    //  theCreationCmd->SetArg( 1, geom );
    //}
    //else {
    // ------------------------->>>>> GroupOnGeom( geom, name, typ )
      _pyID type = theCreationCmd->GetArg( 1 );
      _pyID name = theCreationCmd->GetArg( 2 );
      theCreationCmd->SetMethod( "GroupOnGeom" );
      theCreationCmd->RemoveArgs();
      theCreationCmd->SetArg( 1, geom );
      theCreationCmd->SetArg( 2, name );
      theCreationCmd->SetArg( 3, type );
    //}
  }
  else if ( method == "CreateGroupFromFilter" )
  {
    // -> GroupOnFilter(typ, name, aFilter0x4743dc0 -> aFilter_1)
    theCreationCmd->SetMethod( "GroupOnFilter" );

    _pyID filterID = theCreationCmd->GetArg(3);
    Handle(_pyFilter) filter = Handle(_pyFilter)::DownCast( theGen->FindObject( filterID ));
    if ( !filter.IsNull())
    {
      if ( !filter->GetNewID().IsEmpty() )
        theCreationCmd->SetArg( 3, filter->GetNewID() );
      filter->AddUser( this );
    }
    myFilter = filter;
  }
  else
  {
    // theCreationCmd does something else apart from creation of this group
    // and thus it can't be cleared if this group is removed
    myCanClearCreationCmd = false;
  }
}

Here is the call graph for this function:


Member Function Documentation

const char * _pyObject::AccessorMethod ( ) const [virtual, inherited]

Return method name giving access to an interaface object wrapped by python class.

Return values:
constchar* - method name

Reimplemented in _pyAlgorithm, _pyMesh, and _pyGen.

Definition at line 3623 of file SMESH_2smeshpy.cxx.

{
  return 0;
}
void _pyObject::AddProcessedCmd ( const Handle(_pyCommand)&  cmd) [inline, inherited]

Definition at line 181 of file SMESH_2smeshpy.hxx.

  { if (myProcessedCmds.empty() || myProcessedCmds.back()!=cmd) myProcessedCmds.push_back( cmd );}

Here is the caller graph for this function:

virtual bool _pyObject::CanClear ( ) [inline, virtual, inherited]

Reimplemented in _pyFilter, _pyHypothesis, _pyMeshEditor, and _pyMesh.

Definition at line 187 of file SMESH_2smeshpy.hxx.

{ return !myIsPublished; }

Here is the caller graph for this function:

void _pyObject::ClearCommands ( ) [virtual, inherited]

Clear myCreationCmd and myProcessedCmds.

Reimplemented in _pyHypothesis, _pyMesh, and _pyGen.

Definition at line 3603 of file SMESH_2smeshpy.cxx.

{
  if ( !CanClear() )
    return;

  if ( !myCreationCmd.IsNull() )
    myCreationCmd->Clear();

  list< Handle(_pyCommand) >::iterator cmd = myProcessedCmds.begin();
  for ( ; cmd != myProcessedCmds.end(); ++cmd )
    (*cmd)->Clear();
}

Here is the call graph for this function:

_pyID _pyObject::FatherID ( const _pyID childID) [static, inherited]

Return ID of a father.

Definition at line 3633 of file SMESH_2smeshpy.cxx.

{
  int colPos = childID.SearchFromEnd(':');
  if ( colPos > 0 )
    return childID.SubString( 1, colPos-1 );
  return "";
}

Here is the caller graph for this function:

void _pyGroup::Flush ( ) [virtual]

Prevent clearing "DoubleNode...() command if a group created by it is removed.

Reimplemented from _pySubMesh.

Definition at line 3838 of file SMESH_2smeshpy.cxx.

{
  if ( !theGen->IsToKeepAllCommands() &&
       myCreationCmd && !myCanClearCreationCmd )
  {
    myCreationCmd.Nullify(); // this way myCreationCmd won't be cleared
  }
}

Here is the call graph for this function:

virtual void _pyGroup::Free ( ) [inline, virtual]

Reimplemented from _pySubMesh.

Definition at line 587 of file SMESH_2smeshpy.hxx.

{ myFilter.Nullify(); }
int _pyObject::GetCommandNb ( ) [inline, inherited]

Definition at line 180 of file SMESH_2smeshpy.hxx.

{ return myCreationCmd->GetOrderNb(); }
const _pyID& _pyObject::GetID ( ) [inline, inherited]

Definition at line 173 of file SMESH_2smeshpy.hxx.

{ return myID.IsEmpty() ? myCreationCmd->GetResultValue() : myID; }

Here is the call graph for this function:

Here is the caller graph for this function:

int _pyObject::GetNbCalls ( ) const [inline, inherited]

Definition at line 176 of file SMESH_2smeshpy.hxx.

{ return myProcessedCmds.size(); }

Here is the caller graph for this function:

std::list< Handle(_pyCommand) >& _pyObject::GetProcessedCmds ( ) [inline, inherited]

Definition at line 183 of file SMESH_2smeshpy.hxx.

{ return myProcessedCmds; }
_pyObject::Handle ( _pyCommand  ) [protected, inherited]

Reimplemented in _pyMesh, _pyGen, and _pyGen.

Here is the caller graph for this function:

virtual _pySubMesh::Handle ( _pyMesh  ) [inline, virtual, inherited]

Definition at line 546 of file SMESH_2smeshpy.hxx.

{ return myMesh; }
_pyGroup::Handle ( _pyFilter  ) [private]

Here is the caller graph for this function:

bool _pyObject::IsInStudy ( ) const [inline, inherited]

Definition at line 177 of file SMESH_2smeshpy.hxx.

{ return myIsPublished; }

Here is the caller graph for this function:

void _pyGroup::Process ( const Handle(_pyCommand)&  theCommand) [virtual]

To convert creation of a group by filter.

Reimplemented from _pySubMesh.

Definition at line 3762 of file SMESH_2smeshpy.cxx.

{
  // Convert the following set of commands into mesh.MakeGroupByFilter(groupName, theFilter)
  // group = mesh.CreateEmptyGroup( elemType, groupName )
  // aFilter.SetMesh(mesh)
  // nbAdd = group.AddFrom( aFilter )
  Handle(_pyFilter) filter;
  if ( theCommand->GetMethod() == "AddFrom" )
  {
    _pyID idSource = theCommand->GetArg(1);
    // check if idSource is a filter
    filter = Handle(_pyFilter)::DownCast( theGen->FindObject( idSource ));
    if ( !filter.IsNull() )
    {
      // find aFilter.SetMesh(mesh) to clear it, it should be just before theCommand
      list< Handle(_pyCommand) >::reverse_iterator cmdIt = theGen->GetCommands().rbegin();
      while ( *cmdIt != theCommand ) ++cmdIt;
      while ( (*cmdIt)->GetOrderNb() != 1 )
      {
        const Handle(_pyCommand)& setMeshCmd = *(++cmdIt);
        if ((setMeshCmd->GetObject() == idSource ||
             setMeshCmd->GetObject() == filter->GetNewID() )
            &&
            setMeshCmd->GetMethod() == "SetMesh")
        {
          setMeshCmd->Clear();
          break;
        }
      }
      // replace 3 commands by one
      theCommand->Clear();
      const Handle(_pyCommand)& makeGroupCmd = GetCreationCmd();
      TCollection_AsciiString name = makeGroupCmd->GetArg( 2 );
      if ( !filter->GetNewID().IsEmpty() )
        idSource = filter->GetNewID();
      makeGroupCmd->SetMethod( "MakeGroupByFilter" );
      makeGroupCmd->SetArg( 1, name );
      makeGroupCmd->SetArg( 2, idSource );
    }
  }
  else if ( theCommand->GetMethod() == "SetFilter" )
  {
    // set new name of a filter or clear the command if the same filter is set
    _pyID filterID = theCommand->GetArg(1);
    filter = Handle(_pyFilter)::DownCast( theGen->FindObject( filterID ));
    if ( !myFilter.IsNull() && filter == myFilter )
      theCommand->Clear();
    else if ( !filter.IsNull() && !filter->GetNewID().IsEmpty() )
      theCommand->SetArg( 1, filter->GetNewID() );
    myFilter = filter;
  }
  else if ( theCommand->GetMethod() == "GetFilter" )
  {
    // GetFilter() returns a filter with other ID, make myFilter process
    // calls of the returned filter
    if ( !myFilter.IsNull() )
    {
      theGen->SetProxyObject( theCommand->GetResultValue(), myFilter );
      theCommand->Clear();
    }
  }

  if ( !filter.IsNull() )
    filter->AddUser( this );

  theGen->AddMeshAccessorMethod( theCommand );
}

Here is the call graph for this function:

void _pyObject::SetCreationCmd ( Handle(_pyCommand cmd) [inline, inherited]

Definition at line 179 of file SMESH_2smeshpy.hxx.

{ myCreationCmd = cmd; }

Here is the caller graph for this function:

void _pySubMesh::SetCreator ( const Handle(_pyObject)&  theCreator) [inline, inherited]

Definition at line 548 of file SMESH_2smeshpy.hxx.

{ myCreator = theCreator; }
void _pyObject::setID ( const _pyID theID) [protected, inherited]

Set up myID and myIsPublished.

Definition at line 3591 of file SMESH_2smeshpy.cxx.

{
  myID = theID;
  myIsPublished = !theGen->IsNotPublished( GetID() );
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void _pyObject::SetRemovedFromStudy ( const bool  isRemoved) [inline, virtual, inherited]

Reimplemented in _pyMesh.

Definition at line 178 of file SMESH_2smeshpy.hxx.

{ myIsPublished = !isRemoved; }

Member Data Documentation

Definition at line 582 of file SMESH_2smeshpy.hxx.

_pyID _pyObject::myID [protected, inherited]

Definition at line 165 of file SMESH_2smeshpy.hxx.

bool _pyObject::myIsPublished [protected, inherited]

Definition at line 168 of file SMESH_2smeshpy.hxx.

std::list< Handle(_pyCommand) > _pyObject::myProcessedCmds [protected, inherited]

Definition at line 167 of file SMESH_2smeshpy.hxx.


The documentation for this class was generated from the following files: