Salome HOME
Fix for "[CEA]: Windows version: Dump Python: there is an error in the file name...
[modules/geom.git] / src / XAOPlugin / XAOPlugin_IOperations.cxx
index a6f094194cd7edbc01b88b41698a0043ce0f5a44..91c0c3e4f028b94e33212c7719a2a3327c1f6861 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2015  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2014-2019  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 #include "XAOPlugin_IImportExport.hxx"
 
 // KERNEL includes
+#include <Basics_DirUtils.hxx>
 #include <utilities.h>
 #include <Utils_SALOME_Exception.hxx>
 
 // GEOM includes
-#include "GEOM_PythonDump.hxx"
-#include "GEOMImpl_Types.hxx"
-#include "GEOMImpl_IGroupOperations.hxx"
-#include "GEOMImpl_IShapesOperations.hxx"
-#include "GEOMImpl_IFieldOperations.hxx"
-#include "GEOM_ISubShape.hxx"
+#include <GEOM_PythonDump.hxx>
+#include <GEOMImpl_Types.hxx>
+#include <GEOMImpl_IGroupOperations.hxx>
+#include <GEOMImpl_IShapesOperations.hxx>
+#include <GEOMImpl_IFieldOperations.hxx>
+#include <GEOM_ISubShape.hxx>
+#include <GEOM_Object.hxx>
+#include <GEOM_Field.hxx>
 
 #include <XAO_Geometry.hxx>
 #include <XAO_BrepGeometry.hxx>
@@ -97,8 +100,8 @@ TopAbs_ShapeEnum getGroupDimension(XAO::Group* group)
  *  Constructor
  */
 //=============================================================================
-XAOPlugin_IOperations::XAOPlugin_IOperations( GEOM_Engine* theEngine, int theDocID )
-: GEOMImpl_IBaseIEOperations( theEngine, theDocID )
+XAOPlugin_IOperations::XAOPlugin_IOperations( GEOM_Engine* theEngine )
+: GEOMImpl_IBaseIEOperations( theEngine )
 {
   MESSAGE( "XAOPlugin_IOperations::XAOPlugin_IOperations" );
 }
@@ -309,7 +312,8 @@ bool XAOPlugin_IOperations::ExportXAO( Handle(GEOM_Object) shape,
                                        std::list<Handle(GEOM_Object)> groupList,
                                        std::list<Handle(GEOM_Field)> fieldList,
                                        const char* author,
-                                       const char* fileName )
+                                       const char* fileName,
+                                       const char* shapeFileName )
 {
   SetErrorCode(KO);
 
@@ -320,7 +324,7 @@ bool XAOPlugin_IOperations::ExportXAO( Handle(GEOM_Object) shape,
   if (lastFunction.IsNull()) return false;
 
   // add a new result object
-  Handle(GEOM_Object) result = GetEngine()->AddObject(GetDocID(), GEOM_IMPORT);
+  Handle(GEOM_Object) result = GetEngine()->AddObject(GEOM_IMPORT);
 
   // add an Export function
   Handle(GEOM_Function) exportFunction = result->AddFunction(XAOPlugin_Driver::GetID(), EXPORT_SHAPE);
@@ -346,10 +350,11 @@ bool XAOPlugin_IOperations::ExportXAO( Handle(GEOM_Object) shape,
   exportFields(fieldList, xaoObject, geometry);
 
   // export the XAO to the file
-  xaoObject->exportXAO(fileName);
+  xaoObject->exportXAO(fileName, shapeFileName);
 
   // make a Python command
   GEOM::TPythonDump pd(exportFunction);
+  std::string convFileName = Kernel_Utils::BackSlashToSlash(fileName);
   pd << "exported = geompy.ExportXAO(" << shape;
 
   // list of groups
@@ -376,7 +381,7 @@ bool XAOPlugin_IOperations::ExportXAO( Handle(GEOM_Object) shape,
     }
   }
   pd << "], ";
-  pd << "\"" << author << "\", \"" << fileName << "\")";
+  pd << "\"" << author << "\", \"" << convFileName.c_str() << "\", \"" << shapeFileName << "\")";
 
   SetErrorCode(OK);
   delete xaoObject;
@@ -406,7 +411,7 @@ void XAOPlugin_IOperations::importSubShapes( XAO::Geometry* xaoGeometry,
     anArray = new TColStd_HArray1OfInteger(1, 1);
     anArray->SetValue(1, iref);
 
-    subShape = GetEngine()->AddObject(GetDocID(), GEOM_SUBSHAPE);
+    subShape = GetEngine()->AddObject(GEOM_SUBSHAPE);
     Handle(GEOM_Function) aFunction = subShape->AddFunction(GEOM_Object::GetSubShapeID(), 1);
     if (aFunction.IsNull())
       return;
@@ -470,7 +475,7 @@ bool XAOPlugin_IOperations::ImportXAO( const char* fileName,
   }
 
   // create the shape
-  shape = GetEngine()->AddObject(GetDocID(), GEOM_IMPORT);
+  shape = GetEngine()->AddObject(GEOM_IMPORT);
   Handle(GEOM_Function) function = shape->AddFunction(XAOPlugin_Driver::GetID(), IMPORT_SHAPE);
   if (function.IsNull()) return false;
   if (function->GetDriverGUID() != XAOPlugin_Driver::GetID()) return false;
@@ -524,8 +529,6 @@ bool XAOPlugin_IOperations::ImportXAO( const char* fileName,
     TDF_Label freeLabel = group->GetFreeLabel();
     TDataStd_Integer::Set(freeLabel, (Standard_Integer) getGroupDimension(xaoGroup));
     groups->Append(group);
-
-    function = group->GetLastFunction();
   }
 
   // create the fields
@@ -663,8 +666,9 @@ bool XAOPlugin_IOperations::ImportXAO( const char* fileName,
       pd << obj << ((i < nbFields) ? ", " : "");
     }
   }
+  std::string convFileName =  Kernel_Utils::BackSlashToSlash( fileName );
   pd << "]";
-  pd << ") = geompy.ImportXAO(\"" << fileName << "\")";
+  pd << ") = geompy.ImportXAO(\"" << convFileName.c_str() << "\")";
 
   delete xaoObject;
   SetErrorCode(OK);