#include "FeaturesPlugin_CompositeBoolean.h"
#include <ModelAPI_AttributeSelectionList.h>
-#include <ModelAPI_ResultCompSolid.h>
#include <ModelAPI_Tools.h>
#include <GeomAlgoAPI_Boolean.h>
+#include <GeomAlgoAPI_CompoundBuilder.h>
#include <GeomAlgoAPI_MakeShapeList.h>
#include <GeomAlgoAPI_PaveFiller.h>
#include <GeomAlgoAPI_ShapeTools.h>
// Store result.
int aResultIndex = 0;
+ std::vector<ResultBaseAlgo> aResultBaseAlgoList;
+ ListOfShape aResultShapesList;
ListOfShape::const_iterator aBoolObjIt = aBooleanObjects.cbegin();
ListOfMakeShape::const_iterator aBoolMSIt = aBooleanMakeShapes.cbegin();
for(; aBoolObjIt != aBooleanObjects.cend() && aBoolMSIt != aBooleanMakeShapes.cend();
int aTag = 1;
ResultBodyPtr aResultBody = myFeature->document()->createBody(myFeature->data(), aResultIndex);
- aResultBody->storeModified(*aBoolObjIt, (*aBoolMSIt)->shape(), aTag);
- aTag += 5000;
-
- // Store generation history.
- ListOfShape::const_iterator aGenBaseIt = aGenBaseShapes.cbegin();
- ListOfMakeShape::const_iterator aGenMSIt = aGenMakeShapes.cbegin();
- for(; aGenBaseIt != aGenBaseShapes.cend() && aGenMSIt != aGenMakeShapes.cend();
- ++aGenBaseIt, ++aGenMSIt) {
- storeGenerationHistory(aResultBody, *aGenBaseIt, *aGenMSIt, aTag);
+ if((*aBoolObjIt)->isEqual((*aBoolMSIt)->shape())) {
+ aResultBody->store((*aBoolMSIt)->shape(), false);
}
+ else
+ {
+ aResultBody->storeModified(*aBoolObjIt, (*aBoolMSIt)->shape());
+
+ aTag += 5000;
+
+ // Store generation history.
+ ListOfShape::const_iterator aGenBaseIt = aGenBaseShapes.cbegin();
+ ListOfMakeShape::const_iterator aGenMSIt = aGenMakeShapes.cbegin();
+ for(; aGenBaseIt != aGenBaseShapes.cend() && aGenMSIt != aGenMakeShapes.cend();
+ ++aGenBaseIt, ++aGenMSIt) {
+ storeGenerationHistory(aResultBody, *aGenBaseIt, *aGenMSIt);
+ }
- int aModTag = aTag;
- storeModificationHistory(aResultBody, *aBoolObjIt, aTools, *aBoolMSIt, aModTag);
+ storeModificationHistory(aResultBody, *aBoolObjIt, aTools, *aBoolMSIt);
+
+ ResultBaseAlgo aRBA;
+ aRBA.resultBody = aResultBody;
+ aRBA.baseShape = *aBoolObjIt;
+ aRBA.makeShape = *aBoolMSIt;
+ aResultBaseAlgoList.push_back(aRBA);
+ aResultShapesList.push_back((*aBoolMSIt)->shape());
+ }
myFeature->setResult(aResultBody, aResultIndex++);
}
+ // 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.
+ GeomShapePtr aResultShapesCompound = GeomAlgoAPI_CompoundBuilder::compound(aResultShapesList);
+ storeDeletedShapes(aResultBaseAlgoList, aTools, aResultShapesCompound);
+
myFeature->removeResults(aResultIndex);
}
return false;
}
ResultPtr aContext = anObjectAttr->context();
- ResultCompSolidPtr aResCompSolidPtr = ModelAPI_Tools::compSolidOwner(aContext);
+ ResultBodyPtr aResCompSolidPtr = ModelAPI_Tools::bodyOwner(aContext);
if(aResCompSolidPtr.get()) {
GeomShapePtr aContextShape = aResCompSolidPtr->shape();
std::map<GeomShapePtr, ListOfShape>::iterator anIt = aCompSolidsObjects.begin();
void FeaturesPlugin_CompositeBoolean::storeModificationHistory(ResultBodyPtr theResultBody,
const GeomShapePtr theObject,
const ListOfShape& theTools,
- const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape,
- int& theTag)
+ const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape)
{
- int aModTag = theTag;
- int anEdgesAndFacesTag = ++aModTag;
- int aDelTag = ++anEdgesAndFacesTag;
- theTag = aDelTag;
-
- const std::string aModName = "Modfied";
-
ListOfShape aTools = theTools;
aTools.push_back(theObject);
- std::shared_ptr<GeomAPI_DataMapOfShapeShape> aMap = theMakeShape->mapOfSubShapes();
-
- int aTag;
std::string aName;
for(ListOfShape::const_iterator anIt = aTools.begin(); anIt != aTools.end(); anIt++) {
- if((*anIt)->shapeType() == GeomAPI_Shape::EDGE) {
- aTag = anEdgesAndFacesTag;
- aName = aModName + "_Edge";
- }
- else if((*anIt)->shapeType() == GeomAPI_Shape::FACE) {
- aTag = anEdgesAndFacesTag;
- aName = aModName + "_Face";
- } else {
- aTag = aModTag;
- aName = aModName;
+ theResultBody->loadModifiedShapes(theMakeShape, *anIt,
+ (*anIt)->shapeType() == GeomAPI_Shape::EDGE ?
+ GeomAPI_Shape::EDGE :
+ GeomAPI_Shape::FACE);
+ }
+}
+
+//==================================================================================================
+void FeaturesPlugin_CompositeBoolean::storeDeletedShapes(
+ std::vector<ResultBaseAlgo>& theResultBaseAlgoList,
+ const ListOfShape& theTools,
+ const GeomShapePtr theResultShapesCompound)
+{
+ for (std::vector<ResultBaseAlgo>::iterator anIt = theResultBaseAlgoList.begin();
+ anIt != theResultBaseAlgoList.end();
+ ++anIt)
+ {
+ ResultBaseAlgo& aRCA = *anIt;
+ aRCA.resultBody->loadDeletedShapes(aRCA.makeShape,
+ aRCA.baseShape,
+ GeomAPI_Shape::FACE,
+ theResultShapesCompound);
+
+ for (ListOfShape::const_iterator anIter = theTools.begin(); anIter != theTools.end(); anIter++)
+ {
+ aRCA.resultBody->loadDeletedShapes(aRCA.makeShape,
+ *anIter,
+ GeomAPI_Shape::FACE,
+ theResultShapesCompound);
}
- theResultBody->loadAndOrientModifiedShapes(theMakeShape.get(), *anIt,
- (*anIt)->shapeType() == GeomAPI_Shape::EDGE ?
- GeomAPI_Shape::EDGE : GeomAPI_Shape::FACE, aTag, aName, *aMap.get(), false, false, true);
- theResultBody->loadDeletedShapes(theMakeShape.get(), *anIt, GeomAPI_Shape::FACE, aDelTag);
}
}