X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FFeaturesPlugin%2FFeaturesPlugin_Extrusion.cpp;h=c0bcd77f3bcb125d4f58cb8c534c9212ccd66084;hb=3205d0f18200948632155bbe7b640bc1e482243d;hp=a6372cf9a2b8b7064a70843813886feaac6ba1da;hpb=65bd7c71b6eda2cad73adcc3be6c6ad725c26b94;p=modules%2Fshaper.git diff --git a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp index a6372cf9a..c0bcd77f3 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp @@ -4,23 +4,18 @@ // Created: 30 May 2014 // Author: Vitaly SMETANNIKOV -#include +#include "FeaturesPlugin_Extrusion.h" -#include #include #include -#include -#include #include -#include #include #include #include #include -#include #include -#include +#include #include #include @@ -60,34 +55,26 @@ void FeaturesPlugin_Extrusion::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 extrusion"; 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); } @@ -130,11 +117,12 @@ void FeaturesPlugin_Extrusion::execute() // Searching faces with common edges. ListOfShape aShells; ListOfShape aFreeFaces; - GeomAlgoAPI_ShapeTools::combineFacesToShells(aFacesList, aShells, aFreeFaces); - aShells.merge(aFreeFaces); + std::shared_ptr aFacesCompound = GeomAlgoAPI_CompoundBuilder::compound(aFacesList); + GeomAlgoAPI_ShapeTools::combineShapes(aFacesCompound, GeomAPI_Shape::SHELL, aShells, aFreeFaces); + aShells.insert(aShells.end(), aFreeFaces.begin(), aFreeFaces.end()); // Generating result for each shell and face. - int anIndex = 0, aResultIndex = 0; + int aResultIndex = 0; for(ListOfShape::const_iterator anIter = aShells.cbegin(); anIter != aShells.cend(); anIter++) { std::shared_ptr aBaseShape = *anIter; @@ -175,40 +163,36 @@ void FeaturesPlugin_Extrusion::loadNamingDS(GeomAlgoAPI_Prism& thePrismAlgo, std::shared_ptr theBasis) { //load result - ModelAPI_BodyBuilder* aResultBuilder = theResultBody->getBodyBuilder(); - if(thePrismAlgo.shape()->shapeType() == GeomAPI_Shape::COMPSOLID) { - int a = 1; - } - aResultBuilder->storeGenerated(theBasis, thePrismAlgo.shape()); + theResultBody->storeGenerated(theBasis, thePrismAlgo.shape()); - std::shared_ptr aSubShapes = thePrismAlgo.mapOfShapes(); + std::shared_ptr aSubShapes = thePrismAlgo.mapOfSubShapes(); //Insert lateral face : Face from Edge - std::string aLatName = "LateralFace"; + const std::string aLatName = "LateralFace"; const int aLatTag = 1; - aResultBuilder->loadAndOrientGeneratedShapes(thePrismAlgo.makeShape().get(), theBasis, GeomAPI_Shape::EDGE, aLatTag, aLatName, *aSubShapes); + theResultBody->loadAndOrientGeneratedShapes(&thePrismAlgo, theBasis, GeomAPI_Shape::EDGE, aLatTag, aLatName, *aSubShapes); //Insert to faces - std::string aToName = "ToFace"; - const int aToTag = 2; + const std::string aToName = "ToFace"; + int aToTag = 2; const ListOfShape& aToFaces = thePrismAlgo.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); } - aResultBuilder->generated(aToFace, aToName, aToTag); + theResultBody->generated(aToFace, aToName, aToTag++); } //Insert from faces - std::string aFromName = "FromFace"; - const int aFromTag = 3; + const std::string aFromName = "FromFace"; + int aFromTag = aToTag > 10000 ? aToTag : 10000; const ListOfShape& aFromFaces = thePrismAlgo.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); } - aResultBuilder->generated(aFromFace, aFromName, aFromTag); + theResultBody->generated(aFromFace, aFromName, aFromTag++); } }