Salome HOME
0020799: [CEA] Smesh script fails
[modules/smesh.git] / src / SMESH_I / SMESH_DumpPython.cxx
index 5b012b59cfc4cf48b5500a28f2a5c52c416e0431..629a7d8f1cc13d883d4c1f2318109074939006e4 100644 (file)
@@ -208,6 +208,32 @@ namespace SMESH
     return *this;
   }
 
+  TPythonDump& 
+  TPythonDump::
+  operator<<(SMESH::SMESH_Hypothesis_ptr theArg)
+  {
+    SALOMEDS::Study_var aStudy = SMESH_Gen_i::GetSMESHGen()->GetCurrentStudy();
+    SALOMEDS::SObject_var aSObject = SMESH_Gen_i::ObjectToSObject(aStudy,theArg);
+    if(aSObject->_is_nil() && !CORBA::is_nil(theArg))
+      myStream << "hyp_" << theArg->GetId();
+    else
+      *this << CORBA::Object_ptr( theArg );
+    return *this;
+  }
+
+  TPythonDump& 
+  TPythonDump::
+  operator<<(SMESH::SMESH_IDSource_ptr theArg)
+  {
+    SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
+    SALOMEDS::Study_var aStudy = aSMESHGen->GetCurrentStudy();
+    SALOMEDS::SObject_var aSObject = SMESH_Gen_i::ObjectToSObject(aStudy,theArg);
+    if(!aSObject->_is_nil() || CORBA::is_nil( theArg ))
+      return *this << aSObject;
+    SMESH::long_array_var anElementsId = theArg->GetIDs();
+    return *this << anElementsId;
+  }
+
   TPythonDump& 
   TPythonDump::
   operator<<(SMESH::FilterLibrary_i* theArg)
@@ -484,9 +510,7 @@ Engines::TMPFile* SMESH_Gen_i::DumpPython (CORBA::Object_ptr theStudy,
   TCollection_AsciiString aSavedTrace (oldValue);
 
   // Add trace of API methods calls and replace study entries by names
-  TCollection_AsciiString aScript =
-   "# -*- coding: iso-8859-1 -*-\n"
-    "### This file is generated by SALOME automatically by dump python functionality of SMESH component\n\n";
+  TCollection_AsciiString aScript;
   aScript += DumpPython_impl(aStudy, aMap, aMapNames,
                              isPublished, isValidScript, aSavedTrace);