X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModelAPI%2FModelAPI_Tools.cpp;h=c6b8a6f7257df6ba4933747cb038402399502a87;hb=ac53df4563f345f48d3a7274dbbb3f2618bacbda;hp=9dc5e4e9a36fb8d4aa85676609251888532662c6;hpb=9b61e5ee5eafe9d6948d9a78667efa2abec132c3;p=modules%2Fshaper.git diff --git a/src/ModelAPI/ModelAPI_Tools.cpp b/src/ModelAPI/ModelAPI_Tools.cpp old mode 100755 new mode 100644 index 9dc5e4e9a..c6b8a6f72 --- a/src/ModelAPI/ModelAPI_Tools.cpp +++ b/src/ModelAPI/ModelAPI_Tools.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 "ModelAPI_Tools.h" @@ -24,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -107,6 +107,7 @@ std::shared_ptr shape(const ResultPtr& theResult) return theResult->shape(); } +// LCOV_EXCL_START const char* toString(ModelAPI_ExecState theExecState) { switch (theExecState) { @@ -119,7 +120,6 @@ const char* toString(ModelAPI_ExecState theExecState) } } -// LCOV_EXCL_START std::string getFeatureError(const FeaturePtr& theFeature) { std::string anError; @@ -302,14 +302,16 @@ bool hasSubResults(const ResultPtr& theResult) return aCompSolid.get() && aCompSolid->numberOfSubs() > 0; } -void allSubs(const ResultBodyPtr& theResult, std::list& theResults) { +void allSubs(const ResultBodyPtr& theResult, std::list& theResults, + const bool theLowerOnly) { // iterate sub-bodies of compsolid ResultBodyPtr aComp = std::dynamic_pointer_cast(theResult); if (aComp.get()) { int aNumSub = aComp->numberOfSubs(); for (int a = 0; a < aNumSub; a++) { ResultBodyPtr aSub = aComp->subResult(a); - theResults.push_back(aSub); + if (!theLowerOnly || aSub->numberOfSubs() == 0) + theResults.push_back(aSub); allSubs(aSub, theResults); } } @@ -759,4 +761,27 @@ std::set getParents(const FeaturePtr& theFeature) return aParents; } +void removeResults(const std::list& theResults) +{ + // collect all documents where the results must be removed + std::map > aDocs; + + std::list::const_iterator aResIter = theResults.cbegin(); + for(; aResIter != theResults.cend(); aResIter++) { + DocumentPtr aDoc = (*aResIter)->document(); + if (!aDocs.count(aDoc)) + aDocs[aDoc] = std::list(); + aDocs[aDoc].push_back(*aResIter); + } + // create a "remove" feature in each doc + std::map >::iterator aDoc = aDocs.begin(); + for(; aDoc != aDocs.end(); aDoc++) { + FeaturePtr aRemove = aDoc->first->addFeature("RemoveResults"); + if (aRemove) { + for(aResIter = aDoc->second.cbegin(); aResIter != aDoc->second.cend(); aResIter++) + aRemove->selectionList("results")->append(*aResIter, GeomShapePtr()); + } + } +} + } // namespace ModelAPI_Tools