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,
19 const bool theIsMakeCompSolids)
21 build(theListOfShape, theIsMakeCompSolids);
25 //=================================================================================================
26 void GeomAlgoAPI_PaveFiller::build(const ListOfShape& theListOfShape,
27 const bool theIsMakeCompSolids)
29 BOPAlgo_PaveFiller aPaveFiller;
30 BOPCol_ListOfShape aListOfShape;
31 for(ListOfShape::const_iterator
32 anIt = theListOfShape.cbegin(); anIt != theListOfShape.cend(); anIt++) {
33 const TopoDS_Shape& aShape = (*anIt)->impl<TopoDS_Shape>();
34 if(aShape.ShapeType() == TopAbs_COMPOUND) {
35 for(TopoDS_Iterator anIter(aShape); anIter.More(); anIter.Next()) {
36 aListOfShape.Append(anIter.Value());
39 aListOfShape.Append(aShape);
42 aPaveFiller.SetArguments(aListOfShape);
43 aPaveFiller.Perform();
44 Standard_Integer iErr = aPaveFiller.ErrorStatus();
49 BOPAlgo_Builder* aBuilder = new BOPAlgo_Builder();
50 this->setImpl(aBuilder);
51 this->setBuilderType(OCCT_BOPAlgo_Builder);
52 aBuilder->SetArguments(aListOfShape);
53 aBuilder->PerformWithFiller(aPaveFiller);
54 iErr = aBuilder->ErrorStatus();
59 TopoDS_Shape aResult = aBuilder->Shape();
60 if(aResult.ShapeType() == TopAbs_COMPOUND) {
61 aResult = GeomAlgoAPI_DFLoader::refineResult(aResult);
63 if(theIsMakeCompSolids && aResult.ShapeType() == TopAbs_COMPOUND) {
64 std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape);
65 aGeomShape->setImpl(new TopoDS_Shape(aResult));
66 ListOfShape aCompSolids, aFreeSolids;
67 aGeomShape = GeomAlgoAPI_ShapeTools::combineShapes(aGeomShape,
68 GeomAPI_Shape::COMPSOLID,
71 aResult = aGeomShape->impl<TopoDS_Shape>();
74 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
75 aShape->setImpl(new TopoDS_Shape(aResult));
76 this->setShape(aShape);