Salome HOME
Copyright update 2022
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_IGESImport.cpp
index 8e20cb32aec65b37fb6cbe8b2551efb1605bdeaa..8f030b96a78d127c8c57f56f82d0d189a5d0cdef 100644 (file)
@@ -1,7 +1,26 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+// Copyright (C) 2014-2022  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
 
 #include <GeomAlgoAPI_IGESImport.h>
 
+#include <TopoDS_Shape.hxx>
+
 // OOCT includes
 #include <IGESControl_Reader.hxx>
 #include <IGESData_IGESModel.hxx>
  *
  */
 //=============================================================================
-//extern "C" {
-namespace IGESImport {
-TopoDS_Shape Import(const TCollection_AsciiString& theFileName,
-                    const TCollection_AsciiString&,
-                    TCollection_AsciiString& theError)
+std::shared_ptr<GeomAPI_Shape> IGESImport(const std::string& theFileName,
+                                          const std::string&,
+                                          std::string& theError)
 {
   #ifdef _DEBUG
   std::cout << "Import IGES from file " << theFileName << std::endl;
   #endif
-  TopoDS_Shape aResShape;
+  TopoDS_Shape aShape;
   IGESControl_Reader aReader;
   try {
-    IFSelect_ReturnStatus status = aReader.ReadFile( theFileName.ToCString() );
+    IFSelect_ReturnStatus status = aReader.ReadFile( theFileName.c_str() );
 
     if (status == IFSelect_RetDone) {
       #ifdef _DEBUG
@@ -35,7 +52,7 @@ TopoDS_Shape Import(const TCollection_AsciiString& theFileName,
       #ifdef _DEBUG
       std::cout << "ImportIGES : count of shapes produced = " << aReader.NbShapes() << std::endl;
       #endif
-      aResShape = aReader.OneShape();
+      aShape = aReader.OneShape();
     }
     else {
       switch (status) {
@@ -55,17 +72,15 @@ TopoDS_Shape Import(const TCollection_AsciiString& theFileName,
           theError = "Wrong format of the imported file. Can't import file.";
           break;
       }
-      aResShape.Nullify();
+      aShape.Nullify();
     }
   }
-  catch( Standard_Failure ) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    theError = aFail->GetMessageString();
-    aResShape.Nullify();
+  catch( Standard_Failure const& anException) {
+    theError = anException.GetMessageString();
+    aShape.Nullify();
   }
 
-  return aResShape;
-}
-
+  std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape);
+  aGeomShape->setImpl(new TopoDS_Shape(aShape));
+  return aGeomShape;
 }
-//}