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 <BRepCheck_Analyzer.hxx>
15 #include <TopExp_Explorer.hxx>
16 #include <TopoDS_Builder.hxx>
18 //=================================================================================================
19 GeomAlgoAPI_PaveFiller::GeomAlgoAPI_PaveFiller(const ListOfShape& theListOfShape, const bool theIsMakeCompSolids)
22 build(theListOfShape, theIsMakeCompSolids);
26 //=================================================================================================
27 void GeomAlgoAPI_PaveFiller::build(const ListOfShape& theListOfShape, const bool theIsMakeCompSolids)
29 BOPAlgo_PaveFiller aPaveFiller;
30 BOPCol_ListOfShape aListOfShape;
31 for(ListOfShape::const_iterator anIt = theListOfShape.cbegin(); anIt != theListOfShape.cend(); anIt++) {
32 aListOfShape.Append((*anIt)->impl<TopoDS_Shape>());
34 aPaveFiller.SetArguments(aListOfShape);
35 aPaveFiller.Perform();
36 Standard_Integer iErr = aPaveFiller.ErrorStatus();
41 BOPAlgo_Builder* aBuilder = new BOPAlgo_Builder();
42 myMkShape.reset(new GeomAlgoAPI_MakeShape(aBuilder, GeomAlgoAPI_MakeShape::BOPAlgoBuilder));
43 aBuilder->SetArguments(aListOfShape);
44 aBuilder->PerformWithFiller(aPaveFiller);
45 iErr = aBuilder->ErrorStatus();
50 TopoDS_Shape aResult = aBuilder->Shape();
51 if(aResult.ShapeType() == TopAbs_COMPOUND) {
52 aResult = GeomAlgoAPI_DFLoader::refineResult(aResult);
54 if(theIsMakeCompSolids && aResult.ShapeType() == TopAbs_COMPOUND) {
55 std::shared_ptr<GeomAPI_Shape> aCompound(new GeomAPI_Shape);
56 aCompound->setImpl(new TopoDS_Shape(aResult));
57 ListOfShape aCompSolids, aFreeSolids;
58 GeomAlgoAPI_ShapeTools::combineShapes(aCompound, GeomAPI_Shape::COMPSOLID, aCompSolids, aFreeSolids);
59 if(aCompSolids.size() == 1 && aFreeSolids.size() == 0) {
60 aResult = aCompSolids.front()->impl<TopoDS_Shape>();
61 } else if (aCompSolids.size() > 1 || (aCompSolids.size() >= 1 && aFreeSolids.size() >= 1)) {
62 TopoDS_Compound aResultComp;
63 TopoDS_Builder aBuilder;
64 aBuilder.MakeCompound(aResultComp);
65 for(ListOfShape::const_iterator anIter = aCompSolids.cbegin(); anIter != aCompSolids.cend(); anIter++) {
66 aBuilder.Add(aResultComp, (*anIter)->impl<TopoDS_Shape>());
68 for(ListOfShape::const_iterator anIter = aFreeSolids.cbegin(); anIter != aFreeSolids.cend(); anIter++) {
69 aBuilder.Add(aResultComp, (*anIter)->impl<TopoDS_Shape>());
71 aResult = aResultComp;
75 // fill data map to keep correct orientation of sub-shapes
76 myMap.reset(new GeomAPI_DataMapOfShapeShape());
77 for (TopExp_Explorer Exp(aResult, TopAbs_FACE); Exp.More(); Exp.Next()) {
78 std::shared_ptr<GeomAPI_Shape> aCurrentShape(new GeomAPI_Shape());
79 aCurrentShape->setImpl(new TopoDS_Shape(Exp.Current()));
80 myMap->bind(aCurrentShape, aCurrentShape);
83 myShape.reset(new GeomAPI_Shape());
84 myShape->setImpl(new TopoDS_Shape(aResult));
89 //=================================================================================================
90 const bool GeomAlgoAPI_PaveFiller::isDone() const
95 //=================================================================================================
96 const bool GeomAlgoAPI_PaveFiller::isValid() const
98 BRepCheck_Analyzer aChecker(myShape->impl<TopoDS_Shape>());
99 return (aChecker.IsValid() == Standard_True);
102 //=================================================================================================
103 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_PaveFiller::shape() const
108 //=================================================================================================
109 std::shared_ptr<GeomAPI_DataMapOfShapeShape> GeomAlgoAPI_PaveFiller::mapOfShapes() const
114 //=================================================================================================
115 std::shared_ptr<GeomAlgoAPI_MakeShape> GeomAlgoAPI_PaveFiller::makeShape() const