-// 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
//
// 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<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "ModelAPI_Tools.h"
#include <ModelAPI_Document.h>
#include <ModelAPI_Object.h>
#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_ResultBody.h>
#include <ModelAPI_ResultParameter.h>
#include <ModelAPI_ResultPart.h>
return theResult->shape();
}
+// LCOV_EXCL_START
const char* toString(ModelAPI_ExecState theExecState)
{
switch (theExecState) {
}
}
-// LCOV_EXCL_START
std::string getFeatureError(const FeaturePtr& theFeature)
{
std::string anError;
return aCompSolid.get() && aCompSolid->numberOfSubs() > 0;
}
-void allSubs(const ResultBodyPtr& theResult, std::list<ResultPtr>& theResults) {
+void allSubs(const ResultBodyPtr& theResult, std::list<ResultPtr>& theResults,
+ const bool theLowerOnly) {
// iterate sub-bodies of compsolid
ResultBodyPtr aComp = std::dynamic_pointer_cast<ModelAPI_ResultBody>(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);
}
}
return aParents;
}
+void removeResults(const std::list<ResultPtr>& theResults)
+{
+ // collect all documents where the results must be removed
+ std::map<DocumentPtr, std::list<ResultPtr> > aDocs;
+
+ std::list<ResultPtr>::const_iterator aResIter = theResults.cbegin();
+ for(; aResIter != theResults.cend(); aResIter++) {
+ DocumentPtr aDoc = (*aResIter)->document();
+ if (!aDocs.count(aDoc))
+ aDocs[aDoc] = std::list<ResultPtr>();
+ aDocs[aDoc].push_back(*aResIter);
+ }
+ // create a "remove" feature in each doc
+ std::map<DocumentPtr, std::list<ResultPtr> >::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