1 // Copyright (C) 2014-2017 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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #include "GeomAlgoAPI_PaveFiller.h"
23 #include <GeomAlgoAPI_DFLoader.h>
24 #include <GeomAlgoAPI_ShapeTools.h>
26 #include <BOPAlgo_Builder.hxx>
27 #include <BOPAlgo_PaveFiller.hxx>
28 #include <TopoDS_Builder.hxx>
29 #include <TopoDS_Iterator.hxx>
31 //=================================================================================================
32 GeomAlgoAPI_PaveFiller::GeomAlgoAPI_PaveFiller(const ListOfShape& theListOfShape,
33 const bool theIsMakeCompSolids)
35 build(theListOfShape, theIsMakeCompSolids);
39 //=================================================================================================
40 void GeomAlgoAPI_PaveFiller::build(const ListOfShape& theListOfShape,
41 const bool theIsMakeCompSolids)
43 BOPAlgo_PaveFiller aPaveFiller;
44 BOPCol_ListOfShape aListOfShape;
45 for(ListOfShape::const_iterator
46 anIt = theListOfShape.cbegin(); anIt != theListOfShape.cend(); anIt++) {
47 const TopoDS_Shape& aShape = (*anIt)->impl<TopoDS_Shape>();
48 if(aShape.ShapeType() == TopAbs_COMPOUND) {
49 for(TopoDS_Iterator anIter(aShape); anIter.More(); anIter.Next()) {
50 aListOfShape.Append(anIter.Value());
53 aListOfShape.Append(aShape);
56 aPaveFiller.SetArguments(aListOfShape);
57 aPaveFiller.Perform();
59 if (aPaveFiller.HasErrors())
62 Standard_Integer iErr = aPaveFiller.ErrorStatus();
68 BOPAlgo_Builder* aBuilder = new BOPAlgo_Builder();
69 this->setImpl(aBuilder);
70 this->setBuilderType(OCCT_BOPAlgo_Builder);
71 aBuilder->SetArguments(aListOfShape);
72 aBuilder->PerformWithFiller(aPaveFiller);
74 if (aBuilder->HasErrors())
77 iErr = aBuilder->ErrorStatus();
83 TopoDS_Shape aResult = aBuilder->Shape();
84 if(aResult.ShapeType() == TopAbs_COMPOUND) {
85 aResult = GeomAlgoAPI_DFLoader::refineResult(aResult);
87 if(theIsMakeCompSolids && aResult.ShapeType() == TopAbs_COMPOUND) {
88 std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape);
89 aGeomShape->setImpl(new TopoDS_Shape(aResult));
90 ListOfShape aCompSolids, aFreeSolids;
91 aGeomShape = GeomAlgoAPI_ShapeTools::combineShapes(aGeomShape,
92 GeomAPI_Shape::COMPSOLID,
95 aResult = aGeomShape->impl<TopoDS_Shape>();
98 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
99 aShape->setImpl(new TopoDS_Shape(aResult));
100 this->setShape(aShape);