X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fengine%2FForLoop.cxx;h=79c2b0dfae5e0a74281873d4da271c76911e0651;hb=3faa9bfe96ae74fdca18143c639dcfb9b41cd43e;hp=e5368047f67de8d643d8488a4cb26c2f9b1d1a47;hpb=216c15bc1ec59372c7313d273cc0fa1d206a68d4;p=modules%2Fyacs.git diff --git a/src/engine/ForLoop.cxx b/src/engine/ForLoop.cxx index e5368047f..79c2b0dfa 100644 --- a/src/engine/ForLoop.cxx +++ b/src/engine/ForLoop.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2006-2014 CEA/DEN, EDF R&D +// Copyright (C) 2006-2023 CEA, EDF // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -67,7 +67,7 @@ Node *ForLoop::simpleClone(ComposedNode *father, bool editionOnly) const return new ForLoop(*this,father,editionOnly); } -InputPort* ForLoop::getInputPort(const std::string& name) const throw(YACS::Exception) +InputPort* ForLoop::getInputPort(const std::string& name) const { if(name == NAME_OF_NSTEPS_NUMBER)return (InputPort*)&_nbOfTimesPort; return Loop::getInputPort(name); @@ -182,14 +182,14 @@ std::list ForLoop::getLocalInputPorts() const return ret; } -OutPort *ForLoop::getOutPort(const std::string& name) const throw(YACS::Exception) +OutPort *ForLoop::getOutPort(const std::string& name) const { if(name==NAME_OF_INDEX) return (OutPort *)&_indexPort; return Loop::getOutPort(name); } -OutputPort *ForLoop::getOutputPort(const std::string& name) const throw(YACS::Exception) +OutputPort *ForLoop::getOutputPort(const std::string& name) const { if(name==NAME_OF_INDEX) return (OutputPort *)&_indexPort; @@ -265,17 +265,51 @@ std::list ForLoop::getSetOfOutputPort() const return ret; } + +int ForLoop::getNbSteps() const +{ + AnyInputPort* aNbStepsPort = (AnyInputPort*)&_nbOfTimesPort; + int nbSteps = 0; + if (aNbStepsPort && !aNbStepsPort->isEmpty()) + nbSteps = aNbStepsPort->getIntValue(); + return nbSteps; +} + std::string ForLoop::getProgress() const { std::stringstream aProgress; aProgress << "0"; - AnyInputPort* aNbStepsPort = (AnyInputPort*)&_nbOfTimesPort; - if (aNbStepsPort && !aNbStepsPort->isEmpty()) { - int nbSteps = aNbStepsPort->getIntValue(); - if (nbSteps > 0 && _nbOfTurns >= 0) { + int nbSteps = getNbSteps(); + if (nbSteps > 0 && _nbOfTurns >= 0) + { aProgress.str(""); aProgress << _nbOfTurns << "/" << nbSteps; } - } return aProgress.str(); } + +//! Get the progress weight for all elementary nodes +/*! + * Only elementary nodes have weight. For each node in the loop, the weight done is multiplied + * by the number of steps done and the weight total by the number total of steps + * + */ +list ForLoop::getProgressWeight() const +{ + list ret; + list setOfNode=edGetDirectDescendants(); + int nbStepsDone=getNbOfTurns(); + int nbStepsTotal=getNbSteps(); + for(list::const_iterator iter=setOfNode.begin();iter!=setOfNode.end();iter++) + { + list myCurrentSet=(*iter)->getProgressWeight(); + for(list::iterator iter=myCurrentSet.begin();iter!=myCurrentSet.end();iter++) + { + (*iter).weightDone=((*iter).weightTotal) * nbStepsDone; + (*iter).weightTotal*=nbStepsTotal; + } + ret.insert(ret.end(),myCurrentSet.begin(),myCurrentSet.end()); + } + return ret; +} +