#include <ModelAPI_Document.h>
#include <ModelAPI_AttributeReference.h>
#include <ModelAPI_AttributeInteger.h>
-#include <ModelAPI_ResultCompSolid.h>
#include <ModelAPI_ResultBody.h>
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_Session.h>
#include <map>
//=================================================================================================
-FeaturesPlugin_Boolean::FeaturesPlugin_Boolean()
+FeaturesPlugin_Boolean::FeaturesPlugin_Boolean(const OperationType theOperationType)
+: myOperationType(theOperationType)
{
}
//=================================================================================================
void FeaturesPlugin_Boolean::initAttributes()
{
- data()->addAttribute(FeaturesPlugin_Boolean::TYPE_ID(), ModelAPI_AttributeInteger::typeId());
-
AttributeSelectionListPtr aSelection =
std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(data()->addAttribute(
FeaturesPlugin_Boolean::OBJECT_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()));
}
//=================================================================================================
-void FeaturesPlugin_Boolean::execute()
+FeaturesPlugin_Boolean::OperationType FeaturesPlugin_Boolean::operationType()
{
- // Getting operation type.
- std::shared_ptr<ModelAPI_AttributeInteger> aTypeAttr = std::dynamic_pointer_cast<
- ModelAPI_AttributeInteger>(data()->attribute(FeaturesPlugin_Boolean::TYPE_ID()));
- if (!aTypeAttr)
- return;
- OperationType aType = (FeaturesPlugin_Boolean::OperationType)aTypeAttr->value();
+ return myOperationType;
+}
+//=================================================================================================
+void FeaturesPlugin_Boolean::execute()
+{
ListOfShape anObjects, aTools, anEdgesAndFaces, aPlanes;
std::map<std::shared_ptr<GeomAPI_Shape>, ListOfShape> aCompSolidsObjects;
return;
}
ResultPtr aContext = anObjectAttr->context();
- ResultCompSolidPtr aResCompSolidPtr = ModelAPI_Tools::compSolidOwner(aContext);
+ ResultBodyPtr aResCompSolidPtr = ModelAPI_Tools::bodyOwner(aContext);
if(aResCompSolidPtr.get()
&& aResCompSolidPtr->shape()->shapeType() == GeomAPI_Shape::COMPSOLID) {
std::shared_ptr<GeomAPI_Shape> aContextShape = aResCompSolidPtr->shape();
aCompSolidsObjects[aContextShape].push_back(anObject);
}
} else {
- if(aType != BOOL_FILL
+ if(myOperationType != BOOL_FILL
&& (anObject->shapeType() == GeomAPI_Shape::EDGE
|| anObject->shapeType() == GeomAPI_Shape::FACE))
{
ResultPtr aContext = aToolAttr->context();
aPlanes.push_back(aToolAttr->context()->shape());
}
- else if(aType != BOOL_FILL
+ else if (myOperationType != BOOL_FILL
&& (aTool->shapeType() == GeomAPI_Shape::EDGE
|| aTool->shapeType() == GeomAPI_Shape::FACE))
{
int aResultIndex = 0;
- switch(aType) {
+ switch(myOperationType) {
case BOOL_CUT:
case BOOL_COMMON:
case BOOL_FILL: {
std::shared_ptr<GeomAlgoAPI_MakeShape> aBoolAlgo;
GeomShapePtr aResShape;
- switch(aType) {
+ switch(myOperationType) {
case BOOL_CUT: {
aBoolAlgo.reset(new GeomAlgoAPI_Boolean(aListWithObject,
aTools,
aBoolAlgo.reset(new GeomAlgoAPI_Partition(aListWithObject, aToolsWithPlanes));
aResShape = aBoolAlgo->shape();
- if(aResShape->shapeType() == GeomAPI_Shape::COMPOUND) {
+ if (aResShape.get() && aResShape->shapeType() == GeomAPI_Shape::COMPOUND) {
int aSubResultsNb = 0;
GeomAPI_ShapeIterator anIt(aResShape);
for(; anIt.more(); anIt.next()) {
aMakeShapeList.appendAlgo(aBoolAlgo);
if(GeomAlgoAPI_ShapeTools::volume(aResShape) > 1.e-27
- || (aType != BOOL_CUT && aType != BOOL_COMMON))
+ || (myOperationType != BOOL_CUT && myOperationType != BOOL_COMMON))
{
std::shared_ptr<ModelAPI_ResultBody> aResultBody =
document()->createBody(data(), aResultIndex);
ListOfShape aUsedTools = aTools;
- if (aType == BOOL_FILL) {
+ if (myOperationType == BOOL_FILL) {
aUsedTools.insert(aUsedTools.end(), aPlanes.begin(), aPlanes.end());
}
loadNamingDS(aResultBody, anObject, aUsedTools, aResShape,
- aMakeShapeList, *(aBoolAlgo->mapOfSubShapes()), aType == BOOL_FILL);
+ aMakeShapeList, *(aBoolAlgo->mapOfSubShapes()),
+ myOperationType == BOOL_FILL);
setResult(aResultBody, aResultIndex);
aResultIndex++;
}
GeomAlgoAPI_MakeShapeList aMakeShapeList;
std::shared_ptr<GeomAlgoAPI_MakeShape> aBoolAlgo;
- switch(aType) {
+ switch(myOperationType) {
case BOOL_CUT: {
aBoolAlgo.reset(new GeomAlgoAPI_Boolean(aUsedInOperationSolids,
aTools,
}
if(GeomAlgoAPI_ShapeTools::volume(aResultShape) > 1.e-27
- || (aType != BOOL_CUT && aType != BOOL_COMMON))
+ || (myOperationType != BOOL_CUT && myOperationType != BOOL_COMMON))
{
std::shared_ptr<ModelAPI_ResultBody> aResultBody =
document()->createBody(data(), aResultIndex);
ListOfShape aUsedTools = aTools;
- if (aType == BOOL_FILL) {
+ if (myOperationType == BOOL_FILL) {
aUsedTools.insert(aUsedTools.end(), aPlanes.begin(), aPlanes.end());
}
aResultShape,
aMakeShapeList,
aMapOfShapes,
- aType == BOOL_FILL);
+ myOperationType == BOOL_FILL);
setResult(aResultBody, aResultIndex);
aResultIndex++;
}