+}
+
+//=================================================================================================
+void GeomAlgoAPI_MakeShape::setBuilderType(const BuilderType theBuilderType)
+{
+ myBuilderType = theBuilderType;
+}
+
+//=================================================================================================
+void GeomAlgoAPI_MakeShape::setDone(const bool theFlag)
+{
+ myDone = theFlag;
+}
+
+//=================================================================================================
+void GeomAlgoAPI_MakeShape::setShape(const std::shared_ptr<GeomAPI_Shape> theShape)
+{
+ if(myShape.get() && myShape->isEqual(theShape)) {
+ return;
+ }
+
+ myShape = theShape;
+
+ // Filling data map to keep correct orientation of sub-shapes.
+ if(myShape.get()) {
+ if(myMap.get()) {
+ myMap->clear();
+ } else {
+ myMap.reset(new GeomAPI_DataMapOfShapeShape);
+ }
+
+ const TopoDS_Shape& aTopoDSShape = myShape->impl<TopoDS_Shape>();
+ for(TopExp_Explorer anExp(aTopoDSShape,TopAbs_VERTEX); anExp.More(); anExp.Next()) {
+ std::shared_ptr<GeomAPI_Shape> aCurrentShape(new GeomAPI_Shape());
+ aCurrentShape->setImpl(new TopoDS_Shape(anExp.Current()));
+ myMap->bind(aCurrentShape, aCurrentShape);
+ }
+ for(TopExp_Explorer anExp(aTopoDSShape,TopAbs_EDGE); anExp.More(); anExp.Next()) {
+ std::shared_ptr<GeomAPI_Shape> aCurrentShape(new GeomAPI_Shape());
+ aCurrentShape->setImpl(new TopoDS_Shape(anExp.Current()));
+ myMap->bind(aCurrentShape, aCurrentShape);
+ }
+ for(TopExp_Explorer anExp(aTopoDSShape,TopAbs_FACE); anExp.More(); anExp.Next()) {
+ std::shared_ptr<GeomAPI_Shape> aCurrentShape(new GeomAPI_Shape());
+ aCurrentShape->setImpl(new TopoDS_Shape(anExp.Current()));
+ myMap->bind(aCurrentShape, aCurrentShape);
+ }
+ } else {
+ if(myMap.get()) {
+ myMap->clear();
+ }
+ }
+}
+
+//=================================================================================================
+void GeomAlgoAPI_MakeShape::initialize() {
+ switch (myBuilderType) {
+ case OCCT_BRepBuilderAPI_MakeShape: {
+ myDone = implPtr<BRepBuilderAPI_MakeShape>()->IsDone() == Standard_True;
+ myShape.reset(new GeomAPI_Shape());
+ myShape->setImpl(new TopoDS_Shape(implPtr<BRepBuilderAPI_MakeShape>()->Shape()));
+ break;
+ }
+ case OCCT_BOPAlgo_Builder: {
+ myDone = true;
+ myShape.reset(new GeomAPI_Shape());
+ myShape->setImpl(new TopoDS_Shape(implPtr<BOPAlgo_Builder>()->Shape()));
+ break;
+ }
+ }
+
+ if(myMap.get()) {
+ myMap->clear();
+ } else {
+ myMap.reset(new GeomAPI_DataMapOfShapeShape);
+ }
+
+ const TopoDS_Shape& aTopoDSShape = myShape->impl<TopoDS_Shape>();
+ for(TopExp_Explorer anExp(aTopoDSShape,TopAbs_FACE); anExp.More(); anExp.Next()) {
+ std::shared_ptr<GeomAPI_Shape> aCurrentShape(new GeomAPI_Shape());
+ aCurrentShape->setImpl(new TopoDS_Shape(anExp.Current()));
+ myMap->bind(aCurrentShape, aCurrentShape);
+ }
+}
+
+
+//=================================================================================================
+void GeomAlgoAPI_MakeShape::prepareNamingFaces()
+{
+ long long index = 1;
+ GeomAPI_ShapeExplorer anExp(shape(), GeomAPI_Shape::FACE);
+ for(GeomAPI_ShapeExplorer anExp(shape(), GeomAPI_Shape::FACE); anExp.more(); anExp.next()) {
+ std::shared_ptr<GeomAPI_Shape> aFace = anExp.current();
+ myCreatedFaces["Face_" + std::to_string(index++)] = aFace;
+ }
+}
+
+
+//=================================================================================================
+bool GeomAlgoAPI_MakeShape::checkValid(std::string theMessage){
+
+ // isValid() is called from this method
+ if (!isValid()) {
+ myError = theMessage + " :: resulting shape is not valid.";
+ return false;
+ }
+
+ // Check the number of volumes in myShape, make sure there's one and only one.
+ TopoDS_Shape aTopoDSShape = myShape->impl<TopoDS_Shape>();
+ int aNbVolumes = 0;
+ for(TopExp_Explorer anExp(aTopoDSShape,TopAbs_SOLID); anExp.More(); anExp.Next()) {
+ aNbVolumes ++;
+ }
+
+ if (aNbVolumes != 1) {
+ myError = theMessage +
+ " :: connexity error, the resulting shape is made of several separate solids.";
+ return false;
+ }
+
+ return true ;
+}
+