-// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
size_t TPythonDump::myCounter = 0;
const char theNotPublishedObjectName[] = "__NOT__Published__Object__";
- TVar::TVar(CORBA::Double value):myVals(1) { myVals[0] = SMESH_Comment(value); }
- TVar::TVar(CORBA::Long value):myVals(1) { myVals[0] = SMESH_Comment(value); }
- TVar::TVar(CORBA::Short value):myVals(1) { myVals[0] = SMESH_Comment(value); }
- TVar::TVar(const SMESH::double_array& value):myVals(value.length())
+ TVar::TVar(CORBA::Double value):myVals(1), myIsList(false) { myVals[0] = SMESH_Comment(value); }
+ TVar::TVar(CORBA::Long value):myVals(1), myIsList(false) { myVals[0] = SMESH_Comment(value); }
+ TVar::TVar(CORBA::Short value):myVals(1), myIsList(false) { myVals[0] = SMESH_Comment(value); }
+ TVar::TVar(const SMESH::double_array& value):myVals(value.length()), myIsList(true)
{
for ( size_t i = 0; i < value.length(); i++)
myVals[i] = SMESH_Comment(value[i]);
SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
std::string aString = myStream.str();
TCollection_AsciiString aCollection(Standard_CString(aString.c_str()));
- SALOMEDS::Study_var aStudy = aSMESHGen->GetCurrentStudy();
- if(!aStudy->_is_nil() && !aCollection.IsEmpty())
+ if(!aCollection.IsEmpty())
{
const std::string & objEntry = SMESH_Gen_i::GetSMESHGen()->GetLastObjEntry();
if ( !objEntry.empty() )
aCollection += (TVar::ObjPrefix() + objEntry ).c_str();
- aSMESHGen->AddToPythonScript(aStudy->StudyId(),aCollection);
+ aSMESHGen->AddToPythonScript(aCollection);
if(MYDEBUG) MESSAGE(aString);
// prevent misuse of already treated variables
aSMESHGen->UpdateParameters(CORBA::Object_var().in(),"");
operator<<(const TVar& theVarValue)
{
const std::vector< int >& varIDs = SMESH_Gen_i::GetSMESHGen()->GetLastParamIndices();
- if ( theVarValue.myVals.size() != 1 )
+ if ( theVarValue.myIsList )
{
myStream << "[ ";
for ( size_t i = 1; i <= theVarValue.myVals.size(); ++i )
return *this;
}
+ TPythonDump&
+ TPythonDump::
+ operator<<(const std::string& theArg){
+ myStream<<theArg;
+ return *this;
+ }
+
TPythonDump&
TPythonDump::
operator<<(const SMESH::ElementType& theArg)
operator<<(CORBA::Object_ptr theArg)
{
SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
- SALOMEDS::Study_var aStudy = aSMESHGen->GetCurrentStudy();
- SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(aStudy,theArg);
+ SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(theArg);
if(!aSObject->_is_nil()) {
CORBA::String_var id = aSObject->GetID();
myStream << id;
TPythonDump::
operator<<(SMESH::SMESH_Hypothesis_ptr theArg)
{
- SALOMEDS::Study_var aStudy = SMESH_Gen_i::GetSMESHGen()->GetCurrentStudy();
- SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(aStudy,theArg);
+ SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(theArg);
if(aSObject->_is_nil() && !CORBA::is_nil(theArg))
myStream << "hyp_" << theArg->GetId();
else
if ( CORBA::is_nil( theArg ) )
return *this << "None";
SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
- SALOMEDS::Study_var aStudy = aSMESHGen->GetCurrentStudy();
- SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(aStudy,theArg);
+ SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(theArg);
if(!aSObject->_is_nil())
{
return *this << aSObject;
SMESH::long_array_var anElementsId = theArg->GetIDs();
SMESH::array_of_ElementType_var types = theArg->GetTypes();
SMESH::ElementType type = types->length() ? types[0] : SMESH::ALL;
- SALOMEDS::SObject_wrap meshSO = SMESH_Gen_i::ObjectToSObject(aStudy,mesh);
+ SALOMEDS::SObject_wrap meshSO = SMESH_Gen_i::ObjectToSObject(mesh);
if ( meshSO->_is_nil() ) // don't waste memory for dumping not published objects
return *this << mesh << ".GetIDSource([], " << type << ")";
else
case FT_MultiConnection2D: myStream<< "aMultiConnection2D"; break;
case FT_Length: myStream<< "aLength"; break;
case FT_Length2D: myStream<< "aLength2D"; break;
+ case FT_NodeConnectivityNumber:myStream<< "aNodeConnectivityNumber";break;
case FT_BelongToMeshGroup: myStream<< "aBelongToMeshGroup"; break;
case FT_BelongToGeom: myStream<< "aBelongToGeom"; break;
case FT_BelongToPlane: myStream<< "aBelongToPlane"; break;
case FT_LogicalNOT: myStream<< "aLogicalNOT"; break;
case FT_LogicalAND: myStream<< "aLogicalAND"; break;
case FT_LogicalOR: myStream<< "aLogicalOR"; break;
- case FT_Undefined:
- default: myStream<< "anUndefined"; break;
+ case FT_Undefined: myStream<< "anUndefined"; break;
+ //default: -- commented to have a compilation warning
}
myStream<<theArg;
}
//function : DumpPython
//purpose :
//=======================================================================
-Engines::TMPFile* SMESH_Gen_i::DumpPython (CORBA::Object_ptr theStudy,
- CORBA::Boolean isPublished,
+Engines::TMPFile* SMESH_Gen_i::DumpPython (CORBA::Boolean isPublished,
CORBA::Boolean isMultiFile,
CORBA::Boolean& isValidScript)
{
- SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(theStudy);
+ SALOMEDS::Study_var aStudy = getStudyServant();
if (CORBA::is_nil(aStudy))
return new Engines::TMPFile(0);
// Add trace of API methods calls and replace study entries by names
TCollection_AsciiString aScript;
- aScript += DumpPython_impl(aStudy, aMap, aMapNames, isPublished, isMultiFile,
+ aScript += DumpPython_impl(aMap, aMapNames, isPublished, isMultiFile,
myIsHistoricalPythonDump, isValidScript, aSavedTrace);
int aLen = aScript.Length();
* AddToPythonScript
*/
//=============================================================================
-void SMESH_Gen_i::AddToPythonScript (int theStudyID, const TCollection_AsciiString& theString)
+void SMESH_Gen_i::AddToPythonScript (const TCollection_AsciiString& theString)
{
- if (myPythonScripts.find(theStudyID) == myPythonScripts.end()) {
- myPythonScripts[theStudyID] = new TColStd_HSequenceOfAsciiString;
+ if (myPythonScript.IsNull()) {
+ myPythonScript = new TColStd_HSequenceOfAsciiString;
}
- myPythonScripts[theStudyID]->Append(theString);
+ myPythonScript->Append(theString);
}
//=============================================================================
* RemoveLastFromPythonScript
*/
//=============================================================================
-void SMESH_Gen_i::RemoveLastFromPythonScript (int theStudyID)
+void SMESH_Gen_i::RemoveLastFromPythonScript()
{
- if (myPythonScripts.find(theStudyID) != myPythonScripts.end()) {
- int aLen = myPythonScripts[theStudyID]->Length();
- myPythonScripts[theStudyID]->Remove(aLen);
+ if (!myPythonScript.IsNull()) {
+ int aLen = myPythonScript->Length();
+ myPythonScript->Remove(aLen);
}
}
//function : SavePython
//purpose :
//=======================================================================
-void SMESH_Gen_i::SavePython (SALOMEDS::Study_ptr theStudy)
+void SMESH_Gen_i::SavePython()
{
// Dump trace of API methods calls
- TCollection_AsciiString aScript = GetNewPythonLines(theStudy->StudyId());
+ TCollection_AsciiString aScript = GetNewPythonLines();
// Check contents of PythonObject attribute
CORBA::String_var compDataType = ComponentDataType();
- SALOMEDS::SObject_wrap aSO = theStudy->FindComponent( compDataType.in() );
- SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
+ SALOMEDS::SObject_wrap aSO = getStudyServant()->FindComponent( compDataType.in() );
+ SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
SALOMEDS::GenericAttribute_wrap anAttr =
aStudyBuilder->FindOrCreateAttribute(aSO, "AttributePythonObject");
pyAttr->SetObject(oldScript.ToCString(), 1);
// Clean trace of API methods calls
- CleanPythonTrace(theStudy->StudyId());
+ CleanPythonTrace();
}
//================================================================================
/*!
* \brief Createa a Dump Python script
- * \param [in] theStudy - the study to dump
* \param [in,out] theObjectNames - map of an entry to a study and python name
* \param [in] theNames - - map of an entry to a study name
* \param [in] isPublished - \c true if dump of object publication in study is needed
//================================================================================
TCollection_AsciiString SMESH_Gen_i::DumpPython_impl
- (SALOMEDS::Study_ptr theStudy,
- Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
+ (Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
Resource_DataMapOfAsciiStringAsciiString& theNames,
bool isPublished,
bool isMultiFile,
TCollection_AsciiString& theSavedTrace)
{
SMESH_TRY;
- const int aStudyID = theStudy->StudyId();
const TCollection_AsciiString aSmeshpy ( SMESH_2smeshpy::SmeshpyName() );
const TCollection_AsciiString aSMESHGen( SMESH_2smeshpy::GenName() );
std::list< TCollection_AsciiString >::iterator linesIt;
if ( isPublished )
- lines.push_back( aSMESHGen + " = smeshBuilder.New(theStudy)" );
+ lines.push_back( aSMESHGen + " = smeshBuilder.New()" );
else
- lines.push_back( aSMESHGen + " = smeshBuilder.New(None)" );
+ lines.push_back( aSMESHGen + " = smeshBuilder.New(False)" );
lines.push_back( helper + "aFilterManager = " + aSMESHGen + ".CreateFilterManager()" );
lines.push_back( helper + "aMeasurements = " + aSMESHGen + ".CreateMeasurements()" );
lines.push_back( theSavedTrace.SubString( from, to - 1 ));
from = to + 1;
}
- // For the convertion of IDL API calls -> smeshBuilder.py API, "smesh" standing for SMESH_Gen
+ // For the conversion of IDL API calls -> smeshBuilder.py API, "smesh" standing for SMESH_Gen
// was replaces with "smeshgen" (==TPythonDump::SMESHGenName()).
// Change "smesh" -> "smeshgen" in the trace saved before passage to smeshBuilder.py API
bool isNewVersion =
}
// Add new dump trace of API methods calls to script lines
- if (myPythonScripts.find( aStudyID ) != myPythonScripts.end())
+ if (!myPythonScript.IsNull())
{
- Handle(TColStd_HSequenceOfAsciiString) aPythonScript = myPythonScripts[ aStudyID ];
+ Handle(TColStd_HSequenceOfAsciiString) aPythonScript = myPythonScript;
Standard_Integer istr, aLen = aPythonScript->Length();
for (istr = 1; istr <= aLen; istr++)
lines.push_back( aPythonScript->Value( istr ));
if ( !getenv("NO_2smeshpy_conversion"))
SMESH_2smeshpy::ConvertScript( lines, anEntry2AccessorMethod,
theObjectNames, aRemovedObjIDs,
- theStudy, isHistoricalDump );
+ isHistoricalDump );
bool importGeom = false;
GEOM::GEOM_Gen_ptr geom = GetGeomEngine();
}
if ( isMultiFile )
- initPart += "def RebuildData(theStudy):";
+ initPart += "def RebuildData():";
initPart += "\n";
anUpdatedScript.Prepend( initPart );
TCollection_AsciiString removeObjPart;
if ( !mapRemoved.IsEmpty() ) {
removeObjPart += nt + "## some objects were removed";
- removeObjPart += nt + "aStudyBuilder = theStudy.NewBuilder()";
+ removeObjPart += nt + "aStudyBuilder = salome.myStudy.NewBuilder()";
Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString mapRemovedIt;
for ( mapRemovedIt.Initialize( mapRemoved ); mapRemovedIt.More(); mapRemovedIt.Next() ) {
aName = mapRemovedIt.Value(); // python name
anEntry = mapRemovedIt.Key();
- removeObjPart += nt + "SO = theStudy.FindObjectIOR(theStudy.ConvertObjectToIOR(";
+ removeObjPart += nt + "SO = salome.myStudy.FindObjectIOR(salome.myStudy.ConvertObjectToIOR(";
removeObjPart += aName;
// for object wrapped by class of smeshBuilder.py
if ( anEntry2AccessorMethod.IsBound( anEntry ) )
{
//Output the script that sets up the visual parameters.
CORBA::String_var compDataType = ComponentDataType();
- CORBA::String_var script = theStudy->GetDefaultScript( compDataType.in(), tab.ToCString() );
+ CORBA::String_var script = getStudyServant()->GetDefaultScript( compDataType.in(), tab.ToCString() );
if ( script.in() && script.in()[0] ) {
visualPropertiesPart += nt + "### Store presentation parameters of displayed objects\n";
visualPropertiesPart += script.in();
"\nif __name__ == '__main__':"
"\n\tSMESH_RebuildData = RebuildData"
"\n\texec('import '+re.sub('SMESH$','GEOM',thisModule)+' as GEOM_dump')"
- "\n\tGEOM_dump.RebuildData( salome.myStudy )"
+ "\n\tGEOM_dump.RebuildData()"
"\n\texec('from '+re.sub('SMESH$','GEOM',thisModule)+' import * ')"
- "\n\tSMESH_RebuildData( salome.myStudy )";
+ "\n\tSMESH_RebuildData()";
}
anUpdatedScript += "\n";
* GetNewPythonLines
*/
//=============================================================================
-TCollection_AsciiString SMESH_Gen_i::GetNewPythonLines (int theStudyID)
+TCollection_AsciiString SMESH_Gen_i::GetNewPythonLines()
{
TCollection_AsciiString aScript;
// Dump trace of API methods calls
- if (myPythonScripts.find(theStudyID) != myPythonScripts.end()) {
- Handle(TColStd_HSequenceOfAsciiString) aPythonScript = myPythonScripts[theStudyID];
+ if (!myPythonScript.IsNull()) {
+ Handle(TColStd_HSequenceOfAsciiString) aPythonScript = myPythonScript;
Standard_Integer istr, aLen = aPythonScript->Length();
for (istr = 1; istr <= aLen; istr++) {
aScript += "\n";
* CleanPythonTrace
*/
//=============================================================================
-void SMESH_Gen_i::CleanPythonTrace (int theStudyID)
+void SMESH_Gen_i::CleanPythonTrace()
{
TCollection_AsciiString aScript;
// Clean trace of API methods calls
- if (myPythonScripts.find(theStudyID) != myPythonScripts.end()) {
- myPythonScripts[theStudyID]->Clear();
+ if (!myPythonScript.IsNull()) {
+ myPythonScript->Clear();
}
}