- GeomShapePtr aResShape = getSingleSubshape(aVolumeMaker->shape(), GeomAPI_Shape::SOLID);
- int anIndex = 0;
- if (aResShape) {
- storeResult(anOriginalShapes, aResShape, aVolumeMaker);
- ++anIndex;
- }
- removeResults(anIndex);
-}
-
-//=================================================================================================
-bool BuildPlugin_Solid::build(ListOfShape& theOriginalShapes,
- std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgorithm)
-{
- // Get base objects list.
- AttributeSelectionListPtr aSelectionList = selectionList(BASE_OBJECTS_ID());
- if (!aSelectionList.get()) {
- setError("Error: Could not get selection list.");
- return false;
- }
- if (aSelectionList->size() == 0) {
- setError("Error: Empty selection list.");
- return false;
- }
-
- // Collect base shapes.
- for (int anIndex = 0; anIndex < aSelectionList->size(); ++anIndex) {
- AttributeSelectionPtr aSelection = aSelectionList->value(anIndex);
- GeomShapePtr aShape = aSelection->value();
- if (!aShape.get())
- aShape = aSelection->context()->shape();
- theOriginalShapes.push_back(aShape);
- }
-
- theAlgorithm =
- std::shared_ptr<GeomAlgoAPI_MakeVolume>(new GeomAlgoAPI_MakeVolume(theOriginalShapes));
- return !isAlgorithmFailed(theAlgorithm);
-}
-
-void BuildPlugin_Solid::storeResult(const ListOfShape& theOriginalShapes,
- const GeomShapePtr& theResultShape,
- const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgorithm)
-{
- ResultBodyPtr aResultBody = document()->createBody(data());
- aResultBody->store(theResultShape);
-
- // Store faces
- std::shared_ptr<GeomAPI_DataMapOfShapeShape> aMapOfSubs = theAlgorithm->mapOfSubShapes();
- int aModifiedTag = 1;
- for(ListOfShape::const_iterator anIt = theOriginalShapes.cbegin();
- anIt != theOriginalShapes.cend(); ++anIt) {
- GeomShapePtr aShape = *anIt;
- aResultBody->loadAndOrientModifiedShapes(theAlgorithm.get(), aShape, GeomAPI_Shape::FACE,
- aModifiedTag, "Modified_Face", *aMapOfSubs.get(), false, true, true);
- }
-
- setResult(aResultBody);