1 // Copyright (C) 2015-2016 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "BagPoint.hxx"
21 #include "Exception.hxx"
22 #include "LinkedBlocPoint.hxx"
23 #include "ForkBlocPoint.hxx"
28 using namespace YACS::ENGINE;
30 BagPoint::BagPoint(const std::list<AbstractPoint *>& nodes, AbstractPoint *father):BlocPoint(nodes,father)
34 AbstractPoint *BagPoint::getUnique()
37 throw YACS::Exception("BagPoint::getUnique : invalid call !");
40 AbstractPoint *ret(*_nodes.begin());
42 throw YACS::Exception("BagPoint::getUnique : Ooops !");
47 const AbstractPoint *BagPoint::getUnique() const
50 throw YACS::Exception("BagPoint::getUnique const : invalid call !");
53 AbstractPoint *ret(*_nodes.begin());
55 throw YACS::Exception("BagPoint::getUnique : Ooops !");
60 AbstractPoint *BagPoint::getUniqueAndReleaseIt()
62 AbstractPoint *ret(getUnique());
67 Node *BagPoint::getFirstNode()
69 return getUnique()->getFirstNode();
72 Node *BagPoint::getLastNode()
74 return getUnique()->getLastNode();
77 int BagPoint::getMaxLevelOfParallelism() const
79 return getUnique()->getMaxLevelOfParallelism();
82 double BagPoint::getWeightRegardingDPL() const
84 return getUnique()->getWeightRegardingDPL();
87 void BagPoint::partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap) const
89 getUnique()->partitionRegardingDPL(pd,zeMap);
92 std::string BagPoint::getRepr() const
94 std::ostringstream oss;
95 for(std::list<AbstractPoint *>::const_iterator it=_nodes.begin();it!=_nodes.end();it++)
96 oss << (*it)->getRepr() << " - ";
102 void BagPoint::replaceInMe(BlocPoint *aSet)
104 const std::list<AbstractPoint *>& pts(aSet->getListOfPoints());
105 for(std::list<AbstractPoint *>::const_iterator it0=pts.begin();it0!=pts.end();it0++)
107 std::list<AbstractPoint *>::iterator it1(std::find(_nodes.begin(),_nodes.end(),*it0));
108 if(it1==_nodes.end())
109 throw Exception("SetOfPoints::replaceInMe : internal error !");
112 _nodes.push_back(aSet);
115 void BagPoint::deal1(bool& somethingDone)
118 for(std::list<AbstractPoint *>::iterator it=_nodes.begin();it!=_nodes.end();it++)
120 if(!(*it)->isSimplyLinkedBeforeAfter(this))
121 if(!(*it)->isSimplyLinkedAfterNullBefore(this) && !(*it)->isSimplyLinkedBeforeNullAfter(this))
123 LinkedBlocPoint *try0((*it)->tryAsLink(this));
133 void BagPoint::deal2(bool& somethingDone)
136 for(std::list<AbstractPoint *>::iterator it=_nodes.begin();it!=_nodes.end();it++)
138 if(!(*it)->isSimplyLinkedBeforeAfter(this))
140 ForkBlocPoint *try1((*it)->tryAsFork(this));
150 void BagPoint::deal2Bis(bool& somethingDone)
153 for(std::list<AbstractPoint *>::iterator it=_nodes.begin();it!=_nodes.end();it++)
155 if(!(*it)->isSimplyLinkedAfterNullBefore(this))
157 ForkBlocPoint *try1((*it)->tryAsForkBis(this));
167 void BagPoint::deal2Ter(bool& somethingDone)
170 for(std::list<AbstractPoint *>::iterator it=_nodes.begin();it!=_nodes.end();it++)
172 if(!(*it)->isSimplyLinkedBeforeNullAfter(this))
174 ForkBlocPoint *try1((*it)->tryAsForkTer(this));