Salome HOME
Porting to OCCT7.5.0
[modules/smesh.git] / src / SMESH_I / SMESH_PythonDump.cxx
index e1c3002c0a583800cfd546adf15618eb0b3c12ba..3ecff618477b9bb3f43b2cc468048125bb85bbff 100644 (file)
 #include "SMESH_MeshEditor_i.hxx"
 
 #include <Basics_Utils.hxx>
+#include <Basics_OCCTVersion.hxx>
 #include <SALOMEDS_wrap.hxx>
 
 #include <LDOMParser.hxx>
-#include <Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString.hxx>
 #include <TColStd_HSequenceOfInteger.hxx>
 #include <TCollection_AsciiString.hxx>
 
+#if OCC_VERSION_LARGE < 0x07050000
+#include <Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString.hxx>
+#endif
+
 #include <cstring>
 
 #ifdef _DEBUG_
@@ -367,7 +371,7 @@ namespace SMESH
 
   TPythonDump&
   TPythonDump::
-  operator<<(SMESH::FilterManager_i* theArg)
+  operator<<(SMESH::FilterManager_i* /*theArg*/)
   {
     myStream<<"aFilterManager";
     return *this;
@@ -448,13 +452,13 @@ namespace SMESH
 
   TPythonDump&
   TPythonDump::
-  operator<<(SMESH::Measurements_i* theArg)
+  operator<<(SMESH::Measurements_i* /*theArg*/)
   {
     myStream<<"aMeasurements";
     return *this;
   }
 
-  TPythonDump& TPythonDump:: operator<<(SMESH_Gen_i* theArg)
+  TPythonDump& TPythonDump:: operator<<(SMESH_Gen_i* /*theArg*/)
   {
     myStream << SMESHGenName(); return *this;
   }
@@ -671,6 +675,8 @@ namespace SMESH
   {
 #ifdef _DEBUG_
     std::cout << "Exception in SMESH_Gen_i::DumpPython(): " << text << std::endl;
+#else
+    (void)text; // unused in release mode
 #endif
   }
 
@@ -1080,10 +1086,15 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl
   TCollection_AsciiString anUpdatedScript;
 
   Resource_DataMapOfAsciiStringAsciiString mapRemoved;
-  Resource_DataMapOfAsciiStringAsciiString mapEntries; // names and entries present in anUpdatedScript
+  Resource_DataMapOfAsciiStringAsciiString mapEntries; // { entry: name } present in anUpdatedScript
   Standard_Integer objectCounter = 0;
   TCollection_AsciiString anEntry, aName, aGUIName, aBaseName("smeshObj_");
 
+  std::string           compDataType = ComponentDataType(); // SMESH module's data type
+  SALOMEDS::SComponent_var   smeshSO = getStudyServant()->FindComponent( compDataType.c_str() );
+  CORBA::String_var          smeshID = smeshSO->GetID();
+  TCollection_AsciiString smeshEntry = smeshID.in();
+
   // Treat every script line and add it to anUpdatedScript
   for ( linesIt = lines.begin(); linesIt != lines.end(); ++linesIt )
   {
@@ -1135,15 +1146,22 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl
         }
         else
         {
-          // Removed Object
-          do {
-            aName = aBaseName + (++objectCounter);
-          } while (theObjectNames.IsBound(aName));
+          if ( !anEntry.StartsWith( smeshEntry )) // not SMESH object
+          {
+            aName = SMESH::TPythonDump::NotPublishedObjectName();
+          }
+          else
+          {
+            // Removed Object
+            do {
+              aName = aBaseName + (++objectCounter);
+            } while (theObjectNames.IsBound(aName));
 
-          if ( !aRemovedObjIDs.count( anEntry ) && aLine.Value(1) != '#')
-            mapRemoved.Bind(anEntry, aName);
+            if ( !aRemovedObjIDs.count( anEntry ) && aLine.Value(1) != '#')
+              mapRemoved.Bind(anEntry, aName);
 
-          theObjectNames.Bind(anEntry, aName);
+            theObjectNames.Bind(anEntry, aName);
+          }
         }
         theObjectNames.Bind(aName, anEntry); // to detect same name of diff objects
       }