Version: 6.3.1
Static Public Member Functions

SMESH_2smeshpy Class Reference

Tool converting SMESH engine calls into commands defined in smesh.py. More...

#include <SMESH_PythonDump.hxx>

Static Public Member Functions

static TCollection_AsciiString ConvertScript (const TCollection_AsciiString &theScript, Resource_DataMapOfAsciiStringAsciiString &theEntry2AccessorMethod, Resource_DataMapOfAsciiStringAsciiString &theObjectNames)
 Convert a python script using commands of smesh.py.
static const char * SmeshpyName ()
 Return the name of the python file wrapping IDL API.
static const char * GenName ()

Detailed Description

Tool converting SMESH engine calls into commands defined in smesh.py.

Implementation is in SMESH_2smeshpy.cxx

Definition at line 47 of file SMESH_PythonDump.hxx.


Member Function Documentation

TCollection_AsciiString SMESH_2smeshpy::ConvertScript ( const TCollection_AsciiString &  theScript,
Resource_DataMapOfAsciiStringAsciiString &  theEntry2AccessorMethod,
Resource_DataMapOfAsciiStringAsciiString &  theObjectNames 
) [static]

Convert a python script using commands of smesh.py.

Convert python script using commands of smesh.py.

Parameters:
theScript- Input script
theEntry2AccessorMethod- The returning method names to access to objects wrapped with python class
Return values:
TCollection_AsciiString- Convertion result
Parameters:
theScript- Input script
Return values:
TCollection_AsciiString- Convertion result

Class SMESH_2smeshpy declared in SMESH_PythonDump.hxx

Definition at line 122 of file SMESH_2smeshpy.cxx.

References SMESH_NoteBook.AddCommand(), _pyGen.Flush(), _pyGen.GetCommands(), SMESH_NoteBook.GetResultScript(), and SMESH_NoteBook.ReplaceVariables().

Referenced by SMESH_Gen_i.DumpPython_impl().

{
  theGen = new _pyGen( theEntry2AccessorMethod, theObjectNames );

  // split theScript into separate commands

  SMESH_NoteBook * aNoteBook = new SMESH_NoteBook();
  
  int from = 1, end = theScript.Length(), to;
  while ( from < end && ( to = theScript.Location( "\n", from, end )))
  {
    if ( to != from )
        // cut out and store a command
        aNoteBook->AddCommand( theScript.SubString( from, to - 1 ));
      from = to + 1;
  }
  
  aNoteBook->ReplaceVariables();

  TCollection_AsciiString aNoteScript = aNoteBook->GetResultScript();
  delete aNoteBook;
  aNoteBook = 0;
  
  // split theScript into separate commands
  from = 1, end = aNoteScript.Length();
  while ( from < end && ( to = aNoteScript.Location( "\n", from, end )))
  {
    if ( to != from )
      // cut out and store a command
      theGen->AddCommand( aNoteScript.SubString( from, to - 1 ));
    from = to + 1;
  }

  // finish conversion
  theGen->Flush();
#ifdef DUMP_CONVERSION
  MESSAGE_BEGIN ( std::endl << " ######## RESULT ######## " << std::endl<< std::endl );
#endif

  // reorder commands after conversion
  list< Handle(_pyCommand) >::iterator cmd;
  bool orderChanges;
  do {
    orderChanges = false;
    for ( cmd = theGen->GetCommands().begin(); cmd != theGen->GetCommands().end(); ++cmd )
      if ( (*cmd)->SetDependentCmdsAfter() )
        orderChanges = true;
  } while ( orderChanges );
  
  // concat commands back into a script
  TCollection_AsciiString aScript;
  for ( cmd = theGen->GetCommands().begin(); cmd != theGen->GetCommands().end(); ++cmd )
  {
#ifdef DUMP_CONVERSION
    MESSAGE_ADD ( "## COM " << (*cmd)->GetOrderNb() << ": "<< (*cmd)->GetString() << std::endl );
#endif
    if ( !(*cmd)->IsEmpty() ) {
      aScript += "\n";
      aScript += (*cmd)->GetString();
    }
  }
  aScript += "\n";

  theGen.Nullify();

  return aScript;
}
static const char* SMESH_2smeshpy.GenName ( ) [static]

Definition at line 67 of file SMESH_PythonDump.hxx.

Referenced by _pyGen.AccessorMethod(), SMESH_Gen_i.DumpPython_impl(), _pyGen.Flush(), Handle(), and _pyGen.Process().

{ return "smesh"; }
static const char* SMESH_2smeshpy.SmeshpyName ( ) [static]

Return the name of the python file wrapping IDL API.

Return values:
TCollection_AsciiString- The file name

Definition at line 66 of file SMESH_PythonDump.hxx.

Referenced by _pyMesh._pyMesh(), SMESH_Gen_i.DumpPython_impl(), _pyGen.Process(), and SMESH_NoteBook.ReplaceVariables().

{ return "smesh"; }
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