return aResultShape;
}
+//=================================================================================================
+void FeaturesPlugin_Boolean::storeResult(
+ const ListOfShape& theObjects,
+ const ListOfShape& theTools,
+ const GeomShapePtr theResultShape,
+ int& theResultIndex,
+ std::shared_ptr<GeomAlgoAPI_MakeShapeList> theMakeShapeList,
+ std::vector<FeaturesPlugin_Tools::ResultBaseAlgo>& theResultBaseAlgoList)
+{
+ if (!theResultShape)
+ return;
+
+ std::shared_ptr<ModelAPI_ResultBody> 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<FeaturesPlugin_Tools::ResultBaseAlgo>::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()
{
const ObjectHierarchy& theToolsHierarchy,
std::shared_ptr<GeomAlgoAPI_MakeShapeList> 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<GeomAlgoAPI_MakeShapeList> theMakeShapeList,
+ std::vector<FeaturesPlugin_Tools::ResultBaseAlgo>& theResultBaseAlgoList);
+
/// Return version of the feature
int version();
}
}
- GeomAPI_ShapeIterator aShapeIt(aResultCompound);
- if (aShapeIt.more()) {
- std::shared_ptr<ModelAPI_ResultBody> 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<FeaturesPlugin_Tools::ResultBaseAlgo>::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
}
}
- GeomAPI_ShapeIterator aShapeIt(aResultCompound);
- if (aShapeIt.more()) {
- std::shared_ptr<ModelAPI_ResultBody> 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<FeaturesPlugin_Tools::ResultBaseAlgo>::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.
}
}
- GeomAPI_ShapeIterator aShapeIt(aResultCompound);
- if (aShapeIt.more()) {
- std::shared_ptr<ModelAPI_ResultBody> 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<FeaturesPlugin_Tools::ResultBaseAlgo>::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.