Version: 6.3.1
Public Member Functions | Static Public Member Functions | 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]

Public Member Functions

 _pyMeshEditor (const Handle(_pyCommand)&theCreationCmd)
 MeshEditor convert its commands to ones of mesh.
void Process (const Handle(_pyCommand)&theCommand)
 convert its commands to ones of mesh
virtual void Flush ()
const Handle (_pyCommand)&GetCreationCmd()
const _pyIDGetID ()
int GetNbCalls () const
void SetCreationCmd (Handle(_pyCommand) cmd)
int GetCommandNb ()
virtual const char * AccessorMethod () const
 Return method name giving access to an interaface object wrapped by python class.

Static Public Member Functions

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

Private Attributes

_pyID myMesh
TCollection_AsciiString myCreationCmdStr

Detailed Description

MeshEditor convert its commands to ones of mesh.

Definition at line 259 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 1106 of file SMESH_2smeshpy.cxx.

References _pyCommand.Clear(), _pyCommand.GetObject(), _pyCommand.GetString(), myCreationCmdStr, and myMesh.

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

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 _pyGen, _pyMesh, and _pyAlgorithm.

Definition at line 2484 of file SMESH_2smeshpy.cxx.

{
  return 0;
}
_pyID _pyObject::FatherID ( const _pyID childID) [static, inherited]

Return ID of a father.

Definition at line 2494 of file SMESH_2smeshpy.cxx.

Referenced by _pySegmentLengthAroundVertexHyp.Addition2Creation().

{
  int colPos = childID.SearchFromEnd(':');
  if ( colPos > 0 )
    return childID.SubString( 1, colPos-1 );
  return "";
}
virtual void _pyMeshEditor.Flush ( ) [virtual]

Implements _pyObject.

Definition at line 266 of file SMESH_2smeshpy.hxx.

{}
int _pyObject.GetCommandNb ( ) [inherited]

Definition at line 167 of file SMESH_2smeshpy.hxx.

{ return myCreationCmd->GetOrderNb(); }
const _pyID& _pyObject.GetID ( ) [inherited]
int _pyObject.GetNbCalls ( ) const [inherited]

Definition at line 165 of file SMESH_2smeshpy.hxx.

References _pyObject.myNbCalls.

Referenced by _pySubMesh.Flush(), and _pySelfEraser.Flush().

{ return myNbCalls; }
const _pyObject.Handle ( _pyCommand  ) [inherited]

Reimplemented in _pyGen, and _pyGen.

Definition at line 164 of file SMESH_2smeshpy.hxx.

{ return myCreationCmd; }
void _pyMeshEditor::Process ( const Handle(_pyCommand)&  theCommand) [virtual]

convert its commands to ones of mesh

Reimplemented from _pyObject.

Definition at line 1120 of file SMESH_2smeshpy.cxx.

References _pyGen.AddMeshAccessorMethod(), _pyCommand.GetArg(), _pyCommand.GetMethod(), _pyCommand.GetNbArgs(), _pyObject.Handle(), myCreationCmdStr, myMesh, SMESH_reg.names, _pyGen.Process(), _pyCommand.SetArg(), _pyCommand.SetMethod(), and _pyCommand.SetObject().

{
  // 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"
      ,"" }; // <- 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;

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

      // 2. And add last "True" argument(s)
      while(nbArgsToAdd--)
        theCommand->SetArg(theCommand->GetNbArgs()+1,"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");
  }
  // DoubleNodeElemGroupNew() -> DoubleNodeElemGroup()
  // DoubleNodeGroupNew() -> DoubleNodeGroup()
  // DoubleNodeGroupsNew() -> DoubleNodeGroups()
  // DoubleNodeElemGroupsNew() -> DoubleNodeElemGroups()
  if ( !isPyMeshMethod && ( method == "DoubleNodeElemGroupNew"  ||
                            method == "DoubleNodeElemGroupsNew" ||
                            method == "DoubleNodeGroupNew"      ||
                            method == "DoubleNodeGroupsNew"))
  {
    isPyMeshMethod=true;
    theCommand->SetMethod( method.SubString( 1, method.Length()-3));
    theCommand->SetArg(theCommand->GetNbArgs()+1,"True");
  }
  // 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 );
  }

  // 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();
    }
  }
}
void _pyObject.SetCreationCmd ( Handle(_pyCommand cmd) [inherited]

Definition at line 166 of file SMESH_2smeshpy.hxx.

Referenced by _pyHypothesis.Addition2Creation().

{ myCreationCmd = cmd; }

Field Documentation

TCollection_AsciiString _pyMeshEditor.myCreationCmdStr [private]

Definition at line 262 of file SMESH_2smeshpy.hxx.

Referenced by _pyMeshEditor(), and Process().

Definition at line 261 of file SMESH_2smeshpy.hxx.

Referenced by _pyMeshEditor(), and Process().

Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS