// Publish hypothesis/algorithm in the study
if ( CanPublishInStudy( hyp ) ) {
SALOMEDS::SObject_var aSO = PublishHypothesis( myCurrentStudy, hyp );
-
- // Update Python script
- TCollection_AsciiString aStr (aSO->GetID());
- aStr += " = smesh.CreateHypothesis(\"";
- aStr += Standard_CString(theHypName);
- aStr += "\", \"";
- aStr += Standard_CString(theLibName);
- aStr += "\")";
-
- AddToPythonScript(myCurrentStudy->StudyId(), aStr);
+ if ( !aSO->_is_nil() ) {
+ // Update Python script
+ TCollection_AsciiString aStr (aSO->GetID());
+ aStr += " = smesh.CreateHypothesis(\"";
+ aStr += Standard_CString(theHypName);
+ aStr += "\", \"";
+ aStr += Standard_CString(theLibName);
+ aStr += "\")";
+
+ AddToCurrentPyScript(aStr);
+ }
}
return hyp._retn();
// publish mesh in the study
if ( CanPublishInStudy( mesh ) ) {
SALOMEDS::SObject_var aSO = PublishMesh( myCurrentStudy, mesh.in() );
-
- // Update Python script
- TCollection_AsciiString aStr (aSO->GetID());
- aStr += " = smesh.CreateMesh(";
- SMESH_Gen_i::AddObject(aStr, theShapeObject) += ")";
-
- AddToPythonScript(myCurrentStudy->StudyId(), aStr);
+ if ( !aSO->_is_nil() ) {
+ // Update Python script
+ TCollection_AsciiString aStr (aSO->GetID());
+ aStr += " = smesh.CreateMesh(";
+ SMESH_Gen_i::AddObject(aStr, theShapeObject) += ")";
+
+ AddToCurrentPyScript(aStr);
+ }
}
return mesh._retn();
// publish mesh in the study
if ( CanPublishInStudy( aMesh ) ) {
SALOMEDS::SObject_var aSO = PublishMesh( myCurrentStudy, aMesh.in(), aFileName.c_str() );
-
- // Update Python script
- TCollection_AsciiString aStr (aSO->GetID());
- aStr += " = smesh.CreateMeshesFromUNV(\"";
- aStr += Standard_CString(theFileName);
- aStr += "\")";
-
- AddToPythonScript(myCurrentStudy->StudyId(), aStr);
+ if ( !aSO->_is_nil() ) {
+ // Update Python script
+ TCollection_AsciiString aStr (aSO->GetID());
+ aStr += " = smesh.CreateMeshesFromUNV(\"";
+ aStr += Standard_CString(theFileName);
+ aStr += "\")";
+
+ AddToCurrentPyScript(aStr);
+ }
}
SMESH_Mesh_i* aServant = dynamic_cast<SMESH_Mesh_i*>( GetServant( aMesh ).in() );
SMESH::SMESH_Mesh_var mesh = createMesh();
// publish mesh in the study
- if ( CanPublishInStudy( mesh ) ) {
- SALOMEDS::SObject_var aSO = PublishMesh( myCurrentStudy, mesh.in(), (*it).c_str() );
-
+ SALOMEDS::SObject_var aSO;
+ if ( CanPublishInStudy( mesh ) )
+ aSO = PublishMesh( myCurrentStudy, mesh.in(), (*it).c_str() );
+ if ( !aSO->_is_nil() ) {
// Python Dump
aStr += aSO->GetID();
} else {
aStr += Standard_CString(theFileName);
aStr += "\")";
- AddToPythonScript(myCurrentStudy->StudyId(), aStr);
+ AddToCurrentPyScript(aStr);
return aResult._retn();
}
if ( CanPublishInStudy( aMesh ) ) {
SALOMEDS::SObject_var aSO = PublishInStudy
( myCurrentStudy, SALOMEDS::SObject::_nil(), aMesh.in(), aFileName.c_str() );
-
+ if ( !aSO->_is_nil() ) {
// Update Python script
- TCollection_AsciiString aStr (aSO->GetID());
- aStr += " = smesh.CreateMeshesFromSTL(\"";
- aStr += Standard_CString(theFileName);
- aStr += "\")";
+ TCollection_AsciiString aStr (aSO->GetID());
+ aStr += " = smesh.CreateMeshesFromSTL(\"";
+ aStr += Standard_CString(theFileName);
+ aStr += "\")";
- AddToPythonScript(myCurrentStudy->StudyId(), aStr);
+ AddToCurrentPyScript(aStr);
+ }
}
SMESH_Mesh_i* aServant = dynamic_cast<SMESH_Mesh_i*>( GetServant( aMesh ).in() );
SMESH_Gen_i::AddObject(aStr, theMesh) += ", ";
SMESH_Gen_i::AddObject(aStr, theShapeObject) += ")";
- AddToPythonScript(myCurrentStudy->StudyId(), aStr);
+ AddToCurrentPyScript(aStr);
aStr = "if isDone == 0: print \"Mesh ";
SMESH_Gen_i::AddObject(aStr, theMesh) += " computation failed\"";
- AddToPythonScript(myCurrentStudy->StudyId(), aStr);
+ AddToCurrentPyScript(aStr);
try {
// get mesh servant
TCollection_AsciiString& SMESH_Gen_i::AddObject(TCollection_AsciiString& theStr,
CORBA::Object_ptr theObject)
{
- GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( theObject );
- if ( !geomObj->_is_nil() ) {
- theStr += "salome.IDToObject(\"";
- theStr += geomObj->GetStudyEntry();
- theStr += "\")";
- }
- else {
- SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
- SALOMEDS::SObject_var aSO =
- aSMESHGen->ObjectToSObject(aSMESHGen->GetCurrentStudy(), theObject);
- if ( !aSO->_is_nil() )
- theStr += aSO->GetID();
- else if ( !CORBA::is_nil( theObject ) )
- theStr += aSMESHGen->GetORB()->object_to_string( theObject );
- else
- theStr += "None";
- }
+ SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
+ SALOMEDS::SObject_var aSO =
+ aSMESHGen->ObjectToSObject(aSMESHGen->GetCurrentStudy(), theObject);
+ if ( !aSO->_is_nil() )
+ theStr += aSO->GetID();
+ else if ( !CORBA::is_nil( theObject ) )
+ theStr += GetORB()->object_to_string( theObject );
+ else
+ theStr += "None";
+
return theStr;
}
aScript += "import geompy\n\n";
aScript += "import SMESH\n";
aScript += "import StdMeshers\n\n";
+ aScript += "#import GEOM module\n";
+ aScript += "import string\n";
+ aScript += "import os\n";
+ aScript += "import sys\n";
+ aScript += "sys.path.append( os.path.dirname(__file__) )\n";
+ aScript += "exec(\"from \"+string.replace(__name__,\"SMESH\",\"GEOM\")+\" import *\")\n\n";
+
aScript += "def RebuildData(theStudy):";
aScript += "\n\tsmesh = salome.lcc.FindOrLoadComponent(\"FactoryServer\", \"SMESH\")";
- aScript += "\n\tsmesh.SetCurrentStudy(theStudy)";
+ if ( isPublished )
+ aScript += "\n\tsmesh.SetCurrentStudy(theStudy)";
+ else
+ aScript += "\n\tsmesh.SetCurrentStudy(None)";
+
+ Standard_Integer posToInertGlobalVars = aScript.Length();
+ TCollection_AsciiString globalVars;
// Dump trace of restored study
if (theSavedTrace.Length() > 0) {
return aScript;
// Replace entries by the names
+ GEOM::GEOM_Gen_ptr geom = GetGeomEngine();
TColStd_SequenceOfAsciiString seqRemoved;
Resource_DataMapOfAsciiStringAsciiString mapRemoved;
Resource_DataMapOfAsciiStringAsciiString aNames;
theObjectNames(anEntry) = aName;
}
} else {
+ // is a GEOM object?
+ aName = geom->GetDumpName( anEntry.ToCString() );
+ if ( aName.IsEmpty() ) {
// ? Removed Object ?
- do {
- aName = aBaseName + TCollection_AsciiString(++objectCounter);
- } while (theObjectNames.IsBound(aName));
+ do {
+ aName = aBaseName + TCollection_AsciiString(++objectCounter);
+ } while (theObjectNames.IsBound(aName));
+ seqRemoved.Append(aName);
+ mapRemoved.Bind(anEntry, "1");
+ }
theObjectNames.Bind(anEntry, aName);
- seqRemoved.Append(aName);
- mapRemoved.Bind(anEntry, "1");
}
theObjectNames.Bind(aName, anEntry); // to detect same name of diff objects