From: azv Date: Mon, 13 May 2019 13:24:58 +0000 (+0300) Subject: Small refactoring: separate storing a compound of sub-results. X-Git-Tag: VEDF2019Lot4~139^2~6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4dac51be8dafc9fd0e2b50ce5f773471ee174ff2;p=modules%2Fshaper.git Small refactoring: separate storing a compound of sub-results. --- diff --git a/src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp b/src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp index 44612077c..066bf02af 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp @@ -488,6 +488,42 @@ GeomShapePtr FeaturesPlugin_Boolean::keepUnusedSubsOfCompound( return aResultShape; } +//================================================================================================= +void FeaturesPlugin_Boolean::storeResult( + const ListOfShape& theObjects, + const ListOfShape& theTools, + const GeomShapePtr theResultShape, + int& theResultIndex, + std::shared_ptr theMakeShapeList, + std::vector& theResultBaseAlgoList) +{ + if (!theResultShape) + return; + + std::shared_ptr aResultBody = + document()->createBody(data(), theResultIndex); + + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, + theObjects, + theTools, + theMakeShapeList, + theResultShape); + setResult(aResultBody, theResultIndex++); + + // merge algorithms + FeaturesPlugin_Tools::ResultBaseAlgo aRBA; + aRBA.resultBody = aResultBody; + aRBA.baseShape = theObjects.front(); + for (std::vector::iterator + aRBAIt = theResultBaseAlgoList.begin(); + aRBAIt != theResultBaseAlgoList.end(); ++aRBAIt) { + theMakeShapeList->appendAlgo(aRBAIt->makeShape); + } + aRBA.makeShape = theMakeShapeList; + theResultBaseAlgoList.clear(); + theResultBaseAlgoList.push_back(aRBA); +} + //================================================================================================= int FeaturesPlugin_Boolean::version() { diff --git a/src/FeaturesPlugin/FeaturesPlugin_Boolean.h b/src/FeaturesPlugin/FeaturesPlugin_Boolean.h index 6fe5a24d6..c18d2eb67 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Boolean.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Boolean.h @@ -223,6 +223,14 @@ protected: const ObjectHierarchy& theToolsHierarchy, std::shared_ptr theMakeShapeList); + /// Store result shape if it is not empty and increase results counter + void storeResult(const ListOfShape& theObjects, + const ListOfShape& theTools, + const GeomShapePtr theResultShape, + int& theResultIndex, + std::shared_ptr theMakeShapeList, + std::vector& theResultBaseAlgoList); + /// Return version of the feature int version(); diff --git a/src/FeaturesPlugin/FeaturesPlugin_BooleanCommon.cpp b/src/FeaturesPlugin/FeaturesPlugin_BooleanCommon.cpp index 9dd105a9d..9911d4283 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_BooleanCommon.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanCommon.cpp @@ -188,33 +188,8 @@ void FeaturesPlugin_BooleanCommon::execute() } } - GeomAPI_ShapeIterator aShapeIt(aResultCompound); - if (aShapeIt.more()) { - std::shared_ptr aResultBody = - document()->createBody(data(), aResultIndex); - - ListOfShape anObjectList = anObjects.Objects(); - ListOfShape aToolsList = aTools.Objects(); - FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, - anObjectList, - aToolsList, - aMakeShapeList, - aResultCompound); - setResult(aResultBody, aResultIndex++); - - // merge algorithms - FeaturesPlugin_Tools::ResultBaseAlgo aRBA; - aRBA.resultBody = aResultBody; - aRBA.baseShape = anObjectList.front(); - for (std::vector::iterator - aRBAIt = aResultBaseAlgoList.begin(); - aRBAIt != aResultBaseAlgoList.end(); ++aRBAIt) { - aMakeShapeList->appendAlgo(aRBAIt->makeShape); - } - aRBA.makeShape = aMakeShapeList; - aResultBaseAlgoList.clear(); - aResultBaseAlgoList.push_back(aRBA); - } + storeResult(anObjects.Objects(), aTools.Objects(), aResultCompound, aResultIndex, + aMakeShapeList, aResultBaseAlgoList); } // Store deleted shapes after all results has been proceeded. This is to avoid issue when in one diff --git a/src/FeaturesPlugin/FeaturesPlugin_BooleanCut.cpp b/src/FeaturesPlugin/FeaturesPlugin_BooleanCut.cpp index cb87cb69a..07ba068f7 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_BooleanCut.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanCut.cpp @@ -118,33 +118,8 @@ void FeaturesPlugin_BooleanCut::execute() } } - GeomAPI_ShapeIterator aShapeIt(aResultCompound); - if (aShapeIt.more()) { - std::shared_ptr aResultBody = - document()->createBody(data(), aResultIndex); - - ListOfShape anObjectList = anObjects.Objects(); - ListOfShape aToolsList = aTools.Objects(); - FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, - anObjectList, - aToolsList, - aMakeShapeList, - aResultCompound); - setResult(aResultBody, aResultIndex++); - - // merge algorithms - FeaturesPlugin_Tools::ResultBaseAlgo aRBA; - aRBA.resultBody = aResultBody; - aRBA.baseShape = anObjectList.front(); - for (std::vector::iterator - aRBAIt = aResultBaseAlgoList.begin(); - aRBAIt != aResultBaseAlgoList.end(); ++aRBAIt) { - aMakeShapeList->appendAlgo(aRBAIt->makeShape); - } - aRBA.makeShape = aMakeShapeList; - aResultBaseAlgoList.clear(); - aResultBaseAlgoList.push_back(aRBA); - } + storeResult(anObjects.Objects(), aTools.Objects(), aResultCompound, aResultIndex, + aMakeShapeList, aResultBaseAlgoList); // Store deleted shapes after all results has been proceeded. This is to avoid issue when in one // result shape has been deleted, but in another it was modified or stayed. diff --git a/src/FeaturesPlugin/FeaturesPlugin_BooleanFill.cpp b/src/FeaturesPlugin/FeaturesPlugin_BooleanFill.cpp index 94630430f..08d50f6f6 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_BooleanFill.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanFill.cpp @@ -120,33 +120,8 @@ void FeaturesPlugin_BooleanFill::execute() } } - GeomAPI_ShapeIterator aShapeIt(aResultCompound); - if (aShapeIt.more()) { - std::shared_ptr aResultBody = - document()->createBody(data(), aResultIndex); - - ListOfShape anObjectList = anObjects.Objects(); - ListOfShape aToolsList = aTools.Objects(); - FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, - anObjectList, - aToolsList, - aMakeShapeList, - aResultCompound); - setResult(aResultBody, aResultIndex++); - - // merge algorithms - FeaturesPlugin_Tools::ResultBaseAlgo aRBA; - aRBA.resultBody = aResultBody; - aRBA.baseShape = anObjectList.front(); - for (std::vector::iterator - aRBAIt = aResultBaseAlgoList.begin(); - aRBAIt != aResultBaseAlgoList.end(); ++aRBAIt) { - aMakeShapeList->appendAlgo(aRBAIt->makeShape); - } - aRBA.makeShape = aMakeShapeList; - aResultBaseAlgoList.clear(); - aResultBaseAlgoList.push_back(aRBA); - } + storeResult(anObjects.Objects(), aTools.Objects(), aResultCompound, aResultIndex, + aMakeShapeList, aResultBaseAlgoList); // Store deleted shapes after all results has been proceeded. This is to avoid issue when in one // result shape has been deleted, but in another it was modified or stayed.