Salome HOME
Porting Salome to OCCT 7.7.0
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_STLImport.cpp
index 65881759deddc5c79c69d246471ed1ed39fa1f39..90a2c78f01a3f8fff9d600d996d9774e1ced9c48 100644 (file)
 //
 
 #include <GeomAlgoAPI_STLImport.h>
+
 #include "GeomAlgoAPI_Tools.h"
+
+#include <Basics_OCCTVersion.hxx>
+
+#include <TopoDS.hxx>
 #include <TopoDS_Shape.hxx>
-#include <StlAPI_Reader.hxx>
 #include <TopoDS_Shell.hxx>
-#include <TopoDS.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)
@@ -38,6 +43,15 @@ 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));