1 // Copyright (C) 2014-2019 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>
30 //=================================================================================================
31 GeomAlgoAPI_PaveFiller::GeomAlgoAPI_PaveFiller(const ListOfShape& theListOfShape,
32 const bool theIsMakeCompSolids)
34 build(theListOfShape, theIsMakeCompSolids);
38 //=================================================================================================
39 void GeomAlgoAPI_PaveFiller::build(const ListOfShape& theListOfShape,
40 const bool theIsMakeCompSolids)
42 BOPAlgo_PaveFiller* aPaveFiller = new BOPAlgo_PaveFiller;
43 TopTools_ListOfShape aListOfShape;
44 for(ListOfShape::const_iterator
45 anIt = theListOfShape.cbegin(); anIt != theListOfShape.cend(); anIt++) {
46 const TopoDS_Shape& aShape = (*anIt)->impl<TopoDS_Shape>();
47 if(aShape.ShapeType() == TopAbs_COMPOUND) {
48 for(TopoDS_Iterator anIter(aShape); anIter.More(); anIter.Next()) {
49 aListOfShape.Append(anIter.Value());
52 aListOfShape.Append(aShape);
55 aPaveFiller->SetArguments(aListOfShape);
56 aPaveFiller->Perform();
57 if (aPaveFiller->HasErrors())
60 BOPAlgo_Builder* aBuilder = new BOPAlgo_Builder();
61 this->setImpl(aBuilder);
62 this->setBuilderType(OCCT_BOPAlgo_Builder);
63 aBuilder->SetArguments(aListOfShape);
64 aBuilder->PerformWithFiller(*aPaveFiller);
65 if (aBuilder->HasErrors())
68 TopoDS_Shape aResult = aBuilder->Shape();
69 if(aResult.ShapeType() == TopAbs_COMPOUND) {
70 aResult = GeomAlgoAPI_DFLoader::refineResult(aResult);
72 if(theIsMakeCompSolids && aResult.ShapeType() == TopAbs_COMPOUND) {
73 std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape);
74 aGeomShape->setImpl(new TopoDS_Shape(aResult));
76 aGeomShape = GeomAlgoAPI_ShapeTools::combineShapes(aGeomShape,
77 GeomAPI_Shape::COMPSOLID,
79 aResult = aGeomShape->impl<TopoDS_Shape>();
82 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
83 aShape->setImpl(new TopoDS_Shape(aResult));
84 this->setShape(aShape);