#include "FeaturesPlugin_CompositeBoolean.h"
#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_ResultCompSolid.h>
#include <ModelAPI_Tools.h>
#include <GeomAlgoAPI_Boolean.h>
}
//=================================================================================================
-void FeaturesPlugin_CompositeBoolean::execute()
+void FeaturesPlugin_CompositeBoolean::executeCompositeBoolean()
{
// Make generation.
ListOfShape aGenBaseShapes;
// Getting tools.
ListOfShape aTools;
- for(ListOfMakeShape::const_iterator anIt = aGenMakeShapes.cbegin(); anIt != aGenMakeShapes.cend(); ++anIt) {
+ for(ListOfMakeShape::const_iterator
+ anIt = aGenMakeShapes.cbegin(); anIt != aGenMakeShapes.cend(); ++anIt) {
aTools.push_back((*anIt)->shape());
}
int aModTag = aTag;
storeModificationHistory(aResultBody, *aBoolObjIt, aTools, *aBoolMSIt, aModTag);
+
+ myFeature->setResult(aResultBody, aResultIndex++);
}
+
+ myFeature->removeResults(aResultIndex);
}
//=================================================================================================
}
// For solids cut each object with all tools.
- for(ListOfShape::const_iterator anIt = anObjects.cbegin(); anIt != anObjects.cend(); ++anIt) {
+ for(ListOfShape::const_iterator
+ anIt = anObjects.cbegin(); anIt != anObjects.cend(); ++anIt) {
GeomShapePtr anObject = *anIt;
ListOfShape aListWithObject;
aListWithObject.push_back(anObject);
std::shared_ptr<GeomAlgoAPI_Boolean> aBoolAlgo(new GeomAlgoAPI_Boolean(aListWithObject,
- theTools,
- GeomAlgoAPI_Boolean::BOOL_CUT));
+ theTools,
+ GeomAlgoAPI_Boolean::BOOL_CUT));
// Checking that the algorithm worked properly.
if(!aBoolAlgo->isDone() || aBoolAlgo->shape()->isNull() || !aBoolAlgo->isValid()) {
return false;
}
- if(GeomAlgoAPI_ShapeTools::volume(aBoolAlgo->shape()) > 1.e-7) {
+ if(GeomAlgoAPI_ShapeTools::volume(aBoolAlgo->shape()) > 1.e-27) {
theObjects.push_back(anObject);
theMakeShapes.push_back(aBoolAlgo);
}
// Collecting solids from compsolids which will not be modified in boolean operation.
ListOfShape aShapesToAdd;
- for(GeomAPI_ShapeExplorer anExp(aCompSolid, GeomAPI_Shape::SOLID); anExp.more(); anExp.next()) {
+ for(GeomAPI_ShapeExplorer
+ anExp(aCompSolid, GeomAPI_Shape::SOLID); anExp.more(); anExp.next()) {
GeomShapePtr aSolidInCompSolid = anExp.current();
ListOfShape::const_iterator aUsedShapesIt = aUsedShapes.cbegin();
for(; aUsedShapesIt != aUsedShapes.cend(); ++aUsedShapesIt) {
}
std::shared_ptr<GeomAlgoAPI_Boolean> aBoolAlgo(new GeomAlgoAPI_Boolean(aUsedShapes,
- theTools,
- GeomAlgoAPI_Boolean::BOOL_CUT));
+ theTools,
+ GeomAlgoAPI_Boolean::BOOL_CUT));
// Checking that the algorithm worked properly.
if(!aBoolAlgo->isDone() || aBoolAlgo->shape()->isNull() || !aBoolAlgo->isValid()) {
return false;
}
- GeomAlgoAPI_MakeShapeList aMakeShapeList;
- aMakeShapeList.appendAlgo(aBoolAlgo);
+ std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
+ aMakeShapeList->appendAlgo(aBoolAlgo);
// Add result to not used solids from compsolid.
aShapesToAdd.push_back(aBoolAlgo->shape());
- std::shared_ptr<GeomAlgoAPI_PaveFiller> aFillerAlgo(new GeomAlgoAPI_PaveFiller(aShapesToAdd, true));
+ std::shared_ptr<GeomAlgoAPI_PaveFiller> aFillerAlgo(
+ new GeomAlgoAPI_PaveFiller(aShapesToAdd, true));
if(!aFillerAlgo->isDone() || aFillerAlgo->shape()->isNull() || !aFillerAlgo->isValid()) {
myFeature->setError("Error: PaveFiller algorithm failed.");
return false;
}
- aMakeShapeList.appendAlgo(aFillerAlgo);
+ aMakeShapeList->appendAlgo(aFillerAlgo);
- if(GeomAlgoAPI_ShapeTools::volume(aFillerAlgo->shape()) > 1.e-7) {
+ if(GeomAlgoAPI_ShapeTools::volume(aFillerAlgo->shape()) > 1.e-27) {
theObjects.push_back(aCompSolid);
- theMakeShapes.push_back(aBoolAlgo);
+ theMakeShapes.push_back(aMakeShapeList);
}
}
break;
// Filter edges and faces in tools.
ListOfShape aTools;
- for(ListOfShape::const_iterator anIt = aTools.cbegin(); anIt != aTools.cend(); ++anIt) {
+ for(ListOfShape::const_iterator anIt = theTools.cbegin(); anIt != theTools.cend(); ++anIt) {
if((*anIt)->shapeType() == GeomAPI_Shape::EDGE ||
(*anIt)->shapeType() == GeomAPI_Shape::FACE) {
anEdgesAndFaces.push_back(*anIt);
}
}
- if((anObjects.size() + aTools.size() + aCompSolidsObjects.size() + anEdgesAndFaces.size()) < 2) {
+ if((anObjects.size() + aTools.size() +
+ aCompSolidsObjects.size() + anEdgesAndFaces.size()) < 2) {
myFeature->setError("Error: Not enough objects for boolean operation.");
return false;
}
aSolidsToFuse.insert(aSolidsToFuse.end(), anObjects.begin(), anObjects.end());
aSolidsToFuse.insert(aSolidsToFuse.end(), aTools.begin(), aTools.end());
- // Collecting solids from compsolids which will not be modified in boolean operation and will be added to result.
+ // Collecting solids from compsolids which will not be
+ // modified in boolean operation and will be added to result.
ListOfShape aShapesToAdd;
for(std::map<GeomShapePtr, ListOfShape>::iterator anIt = aCompSolidsObjects.begin();
anIt != aCompSolidsObjects.end(); anIt++) {
aSolidsToFuse.insert(aSolidsToFuse.end(), aUsedShapes.begin(), aUsedShapes.end());
// Collect solids from compsolid which will not be modified in boolean operation.
- for(GeomAPI_ShapeExplorer anExp(aCompSolid, GeomAPI_Shape::SOLID); anExp.more(); anExp.next()) {
+ for(GeomAPI_ShapeExplorer
+ anExp(aCompSolid, GeomAPI_Shape::SOLID); anExp.more(); anExp.next()) {
GeomShapePtr aSolidInCompSolid = anExp.current();
ListOfShape::iterator anIt = aUsedShapes.begin();
for(; anIt != aUsedShapes.end(); anIt++) {
aCutTools.insert(aCutTools.end(), aCompSolids.begin(), aCompSolids.end());
aCutTools.insert(aCutTools.end(), aTools.begin(), aTools.end());
- GeomAlgoAPI_MakeShapeList aMakeShapeList;
+ std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
if(!anEdgesAndFaces.empty() && !aCutTools.empty()) {
std::shared_ptr<GeomAlgoAPI_Boolean> aCutAlgo(new GeomAlgoAPI_Boolean(anEdgesAndFaces,
- aCutTools,
- GeomAlgoAPI_Boolean::BOOL_CUT));
+ aCutTools,
+ GeomAlgoAPI_Boolean::BOOL_CUT));
if(aCutAlgo->isDone() && !aCutAlgo->shape()->isNull() && aCutAlgo->isValid()) {
anEdgesAndFaces.clear();
anEdgesAndFaces.push_back(aCutAlgo->shape());
- aMakeShapeList.appendAlgo(aCutAlgo);
+ aMakeShapeList->appendAlgo(aCutAlgo);
}
}
// If we have compsolids then cut with not used solids all others.
if(!aShapesToAdd.empty()) {
std::shared_ptr<GeomAlgoAPI_Boolean> aCutAlgo(new GeomAlgoAPI_Boolean(aSolidsToFuse,
- aShapesToAdd,
- GeomAlgoAPI_Boolean::BOOL_CUT));
- if(aCutAlgo->isDone() && GeomAlgoAPI_ShapeTools::volume(aCutAlgo->shape()) > 1.e-7) {
+ aShapesToAdd,
+ GeomAlgoAPI_Boolean::BOOL_CUT));
+ if(aCutAlgo->isDone() && GeomAlgoAPI_ShapeTools::volume(aCutAlgo->shape()) > 1.e-27) {
aSolidsToFuse.clear();
aSolidsToFuse.push_back(aCutAlgo->shape());
- aMakeShapeList.appendAlgo(aCutAlgo);
+ aMakeShapeList->appendAlgo(aCutAlgo);
}
}
aTools = aSolidsToFuse;
std::shared_ptr<GeomAlgoAPI_Boolean> aFuseAlgo(new GeomAlgoAPI_Boolean(anObjects,
- aTools,
- GeomAlgoAPI_Boolean::BOOL_FUSE));
+ aTools,
+ GeomAlgoAPI_Boolean::BOOL_FUSE));
// Checking that the algorithm worked properly.
if(!aFuseAlgo->isDone() || aFuseAlgo->shape()->isNull() || !aFuseAlgo->isValid()) {
}
aFusedShape = aFuseAlgo->shape();
- aMakeShapeList.appendAlgo(aFuseAlgo);
+ aMakeShapeList->appendAlgo(aFuseAlgo);
}
// Combine result with not used solids from compsolid and edges and faces (if we have any).
aShapesToAdd.push_back(aFusedShape);
}
- std::shared_ptr<GeomAlgoAPI_PaveFiller> aFillerAlgo(new GeomAlgoAPI_PaveFiller(aShapesToAdd, true));
+ std::shared_ptr<GeomAlgoAPI_PaveFiller> aFillerAlgo(
+ new GeomAlgoAPI_PaveFiller(aShapesToAdd, true));
if(!aFillerAlgo->isDone() || aFillerAlgo->shape()->isNull() || !aFillerAlgo->isValid()) {
myFeature->setError("Error: PaveFiller algorithm failed.");
return false;
}
- aMakeShapeList.appendAlgo(aFillerAlgo);
+ aMakeShapeList->appendAlgo(aFillerAlgo);
}
+
+ theMakeShapes.push_back(aMakeShapeList);
break;
}
}
aTag = aModTag;
aName = aModName;
}
- theResultBody->loadAndOrientModifiedShapes(theMakeShape.get(), *anIt, (*anIt)->shapeType() == GeomAPI_Shape::EDGE ?
- GeomAPI_Shape::EDGE : GeomAPI_Shape::FACE, aTag, aName, *aMap.get());
+ theResultBody->loadAndOrientModifiedShapes(theMakeShape.get(), *anIt,
+ (*anIt)->shapeType() == GeomAPI_Shape::EDGE ?
+ GeomAPI_Shape::EDGE : GeomAPI_Shape::FACE, aTag, aName, *aMap.get());
theResultBody->loadDeletedShapes(theMakeShape.get(), *anIt, GeomAPI_Shape::FACE, aDelTag);
}
}