X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomAlgoAPI%2FGeomAlgoAPI_Boolean.cpp;h=21458a9ce2ab14459e803371484d2342e0b391c5;hb=d8101383b10bf780a1acf5a356007ad6dbf17711;hp=0a3305bcde991df10043552c0915703f31ceaa26;hpb=76d899e9697205290580e6b6ceecbb4c340bf7a5;p=modules%2Fshaper.git diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Boolean.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Boolean.cpp index 0a3305bcd..21458a9ce 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Boolean.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Boolean.cpp @@ -6,55 +6,16 @@ #include "GeomAlgoAPI_Boolean.h" -#include -#include -#include -#include -#include -#include -#include - -//================================================================================================= -std::shared_ptr GeomAlgoAPI_Boolean::makeCut(const ListOfShape& theObjects, - const ListOfShape& theTools) -{ - GeomAlgoAPI_Boolean aBoolAlgo(theObjects, theTools, BOOL_CUT); - if(aBoolAlgo.isDone() && !aBoolAlgo.shape()->isNull() && aBoolAlgo.isValid()) { - return aBoolAlgo.shape(); - } - return std::shared_ptr(); -} +#include +#include -//================================================================================================= -std::shared_ptr GeomAlgoAPI_Boolean::makeFuse(const ListOfShape& theObjects, - const ListOfShape& theTools) -{ - GeomAlgoAPI_Boolean aBoolAlgo(theObjects, theTools, BOOL_FUSE); - if(aBoolAlgo.isDone() && !aBoolAlgo.shape()->isNull() && aBoolAlgo.isValid()) { - return aBoolAlgo.shape(); - } - return std::shared_ptr(); -} - -//================================================================================================= -std::shared_ptr GeomAlgoAPI_Boolean::makeCommon(const ListOfShape& theObjects, - const ListOfShape& theTools) -{ - GeomAlgoAPI_Boolean aBoolAlgo(theObjects, theTools, BOOL_COMMON); - if(aBoolAlgo.isDone() && !aBoolAlgo.shape()->isNull() && aBoolAlgo.isValid()) { - return aBoolAlgo.shape(); - } - return std::shared_ptr(); -} +#include +#include //================================================================================================= GeomAlgoAPI_Boolean::GeomAlgoAPI_Boolean(const ListOfShape& theObjects, const ListOfShape& theTools, const OperationType theOperationType) -: myDone(false), - myShape(new GeomAPI_Shape()), - myMap(new GeomAPI_DataMapOfShapeShape()), - myMkShape(new GeomAlgoAPI_MakeShape()) { build(theObjects, theTools, theOperationType); } @@ -84,73 +45,52 @@ void GeomAlgoAPI_Boolean::build(const ListOfShape& theObjects, } // Creating boolean operation. - BRepAlgoAPI_BooleanOperation* anOperation; + BOPAlgo_BOP* aBuilder = new BOPAlgo_BOP(); switch (theOperationType) { case BOOL_CUT: { - anOperation = new BRepAlgoAPI_Cut(); + aBuilder->SetOperation(BOPAlgo_CUT); break; } case BOOL_FUSE: { - anOperation = new BRepAlgoAPI_Fuse(); + aBuilder->SetOperation(BOPAlgo_FUSE); break; } case BOOL_COMMON: { - anOperation = new BRepAlgoAPI_Common(); + aBuilder->SetOperation(BOPAlgo_COMMON); break; } default: { return; } } - myMkShape->setImpl(anOperation); - anOperation->SetArguments(anObjects); - anOperation->SetTools(aTools); + this->setImpl(aBuilder); + this->setBuilderType(OCCT_BOPAlgo_Builder); + aBuilder->SetArguments(anObjects); + aBuilder->SetTools(aTools); // Building and getting result. - anOperation->Build(); - myDone = anOperation->IsDone() == Standard_True; - if(!myDone) { + aBuilder->Perform(); + if(aBuilder->ErrorStatus() != 0) { return; } - TopoDS_Shape aResult = anOperation->Shape(); + TopoDS_Shape aResult = aBuilder->Shape(); - // fill data map to keep correct orientation of sub-shapes - for (TopExp_Explorer Exp(aResult,TopAbs_FACE); Exp.More(); Exp.Next()) { - std::shared_ptr aCurrentShape(new GeomAPI_Shape()); - aCurrentShape->setImpl(new TopoDS_Shape(Exp.Current())); - myMap->bind(aCurrentShape, aCurrentShape); + if(aResult.ShapeType() == TopAbs_COMPOUND) { + aResult = GeomAlgoAPI_DFLoader::refineResult(aResult); + } + if(aResult.ShapeType() == TopAbs_COMPOUND) { + std::shared_ptr aGeomShape(new GeomAPI_Shape); + aGeomShape->setImpl(new TopoDS_Shape(aResult)); + ListOfShape aCompSolids, aFreeSolids; + aGeomShape = GeomAlgoAPI_ShapeTools::combineShapes(aGeomShape, + GeomAPI_Shape::COMPSOLID, + aCompSolids, + aFreeSolids); + aResult = aGeomShape->impl(); } - myShape->setImpl(new TopoDS_Shape(aResult)); - -} - -//================================================================================================= -const bool GeomAlgoAPI_Boolean::isDone() const -{ - return myDone; -} - -//================================================================================================= -const bool GeomAlgoAPI_Boolean::isValid() const -{ - BRepCheck_Analyzer aChecker(myShape->impl()); - return (aChecker.IsValid() == Standard_True); -} - -//================================================================================================= -const std::shared_ptr& GeomAlgoAPI_Boolean::shape() const -{ - return myShape; -} - -//================================================================================================= -std::shared_ptr GeomAlgoAPI_Boolean::mapOfShapes() const -{ - return myMap; -} -//================================================================================================= -std::shared_ptr GeomAlgoAPI_Boolean::makeShape() const -{ - return myMkShape; + std::shared_ptr aShape(new GeomAPI_Shape()); + aShape->setImpl(new TopoDS_Shape(aResult)); + this->setShape(aShape); + this->setDone(true); }