Salome HOME
0023445: EDF 14284 - Problem with Dump Python
[modules/geom.git] / src / GEOM / GEOM_Engine.cxx
index 41be7c204759355bfbe06639a660505cd3ecd30d..f7ae8fc8e82a29a7217fa2d1dbebecc175e989ee 100644 (file)
@@ -1,4 +1,4 @@
-// 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
 #include <TColStd_MapOfTransient.hxx>
 #include <TColStd_HSequenceOfInteger.hxx>
 
-#include <TColStd_HArray1OfByte.hxx>
 #include <TColStd_DataMapIteratorOfDataMapOfIntegerTransient.hxx>
 
 #include <Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString.hxx>
 
+#if OCC_VERSION_LARGE > 0x07000000
+#include <BinDrivers.hxx>
+#include <StdDrivers_DocumentRetrievalDriver.hxx>
+#include <PCDM_StorageDriver.hxx>
+#endif
+
 #include <set>
 
 #include <Standard_Failure.hxx>
@@ -226,6 +231,11 @@ GEOM_Engine::GEOM_Engine()
   TFunction_DriverTable::Get()->AddDriver(GEOM_Object::GetSubShapeID(), new GEOM_SubShapeDriver());
   
   _OCAFApp = new GEOM_Application();
+#if OCC_VERSION_LARGE > 0x07000000
+  _OCAFApp->DefineFormat("SALOME_GEOM", "GEOM Document Version 1.0", "sgd",
+                         new StdDrivers_DocumentRetrievalDriver, 0);
+  BinDrivers::DefineFormat(_OCAFApp);
+#endif
   _UndoLimit = 0;
 }
 
@@ -265,7 +275,11 @@ Handle(TDocStd_Document) GEOM_Engine::GetDocument(int theDocID, bool force)
     aDoc = Handle(TDocStd_Document)::DownCast(_mapIDDocument(theDocID));
   }
   else if (force) {
+#if OCC_VERSION_MAJOR > 6
+    _OCAFApp->NewDocument("BinOcaf", aDoc);
+#else
     _OCAFApp->NewDocument("SALOME_GEOM", aDoc);
+#endif
     aDoc->SetUndoLimit(_UndoLimit);
     _mapIDDocument.Bind(theDocID, aDoc);
     TDataStd_Integer::Set(aDoc->Main(), theDocID);
@@ -564,6 +578,13 @@ bool GEOM_Engine::Load(int theDocID, const char* theFileName)
     return false;
   }
 
+#if OCC_VERSION_MAJOR > 6
+  // Replace old document format by the new one.
+  if (aDoc->StorageFormat().IsEqual("SALOME_GEOM")) {
+    aDoc->ChangeStorageFormat("BinOcaf");
+  }
+#endif
+
   aDoc->SetUndoLimit(_UndoLimit);
 
   if(_mapIDDocument.IsBound(theDocID)) _mapIDDocument.UnBind(theDocID);
@@ -1832,7 +1853,7 @@ void PublishObject (TObjectData&                              theObjectData,
 
     // store aCreationCommand before publishing commands
     int tag = GetTag(theObjectData._entry);
-    theEntryToCmdMap.insert( std::make_pair( tag + 2*theEntry2ObjData.size(), aCreationCommand ));
+    theEntryToCmdMap.insert( std::make_pair( tag + -2*theEntry2ObjData.size(), aCreationCommand ));
   }
 
   // make a command
@@ -1878,7 +1899,7 @@ TCollection_AsciiString GetPublishCommands
       if (aRefIt != theMapRefs.end()) {
         // Recursively publish all references.
         std::list< int >::const_iterator aRefTagIt = aRefIt->second.begin();
-  
+
         for(; aRefTagIt != aRefIt->second.end(); ++aRefTagIt) {
           const TCollection_AsciiString aRefCmd = GetPublishCommands
             (*aRefTagIt, theEntryToCmdMap, theMapRefs, thePublished);