X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FFeaturesPlugin%2FFeaturesPlugin_Union.cpp;h=8b1a811a262f2cd5aad1b43fd13c5c9d29c0026b;hb=56281d4fef78d0d88e862b409f7dc5add01ae843;hp=2b3188ddcbd4d5f4fcc439063fa034cc734974a5;hpb=a94fc319f2aa64b43c9a73b5ff7063923648faec;p=modules%2Fshaper.git diff --git a/src/FeaturesPlugin/FeaturesPlugin_Union.cpp b/src/FeaturesPlugin/FeaturesPlugin_Union.cpp index 2b3188ddc..8b1a811a2 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Union.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Union.cpp @@ -23,8 +23,10 @@ #include #include #include +#include #include +#include #include #include @@ -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; 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); @@ -161,18 +168,24 @@ void FeaturesPlugin_Union::execute() } // 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 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); }