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>
16 //=================================================================================================
17 GeomAlgoAPI_PaveFiller::GeomAlgoAPI_PaveFiller(const ListOfShape& theListOfShape, const bool theIsMakeCompSolids)
19 build(theListOfShape, theIsMakeCompSolids);
23 //=================================================================================================
24 void GeomAlgoAPI_PaveFiller::build(const ListOfShape& theListOfShape, const bool theIsMakeCompSolids)
26 BOPAlgo_PaveFiller aPaveFiller;
27 BOPCol_ListOfShape aListOfShape;
28 for(ListOfShape::const_iterator anIt = theListOfShape.cbegin(); anIt != theListOfShape.cend(); anIt++) {
29 aListOfShape.Append((*anIt)->impl<TopoDS_Shape>());
31 aPaveFiller.SetArguments(aListOfShape);
32 aPaveFiller.Perform();
33 Standard_Integer iErr = aPaveFiller.ErrorStatus();
38 BOPAlgo_Builder* aBuilder = new BOPAlgo_Builder();
39 this->setImpl(aBuilder);
40 this->setBuilderType(OCCT_BOPAlgo_Builder);
41 aBuilder->SetArguments(aListOfShape);
42 aBuilder->PerformWithFiller(aPaveFiller);
43 iErr = aBuilder->ErrorStatus();
48 TopoDS_Shape aResult = aBuilder->Shape();
49 if(aResult.ShapeType() == TopAbs_COMPOUND) {
50 aResult = GeomAlgoAPI_DFLoader::refineResult(aResult);
52 if(theIsMakeCompSolids && aResult.ShapeType() == TopAbs_COMPOUND) {
53 std::shared_ptr<GeomAPI_Shape> aCompound(new GeomAPI_Shape);
54 aCompound->setImpl(new TopoDS_Shape(aResult));
55 ListOfShape aCompSolids, aFreeSolids;
56 GeomAlgoAPI_ShapeTools::combineShapes(aCompound, GeomAPI_Shape::COMPSOLID, aCompSolids, aFreeSolids);
57 if(aCompSolids.size() == 1 && aFreeSolids.size() == 0) {
58 aResult = aCompSolids.front()->impl<TopoDS_Shape>();
59 } else if (aCompSolids.size() > 1 || (aCompSolids.size() >= 1 && aFreeSolids.size() >= 1)) {
60 TopoDS_Compound aResultComp;
61 TopoDS_Builder aBuilder;
62 aBuilder.MakeCompound(aResultComp);
63 for(ListOfShape::const_iterator anIter = aCompSolids.cbegin(); anIter != aCompSolids.cend(); anIter++) {
64 aBuilder.Add(aResultComp, (*anIter)->impl<TopoDS_Shape>());
66 for(ListOfShape::const_iterator anIter = aFreeSolids.cbegin(); anIter != aFreeSolids.cend(); anIter++) {
67 aBuilder.Add(aResultComp, (*anIter)->impl<TopoDS_Shape>());
69 aResult = aResultComp;
73 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
74 aShape->setImpl(new TopoDS_Shape(aResult));
75 this->setShape(aShape);