Salome HOME
Merge master branch into V9_dev.
[modules/geom.git] / src / GEOMImpl / GEOMImpl_ChamferDriver.cxx
index 9afdb9adb2ac733b478aa976d67aab21677b5dbc..cf7bd0cc67eef62492d6cbee18aed18fdcc8a2af 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016  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
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
-#include <Standard_Stream.hxx>
-
 #include <GEOMImpl_ChamferDriver.hxx>
 #include <GEOMImpl_IChamfer.hxx>
 #include <GEOMImpl_Types.hxx>
 #include <GEOMImpl_ILocalOperations.hxx>
 #include <GEOMImpl_Block6Explorer.hxx>
-
+#include <GEOMUtils.hxx>
 #include <GEOM_Function.hxx>
 
 #include <BRepLib.hxx>
 #include <BRepTools.hxx>
 #include <BRepFilletAPI_MakeChamfer.hxx>
 
-#include <ShapeFix_Shape.hxx>
-#include <ShapeFix_ShapeTolerance.hxx>
-
 #include <TopAbs.hxx>
 #include <TopoDS.hxx>
 #include <TopoDS_Edge.hxx>
 #include <TopoDS_Face.hxx>
 #include <TopoDS_Shape.hxx>
 #include <TopoDS_Iterator.hxx>
-#include <TopExp.hxx>
 #include <TopExp_Explorer.hxx>
 #include <TopTools_MapOfShape.hxx>
 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
 
-#include <Precision.hxx>
-#include <gp_Pnt.hxx>
 #include <StdFail_NotDone.hxx>
 
 //=======================================================================
@@ -63,7 +55,6 @@ const Standard_GUID& GEOMImpl_ChamferDriver::GetID()
   return aChamferDriver;
 }
 
-
 //=======================================================================
 //function : GEOMImpl_ChamferDriver
 //purpose  :
@@ -104,7 +95,7 @@ static Standard_Boolean isGoodForChamfer (const TopoDS_Shape& theShape)
 //function : Execute
 //purpose  :
 //=======================================================================
-Standard_Integer GEOMImpl_ChamferDriver::Execute(TFunction_Logbook& log) const
+Standard_Integer GEOMImpl_ChamferDriver::Execute(Handle(TFunction_Logbook)& log) const
 {
   if (Label().IsNull()) return 0;
   Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
@@ -226,7 +217,7 @@ Standard_Integer GEOMImpl_ChamferDriver::Execute(TFunction_Logbook& log) const
   }
   else if (aType == CHAMFER_SHAPE_EDGES || aType == CHAMFER_SHAPE_EDGES_AD)
   {
-    // chamfer on selected edges with lenght param D1 & D2.
+    // chamfer on selected edges with length param D1 & D2.
 
     int aLen = aCI.GetLength();
     int ind = 1;
@@ -264,24 +255,19 @@ Standard_Integer GEOMImpl_ChamferDriver::Execute(TFunction_Logbook& log) const
   if (!fill.IsDone()) {
     StdFail_NotDone::Raise("Chamfer can not be computed on the given shape with the given parameters");
   }
-  aShape = fill.Shape();
+  aShape = GEOMUtils::ReduceCompound( fill.Shape() );
 
   if (aShape.IsNull()) return 0;
 
   // reduce tolerances
-  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();
+  GEOMUtils::FixShapeTolerance( aShape );
 
   // fix SameParameter flag
   BRepLib::SameParameter(aShape, 1.E-5, Standard_True);
 
   aFunction->SetValue(aShape);
 
-  log.SetTouched(Label());
+  log->SetTouched(Label());
 
   return 1;
 }
@@ -371,6 +357,4 @@ GetCreationInformation(std::string&             theOperationName,
   return true;
 }
 
-IMPLEMENT_STANDARD_HANDLE (GEOMImpl_ChamferDriver,GEOM_BaseDriver);
-
 IMPLEMENT_STANDARD_RTTIEXT (GEOMImpl_ChamferDriver,GEOM_BaseDriver);