Salome HOME
Fix memory leaks
[modules/geom.git] / src / GEOMImpl / GEOMImpl_OffsetDriver.cxx
index 393c8a1336c7da0ebcbe74ec026a1cc40c2b9135..818ce4eceb562b29641552d5cc56d01e764c0b57 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -6,7 +6,7 @@
 // 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.
+// 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
 #include <GEOMImpl_IOffset.hxx>
 #include <GEOMImpl_Types.hxx>
 #include <GEOM_Function.hxx>
+#include <GEOMUtils.hxx>
 
 #include <BRepOffsetAPI_MakeOffsetShape.hxx>
-#include <BRep_Tool.hxx>
-#include <TopoDS.hxx>
 #include <TopoDS_Shape.hxx>
-#include <TopoDS_Vertex.hxx>
 #include <TopAbs.hxx>
-#include <TopExp.hxx>
-
 #include <BRepClass3d_SolidClassifier.hxx>
-
 #include <Precision.hxx>
-#include <gp_Pnt.hxx>
-
-#include <BRepCheck_Analyzer.hxx>
-#include <ShapeFix_ShapeTolerance.hxx>
-#include <ShapeFix_Shape.hxx>
-
 #include <Standard_ConstructionError.hxx>
 #include <StdFail_NotDone.hxx>
 
-#include "utilities.h"
-
 //=======================================================================
 //function : GetID
 //purpose  :
@@ -59,7 +46,6 @@ const Standard_GUID& GEOMImpl_OffsetDriver::GetID()
   return aOffsetDriver;
 }
 
-
 //=======================================================================
 //function : GEOMImpl_OffsetDriver
 //purpose  :
@@ -100,20 +86,8 @@ Standard_Integer GEOMImpl_OffsetDriver::Execute(TFunction_Logbook& log) const
                                       aTol);
     if (MO.IsDone()) {
       aShape = MO.Shape();
-      // 23.04.2010 skl for bug 21699 from Mantis
-      BRepCheck_Analyzer ana (aShape, Standard_True);
-      ana.Init(aShape);
-      if (!ana.IsValid()) {
-        ShapeFix_ShapeTolerance aSFT;
-        aSFT.LimitTolerance(aShape, Precision::Confusion(),
-                            Precision::Confusion(), TopAbs_SHAPE);
-        Handle(ShapeFix_Shape) aSfs = new ShapeFix_Shape(aShape);
-        aSfs->Perform();
-        aShape = aSfs->Shape();
-        ana.Init(aShape);
-        if (!ana.IsValid())
-          Standard_ConstructionError::Raise("Boolean operation aborted : non valid shape result");
-      }
+      if ( !GEOMUtils::CheckShape(aShape, true) && !GEOMUtils::FixShapeTolerance(aShape) )
+        Standard_ConstructionError::Raise("Boolean operation aborted : non valid shape result");
     }
     else {
       StdFail_NotDone::Raise("Offset construction failed");