1 // Copyright (C) 2014-2022 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "GeomAlgoAPI_Utils.h"
22 #include <BRepCheck_Analyzer.hxx>
23 #include <ShapeFix_Shape.hxx>
24 #include <ShapeFix_ShapeTolerance.hxx>
28 //==================================================================================================
29 bool GeomAlgoAPI_Utils::FixShapeTolerance(TopoDS_Shape& theShape,
30 TopAbs_ShapeEnum theType,
31 const double theTolerance,
32 const bool theCheckGeometry)
34 ShapeFix_ShapeTolerance aSft;
35 aSft.LimitTolerance(theShape, theTolerance, theTolerance, theType);
36 Handle(ShapeFix_Shape) aSfs = new ShapeFix_Shape(theShape);
38 theShape = aSfs->Shape();
39 return CheckShape(theShape, theCheckGeometry);
42 //==================================================================================================
43 bool GeomAlgoAPI_Utils::FixShapeTolerance(TopoDS_Shape& theShape,
44 const double theTolerance,
45 const bool theCheckGeometry)
47 return FixShapeTolerance(theShape, TopAbs_SHAPE, theTolerance, theCheckGeometry);
50 //==================================================================================================
51 bool GeomAlgoAPI_Utils::FixShapeTolerance(TopoDS_Shape& theShape,
52 const bool theCheckGeometry)
54 return FixShapeTolerance(theShape, Precision::Confusion(), theCheckGeometry);
57 //==================================================================================================
58 bool GeomAlgoAPI_Utils::CheckShape(TopoDS_Shape& theShape,
59 const bool theCheckGeometry)
61 BRepCheck_Analyzer analyzer(theShape, theCheckGeometry);
62 return analyzer.IsValid();