1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: GeomAlgoAPI_PaveFiller.cpp
4 // Created: 27 August 2015
5 // Author: Dmitry Bobylev
7 #include "GeomAlgoAPI_PaveFiller.h"
9 #include <GeomAlgoAPI_DFLoader.h>
10 #include <GeomAlgoAPI_ShapeTools.h>
12 #include <BOPAlgo_Builder.hxx>
13 #include <BOPAlgo_PaveFiller.hxx>
14 #include <TopoDS_Builder.hxx>
15 #include <TopoDS_Iterator.hxx>
17 //=================================================================================================
18 GeomAlgoAPI_PaveFiller::GeomAlgoAPI_PaveFiller(const ListOfShape& theListOfShape, const bool theIsMakeCompSolids)
20 build(theListOfShape, theIsMakeCompSolids);
24 //=================================================================================================
25 void GeomAlgoAPI_PaveFiller::build(const ListOfShape& theListOfShape, const bool theIsMakeCompSolids)
27 BOPAlgo_PaveFiller aPaveFiller;
28 BOPCol_ListOfShape aListOfShape;
29 for(ListOfShape::const_iterator anIt = theListOfShape.cbegin(); anIt != theListOfShape.cend(); anIt++) {
30 const TopoDS_Shape& aShape = (*anIt)->impl<TopoDS_Shape>();
31 if(aShape.ShapeType() == TopAbs_COMPOUND) {
32 for(TopoDS_Iterator anIter(aShape); anIter.More(); anIter.Next()) {
33 aListOfShape.Append(anIter.Value());
36 aListOfShape.Append(aShape);
39 aPaveFiller.SetArguments(aListOfShape);
40 aPaveFiller.Perform();
41 Standard_Integer iErr = aPaveFiller.ErrorStatus();
46 BOPAlgo_Builder* aBuilder = new BOPAlgo_Builder();
47 this->setImpl(aBuilder);
48 this->setBuilderType(OCCT_BOPAlgo_Builder);
49 aBuilder->SetArguments(aListOfShape);
50 aBuilder->PerformWithFiller(aPaveFiller);
51 iErr = aBuilder->ErrorStatus();
56 TopoDS_Shape aResult = aBuilder->Shape();
57 if(aResult.ShapeType() == TopAbs_COMPOUND) {
58 aResult = GeomAlgoAPI_DFLoader::refineResult(aResult);
60 if(theIsMakeCompSolids && aResult.ShapeType() == TopAbs_COMPOUND) {
61 std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape);
62 aGeomShape->setImpl(new TopoDS_Shape(aResult));
63 ListOfShape aCompSolids, aFreeSolids;
64 aGeomShape = GeomAlgoAPI_ShapeTools::combineShapes(aGeomShape,
65 GeomAPI_Shape::COMPSOLID,
68 aResult = aGeomShape->impl<TopoDS_Shape>();
71 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
72 aShape->setImpl(new TopoDS_Shape(aResult));
73 this->setShape(aShape);