]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/GeomAlgoAPI/GeomAlgoAPI_STLImport.cpp
Salome HOME
updated copyright message
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_STLImport.cpp
index 1c0c6ce4cba90589f71c1877ae731b781218f625..dde034d0c4df38bf203885ebef7b8ed806fe61ef 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2020  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2023  CEA, EDF
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 //
 
 #include <GeomAlgoAPI_STLImport.h>
+
 #include "GeomAlgoAPI_Tools.h"
+
+#include <Basics_OCCTVersion.hxx>
+
+#include <TopoDS.hxx>
 #include <TopoDS_Shape.hxx>
+#include <TopoDS_Shell.hxx>
+#include <BRepBuilderAPI_MakeSolid.hxx>
+#include <BRepBuilderAPI_Sewing.hxx>
 #include <StlAPI_Reader.hxx>
 
-
 std::shared_ptr<GeomAPI_Shape> STLImport(const std::string& theFileName,
                                          std::string& theError)
 {
@@ -36,6 +43,22 @@ std::shared_ptr<GeomAPI_Shape> STLImport(const std::string& theFileName,
       theError = "Can't import file.";
       aResShape.Nullify();
     }
+#if OCC_VERSION_LARGE >= 0x07070000
+    BRepBuilderAPI_Sewing aSewingTool;
+    aSewingTool.Init(1.0e-06, Standard_True);
+    aSewingTool.Load(aResShape);
+    aSewingTool.Perform();
+    TopoDS_Shape aSewedShape = aSewingTool.SewedShape();
+    if (!aSewedShape.IsNull())
+      aResShape = aSewedShape;
+#endif
+    if(aResShape.ShapeType() == TopAbs_SHELL)
+    {
+      BRepBuilderAPI_MakeSolid soliMaker(TopoDS::Shell(aResShape));
+      soliMaker.Build();
+      if(soliMaker.IsDone())
+        aResShape = soliMaker.Shape();
+    }
   }
   catch (Standard_Failure const& anException) {
     theError = anException.GetMessageString();