Back to index

salome-smesh  6.5.0
Static Public Member Functions
SMESH_2smeshpy Class Reference

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

#include <SMESH_PythonDump.hxx>

List of all members.

Static Public Member Functions

static TCollection_AsciiString ConvertScript (const TCollection_AsciiString &theScript, Resource_DataMapOfAsciiStringAsciiString &theEntry2AccessorMethod, Resource_DataMapOfAsciiStringAsciiString &theObjectNames, SALOMEDS::Study_ptr &theStudy, const bool theHistoricalDump)
 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 smeshDC.py.

Implementation is in SMESH_2smeshpy.cxx

Definition at line 48 of file SMESH_PythonDump.hxx.


Member Function Documentation

TCollection_AsciiString SMESH_2smeshpy::ConvertScript ( const TCollection_AsciiString &  theScript,
Resource_DataMapOfAsciiStringAsciiString &  theEntry2AccessorMethod,
Resource_DataMapOfAsciiStringAsciiString &  theObjectNames,
SALOMEDS::Study_ptr &  theStudy,
const bool  theToKeepAllCommands 
) [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
theHistoricalDump- true means to keep all commands, false means to exclude commands relating to objects removed from study
Return values:
TCollection_AsciiString- Convertion result
Parameters:
theScript- Input script
Return values:
TCollection_AsciiString- Convertion result
Parameters:
theToKeepAllCommands- to keep all commands or to exclude commands relating to objects removed from study

Class SMESH_2smeshpy declared in SMESH_PythonDump.hxx

Definition at line 295 of file SMESH_2smeshpy.cxx.

{
  theGen = new _pyGen( theEntry2AccessorMethod, theObjectNames, theStudy, theToKeepAllCommands );

  // 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

  // clean commmands of removed objects depending on myIsPublished flag
  theGen->ClearCommands();

  // 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, aPrevCmd;
  set<_pyID> createdObjects;
  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() && aPrevCmd != (*cmd)->GetString()) {
      CheckObjectPresence( *cmd, createdObjects );
      aPrevCmd = (*cmd)->GetString();
      aScript += "\n";
      aScript += aPrevCmd;
    }
  }
  aScript += "\n";

  theGen->Free();
  theGen.Nullify();

  return aScript;
}

Here is the call graph for this function:

static const char* SMESH_2smeshpy::GenName ( ) [inline, static]

Definition at line 72 of file SMESH_PythonDump.hxx.

{ return "smesh"; }

Here is the caller graph for this function:

static const char* SMESH_2smeshpy::SmeshpyName ( ) [inline, static]

Return the name of the python file wrapping IDL API.

Return values:
constchar* - the file name

Definition at line 71 of file SMESH_PythonDump.hxx.

{ return "smesh"; }

Here is the caller graph for this function:


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