]> SALOME platform Git repositories - modules/smesh.git/blobdiff - src/SMESH/SMESH_DriverShape.cxx
Salome HOME
fixed bos#37786: SMESH_MGAdaptTests_without_session random failures
[modules/smesh.git] / src / SMESH / SMESH_DriverShape.cxx
index d8cf96473d9650a9e44223beee848968fe1499f5..d0ebc096df5cf1b00fc17f31b83670283534fe68 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2021  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2023  CEA, EDF, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -24,8 +24,8 @@
 //  Author : Yoann AUDOUIN, EDF
 //  Module : SMESH
 //
-
 #include <utilities.h>
+#include <Utils_SALOME_Exception.hxx>
 #include "SMESH_DriverShape.hxx"
 
 // step include
 //Occ include
 #include <TopoDS.hxx>
 
+#ifndef WIN32
 #include <boost/filesystem.hpp>
 #include <boost/algorithm/string.hpp>
 namespace fs = boost::filesystem;
+#endif
 
 /**
  * @brief Import the content of a shape file (STEP) into a TopDS_Shape object
@@ -62,8 +64,7 @@ int importSTEPShape(const std::string shape_file, TopoDS_Shape& aShape){
   Interface_Static::SetIVal("read.step.nonmanifold", 1);
   IFSelect_ReturnStatus aStat = reader.ReadFile(shape_file.c_str());
   if(aStat != IFSelect_RetDone){
-    std::cerr << "Reading error for "  << shape_file << std::endl;
-    return true;
+    throw SALOME_Exception("Reading error for " + shape_file);
   }
 
   int NbTrans = reader.TransferRoots();
@@ -94,15 +95,13 @@ int exportSTEPShape(const std::string shape_file, const TopoDS_Shape& aShape){
 
   IFSelect_ReturnStatus aStat = aWriter.Transfer(aShape,STEPControl_AsIs);
   if(aStat != IFSelect_RetDone){
-    std::cerr << "Transfer error for "  << shape_file << std::endl;
-    return true;
+    throw SALOME_Exception("Reading error for " + shape_file);
   }
 
   aStat = aWriter.Write(shape_file.c_str());
 
   if(aStat != IFSelect_RetDone){
-    std::cerr << "Writing error for "  << shape_file << std::endl;
-    return true;
+    throw SALOME_Exception("Writing error for " + shape_file);
   }
   return aStat;
 }
@@ -148,7 +147,8 @@ int exportBREPShape(const std::string shape_file, const TopoDS_Shape& aShape){
  *
  * @return error code
  */
-int importShape(const std::string shape_file, TopoDS_Shape& aShape){
+int SMESH_DriverShape::importShape(const std::string shape_file, TopoDS_Shape& aShape){
+#ifndef WIN32
   std::string type = fs::path(shape_file).extension().string();
   boost::algorithm::to_lower(type);
   if (type == ".brep"){
@@ -156,9 +156,11 @@ int importShape(const std::string shape_file, TopoDS_Shape& aShape){
   } else if (type == ".step"){
     return importSTEPShape(shape_file, aShape);
   } else {
-    std::cerr << "Unknow format: " << type << std::endl;
-    return true;
+    throw SALOME_Exception("Unknow format for importShape: " + type);
   }
+#else
+  return 0;
+#endif
 }
 
 /**
@@ -169,7 +171,8 @@ int importShape(const std::string shape_file, TopoDS_Shape& aShape){
  *
  * @return error code
  */
-int exportShape(const std::string shape_file, const TopoDS_Shape& aShape){
+int SMESH_DriverShape::exportShape(const std::string shape_file, const TopoDS_Shape& aShape){
+#ifndef WIN32
   std::string type = fs::path(shape_file).extension().string();
   boost::algorithm::to_lower(type);
   if (type == ".brep"){
@@ -177,7 +180,9 @@ int exportShape(const std::string shape_file, const TopoDS_Shape& aShape){
   } else if (type == ".step"){
     return exportSTEPShape(shape_file, aShape);
   } else {
-    std::cerr << "Unknow format: " << type << std::endl;
-    return true;
+    throw SALOME_Exception("Unknow format for exportShape: " + type);
   }
+#else
+  return 0;
+#endif
 }