Salome HOME
[bos #33687] EDF 26791 - Points cloud on face
[modules/geom.git] / src / IGESPlugin / IGESPlugin_IOperations.cxx
index a6af6a7aa78bcaf620451f8cfb4a796f3c532b94..ce270659aeebd6991d88b300a36a1d1df6b1fb44 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2014-2022  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
@@ -25,6 +25,7 @@
 #include "IGESPlugin_IImport.hxx"
 
 // KERNEL includes
+#include <Basics_DirUtils.hxx>
 #include <utilities.h>
 
 // GEOM includes
@@ -38,8 +39,8 @@
  *  Constructor
  */
 //=============================================================================
-IGESPlugin_IOperations::IGESPlugin_IOperations( GEOM_Engine* theEngine, int theDocID )
-: GEOMImpl_IBaseIEOperations( theEngine, theDocID )
+IGESPlugin_IOperations::IGESPlugin_IOperations( GEOM_Engine* theEngine )
+: GEOMImpl_IBaseIEOperations( theEngine )
 {
   MESSAGE( "IGESPlugin_IOperations::IGESPlugin_IOperations" );
 }
@@ -77,7 +78,7 @@ void IGESPlugin_IOperations::ExportIGES( const Handle(GEOM_Object)      theOrigi
   if( aRefFunction.IsNull() ) return;  //There is no function which creates an object to be exported
 
   //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) aFunction = result->AddFunction( IGESPlugin_ExportDriver::GetID(), EXPORT_SHAPE );
@@ -94,23 +95,21 @@ void IGESPlugin_IOperations::ExportIGES( const Handle(GEOM_Object)      theOrigi
 
   //Perform the Export
   try {
-#if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
-#endif
     if( !GetSolver()->ComputeFunction( aFunction ) ) {
       SetErrorCode( "Not enough space on disk, or you haven't permissions to write this directory" );
       return;
     }
   }
-  catch( Standard_Failure ) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode( aFail->GetMessageString() );
+  catch( Standard_Failure& aFail ) {
+    SetErrorCode( aFail.GetMessageString() );
     return;
   }
 
   //Make a Python command
+  std::string convFileName = Kernel_Utils::BackSlashToSlash(theFileName.ToCString());
   GEOM::TPythonDump(aFunction) << "geompy.ExportIGES(" << theOriginal << ", \""
-    << theFileName.ToCString() << "\", \"" << theVersion.ToCString() << "\" )";
+    << convFileName.c_str() << "\", \"" << theVersion.ToCString() << "\" )";
 
   SetErrorCode(OK);
 }
@@ -131,7 +130,7 @@ IGESPlugin_IOperations::ImportIGES( const TCollection_AsciiString& theFileName,
   if( theFileName.IsEmpty() ) return NULL;
 
   //Add a new result object
-  Handle(GEOM_Object) anImported = GetEngine()->AddObject( GetDocID(), GEOM_IMPORT );
+  Handle(GEOM_Object) anImported = GetEngine()->AddObject( GEOM_IMPORT );
 
   //Add an Import function
   Handle(GEOM_Function) aFunction =
@@ -150,30 +149,28 @@ IGESPlugin_IOperations::ImportIGES( const TCollection_AsciiString& theFileName,
   Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
 
   try {
-#if OCC_VERSION_LARGE > 0x06010000
     OCC_CATCH_SIGNALS;
-#endif
     if( !GetSolver()->ComputeFunction( aFunction ) ) {
       SetErrorCode( "Import driver failed" );
       return NULL;
     }
     aSeq->Append(anImported);
 
-    // Greate material groups.
+    // Create material groups.
     // MakeMaterialGroups( anImported, aSeq );
   }
-  catch( Standard_Failure ) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode( aFail->GetMessageString() );
+  catch( Standard_Failure& aFail ) {
+    SetErrorCode( aFail.GetMessageString() );
     return NULL;
   }
 
   //Make a Python command
   GEOM::TPythonDump pd (aFunction);
+  std::string convFileName = Kernel_Utils::BackSlashToSlash(theFileName.ToCString());
   if( theIsIgnoreUnits )
-    pd << aSeq << " = geompy.ImportIGES(\"" << theFileName.ToCString() << "\", True)";
+    pd << aSeq << " = geompy.ImportIGES(\"" << convFileName.c_str() << "\", True)";
   else
-    pd << aSeq << " = geompy.ImportIGES(\"" << theFileName.ToCString() << "\")";
+    pd << aSeq << " = geompy.ImportIGES(\"" << convFileName.c_str() << "\")";
   SetErrorCode(OK);
 
   return aSeq;