X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FFeaturesPlugin%2FFeaturesPlugin_Pipe.cpp;h=c3a38788782385f5fa00772b093daaa95fefc2fb;hb=d5c7ad3c50f89a2ddc2de1866ffb7f09397f3be2;hp=ff6815e168e531c5cc2c2032ba90b304ad140afc;hpb=31cb13c6f72349480240ab828a4befc0ef45baed;p=modules%2Fshaper.git diff --git a/src/FeaturesPlugin/FeaturesPlugin_Pipe.cpp b/src/FeaturesPlugin/FeaturesPlugin_Pipe.cpp index ff6815e16..c3a387887 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Pipe.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Pipe.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// Copyright (C) 2014-2019 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -12,10 +12,9 @@ // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or -// email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "FeaturesPlugin_Pipe.h" @@ -30,6 +29,8 @@ #include #include #include +#include + #include #include @@ -145,14 +146,9 @@ void FeaturesPlugin_Pipe::execute() // Searching faces with common edges. if(aCreationMethod == CREATION_METHOD_SIMPLE()) { - ListOfShape aShells; - ListOfShape aFreeFaces; std::shared_ptr aFacesCompound = GeomAlgoAPI_CompoundBuilder::compound(aBaseFacesList); - GeomAlgoAPI_ShapeTools::combineShapes(aFacesCompound, GeomAPI_Shape::SHELL, - aShells, aFreeFaces); - aBaseShapesList.insert(aBaseShapesList.end(), aFreeFaces.begin(), aFreeFaces.end()); - aBaseShapesList.insert(aBaseShapesList.end(), aShells.begin(), aShells.end()); + GeomAlgoAPI_ShapeTools::combineShapes(aFacesCompound, GeomAPI_Shape::SHELL, aBaseShapesList); } else { aBaseShapesList.insert(aBaseShapesList.end(), aBaseFacesList.begin(), aBaseFacesList.end()); } @@ -165,8 +161,8 @@ void FeaturesPlugin_Pipe::execute() } std::shared_ptr aPathShape = std::dynamic_pointer_cast(aPathSelection->value()); - if(!aPathShape.get()) { - // Probaply it is a construction. + if(!aPathShape.get() && aPathSelection->context().get()) { + // Probably it is a construction. aPathShape = aPathSelection->context()->shape(); } if(!aPathShape.get() || aPathShape->isNull()) { @@ -183,7 +179,7 @@ void FeaturesPlugin_Pipe::execute() return; } aBiNormal = std::dynamic_pointer_cast(aBiNormalSelection->value()); - if(!aBiNormal.get()) { + if(!aBiNormal.get() && aBiNormalSelection->context().get()) { // Probably it is a construction. aBiNormal = aBiNormalSelection->context()->shape(); } @@ -208,7 +204,7 @@ void FeaturesPlugin_Pipe::execute() return; } std::shared_ptr aLocationShape = aLocationSelection->value(); - if(!aLocationShape.get()) { + if(!aLocationShape.get() && aLocationSelection->context().get()) { // Probably it is a construction. aLocationShape = aLocationSelection->context()->shape(); } @@ -222,6 +218,7 @@ void FeaturesPlugin_Pipe::execute() // Generating result for each object. int aResultIndex = 0; + std::string anError; if(aCreationMethod == CREATION_METHOD_SIMPLE() || aCreationMethod == CREATION_METHOD_BINORMAL()) { for(ListOfShape::const_iterator @@ -235,50 +232,26 @@ void FeaturesPlugin_Pipe::execute() aPathShape, aBiNormal)); - if(!aPipeAlgo->isDone()) { - setError("Error: Pipe algorithm failed."); - aResultIndex = 0; - break; - } - - // Check if shape is valid - if(!aPipeAlgo->shape().get() || aPipeAlgo->shape()->isNull()) { - setError("Error: Resulting shape is Null."); - aResultIndex = 0; - break; - } - if(!aPipeAlgo->isValid()) { - setError("Error: Resulting shape is not valid."); + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aPipeAlgo, getKind(), anError)) { + setError(anError); aResultIndex = 0; break; } - storeResult(aBaseShape, aPipeAlgo, aResultIndex++); + storeResult(aBaseShape, aPathShape, aPipeAlgo, aResultIndex++); } } else if(aCreationMethod == CREATION_METHOD_LOCATIONS()) { std::shared_ptr aPipeAlgo(new GeomAlgoAPI_Pipe(aBaseShapesList, aLocations, aPathShape)); - if(!aPipeAlgo->isDone()) { - setError("Error: Pipe algorithm failed."); + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aPipeAlgo, getKind(), anError)) { + setError(anError); removeResults(0); return; } - // Check if shape is valid - if(!aPipeAlgo->shape().get() || aPipeAlgo->shape()->isNull()) { - setError("Error: Resulting shape is Null."); - removeResults(0); - return; - } - if(!aPipeAlgo->isValid()) { - setError("Error: Resulting shape is not valid."); - removeResults(0); - return; - } - - storeResult(aBaseShapesList, aPipeAlgo, aResultIndex++); + storeResult(aBaseShapesList, aPathShape, aPipeAlgo, aResultIndex++); } else { setError("Error: Wrong creation method."); return; @@ -289,6 +262,7 @@ void FeaturesPlugin_Pipe::execute() //================================================================================================== void FeaturesPlugin_Pipe::storeResult(const std::shared_ptr theBaseShape, + const std::shared_ptr thePathShape, const std::shared_ptr thePipeAlgo, const int theResultIndex) { @@ -339,6 +313,8 @@ void FeaturesPlugin_Pipe::storeResult(const std::shared_ptr theBa aShapeTypeToExplode == GeomAPI_Shape::COMPOUND) { aResultBody->loadGeneratedShapes(thePipeAlgo, theBaseShape, GeomAPI_Shape::EDGE); } + if (thePathShape.get()) + aResultBody->loadGeneratedShapes(thePipeAlgo, thePathShape, GeomAPI_Shape::EDGE); // Store from shapes. storeShapes(aResultBody, aBaseShapeType, thePipeAlgo->fromShapes(), "From_"); @@ -351,6 +327,7 @@ void FeaturesPlugin_Pipe::storeResult(const std::shared_ptr theBa //================================================================================================== void FeaturesPlugin_Pipe::storeResult(const ListOfShape& theBaseShapes, + const std::shared_ptr thePathShape, const std::shared_ptr thePipeAlgo, const int theResultIndex) { @@ -392,6 +369,9 @@ void FeaturesPlugin_Pipe::storeResult(const ListOfShape& theBaseShapes, aResultBody->loadGeneratedShapes(thePipeAlgo, aBaseShape, aShapeTypeToExplode); } + if (thePathShape.get()) + aResultBody->loadGeneratedShapes(thePipeAlgo, thePathShape, GeomAPI_Shape::EDGE); + // Store from shapes. storeShapes(aResultBody, theBaseShapes.front()->shapeType(), thePipeAlgo->fromShapes(), "From_");