]> SALOME platform Git repositories - modules/yacs.git/blob - src/engine/LinkedBlocPoint.cxx
Salome HOME
Optimized algo for PlayGround
[modules/yacs.git] / src / engine / LinkedBlocPoint.cxx
1 // Copyright (C) 2015-2016  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "LinkedBlocPoint.hxx"
21 #include "Exception.hxx"
22
23 using namespace YACS::ENGINE;
24
25 LinkedBlocPoint::LinkedBlocPoint(const std::list<AbstractPoint *>& nodes, AbstractPoint *father):BlocPoint(nodes,father)
26 {
27 }
28
29 Node *LinkedBlocPoint::getFirstNode()
30 {
31   if(_nodes.empty())
32     throw Exception("LinkedBlocPoint::getFirstNode : error no branches !");
33   return _nodes.front()->getFirstNode();
34 }
35
36 Node *LinkedBlocPoint::getLastNode()
37 {
38   if(_nodes.empty())
39     throw Exception("LinkedBlocPoint::getFirstNode : error no branches !");
40   return _nodes.back()->getLastNode();
41 }
42
43 int LinkedBlocPoint::getMaxLevelOfParallelism() const
44 {
45   int ret(0);
46   for(std::list<AbstractPoint *>::const_iterator it=_nodes.begin();it!=_nodes.end();it++)
47     ret=std::max(ret,(*it)->getMaxLevelOfParallelism());
48   return ret;
49 }
50
51 void LinkedBlocPoint::getWeightRegardingDPL(ComplexWeight *weight)
52 {
53   ComplexWeight localWeight;
54   for(std::list<AbstractPoint *>::const_iterator it=_nodes.begin();it!=_nodes.end();it++)
55   {
56     (*it)->getWeightRegardingDPL(&localWeight);
57     weight->addWeight(&localWeight);
58     localWeight.setToZero();
59   }
60 }
61
62 void LinkedBlocPoint::partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap) const
63 {
64   for(std::list<AbstractPoint *>::const_iterator it=_nodes.begin();it!=_nodes.end();it++)
65     (*it)->partitionRegardingDPL(pd,zeMap);
66 }
67
68 std::string LinkedBlocPoint::getRepr() const
69 {
70   std::size_t sz(_nodes.size()),ii(0);
71   std::string ret("(");
72   for(std::list<AbstractPoint *>::const_iterator it=_nodes.begin();it!=_nodes.end();it++,ii++)
73     {
74       ret+=(*it)->getRepr();
75       if(ii!=sz-1)
76         ret+="+";
77     }
78   ret+=")";
79   return ret;
80 }
81
82 LinkedBlocPoint::~LinkedBlocPoint()
83 {
84 }