]> SALOME platform Git repositories - modules/geom.git/blobdiff - src/GEOM/GEOM_Engine.cxx
Salome HOME
0021672: [CEA 565] Dump Study from script
[modules/geom.git] / src / GEOM / GEOM_Engine.cxx
index 53addff1f700071f7a4d62aa30f8d15990f3b169..cc284959899b3c6d8c5b285dbfd65abf269ba376 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012  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
@@ -18,6 +18,7 @@
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
 
 #ifdef WNT
 #pragma warning( disable:4786 )
@@ -218,7 +219,7 @@ void GEOM_Engine::SetEngine(GEOM_Engine* theEngine) { TheEngine = theEngine; }
 GEOM_Engine::GEOM_Engine()
 {
   TFunction_DriverTable::Get()->AddDriver(GEOM_Object::GetSubShapeID(), new GEOM_SubShapeDriver());
-
+  
   _OCAFApp = new GEOM_Application();
   _UndoLimit = 10;
 }
@@ -413,7 +414,7 @@ Handle(GEOM_Object) GEOM_Engine::AddSubShape(Handle(GEOM_Object) theMainShape,
   if (_objects.IsBound(anID)) _objects.UnBind(anID);
   _objects.Bind(anID, anObject);
 
-  // Put this subshape in the list of subshapes of theMainShape
+  // Put this sub-shape in the list of sub-shapes of theMainShape
   aMainShape->AddSubShapeReference(aFunction);
 
   GEOM::TPythonDump pd (aFunction);
@@ -449,7 +450,7 @@ bool GEOM_Engine::RemoveObject(Handle(GEOM_Object) theObject)
   TCollection_AsciiString anID = BuildIDFromObject(theObject);
   if (_objects.IsBound(anID)) _objects.UnBind(anID);
 
-  // If subshape, remove it from the list of subshapes of its main shape
+  // If sub-shape, remove it from the list of sub-shapes of its main shape
   if (!theObject->IsMainShape()) {
     Handle(GEOM_Function) aFunction = theObject->GetFunction(1);
     GEOM_ISubShape aSSI (aFunction);
@@ -670,7 +671,15 @@ TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID,
         continue;
       // add function description before dump
       if (!aCurScript.IsEmpty())
+      {
+        if ( aFunction->GetDriverGUID() == GEOM_Object::GetSubShapeID() )
+          // avoid repeated SubShape...() command at the end
+          if (aFuncScript.Location( aCurScript,
+                                    aFuncScript.Length() - aCurScript.Length(),
+                                    aFuncScript.Length()))
+              continue;
         aFuncScript += aCurScript;
+      }
       if (isDumpCollected ) {
         // Replace entries by the names
         ReplaceEntriesByNames( aFuncScript, aEntry2ObjData, isPublished,