X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FFeaturesPlugin%2FFeaturesPlugin_Extrusion.cpp;h=3ff47274e205bde1c282998eb26c699a0910af94;hb=7417054f9f86129249fdfd652f804183484986ee;hp=baf8f639769f49b80e20980a6b7761b807be346d;hpb=87b6a30a3afb8fb32e7e43ade8d9c947d9eb1684;p=modules%2Fshaper.git diff --git a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp index baf8f6397..3ff47274e 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.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_Extrusion.h" @@ -27,10 +26,12 @@ #include #include +#include #include #include #include +#include //================================================================================================= FeaturesPlugin_Extrusion::FeaturesPlugin_Extrusion() @@ -95,16 +96,29 @@ bool FeaturesPlugin_Extrusion::makeExtrusions(ListOfShape& theBaseShapes, getBaseShapes(theBaseShapes); //Getting direction. - std::shared_ptr aDir; - std::shared_ptr anEdge; + static const std::string aSelectionError = "Error: The direction shape selection is bad."; AttributeSelectionPtr aSelection = selection(DIRECTION_OBJECT_ID()); - if(aSelection.get() && aSelection->value().get() && aSelection->value()->isEdge()) { - anEdge = std::shared_ptr(new GeomAPI_Edge(aSelection->value())); - } else if(aSelection->context().get() && - aSelection->context()->shape().get() && - aSelection->context()->shape()->isEdge()) { - anEdge = std::shared_ptr(new GeomAPI_Edge(aSelection->context()->shape())); + GeomShapePtr aShape = aSelection->value(); + if (!aShape.get()) { + if (aSelection->context().get()) { + aShape = aSelection->context()->shape(); + } + } + + GeomEdgePtr anEdge; + if (aShape.get()) { + if (aShape->isEdge()) + { + anEdge = aShape->edge(); + } + else if (aShape->isCompound()) + { + GeomAPI_ShapeIterator anIt(aShape); + anEdge = anIt.current()->edge(); + } } + + std::shared_ptr aDir; if(anEdge.get()) { if(anEdge->isLine()) { aDir = anEdge->line()->direction(); @@ -134,6 +148,10 @@ bool FeaturesPlugin_Extrusion::makeExtrusions(ListOfShape& theBaseShapes, if(!aToShape.get() && aSelection->context().get()) { aToShape = aSelection->context()->shape(); } + if (aToShape.get() && aToShape->isCompound()) { + GeomAPI_ShapeIterator anIt(aToShape); + aToShape = anIt.current(); + } } aSelection = selection(FROM_OBJECT_ID()); if(aSelection.get()) { @@ -141,10 +159,15 @@ bool FeaturesPlugin_Extrusion::makeExtrusions(ListOfShape& theBaseShapes, if(!aFromShape.get() && aSelection->context().get()) { aFromShape = aSelection->context()->shape(); } + if (aFromShape.get() && aFromShape->isCompound()) { + GeomAPI_ShapeIterator anIt(aFromShape); + aFromShape = anIt.current(); + } } } // Generating result for each base shape. + std::string anError; for(ListOfShape::const_iterator anIter = theBaseShapes.cbegin(); anIter != theBaseShapes.cend(); anIter++) { std::shared_ptr aBaseShape = *anIter; @@ -152,7 +175,8 @@ bool FeaturesPlugin_Extrusion::makeExtrusions(ListOfShape& theBaseShapes, std::shared_ptr aPrismAlgo(new GeomAlgoAPI_Prism(aBaseShape, aDir, aToShape, aToSize, aFromShape, aFromSize)); - if(!isMakeShapeValid(aPrismAlgo)) { + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aPrismAlgo, getKind(), anError)) { + setError(anError); return false; }