Version: 9.15.0
LinkedBlocPoint.cxx
Go to the documentation of this file.
1 // Copyright (C) 2015-2025 CEA, EDF
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 "ElementaryPoint.hxx"
22 #include "NotSimpleCasePoint.hxx"
23 #include "ForkBlocPoint.hxx"
24 #include "PointVisitor.hxx"
25 #include "Exception.hxx"
26 
27 #ifdef WIN32
28 #include <algorithm>
29 #endif
30 
31 
32 using namespace YACS::ENGINE;
33 
34 LinkedBlocPoint::LinkedBlocPoint(const std::list<AbstractPoint *>& nodes, AbstractPoint *father):BlocPoint(nodes,father)
35 {
36 }
37 
39 {
41  ret->deepCopyFrom(*this);
42  ret->setFather(father);
43  return ret;
44 }
45 
47 {
48  if(_nodes.empty())
49  throw Exception("LinkedBlocPoint::getFirstNode : error no branches !");
50  return _nodes.front()->getFirstNode();
51 }
52 
54 {
55  if(_nodes.empty())
56  throw Exception("LinkedBlocPoint::getFirstNode : error no branches !");
57  return _nodes.back()->getLastNode();
58 }
59 
61 {
62  int ret(0);
63  for(std::list<AbstractPoint *>::const_iterator it=_nodes.begin();it!=_nodes.end();it++)
64  ret=std::max(ret,(*it)->getMaxLevelOfParallelism());
65  return ret;
66 }
67 
69 {
70  ComplexWeight localWeight;
71  for(std::list<AbstractPoint *>::const_iterator it=_nodes.begin();it!=_nodes.end();it++)
72  {
73  (*it)->getWeightRegardingDPL(&localWeight);
74  weight->addWeight(&localWeight);
75  localWeight.setToZero();
76  }
77 }
78 
80 {
81  for(std::list<AbstractPoint *>::const_iterator it=_nodes.begin();it!=_nodes.end();it++)
82  (*it)->partitionRegardingDPL(pd,zeMap);
83 }
84 
85 std::string LinkedBlocPoint::getRepr() const
86 {
87  std::size_t sz(_nodes.size()),ii(0);
88  std::string ret("(");
89  for(std::list<AbstractPoint *>::const_iterator it=_nodes.begin();it!=_nodes.end();it++,ii++)
90  {
91  ret+=(*it)->getRepr();
92  if(ii!=sz-1)
93  ret+="+";
94  }
95  ret+=")";
96  return ret;
97 }
98 
99 AbstractPoint *LinkedBlocPoint::expandNonSimpleCaseOn(NotSimpleCasePoint *pathologicalPt, const std::set<Node *>& uncatchedNodes)
100 {
101  if(anyOf(uncatchedNodes))
102  {
103  for(auto& it : _nodes)
104  {
105  AbstractPoint *ret(it->expandNonSimpleCaseOn(pathologicalPt,uncatchedNodes));
106  if(ret!=it)
107  {
108  ret->setFather(this);
109  auto oldIt(it);
110  it = ret;
111  delete oldIt;
112  }
113  }
114  return this;
115  }
116  else
117  {
118  std::list<AbstractPoint *> l;
119  AbstractPoint *p0(this->deepCopy(getFather())),*p1(pathologicalPt->getUnique()->deepCopy(getFather()));
120  l.push_back(p0);
121  l.push_back(p1);
122  AbstractPoint *ret(new ForkBlocPoint(l,getFather()));
123  p0->setFather(ret); p1->setFather(ret);
124  return ret;
125  }
126 }
127 
129 {
130  pv->beginLinkedBlocPoint(this);
131  for(auto it:_nodes)
132  it->accept(pv);
133  pv->endLinkedBlocPoint(this);
134 }
135 
137 {
138 }
virtual AbstractPoint * deepCopy(AbstractPoint *father) const =0
AbstractPoint * getFather() const
void setFather(AbstractPoint *father)
void deepCopyFrom(const BlocPoint &other)
Definition: BlocPoint.cxx:34
AbstractPoint * getUnique()
Definition: BlocPoint.cxx:111
bool anyOf(const std::set< Node * > &nodes) const override
Definition: BlocPoint.cxx:101
std::list< AbstractPoint * > _nodes
Definition: BlocPoint.hxx:35
void addWeight(const ComplexWeight *other)
Base class for all composed nodes.
void accept(PointVisitor *pv) override
AbstractPoint * deepCopy(AbstractPoint *father) const override
void getWeightRegardingDPL(ComplexWeight *weight)
void partitionRegardingDPL(const PartDefinition *pd, std::map< ComposedNode *, YACS::BASES::AutoRefCnt< PartDefinition > > &zeMap) const
AbstractPoint * expandNonSimpleCaseOn(NotSimpleCasePoint *pathologicalPt, const std::set< Node * > &uncatchedNodes) override
Base class for all nodes.
Definition: Node.hxx:70
virtual void beginLinkedBlocPoint(LinkedBlocPoint *pt)=0
virtual void endLinkedBlocPoint(LinkedBlocPoint *pt)=0