From 76d899e9697205290580e6b6ceecbb4c340bf7a5 Mon Sep 17 00:00:00 2001 From: dbv Date: Tue, 9 Jun 2015 16:13:18 +0300 Subject: [PATCH] Improvement #598: Porting Boolean operations to OCCT 6.9.0 --- src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp | 168 +++++--------- src/FeaturesPlugin/FeaturesPlugin_Boolean.h | 10 +- src/GeomAlgoAPI/GeomAlgoAPI_Boolean.cpp | 212 +++++++++--------- src/GeomAlgoAPI/GeomAlgoAPI_Boolean.h | 103 +++++---- 4 files changed, 217 insertions(+), 276 deletions(-) diff --git a/src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp b/src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp index 96b7de83f..c2a4ea46b 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp @@ -65,7 +65,7 @@ void FeaturesPlugin_Boolean::execute() ModelAPI_AttributeInteger>(data()->attribute(FeaturesPlugin_Boolean::TYPE_ID())); if (!aTypeAttr) return; - int aType = aTypeAttr->value(); + GeomAlgoAPI_Boolean::OperationType aType = (GeomAlgoAPI_Boolean::OperationType)aTypeAttr->value(); ListOfShape anObjects, aTools; @@ -103,31 +103,39 @@ void FeaturesPlugin_Boolean::execute() std::shared_ptr aDataMapOfShapes; switch(aType) { - case GeomAlgoAPI_Boolean::BOOL_CUT: { + case GeomAlgoAPI_Boolean::BOOL_CUT: + case GeomAlgoAPI_Boolean::BOOL_COMMON:{ // Cut each object with all tools for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end(); anObjectsIt++) { std::shared_ptr anObject = *anObjectsIt; + ListOfShape aListWithObject; + aListWithObject.push_back(anObject); aResShape = anObject; - ListOfShape aSingleObjectList; aSingleObjectList.push_back(anObject); - for(ListOfShape::iterator aToolsIt = aTools.begin(); aToolsIt != aTools.end(); aToolsIt++) { - std::shared_ptr aTool = *aToolsIt; - GeomAlgoAPI_Boolean* aBoolAlgo = new GeomAlgoAPI_Boolean(aResShape, aTool, aType); - if(!aBoolAlgo->isDone() || aBoolAlgo->shape()->isNull() || !aBoolAlgo->isValid()) { - static const std::string aBoolAlgoError = "Boolean feature: algorithm failed"; - setError(aBoolAlgoError); - return; - } - aListOfMakeShape.push_back(aBoolAlgo->makeShape()); - aResShape = aBoolAlgo->shape(); - aBoolAlgo->mapOfShapes(aDataMapOfShapes); + GeomAlgoAPI_Boolean aBoolAlgo(aListWithObject, aTools, aType); + + // Checking that the algorithm worked properly. + if(!aBoolAlgo.isDone()) { + static const std::string aFeatureError = "Boolean algorithm failed"; + setError(aFeatureError); + return; + } + if(aBoolAlgo.shape()->isNull()) { + static const std::string aShapeError = "Resulting shape is Null"; + setError(aShapeError); + return; + } + if(!aBoolAlgo.isValid()) { + std::string aFeatureError = "Warning: resulting shape is not valid"; + setError(aFeatureError); + return; } - if(GeomAlgoAPI_ShapeProps::volume(aResShape) > 10.e-5) { + if(GeomAlgoAPI_ShapeProps::volume(aBoolAlgo.shape()) > 1.e-7) { std::shared_ptr aResultBody = document()->createBody(data(), aResultIndex); std::shared_ptr aMakeShapeList = std::shared_ptr( new GeomAlgoAPI_MakeShapeList(aListOfMakeShape)); - LoadNamingDS(aMakeShapeList, aResultBody, aResShape, aDataMapOfShapes, aSingleObjectList, aTools); + LoadNamingDS(aResultBody, anObject, aTools, aBoolAlgo); setResult(aResultBody, aResultIndex); aResultIndex++; } @@ -135,91 +143,39 @@ void FeaturesPlugin_Boolean::execute() break; } case GeomAlgoAPI_Boolean::BOOL_FUSE: { - // Fuse all objects. - std::shared_ptr aTempRes = anObjects.front(); - for(ListOfShape::iterator anObjectsIt = ++anObjects.begin(); anObjectsIt != anObjects.end(); anObjectsIt++) { - std::shared_ptr anObject = *anObjectsIt; - GeomAlgoAPI_Boolean* aBoolAlgo = new GeomAlgoAPI_Boolean(aTempRes, anObject, aType); - if(!aBoolAlgo->isDone() || aBoolAlgo->shape()->isNull() || !aBoolAlgo->isValid()) { - static const std::string aBoolAlgoError = "Boolean feature: algorithm failed"; - setError(aBoolAlgoError); - return; - } - aListOfMakeShape.push_back(aBoolAlgo->makeShape()); - aTempRes = aBoolAlgo->shape(); + // Fuse all objects and all tools. + GeomAlgoAPI_Boolean aBoolAlgo(anObjects, aTools, aType); + + // Checking that the algorithm worked properly. + if(!aBoolAlgo.isDone()) { + static const std::string aFeatureError = "Boolean algorithm failed"; + setError(aFeatureError); + return; } - - // Fuse all tools with result of objects fuse. - for(ListOfShape::iterator aToolsIt = aTools.begin(); aToolsIt != aTools.end(); aToolsIt++) { - std::shared_ptr aTool = *aToolsIt; - GeomAlgoAPI_Boolean* aBoolAlgo = new GeomAlgoAPI_Boolean(aTempRes, aTool, aType); - if(!aBoolAlgo->isDone() || aBoolAlgo->shape()->isNull() || !aBoolAlgo->isValid()) { - static const std::string aBoolAlgoError = "Boolean feature: algorithm failed"; - setError(aBoolAlgoError); - return; - } - aListOfMakeShape.push_back(aBoolAlgo->makeShape()); - aTempRes = aBoolAlgo->shape(); - aBoolAlgo->mapOfShapes(aDataMapOfShapes); + if(aBoolAlgo.shape()->isNull()) { + static const std::string aShapeError = "Resulting shape is Null"; + setError(aShapeError); + return; + } + if(!aBoolAlgo.isValid()) { + std::string aFeatureError = "Warning: resulting shape is not valid"; + setError(aFeatureError); + return; } - aResShape = aTempRes; - std::shared_ptr aResultBody = document()->createBody(data()); + std::shared_ptr aResultBody = document()->createBody(data(), aResultIndex); std::shared_ptr aMakeShapeList = std::shared_ptr( new GeomAlgoAPI_MakeShapeList(aListOfMakeShape)); - LoadNamingDS(aMakeShapeList, aResultBody, aResShape, aDataMapOfShapes, anObjects, aTools); - setResult(aResultBody); + LoadNamingDS(aResultBody, anObjects.front(), aTools, aBoolAlgo); + setResult(aResultBody, aResultIndex); aResultIndex++; break; } - case GeomAlgoAPI_Boolean::BOOL_COMMON: { - // Search common between object and tool and fuse them. - for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end(); anObjectsIt++) { - std::shared_ptr anObject = *anObjectsIt; - std::shared_ptr aTempRes; - ListOfShape aSingleObjectList; aSingleObjectList.push_back(anObject); - for(ListOfShape::iterator aToolsIt = aTools.begin(); aToolsIt != aTools.end(); aToolsIt++) { - std::shared_ptr aTool = *aToolsIt; - GeomAlgoAPI_Boolean* aBoolAlgo1 = new GeomAlgoAPI_Boolean(anObject, aTool, aType); - if(!aBoolAlgo1->isDone() || aBoolAlgo1->shape()->isNull() || !aBoolAlgo1->isValid()) { - static const std::string aBoolAlgoError = "Boolean feature: algorithm failed"; - setError(aBoolAlgoError); - return; - } - aListOfMakeShape.push_back(aBoolAlgo1->makeShape()); - - if(!aTempRes) { - aTempRes = aBoolAlgo1->shape(); - aBoolAlgo1->mapOfShapes(aDataMapOfShapes); - } else { - // Fuse common result with previous common results. - GeomAlgoAPI_Boolean* aBoolAlgo2 = new GeomAlgoAPI_Boolean(aTempRes, - aBoolAlgo1->shape(), - GeomAlgoAPI_Boolean::BOOL_FUSE); - if(!aBoolAlgo1->isDone() || aBoolAlgo1->shape()->isNull() || !aBoolAlgo1->isValid()) { - static const std::string aBoolAlgoError = "Boolean feature: algorithm failed"; - setError(aBoolAlgoError); - return; - } - aListOfMakeShape.push_back(aBoolAlgo2->makeShape()); - aTempRes = aBoolAlgo2->shape(); - aBoolAlgo2->mapOfShapes(aDataMapOfShapes); - } - } - aResShape = aTempRes; - - if(GeomAlgoAPI_ShapeProps::volume(aResShape) > 10.e-5) { - std::shared_ptr aResultBody = document()->createBody(data(), aResultIndex); - std::shared_ptr aMakeShapeList = std::shared_ptr( - new GeomAlgoAPI_MakeShapeList(aListOfMakeShape)); - - LoadNamingDS(aMakeShapeList, aResultBody, aResShape, aDataMapOfShapes, aSingleObjectList, aTools); - setResult(aResultBody, aResultIndex); - aResultIndex++; - } - } - break; + default: { + std::string anOperationError = "Error: wrong type of operation"; + setError(anOperationError); + return; } } // remove the rest results if there were produced in the previous pass @@ -227,30 +183,28 @@ void FeaturesPlugin_Boolean::execute() } //================================================================================================= -void FeaturesPlugin_Boolean::LoadNamingDS(std::shared_ptr theMakeShapeList, - std::shared_ptr theResultBody, - std::shared_ptr theResult, - std::shared_ptr theDataMapOfShapes, - const ListOfShape& theObjects, - const ListOfShape& theTools) +void FeaturesPlugin_Boolean::LoadNamingDS(std::shared_ptr theResultBody, + const std::shared_ptr& theBaseShape, + const ListOfShape& theTools, + const GeomAlgoAPI_Boolean& theAlgo) { //load result - if(theObjects.front()->isEqual(theResult)) { - theResultBody->store(theObjects.front()); + if(theBaseShape->isEqual(theAlgo.shape())) { + theResultBody->store(theAlgo.shape()); } else { - theResultBody->storeModified(theObjects.front(), theResult); + theResultBody->storeModified(theBaseShape, theAlgo.shape()); GeomAPI_DataMapOfShapeShape* aSubShapes = new GeomAPI_DataMapOfShapeShape(); std::string aModName = "Modified"; - for(ListOfShape::const_iterator anIter = theObjects.begin(); anIter != theObjects.end(); anIter++) { - theResultBody->loadAndOrientModifiedShapes(theMakeShapeList.get(), *anIter, FACE, _MODIFY_TAG, aModName, *theDataMapOfShapes.get()); - theResultBody->loadDeletedShapes(theMakeShapeList.get(), *anIter, FACE, _DELETED_TAG); - } + theResultBody->loadAndOrientModifiedShapes(theAlgo.makeShape().get(), theBaseShape, FACE, + _MODIFY_TAG, aModName, *theAlgo.mapOfShapes().get()); + theResultBody->loadDeletedShapes(theAlgo.makeShape().get(), theBaseShape, FACE, _DELETED_TAG); for(ListOfShape::const_iterator anIter = theTools.begin(); anIter != theTools.end(); anIter++) { - theResultBody->loadAndOrientModifiedShapes(theMakeShapeList.get(), *anIter, FACE, _MODIFY_TAG, aModName, *theDataMapOfShapes.get()); - theResultBody->loadDeletedShapes(theMakeShapeList.get(), *anIter, FACE, _DELETED_TAG); + theResultBody->loadAndOrientModifiedShapes(theAlgo.makeShape().get(), *anIter, FACE, + _MODIFY_TAG, aModName, *theAlgo.mapOfShapes().get()); + theResultBody->loadDeletedShapes(theAlgo.makeShape().get(), *anIter, FACE, _DELETED_TAG); } } } diff --git a/src/FeaturesPlugin/FeaturesPlugin_Boolean.h b/src/FeaturesPlugin/FeaturesPlugin_Boolean.h index 959d06061..20f29ddbf 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Boolean.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Boolean.h @@ -87,12 +87,10 @@ private: std::shared_ptr getShape(const std::string& theAttrName); /// Load Naming data structure of the feature to the document - void LoadNamingDS(std::shared_ptr theMakeShapeList, - std::shared_ptr theResultBody, - std::shared_ptr theResult, - std::shared_ptr theDataMapOfShapes, - const ListOfShape& theObjects, - const ListOfShape& theTools); + void LoadNamingDS(std::shared_ptr theResultBody, + const std::shared_ptr& theBaseObject, + const ListOfShape& theTools, + const GeomAlgoAPI_Boolean& theAlgo); }; #endif diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Boolean.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Boolean.cpp index 4327a194e..0a3305bcd 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Boolean.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Boolean.cpp @@ -6,159 +6,151 @@ #include "GeomAlgoAPI_Boolean.h" -#include +#include #include +#include #include #include #include -#include +#include -std::shared_ptr GeomAlgoAPI_Boolean::makeCut( - std::shared_ptr theShape, - std::shared_ptr theTool) +//================================================================================================= +std::shared_ptr GeomAlgoAPI_Boolean::makeCut(const ListOfShape& theObjects, + const ListOfShape& theTools) { - const TopoDS_Shape& aShape = theShape->impl(); - const TopoDS_Shape& aTool = theTool->impl(); - - BRepAlgoAPI_Cut aCut(aShape, aTool); - if (aCut.IsDone()) { - std::shared_ptr aResult(new GeomAPI_Shape()); - aResult->setImpl(new TopoDS_Shape(aCut.Shape())); - return aResult; + GeomAlgoAPI_Boolean aBoolAlgo(theObjects, theTools, BOOL_CUT); + if(aBoolAlgo.isDone() && !aBoolAlgo.shape()->isNull() && aBoolAlgo.isValid()) { + return aBoolAlgo.shape(); } return std::shared_ptr(); } - -std::shared_ptr GeomAlgoAPI_Boolean::makeFuse( - std::shared_ptr theShape, - std::shared_ptr theTool) +//================================================================================================= +std::shared_ptr GeomAlgoAPI_Boolean::makeFuse(const ListOfShape& theObjects, + const ListOfShape& theTools) { - const TopoDS_Shape& aShape = theShape->impl(); - const TopoDS_Shape& aTool = theTool->impl(); - - BRepAlgoAPI_Fuse aFuse(aShape, aTool); - if (aFuse.IsDone()) { - std::shared_ptr aResult(new GeomAPI_Shape()); - aResult->setImpl(new TopoDS_Shape(aFuse.Shape())); - return aResult; + 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( - std::shared_ptr theShape, - std::shared_ptr theTool) +//================================================================================================= +std::shared_ptr GeomAlgoAPI_Boolean::makeCommon(const ListOfShape& theObjects, + const ListOfShape& theTools) { - const TopoDS_Shape& aShape = theShape->impl(); - const TopoDS_Shape& aTool = theTool->impl(); - - BRepAlgoAPI_Common aCommon(aShape, aTool); - if (aCommon.IsDone()) { - std::shared_ptr aResult(new GeomAPI_Shape()); - aResult->setImpl(new TopoDS_Shape(aCommon.Shape())); - return aResult; + GeomAlgoAPI_Boolean aBoolAlgo(theObjects, theTools, BOOL_COMMON); + if(aBoolAlgo.isDone() && !aBoolAlgo.shape()->isNull() && aBoolAlgo.isValid()) { + return aBoolAlgo.shape(); } return std::shared_ptr(); } -//============================================================================ -GeomAlgoAPI_Boolean::GeomAlgoAPI_Boolean(std::shared_ptr theObject, - std::shared_ptr theTool, - int theType) -: myOperation(theType), myDone(false), myShape(new GeomAPI_Shape()), myMap(new GeomAPI_DataMapOfShapeShape()) +//================================================================================================= +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(theObject, theTool); + build(theObjects, theTools, theOperationType); } -//============================================================================ -void GeomAlgoAPI_Boolean::build(std::shared_ptr theObject, - std::shared_ptr theTool) +//================================================================================================= +void GeomAlgoAPI_Boolean::build(const ListOfShape& theObjects, + const ListOfShape& theTools, + const OperationType theOperationType) { - const TopoDS_Shape& anObject = theObject->impl(); - const TopoDS_Shape& aTool = theTool->impl(); - TopoDS_Shape aResult; - switch (myOperation) { - case BOOL_FUSE: - { - BRepAlgoAPI_Fuse* mkFuse = new BRepAlgoAPI_Fuse(anObject, aTool); - if (mkFuse && mkFuse->IsDone()) { - myDone = mkFuse->IsDone() == Standard_True; - myMkShape = std::shared_ptr(new GeomAlgoAPI_MakeShape (mkFuse)); - aResult = mkFuse->Shape();//GeomAlgoAPI_DFLoader::refineResult(aFuse->Shape()); - } - break; - } - case BOOL_CUT: - { - BRepAlgoAPI_Cut* mkCut = new BRepAlgoAPI_Cut(anObject, aTool); - if (mkCut && mkCut->IsDone()) { - myDone = mkCut->IsDone() == Standard_True; - myMkShape = std::shared_ptr(new GeomAlgoAPI_MakeShape (mkCut)); - aResult = mkCut->Shape(); - } - break; - } - case BOOL_COMMON: - { - BRepAlgoAPI_Common* mkCom = new BRepAlgoAPI_Common(anObject, aTool); - if (mkCom && mkCom->IsDone()) { - myDone = mkCom->IsDone() == Standard_True; - myMkShape = std::shared_ptr(new GeomAlgoAPI_MakeShape (mkCom)); - aResult = mkCom->Shape(); - } - break; - } + if(theObjects.empty() || theTools.empty()) { + return; } - if(myDone) { - if(aResult.ShapeType() == TopAbs_COMPOUND) - aResult = GeomAlgoAPI_DFLoader::refineResult(aResult); - myShape->setImpl(new TopoDS_Shape(aResult)); - std::shared_ptr aGeomResult(new GeomAPI_Shape()); - aGeomResult->setImpl(new TopoDS_Shape(aResult)); - - // 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); - } - } -} + // Getting objects. + TopTools_ListOfShape anObjects; + for(ListOfShape::const_iterator anObjectsIt = theObjects.begin(); anObjectsIt != theObjects.end(); anObjectsIt++) + { + anObjects.Append((*anObjectsIt)->impl()); + } + + // Getting tools. + TopTools_ListOfShape aTools; + for(ListOfShape::const_iterator aToolsIt = theTools.begin(); aToolsIt != theTools.end(); aToolsIt++) + { + aTools.Append((*aToolsIt)->impl()); + } -//============================================================================ + // Creating boolean operation. + BRepAlgoAPI_BooleanOperation* anOperation; + switch (theOperationType) { + case BOOL_CUT: { + anOperation = new BRepAlgoAPI_Cut(); + break; + } + case BOOL_FUSE: { + anOperation = new BRepAlgoAPI_Fuse(); + break; + } + case BOOL_COMMON: { + anOperation = new BRepAlgoAPI_Common(); + break; + } + default: { + return; + } + } + myMkShape->setImpl(anOperation); + anOperation->SetArguments(anObjects); + anOperation->SetTools(aTools); + + // Building and getting result. + anOperation->Build(); + myDone = anOperation->IsDone() == Standard_True; + if(!myDone) { + return; + } + TopoDS_Shape aResult = anOperation->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); + } + myShape->setImpl(new TopoDS_Shape(aResult)); + +} + +//================================================================================================= const bool GeomAlgoAPI_Boolean::isDone() const -{return myDone;} +{ + 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 +//================================================================================================= +const std::shared_ptr& GeomAlgoAPI_Boolean::shape() const { return myShape; } -//============================================================================ -void GeomAlgoAPI_Boolean::mapOfShapes(std::shared_ptr& theMap) const +//================================================================================================= +std::shared_ptr GeomAlgoAPI_Boolean::mapOfShapes() const { - theMap = myMap; + return myMap; } -//============================================================================ -const std::shared_ptr& GeomAlgoAPI_Boolean::makeShape() const +//================================================================================================= +std::shared_ptr GeomAlgoAPI_Boolean::makeShape() const { return myMkShape; } - -//============================================================================ -GeomAlgoAPI_Boolean::~GeomAlgoAPI_Boolean() -{ -} \ No newline at end of file diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Boolean.h b/src/GeomAlgoAPI/GeomAlgoAPI_Boolean.h index 6e92769a9..1c3655d9b 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Boolean.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Boolean.h @@ -16,76 +16,73 @@ #include -/**\class GeomAlgoAPI_Boolean - * \ingroup DataAlgo - * \brief Allows to perform of boolean operations +/** \class GeomAlgoAPI_Boolean + * \ingroup DataAlgo + * \brief Allows to perform of boolean operations */ class GeomAlgoAPI_Boolean : public GeomAPI_Interface { +public: + enum OperationType{ + BOOL_CUT, + BOOL_FUSE, + BOOL_COMMON + }; + public: - /**\brief Creates cut boolean operation - * \param[in] theShape the main shape - * \param[in] theTool toole shape for boolean - * \return a solid as result of operation + /** \brief Creates cut boolean operation. + * \param[in] theObjects the main shape. + * \param[in] theTools toole shape for boolean. + * \return a solid or compound of solids as result of operation. */ - GEOMALGOAPI_EXPORT static std::shared_ptr makeCut( - std::shared_ptr theShape, - std::shared_ptr theTool); - - /**\brief Creates fuse boolean operation - * \param[in] theShape the main shape - * \param[in] theTool second shape - * \return a solid as result of operation + GEOMALGOAPI_EXPORT static std::shared_ptr makeCut(const ListOfShape& theObjects, + const ListOfShape& theTools); + + /** \brief Creates fuse boolean operation. + * \param[in] theObjects the main shape. + * \param[in] theTools second shape. + * \return a solid as result of operation. */ - GEOMALGOAPI_EXPORT static std::shared_ptr makeFuse( - std::shared_ptr theShape, - std::shared_ptr theTool); - - /**\brief Creates common boolean operation - * \param[in] theObject the main shape - * \param[in] theTool second shape - * \return a solid as result of operation + GEOMALGOAPI_EXPORT static std::shared_ptr makeFuse(const ListOfShape& theObjects, + const ListOfShape& theTools); + + /** \brief Creates common boolean operation. + * \param[in] theObjects the main shape. + * \param[in] theTools second shape. + * \return a solid as result of operation. */ - GEOMALGOAPI_EXPORT static std::shared_ptr makeCommon( - std::shared_ptr theObject, - std::shared_ptr theTool); + GEOMALGOAPI_EXPORT static std::shared_ptr makeCommon(const ListOfShape& theObjects, + const ListOfShape& theTools); - enum { - BOOL_CUT, - BOOL_FUSE, - BOOL_COMMON - }; - /// Constructor - GEOMALGOAPI_EXPORT GeomAlgoAPI_Boolean (std::shared_ptr theObject, - std::shared_ptr theTool, - int theType); + /// Constructor. + GEOMALGOAPI_EXPORT GeomAlgoAPI_Boolean(const ListOfShape& theObjects, + const ListOfShape& theTools, + const OperationType theOperationType); - /// Returns True if algorithm succeed + /// \return true if algorithm succeed. GEOMALGOAPI_EXPORT const bool isDone() const; - /// Returns True if resulting shape is valid + /// \return true if resulting shape is valid. GEOMALGOAPI_EXPORT const bool isValid() const; - /// Returns result of the boolean algorithm which may be a Solid or a Face - GEOMALGOAPI_EXPORT const std::shared_ptr& shape () const; - - /// Returns map of sub-shapes of the result. To be used for History keeping - GEOMALGOAPI_EXPORT void mapOfShapes(std::shared_ptr& theMap) const; + /// \return result of the boolean algorithm. + GEOMALGOAPI_EXPORT const std::shared_ptr& shape() const; + + /// \return map of sub-shapes of the result. To be used for History keeping. + GEOMALGOAPI_EXPORT std::shared_ptr mapOfShapes() const; - /// Return interface for for History processing - GEOMALGOAPI_EXPORT const std::shared_ptr& makeShape () const; + /// \return interface for for History processing. + GEOMALGOAPI_EXPORT std::shared_ptr makeShape() const; - ///Destructor - GEOMALGOAPI_EXPORT ~GeomAlgoAPI_Boolean(); +private: + /// Builds resulting shape. + void build(const ListOfShape& theObjects, + const ListOfShape& theTools, + const OperationType theOperationType); - private: - /// builds resulting shape - void build(std::shared_ptr theObject, - std::shared_ptr theTool); - /// fields - double mySize; +private: + /// Fields. bool myDone; - int myOperation; std::shared_ptr myShape; std::shared_ptr myMap; std::shared_ptr myMkShape; -- 2.39.2