X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FFeaturesPlugin%2FFeaturesPlugin_Revolution.cpp;h=6d2c233d604891801e1e9e94fe594f9e03b369ea;hb=5a4405dc843479d921b53b83c181cbe9359414fe;hp=52b00ffc1400fed5daded1ef1031e172995f6f09;hpb=8fbee802bd4c0e7c7e2a1d23e4b800174373f932;p=modules%2Fshaper.git diff --git a/src/FeaturesPlugin/FeaturesPlugin_Revolution.cpp b/src/FeaturesPlugin/FeaturesPlugin_Revolution.cpp index 52b00ffc1..6d2c233d6 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Revolution.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Revolution.cpp @@ -4,7 +4,7 @@ // Created: 12 May 2015 // Author: Dmitry Bobylev -#include +#include "FeaturesPlugin_Revolution.h" #include #include @@ -58,34 +58,26 @@ void FeaturesPlugin_Revolution::execute() ListOfShape aFacesList; AttributeSelectionListPtr aFacesSelectionList = selectionList(LIST_ID()); for(int anIndex = 0; anIndex < aFacesSelectionList->size(); anIndex++) { - std::shared_ptr aFaceSel = aFacesSelectionList->value(anIndex); - ResultPtr aContext = aFaceSel->context(); - std::shared_ptr aContextShape = aContext->shape(); - if(!aContextShape.get()) { - static const std::string aContextError = "The selection context is bad"; - setError(aContextError); - break; - } - + AttributeSelectionPtr aFaceSel = aFacesSelectionList->value(anIndex); std::shared_ptr aFaceShape = aFaceSel->value(); - int aFacesNum = -1; // this mean that "aFace" is used - ResultConstructionPtr aConstruction = - std::dynamic_pointer_cast(aContext); - if(!aFaceShape.get()) { // this may be the whole sketch result selected, check and get faces - if (aConstruction.get()) { - aFacesNum = aConstruction->facesNum(); - } else { + if(aFaceShape.get() && !aFaceShape->isNull()) { // Getting face. + aFacesList.push_back(aFaceShape); + } else { // This may be the whole sketch result selected, check and get faces. + ResultPtr aContext = aFaceSel->context(); + std::shared_ptr aContextShape = aContext->shape(); + if(!aContextShape.get()) { + static const std::string aContextError = "The selection context is bad"; + setError(aContextError); + return; + } + ResultConstructionPtr aConstruction = std::dynamic_pointer_cast(aContext); + if(!aConstruction.get()) { static const std::string aFaceError = "Can not find basis for revolution"; setError(aFaceError); - break; + return; } - } - for(int aFaceIndex = 0; aFaceIndex < aFacesNum || aFacesNum == -1; aFaceIndex++) { - std::shared_ptr aBaseShape; - if (aFacesNum == -1) { - aFacesList.push_back(aFaceShape); - break; - } else { + int aFacesNum = aConstruction->facesNum(); + for(int aFaceIndex = 0; aFaceIndex < aFacesNum || aFacesNum == -1; aFaceIndex++) { aFaceShape = std::dynamic_pointer_cast(aConstruction->face(aFaceIndex)); aFacesList.push_back(aFaceShape); } @@ -143,11 +135,7 @@ void FeaturesPlugin_Revolution::execute() ListOfShape aFreeFaces; std::shared_ptr aFacesCompound = GeomAlgoAPI_CompoundBuilder::compound(aFacesList); GeomAlgoAPI_ShapeTools::combineShapes(aFacesCompound, GeomAPI_Shape::SHELL, aShells, aFreeFaces); - if(aShells.empty()) { - aShells = aFreeFaces; - } else { - aShells.merge(aFreeFaces); - } + aShells.insert(aShells.end(), aFreeFaces.begin(), aFreeFaces.end()); // Generating result for each shell and face. int aResultIndex = 0; @@ -193,34 +181,34 @@ void FeaturesPlugin_Revolution::loadNamingDS(GeomAlgoAPI_Revolution& theRevolAlg //load result theResultBody->storeGenerated(theBasis, theRevolAlgo.shape()); - std::shared_ptr aSubShapes = theRevolAlgo.mapOfShapes(); + std::shared_ptr aSubShapes = theRevolAlgo.mapOfSubShapes(); //Insert lateral face : Face from Edge const std::string aLatName = "LateralFace"; const int aLatTag = 1; - theResultBody->loadAndOrientGeneratedShapes(theRevolAlgo.makeShape().get(), theBasis, GeomAPI_Shape::EDGE, aLatTag, aLatName, *aSubShapes); + theResultBody->loadAndOrientGeneratedShapes(&theRevolAlgo, theBasis, GeomAPI_Shape::EDGE, aLatTag, aLatName, *aSubShapes); //Insert to faces const std::string aToName = "ToFace"; - const int aToTag = 2; + int aToTag = 2; const ListOfShape& aToFaces = theRevolAlgo.toFaces(); for(ListOfShape::const_iterator anIt = aToFaces.cbegin(); anIt != aToFaces.cend(); anIt++) { std::shared_ptr aToFace = *anIt; if(aSubShapes->isBound(aToFace)) { aToFace = aSubShapes->find(aToFace); } - theResultBody->generated(aToFace, aToName, aToTag); + theResultBody->generated(aToFace, aToName, aToTag++); } //Insert from faces const std::string aFromName = "FromFace"; - const int aFromTag = 3; + int aFromTag = aToTag > 10000 ? aToTag : 10000; const ListOfShape& aFromFaces = theRevolAlgo.fromFaces(); for(ListOfShape::const_iterator anIt = aFromFaces.cbegin(); anIt != aFromFaces.cend(); anIt++) { std::shared_ptr aFromFace = *anIt; if(aSubShapes->isBound(aFromFace)) { aFromFace = aSubShapes->find(aFromFace); } - theResultBody->generated(aFromFace, aFromName, aFromTag); + theResultBody->generated(aFromFace, aFromName, aFromTag++); } }