#include "FeaturesPlugin_BooleanCommon.h"
#include <ModelAPI_ResultBody.h>
+#include <ModelAPI_AttributeInteger.h>
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_AttributeString.h>
+#include <ModelAPI_Session.h>
#include <ModelAPI_Tools.h>
+#include <ModelAPI_Validator.h>
#include <GeomAlgoAPI_Boolean.h>
#include <GeomAlgoAPI_MakeShapeCustom.h>
#include <GeomAlgoAPI_CompoundBuilder.h>
#include <GeomAlgoAPI_Tools.h>
-
//==================================================================================================
FeaturesPlugin_BooleanCommon::FeaturesPlugin_BooleanCommon()
: FeaturesPlugin_Boolean(FeaturesPlugin_Boolean::BOOL_COMMON)
data()->addAttribute(OBJECT_LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
data()->addAttribute(TOOL_LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
+
+ initVersion(THE_VERSION_1, selectionList(OBJECT_LIST_ID()), selectionList(TOOL_LIST_ID()));
}
//==================================================================================================
void FeaturesPlugin_BooleanCommon::execute()
{
- ListOfShape aPlanes, anEdgesAndFaces;
+ ListOfShape aPlanes;
ObjectHierarchy anObjects, aTools;
bool isSimpleMode = false;
}
// Getting objects.
- if (!processAttribute(OBJECT_LIST_ID(), anObjects, aPlanes, anEdgesAndFaces))
+ if (!processAttribute(OBJECT_LIST_ID(), anObjects, aPlanes))
return;
// Planes are not supported as objects of COMMON operation
aPlanes.clear();
// Getting tools.
if (!isSimpleMode &&
- !processAttribute(TOOL_LIST_ID(), aTools, aPlanes, anEdgesAndFaces))
+ !processAttribute(TOOL_LIST_ID(), aTools, aPlanes))
return;
if (anObjects.IsEmpty() || (!isSimpleMode && aTools.IsEmpty() && aPlanes.empty())) {
return;
}
+ // version of COMMON feature
+ int aCommonVersion = version();
+
int aResultIndex = 0;
+ GeomShapePtr aResultCompound;
+
std::string anError;
std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
std::vector<FeaturesPlugin_Tools::ResultBaseAlgo> aResultBaseAlgoList;
aMakeShapeList->appendAlgo(aCommonAlgo);
}
+ if (aCommonVersion == THE_VERSION_1) {
+ // merge hierarchies of compounds containing objects and tools
+ // and append the result of the FUSE operation
+ aShape = keepUnusedSubsOfCompound(aShape, anObjects, aTools, aMakeShapeList);
+ }
+
GeomAPI_ShapeIterator aShapeIt(aShape);
if (aShapeIt.more() || aShape->shapeType() == GeomAPI_Shape::VERTEX) {
std::shared_ptr<ModelAPI_ResultBody> aResultBody =
aResultShapesList.push_back(aShape);
}
} else {
+ if (aCommonVersion == THE_VERSION_1) {
+ // merge hierarchies of compounds containing objects and tools
+ aResultCompound =
+ keepUnusedSubsOfCompound(GeomShapePtr(), anObjects, aTools, aMakeShapeList);
+ }
+
bool isOk = true;
for (ObjectHierarchy::Iterator anObjectsIt = anObjects.Begin();
anObjectsIt != anObjects.End() && isOk;
// Compound handling
isOk = processCompound(GeomAlgoAPI_Tools::BOOL_COMMON,
anObjects, aParent, aTools.Objects(),
- aResultIndex, aResultBaseAlgoList, aResultShapesList);
+ aResultIndex, aResultBaseAlgoList, aResultShapesList,
+ aResultCompound);
}
else if (aShapeType == GeomAPI_Shape::COMPSOLID) {
// Compsolid handling
isOk = processCompsolid(GeomAlgoAPI_Tools::BOOL_COMMON,
anObjects, aParent, aTools.Objects(), ListOfShape(),
- aResultIndex, aResultBaseAlgoList, aResultShapesList);
+ aResultIndex, aResultBaseAlgoList, aResultShapesList,
+ aResultCompound);
}
} else {
// process object as is
isOk = processObject(GeomAlgoAPI_Tools::BOOL_COMMON,
anObject, aTools.Objects(), aPlanes,
- aResultIndex, aResultBaseAlgoList, aResultShapesList);
+ aResultIndex, aResultBaseAlgoList, aResultShapesList,
+ aResultCompound);
}
}
+
+ 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.
- GeomShapePtr aResultShapesCompound = GeomAlgoAPI_CompoundBuilder::compound(aResultShapesList);
+ if (!aResultCompound)
+ aResultCompound = GeomAlgoAPI_CompoundBuilder::compound(aResultShapesList);
FeaturesPlugin_Tools::loadDeletedShapes(aResultBaseAlgoList,
aTools.Objects(),
- aResultShapesCompound);
+ aResultCompound);
// remove the rest results if there were produced in the previous pass
removeResults(aResultIndex);