X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FFeaturesPlugin%2FFeaturesPlugin_Union.cpp;h=e9cbaee7de9a13a1aaa3a2d56001da00a5becfaf;hb=e6b01eef5f1645c2dc24f089d9aa3936c7da389a;hp=2b3188ddcbd4d5f4fcc439063fa034cc734974a5;hpb=a94fc319f2aa64b43c9a73b5ff7063923648faec;p=modules%2Fshaper.git diff --git a/src/FeaturesPlugin/FeaturesPlugin_Union.cpp b/src/FeaturesPlugin/FeaturesPlugin_Union.cpp index 2b3188ddc..e9cbaee7d 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Union.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Union.cpp @@ -23,11 +23,13 @@ #include #include #include +#include #include +#include #include -#include +#include #include //================================================================================================= @@ -57,7 +59,7 @@ void FeaturesPlugin_Union::execute() return; } ResultPtr aContext = anObjectAttr->context(); - ResultCompSolidPtr aResCompSolidPtr = ModelAPI_Tools::compSolidOwner(aContext); + ResultBodyPtr aResCompSolidPtr = ModelAPI_Tools::bodyOwner(aContext); if(aResCompSolidPtr.get()) { std::shared_ptr aContextShape = aResCompSolidPtr->shape(); std::map, ListOfShape>::iterator @@ -87,7 +89,7 @@ void FeaturesPlugin_Union::execute() 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 aSolidInCompSolid = anExp.current(); ListOfShape::iterator anIt = aUsedInOperationSolids.begin(); for(; anIt != aUsedInOperationSolids.end(); anIt++) { @@ -107,31 +109,36 @@ void FeaturesPlugin_Union::execute() } // Fuse objects. + std::shared_ptr anAlgo; ListOfShape aTools; - aTools.splice(aTools.begin(), anObjects, anObjects.begin()); - std::shared_ptr 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; + std::shared_ptr aMakeShapeList(new GeomAlgoAPI_MakeShapeList()); 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); @@ -156,24 +163,20 @@ void FeaturesPlugin_Union::execute() } aShape = aFillerAlgo->shape(); - aMakeShapeList.appendAlgo(aFillerAlgo); + aMakeShapeList->appendAlgo(aFillerAlgo); aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes()); } + // workaround: make copy to name edges correctly // 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"; std::shared_ptr aResultBody = document()->createBody(data()); - aResultBody->storeModified(anObjects.front(), aShape, aSubsolidsTag); + aResultBody->storeModified(anObjects.front(), aShape); for(ListOfShape::const_iterator anIter = anObjects.begin(); anIter != anObjects.end(); ++anIter) { - aResultBody->loadAndOrientModifiedShapes(&aMakeShapeList, *anIter, GeomAPI_Shape::FACE, - aModifyTag, aModName, aMapOfShapes); - aResultBody->loadDeletedShapes(&aMakeShapeList, *anIter, GeomAPI_Shape::FACE, aDeletedTag); + aResultBody->loadModifiedShapes(aMakeShapeList, *anIter, GeomAPI_Shape::EDGE); + aResultBody->loadModifiedShapes(aMakeShapeList, *anIter, GeomAPI_Shape::FACE); + //aResultBody->loadDeletedShapes(&aMakeShapeList, *anIter, GeomAPI_Shape::FACE, aDeletedTag); } setResult(aResultBody);