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_PaveFiller.h"
22 #include <GeomAlgoAPI_DFLoader.h>
23 #include <GeomAlgoAPI_ShapeTools.h>
25 #include <BOPAlgo_Builder.hxx>
26 #include <BOPAlgo_PaveFiller.hxx>
27 #include <TopoDS_Builder.hxx>
28 #include <TopoDS_Iterator.hxx>
31 //=================================================================================================
32 GeomAlgoAPI_PaveFiller::GeomAlgoAPI_PaveFiller(const ListOfShape& theListOfShape,
33 const bool theIsMakeCompSolids,
34 const double theFuzzy)
36 build(theListOfShape, theIsMakeCompSolids, theFuzzy);
40 //=================================================================================================
41 void GeomAlgoAPI_PaveFiller::build(const ListOfShape& theListOfShape,
42 const bool theIsMakeCompSolids,
43 const double theFuzzy)
45 BOPAlgo_PaveFiller* aPaveFiller = new BOPAlgo_PaveFiller;
46 TopTools_ListOfShape aListOfShape;
47 for(ListOfShape::const_iterator
48 anIt = theListOfShape.cbegin(); anIt != theListOfShape.cend(); anIt++) {
49 const TopoDS_Shape& aShape = (*anIt)->impl<TopoDS_Shape>();
50 if(aShape.ShapeType() == TopAbs_COMPOUND) {
51 for(TopoDS_Iterator anIter(aShape); anIter.More(); anIter.Next()) {
52 aListOfShape.Append(anIter.Value());
55 aListOfShape.Append(aShape);
58 aPaveFiller->SetArguments(aListOfShape);
59 if (theFuzzy > 0) aPaveFiller->SetFuzzyValue(theFuzzy);
60 aPaveFiller->Perform();
61 if (aPaveFiller->HasErrors())
64 BOPAlgo_Builder* aBuilder = new BOPAlgo_Builder();
65 this->setImpl(aBuilder);
66 this->setBuilderType(OCCT_BOPAlgo_Builder);
67 aBuilder->SetArguments(aListOfShape);
68 if (theFuzzy > 0) aBuilder->SetFuzzyValue(theFuzzy);
69 aBuilder->PerformWithFiller(*aPaveFiller);
70 if (aBuilder->HasErrors())
73 TopoDS_Shape aResult = aBuilder->Shape();
74 if(aResult.ShapeType() == TopAbs_COMPOUND) {
75 aResult = GeomAlgoAPI_DFLoader::refineResult(aResult);
77 if(theIsMakeCompSolids && aResult.ShapeType() == TopAbs_COMPOUND) {
78 std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape);
79 aGeomShape->setImpl(new TopoDS_Shape(aResult));
81 aGeomShape = GeomAlgoAPI_ShapeTools::combineShapes(aGeomShape,
82 GeomAPI_Shape::COMPSOLID,
84 aResult = aGeomShape->impl<TopoDS_Shape>();
87 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
88 aShape->setImpl(new TopoDS_Shape(aResult));
89 this->setShape(aShape);