#include <GeomAlgoAPI_Boolean.h>
#include <GeomAlgoAPI_MakeShapeList.h>
#include <GeomAlgoAPI_PaveFiller.h>
+#include <GeomAlgoAPI_UnifySameDomain.h>
#include <GeomAPI_ShapeExplorer.h>
+#include <GeomAPI_ShapeIterator.h>
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_ResultCompSolid.h>
anObjects.insert(anObjects.end(), aUsedInOperationSolids.begin(), aUsedInOperationSolids.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_ShapeIterator anExp(aCompSolid); anExp.more(); anExp.next()) {
std::shared_ptr<GeomAPI_Shape> aSolidInCompSolid = anExp.current();
ListOfShape::iterator anIt = aUsedInOperationSolids.begin();
for(; anIt != aUsedInOperationSolids.end(); anIt++) {
}
// Fuse objects.
+ std::shared_ptr<GeomAlgoAPI_MakeShape> anAlgo;
ListOfShape aTools;
- aTools.splice(aTools.begin(), anObjects, anObjects.begin());
- std::shared_ptr<GeomAlgoAPI_Boolean> aFuseAlgo(new GeomAlgoAPI_Boolean(anObjects,
- aTools,
- GeomAlgoAPI_Boolean::BOOL_FUSE));
+ if (anObjects.front()->shapeType() == GeomAPI_Shape::SOLID) {
+ aTools.splice(aTools.begin(), anObjects, anObjects.begin());
+ anAlgo.reset(new GeomAlgoAPI_Boolean(anObjects,
+ aTools,
+ GeomAlgoAPI_Boolean::BOOL_FUSE));
+ } else {
+ anAlgo.reset(new GeomAlgoAPI_UnifySameDomain(anObjects));
+ }
// Checking that the algorithm worked properly.
GeomAlgoAPI_MakeShapeList aMakeShapeList;
GeomAPI_DataMapOfShapeShape aMapOfShapes;
- if(!aFuseAlgo->isDone()) {
+ if(!anAlgo->isDone()) {
setError("Error: Boolean algorithm failed.");
return;
}
- if(aFuseAlgo->shape()->isNull()) {
+ if(anAlgo->shape()->isNull()) {
setError("Error: Resulting shape is Null.");
return;
}
- if(!aFuseAlgo->isValid()) {
+ if(!anAlgo->isValid()) {
setError("Error: Resulting shape is not valid.");
return;
}
- GeomShapePtr aShape = aFuseAlgo->shape();
- aMakeShapeList.appendAlgo(aFuseAlgo);
- aMapOfShapes.merge(aFuseAlgo->mapOfSubShapes());
+ GeomShapePtr aShape = anAlgo->shape();
+ aMakeShapeList.appendAlgo(anAlgo);
+ aMapOfShapes.merge(anAlgo->mapOfSubShapes());
// Store original shapes for naming.
anObjects.splice(anObjects.begin(), aTools);
}
// Store result and naming.
- const int aModifyTag = 1;
- const int aDeletedTag = 2;
- /// sub solids will be placed at labels 3, 4, etc. if result is compound of solids
- const int aSubsolidsTag = 3;
- const std::string aModName = "Modified";
+ const int aModifyEdgeTag = 1;
+ const int aModifyFaceTag = 2;
+ const int aDeletedTag = 3;
+ /// sub solids will be placed at labels 4, 5 etc. if result is compound of solids
+ const int aSubsolidsTag = 4;
+ const std::string aModEName = "Modified_Edge";
+ const std::string aModFName = "Modified_Face";
std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data());
aResultBody->storeModified(anObjects.front(), aShape, aSubsolidsTag);
for(ListOfShape::const_iterator anIter = anObjects.begin(); anIter != anObjects.end(); ++anIter) {
+ aResultBody->loadAndOrientModifiedShapes(&aMakeShapeList, *anIter, GeomAPI_Shape::EDGE,
+ aModifyEdgeTag, aModEName, aMapOfShapes,
+ false, false, true);
aResultBody->loadAndOrientModifiedShapes(&aMakeShapeList, *anIter, GeomAPI_Shape::FACE,
- aModifyTag, aModName, aMapOfShapes);
+ aModifyFaceTag, aModFName, aMapOfShapes,
+ false, false, true);
aResultBody->loadDeletedShapes(&aMakeShapeList, *anIter, GeomAPI_Shape::FACE, aDeletedTag);
}