Back to index

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

MeshEditor convert its commands to ones of mesh. More...

#include <SMESH_2smeshpy.hxx>

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

List of all members.

Public Member Functions

 _pyMeshEditor (const Handle(_pyCommand)&theCreationCmd)
 MeshEditor convert its commands to ones of mesh.
_pyID GetMesh () const
virtual void Process (const Handle(_pyCommand)&theCommand)
 convert its commands to ones of mesh
virtual void Flush ()
virtual bool CanClear ()
 Return true if my mesh can be removed.
const Handle (_pyCommand)&GetCreationCmd()
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 void ClearCommands ()
 Clear myCreationCmd and myProcessedCmds.
virtual void Free ()

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 Attributes

_pyID myMesh
_AString myCreationCmdStr

Detailed Description

MeshEditor convert its commands to ones of mesh.

Definition at line 335 of file SMESH_2smeshpy.hxx.


Constructor & Destructor Documentation

_pyMeshEditor::_pyMeshEditor ( const Handle(_pyCommand)&  theCreationCmd)

MeshEditor convert its commands to ones of mesh.

Definition at line 1857 of file SMESH_2smeshpy.cxx.

                                                                    :
  _pyObject( theCreationCmd )
{
  myMesh = theCreationCmd->GetObject();
  myCreationCmdStr = theCreationCmd->GetString();
  theCreationCmd->Clear();

  Handle(_pyMesh) mesh = ObjectToMesh( theGen->FindObject( myMesh ));
  if ( !mesh.IsNull() )
    mesh->AddEditor( this );
}

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:

bool _pyMeshEditor::CanClear ( ) [virtual]

Return true if my mesh can be removed.

Reimplemented from _pyObject.

Definition at line 2045 of file SMESH_2smeshpy.cxx.

{
  Handle(_pyMesh) mesh = ObjectToMesh( theGen->FindObject( myMesh ));
  return mesh.IsNull() ? true : mesh->CanClear();
}

Here is the call 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:

virtual void _pyMeshEditor::Flush ( ) [inline, virtual]

Implements _pyObject.

Definition at line 343 of file SMESH_2smeshpy.hxx.

{}
virtual void _pyObject::Free ( ) [inline, virtual, inherited]

Reimplemented in _pyGroup, _pyFilter, _pySubMesh, _pyLayerDistributionHypo, _pyHypothesis, _pyMesh, and _pyGen.

Definition at line 189 of file SMESH_2smeshpy.hxx.

{}
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:

_pyID _pyMeshEditor::GetMesh ( ) const [inline]

Definition at line 341 of file SMESH_2smeshpy.hxx.

{ return myMesh; }

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:

const _pyObject::Handle ( _pyCommand  ) [inline, inherited]

Reimplemented in _pyMesh, _pyGen, and _pyGen.

Definition at line 175 of file SMESH_2smeshpy.hxx.

{ return myCreationCmd; }
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 _pyMeshEditor::Process ( const Handle(_pyCommand)&  theCommand) [virtual]

convert its commands to ones of mesh

Reimplemented from _pyObject.

Definition at line 1875 of file SMESH_2smeshpy.cxx.

{
  // names of SMESH_MeshEditor methods fully equal to methods of python class Mesh, so
  // commands calling this methods are converted to calls of methods of Mesh
  static TStringSet sameMethods;
  if ( sameMethods.empty() ) {
    const char * names[] = {
      "RemoveElements","RemoveNodes","RemoveOrphanNodes","AddNode","Add0DElement","AddEdge","AddFace","AddPolygonalFace",
      "AddVolume","AddPolyhedralVolume","AddPolyhedralVolumeByFaces","MoveNode", "MoveClosestNodeToPoint",
      "InverseDiag","DeleteDiag","Reorient","ReorientObject","TriToQuad","SplitQuad","SplitQuadObject",
      "BestSplit","Smooth","SmoothObject","SmoothParametric","SmoothParametricObject",
      "ConvertToQuadratic","ConvertFromQuadratic","RenumberNodes","RenumberElements",
      "RotationSweep","RotationSweepObject","RotationSweepObject1D","RotationSweepObject2D",
      "ExtrusionSweep","AdvancedExtrusion","ExtrusionSweepObject","ExtrusionSweepObject1D","ExtrusionSweepObject2D",
      "ExtrusionAlongPath","ExtrusionAlongPathObject","ExtrusionAlongPathX",
      "ExtrusionAlongPathObject1D","ExtrusionAlongPathObject2D",
      "Mirror","MirrorObject","Translate","TranslateObject","Rotate","RotateObject",
      "FindCoincidentNodes",/*"FindCoincidentNodesOnPart",*/"MergeNodes","FindEqualElements",
      "MergeElements","MergeEqualElements","SewFreeBorders","SewConformFreeBorders",
      "SewBorderToSide","SewSideElements","ChangeElemNodes","GetLastCreatedNodes",
      "GetLastCreatedElems",
      "MirrorMakeMesh","MirrorObjectMakeMesh","TranslateMakeMesh",
      "TranslateObjectMakeMesh","RotateMakeMesh","RotateObjectMakeMesh","MakeBoundaryMesh",
      "MakeBoundaryElements"
      ,"" }; // <- mark of the end
    sameMethods.Insert( names );
  }

  // names of SMESH_MeshEditor methods which differ from methods of class Mesh
  // only by last two arguments
  static TStringSet diffLastTwoArgsMethods;
  if (diffLastTwoArgsMethods.empty() ) {
    const char * names[] = {
      "MirrorMakeGroups","MirrorObjectMakeGroups",
      "TranslateMakeGroups","TranslateObjectMakeGroups",
      "RotateMakeGroups","RotateObjectMakeGroups",
      ""};// <- mark of the end
    diffLastTwoArgsMethods.Insert( names );
  }

  const TCollection_AsciiString & method = theCommand->GetMethod();
  bool isPyMeshMethod = sameMethods.Contains( method );
  if ( !isPyMeshMethod )
  {
    //Replace SMESH_MeshEditor "MakeGroups" functions by the Mesh
    //functions with the flag "theMakeGroups = True" like:
    //SMESH_MeshEditor.CmdMakeGroups => Mesh.Cmd(...,True)
    int pos = method.Search("MakeGroups");
    if( pos != -1)
    {
      isPyMeshMethod = true;
      bool is0DmethId  = ( method == "ExtrusionSweepMakeGroups0D" );
      bool is0DmethObj = ( method == "ExtrusionSweepObject0DMakeGroups");

      // 1. Remove "MakeGroups" from the Command
      TCollection_AsciiString aMethod = theCommand->GetMethod();
      int nbArgsToAdd = diffLastTwoArgsMethods.Contains(aMethod) ? 2 : 1;
      
      if(is0DmethObj)
        pos = pos-2;  //Remove "0D" from the Command too
      aMethod.Trunc(pos-1);
      theCommand->SetMethod(aMethod);

      // 2. And add last "True" argument(s)
      while(nbArgsToAdd--)
        theCommand->SetArg(theCommand->GetNbArgs()+1,"True");
      if( is0DmethId || is0DmethObj )
        theCommand->SetArg(theCommand->GetNbArgs()+1,"True");
    }
  }

  // ExtrusionSweep0D() -> ExtrusionSweep()
  // ExtrusionSweepObject0D() -> ExtrusionSweepObject()
  if ( !isPyMeshMethod && ( method == "ExtrusionSweep0D"  ||
                            method == "ExtrusionSweepObject0D" ))
  {
    isPyMeshMethod=true;
    theCommand->SetMethod( method.SubString( 1, method.Length()-2));
    theCommand->SetArg(theCommand->GetNbArgs()+1,"False");  //sets flag "MakeGroups = False"
    theCommand->SetArg(theCommand->GetNbArgs()+1,"True");  //sets flag "IsNode = True"
  }
  // set "ExtrusionAlongPathX()" instead of "ExtrusionAlongPathObjX()"
  if ( !isPyMeshMethod && method == "ExtrusionAlongPathObjX")
  {
    isPyMeshMethod=true;
    theCommand->SetMethod("ExtrusionAlongPathX");
  }

  // set "FindCoincidentNodesOnPart()" instead of "FindCoincidentNodesOnPartBut()"
  if ( !isPyMeshMethod && method == "FindCoincidentNodesOnPartBut")
  {
    isPyMeshMethod=true;
    theCommand->SetMethod("FindCoincidentNodesOnPart");
  }
  // DoubleNode...New(...) -> DoubleNode...(...,True)
  if ( !isPyMeshMethod && ( method == "DoubleNodeElemGroupNew"  ||
                            method == "DoubleNodeElemGroupsNew" ||
                            method == "DoubleNodeGroupNew"      ||
                            method == "DoubleNodeGroupsNew"     ||
                            method == "DoubleNodeElemGroup2New" ||
                            method == "DoubleNodeElemGroups2New"))
  {
    isPyMeshMethod=true;
    const int excessLen = 3 + int( method.Value( method.Length()-3 ) == '2' );
    theCommand->SetMethod( method.SubString( 1, method.Length()-excessLen));
    if ( excessLen == 3 )
    {
      theCommand->SetArg(theCommand->GetNbArgs()+1,"True");
    }
    else if ( theCommand->GetArg(4) == "0" ||
              theCommand->GetArg(5) == "0" )
    {
      // [ nothing, Group ] = DoubleNodeGroup2New(,,,False, True) ->
      // Group = DoubleNodeGroup2New(,,,False, True)
      _pyID groupID = theCommand->GetResultValue( 1 + int( theCommand->GetArg(4) == "0"));
      theCommand->SetResultValue( groupID );
    }
  }
  // ConvertToQuadraticObject(bool,obj) -> ConvertToQuadratic(bool,obj)
  // ConvertFromQuadraticObject(obj) -> ConvertFromQuadratic(obj)
  if ( !isPyMeshMethod && ( method == "ConvertToQuadraticObject" ||
                            method == "ConvertFromQuadraticObject" ))
  {
    isPyMeshMethod=true;
    theCommand->SetMethod( method.SubString( 1, method.Length()-6));
    // prevent moving creation of the converted sub-mesh to the end of the script
    bool isFromQua = ( method.Value( 8 ) == 'F' );
    Handle(_pySubMesh) sm = theGen->FindSubMesh( theCommand->GetArg( isFromQua ? 1 : 2 ));
    if ( !sm.IsNull() )
      sm->Process( theCommand );
  }
  // FindAmongElementsByPoint(meshPart, x, y, z, elementType) ->
  // FindElementsByPoint(x, y, z, elementType, meshPart)
  if ( !isPyMeshMethod && method == "FindAmongElementsByPoint" )
  {
    isPyMeshMethod=true;
    theCommand->SetMethod( "FindElementsByPoint" );
    // make the 1st arg be the last one
    _pyID partID = theCommand->GetArg( 1 );
    int nbArgs = theCommand->GetNbArgs();
    for ( int i = 2; i <= nbArgs; ++i )
      theCommand->SetArg( i-1, theCommand->GetArg( i ));
    theCommand->SetArg( nbArgs, partID );
  }

  // meshes made by *MakeMesh() methods are not wrapped by _pyMesh,
  // so let _pyMesh care of it (TMP?)
  //     if ( theCommand->GetMethod().Search("MakeMesh") != -1 )
  //       _pyMesh( new _pyCommand( theCommand->GetString(), 0 )); // for theGen->SetAccessorMethod()
  if ( isPyMeshMethod )
  {
    theCommand->SetObject( myMesh );
  }
  else
  {
    // editor creation command is needed only if any editor function is called
    theGen->AddMeshAccessorMethod( theCommand ); // for *Object()
    if ( !myCreationCmdStr.IsEmpty() ) {
      GetCreationCmd()->GetString() = myCreationCmdStr;
      myCreationCmdStr.Clear();
    }
  }
}

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 _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 338 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.

Definition at line 337 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: