1 // Copyright (C) 2015-2019 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 "LinkedBlocPoint.hxx"
21 #include "ElementaryPoint.hxx"
22 #include "NotSimpleCasePoint.hxx"
23 #include "ForkBlocPoint.hxx"
24 #include "PointVisitor.hxx"
25 #include "Exception.hxx"
32 using namespace YACS::ENGINE;
34 LinkedBlocPoint::LinkedBlocPoint(const std::list<AbstractPoint *>& nodes, AbstractPoint *father):BlocPoint(nodes,father)
38 AbstractPoint *LinkedBlocPoint::deepCopy(AbstractPoint *father) const
40 LinkedBlocPoint *ret(new LinkedBlocPoint);
41 ret->deepCopyFrom(*this);
42 ret->setFather(father);
46 Node *LinkedBlocPoint::getFirstNode()
49 throw Exception("LinkedBlocPoint::getFirstNode : error no branches !");
50 return _nodes.front()->getFirstNode();
53 Node *LinkedBlocPoint::getLastNode()
56 throw Exception("LinkedBlocPoint::getFirstNode : error no branches !");
57 return _nodes.back()->getLastNode();
60 int LinkedBlocPoint::getMaxLevelOfParallelism() const
63 for(std::list<AbstractPoint *>::const_iterator it=_nodes.begin();it!=_nodes.end();it++)
64 ret=std::max(ret,(*it)->getMaxLevelOfParallelism());
68 void LinkedBlocPoint::getWeightRegardingDPL(ComplexWeight *weight)
70 ComplexWeight localWeight;
71 for(std::list<AbstractPoint *>::const_iterator it=_nodes.begin();it!=_nodes.end();it++)
73 (*it)->getWeightRegardingDPL(&localWeight);
74 weight->addWeight(&localWeight);
75 localWeight.setToZero();
79 void LinkedBlocPoint::partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap) const
81 for(std::list<AbstractPoint *>::const_iterator it=_nodes.begin();it!=_nodes.end();it++)
82 (*it)->partitionRegardingDPL(pd,zeMap);
85 std::string LinkedBlocPoint::getRepr() const
87 std::size_t sz(_nodes.size()),ii(0);
89 for(std::list<AbstractPoint *>::const_iterator it=_nodes.begin();it!=_nodes.end();it++,ii++)
91 ret+=(*it)->getRepr();
99 AbstractPoint *LinkedBlocPoint::expandNonSimpleCaseOn(NotSimpleCasePoint *pathologicalPt, const std::set<Node *>& uncatchedNodes)
101 if(anyOf(uncatchedNodes))
103 for(auto& it : _nodes)
105 AbstractPoint *ret(it->expandNonSimpleCaseOn(pathologicalPt,uncatchedNodes));
108 ret->setFather(this);
118 std::list<AbstractPoint *> l;
119 AbstractPoint *p0(this->deepCopy(getFather())),*p1(pathologicalPt->getUnique()->deepCopy(getFather()));
122 AbstractPoint *ret(new ForkBlocPoint(l,getFather()));
123 p0->setFather(ret); p1->setFather(ret);
128 void LinkedBlocPoint::accept(PointVisitor *pv)
130 pv->beginLinkedBlocPoint(this);
133 pv->endLinkedBlocPoint(this);
136 LinkedBlocPoint::~LinkedBlocPoint()