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 void BagPoint::accept(PointVisitor *pv)
70 throw YACS::Exception("BagPoint::accept : simplification has failed !");
71 AbstractPoint *ret(*_nodes.begin());
73 throw YACS::Exception("BagPoint::accept : Ooops !");
77 Node *BagPoint::getFirstNode()
79 return getUnique()->getFirstNode();
82 Node *BagPoint::getLastNode()
84 return getUnique()->getLastNode();
87 int BagPoint::getMaxLevelOfParallelism() const
89 return getUnique()->getMaxLevelOfParallelism();
92 void BagPoint::getWeightRegardingDPL(ComplexWeight *weight)
94 getUnique()->getWeightRegardingDPL(weight);
97 void BagPoint::partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap) const
99 getUnique()->partitionRegardingDPL(pd,zeMap);
102 std::string BagPoint::getRepr() const
104 std::ostringstream oss;
105 for(std::list<AbstractPoint *>::const_iterator it=_nodes.begin();it!=_nodes.end();it++)
106 oss << (*it)->getRepr() << " - ";
112 void BagPoint::replaceInMe(BlocPoint *aSet)
114 const std::list<AbstractPoint *>& pts(aSet->getListOfPoints());
115 for(std::list<AbstractPoint *>::const_iterator it0=pts.begin();it0!=pts.end();it0++)
117 std::list<AbstractPoint *>::iterator it1(std::find(_nodes.begin(),_nodes.end(),*it0));
118 if(it1==_nodes.end())
119 throw Exception("SetOfPoints::replaceInMe : internal error !");
122 _nodes.push_back(aSet);
125 void BagPoint::deal1(bool& somethingDone)
128 for(std::list<AbstractPoint *>::iterator it=_nodes.begin();it!=_nodes.end();it++)
130 if(!(*it)->isSimplyLinkedBeforeAfter(this))
131 if(!(*it)->isSimplyLinkedAfterNullBefore(this) && !(*it)->isSimplyLinkedBeforeNullAfter(this))
133 LinkedBlocPoint *try0((*it)->tryAsLink(this));
143 void BagPoint::deal2(bool& somethingDone)
146 for(std::list<AbstractPoint *>::iterator it=_nodes.begin();it!=_nodes.end();it++)
148 if(!(*it)->isSimplyLinkedBeforeAfter(this))
150 ForkBlocPoint *try1((*it)->tryAsFork(this));
160 void BagPoint::deal2Bis(bool& somethingDone)
163 for(std::list<AbstractPoint *>::iterator it=_nodes.begin();it!=_nodes.end();it++)
165 if(!(*it)->isSimplyLinkedAfterNullBefore(this))
167 ForkBlocPoint *try1((*it)->tryAsForkBis(this));
177 void BagPoint::deal2Ter(bool& somethingDone)
180 for(std::list<AbstractPoint *>::iterator it=_nodes.begin();it!=_nodes.end();it++)
182 if(!(*it)->isSimplyLinkedBeforeNullAfter(this))
184 ForkBlocPoint *try1((*it)->tryAsForkTer(this));