mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-01-28 17:50:33 +05:00
0022318: [CEA] Problems with study dump in SMESH
Memory needed for SMESH_2smeshpy::ConvertScript() reduced by 3 times
This commit is contained in:
parent
993a87b969
commit
0e341dabe0
@ -447,14 +447,35 @@ namespace {
|
|||||||
*/
|
*/
|
||||||
//================================================================================
|
//================================================================================
|
||||||
|
|
||||||
TCollection_AsciiString
|
void
|
||||||
SMESH_2smeshpy::ConvertScript(const TCollection_AsciiString& theScript,
|
SMESH_2smeshpy::ConvertScript(TCollection_AsciiString& theScript,
|
||||||
Resource_DataMapOfAsciiStringAsciiString& theEntry2AccessorMethod,
|
Resource_DataMapOfAsciiStringAsciiString& theEntry2AccessorMethod,
|
||||||
Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
|
Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
|
||||||
std::set< TCollection_AsciiString >& theRemovedObjIDs,
|
std::set< TCollection_AsciiString >& theRemovedObjIDs,
|
||||||
SALOMEDS::Study_ptr& theStudy,
|
SALOMEDS::Study_ptr& theStudy,
|
||||||
const bool theToKeepAllCommands)
|
const bool theToKeepAllCommands)
|
||||||
{
|
{
|
||||||
|
// process notebook variables
|
||||||
|
{
|
||||||
|
SMESH_NoteBook aNoteBook;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
theScript.Clear();
|
||||||
|
|
||||||
|
aNoteBook.ReplaceVariables();
|
||||||
|
|
||||||
|
theScript = aNoteBook.GetResultScript();
|
||||||
|
}
|
||||||
|
|
||||||
|
// convert to smeshBuilder.py API
|
||||||
|
|
||||||
theGen = new _pyGen( theEntry2AccessorMethod,
|
theGen = new _pyGen( theEntry2AccessorMethod,
|
||||||
theObjectNames,
|
theObjectNames,
|
||||||
theRemovedObjIDs,
|
theRemovedObjIDs,
|
||||||
@ -462,33 +483,15 @@ SMESH_2smeshpy::ConvertScript(const TCollection_AsciiString& theScrip
|
|||||||
theToKeepAllCommands );
|
theToKeepAllCommands );
|
||||||
|
|
||||||
// split theScript into separate commands
|
// split theScript into separate commands
|
||||||
|
|
||||||
SMESH_NoteBook * aNoteBook = new SMESH_NoteBook();
|
|
||||||
|
|
||||||
int from = 1, end = theScript.Length(), to;
|
int from = 1, end = theScript.Length(), to;
|
||||||
while ( from < end && ( to = theScript.Location( "\n", from, end )))
|
while ( from < end && ( to = theScript.Location( "\n", from, end )))
|
||||||
{
|
{
|
||||||
if ( to != from )
|
if ( to != from )
|
||||||
// cut out and store a command
|
// cut out and store a command
|
||||||
aNoteBook->AddCommand( theScript.SubString( from, to - 1 ));
|
theGen->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;
|
from = to + 1;
|
||||||
}
|
}
|
||||||
|
theScript.Clear();
|
||||||
|
|
||||||
// finish conversion
|
// finish conversion
|
||||||
theGen->Flush();
|
theGen->Flush();
|
||||||
@ -510,7 +513,7 @@ SMESH_2smeshpy::ConvertScript(const TCollection_AsciiString& theScrip
|
|||||||
} while ( orderChanges );
|
} while ( orderChanges );
|
||||||
|
|
||||||
// concat commands back into a script
|
// concat commands back into a script
|
||||||
TCollection_AsciiString aScript, aPrevCmd;
|
TCollection_AsciiString aPrevCmd;
|
||||||
set<_pyID> createdObjects;
|
set<_pyID> createdObjects;
|
||||||
createdObjects.insert( "smeshBuilder" );
|
createdObjects.insert( "smeshBuilder" );
|
||||||
createdObjects.insert( "smesh" );
|
createdObjects.insert( "smesh" );
|
||||||
@ -524,17 +527,15 @@ SMESH_2smeshpy::ConvertScript(const TCollection_AsciiString& theScrip
|
|||||||
CheckObjectPresence( *cmd, createdObjects );
|
CheckObjectPresence( *cmd, createdObjects );
|
||||||
if ( !(*cmd)->IsEmpty() ) {
|
if ( !(*cmd)->IsEmpty() ) {
|
||||||
aPrevCmd = (*cmd)->GetString();
|
aPrevCmd = (*cmd)->GetString();
|
||||||
aScript += "\n";
|
theScript += "\n";
|
||||||
aScript += aPrevCmd;
|
theScript += aPrevCmd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
aScript += "\n";
|
theScript += "\n";
|
||||||
|
|
||||||
theGen->Free();
|
theGen->Free();
|
||||||
theGen.Nullify();
|
theGen.Nullify();
|
||||||
|
|
||||||
return aScript;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//================================================================================
|
//================================================================================
|
||||||
|
@ -234,12 +234,12 @@ namespace SMESH
|
|||||||
TPythonDump::
|
TPythonDump::
|
||||||
operator<<(SALOMEDS::SObject_ptr aSObject)
|
operator<<(SALOMEDS::SObject_ptr aSObject)
|
||||||
{
|
{
|
||||||
if ( !aSObject->_is_nil() ) {
|
if ( !aSObject->_is_nil() ) {
|
||||||
CORBA::String_var entry = aSObject->GetID();
|
CORBA::String_var entry = aSObject->GetID();
|
||||||
myStream << entry.in();
|
myStream << entry.in();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
myStream << theNotPublishedObjectName;
|
myStream << theNotPublishedObjectName;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -461,9 +461,9 @@ namespace SMESH
|
|||||||
DumpArray( theList, *this );
|
DumpArray( theList, *this );
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
const char* TPythonDump::NotPublishedObjectName()
|
const char* TPythonDump::NotPublishedObjectName()
|
||||||
{
|
{
|
||||||
return theNotPublishedObjectName;
|
return theNotPublishedObjectName;
|
||||||
}
|
}
|
||||||
|
|
||||||
TCollection_AsciiString myLongStringStart( "TPythonDump::LongStringStart" );
|
TCollection_AsciiString myLongStringStart( "TPythonDump::LongStringStart" );
|
||||||
@ -870,9 +870,9 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl
|
|||||||
Resource_DataMapOfAsciiStringAsciiString anEntry2AccessorMethod;
|
Resource_DataMapOfAsciiStringAsciiString anEntry2AccessorMethod;
|
||||||
std::set< TCollection_AsciiString > aRemovedObjIDs;
|
std::set< TCollection_AsciiString > aRemovedObjIDs;
|
||||||
if ( !getenv("NO_2smeshpy_conversion"))
|
if ( !getenv("NO_2smeshpy_conversion"))
|
||||||
aScript = SMESH_2smeshpy::ConvertScript( aScript, anEntry2AccessorMethod,
|
SMESH_2smeshpy::ConvertScript( aScript, anEntry2AccessorMethod,
|
||||||
theObjectNames, aRemovedObjIDs,
|
theObjectNames, aRemovedObjIDs,
|
||||||
theStudy, isHistoricalDump );
|
theStudy, isHistoricalDump );
|
||||||
|
|
||||||
// Replace characters used instead of quote marks to quote notebook variables
|
// Replace characters used instead of quote marks to quote notebook variables
|
||||||
{
|
{
|
||||||
@ -1005,10 +1005,10 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl
|
|||||||
aSetNameScriptPart += helper + ", '" + aGUIName + "')";
|
aSetNameScriptPart += helper + ", '" + aGUIName + "')";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( !aSetNameScriptPart.IsEmpty() )
|
if ( !aSetNameScriptPart.IsEmpty() )
|
||||||
{
|
{
|
||||||
anUpdatedScript += "\n\t## set object names";
|
anUpdatedScript += "\n\t## set object names";
|
||||||
anUpdatedScript += aSetNameScriptPart;
|
anUpdatedScript += aSetNameScriptPart;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------
|
// -----------------------------------------------------------------
|
||||||
|
@ -46,22 +46,21 @@ class Resource_DataMapOfAsciiStringAsciiString;
|
|||||||
*/
|
*/
|
||||||
// ===========================================================================================
|
// ===========================================================================================
|
||||||
|
|
||||||
class SMESH_2smeshpy
|
namespace SMESH_2smeshpy
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Convert a python script using commands of smesh.py
|
* \brief Convert a python script using commands of smeshBuilder.py
|
||||||
* \param theScript - Input script
|
* \param theScript - the Input script to convert
|
||||||
* \param theEntry2AccessorMethod - returns method names to access to
|
* \param theEntry2AccessorMethod - returns method names to access to
|
||||||
* objects wrapped with python class
|
* objects wrapped with python class
|
||||||
* \param theObjectNames - names of objects
|
* \param theObjectNames - names of objects
|
||||||
* \param theRemovedObjIDs - entries of objects whose created commands were removed
|
* \param theRemovedObjIDs - entries of objects whose created commands were removed
|
||||||
* \param theHistoricalDump - true means to keep all commands, false means
|
* \param theHistoricalDump - true means to keep all commands, false means
|
||||||
* to exclude commands relating to objects removed from study
|
* to exclude commands relating to objects removed from study
|
||||||
* \retval TCollection_AsciiString - Convertion result
|
* \retval TCollection_AsciiString - Convertion result
|
||||||
*/
|
*/
|
||||||
static TCollection_AsciiString
|
void
|
||||||
ConvertScript(const TCollection_AsciiString& theScript,
|
ConvertScript(TCollection_AsciiString& theScript,
|
||||||
Resource_DataMapOfAsciiStringAsciiString& theEntry2AccessorMethod,
|
Resource_DataMapOfAsciiStringAsciiString& theEntry2AccessorMethod,
|
||||||
Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
|
Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
|
||||||
std::set< TCollection_AsciiString >& theRemovedObjIDs,
|
std::set< TCollection_AsciiString >& theRemovedObjIDs,
|
||||||
|
Loading…
Reference in New Issue
Block a user