Salome HOME
Copyright update 2020
[modules/yacs.git] / src / engine / NotSimpleCasePoint.cxx
1 // Copyright (C) 2019-2020  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 "NotSimpleCasePoint.hxx"
21 #include "PointVisitor.hxx"
22 #include "Exception.hxx"
23
24 #include <algorithm>
25
26
27 using namespace YACS::ENGINE;
28
29 NotSimpleCasePoint::NotSimpleCasePoint(const std::list<AbstractPoint *>& nodes, AbstractPoint *father):BlocPoint(nodes,father)
30 {
31 }
32
33 AbstractPoint *NotSimpleCasePoint::deepCopy(AbstractPoint *father) const
34 {
35   NotSimpleCasePoint *ret(new NotSimpleCasePoint);
36   ret->deepCopyFrom(*this);
37   ret->setFather(father);
38   return ret;
39 }
40
41 Node *NotSimpleCasePoint::getFirstNode()
42 {
43   if(_nodes.empty())
44     throw Exception("NotSimpleCasePoint::getFirstNode : error no branches !");
45   return _nodes.front()->getFirstNode();
46 }
47
48 Node *NotSimpleCasePoint::getLastNode()
49 {
50   if(_nodes.empty())
51     throw Exception("NotSimpleCasePoint::getFirstNode : error no branches !");
52   return _nodes.back()->getLastNode();
53 }
54
55 int NotSimpleCasePoint::getMaxLevelOfParallelism() const
56 {
57   int ret(0);
58   for(std::list<AbstractPoint *>::const_iterator it=_nodes.begin();it!=_nodes.end();it++)
59     ret=std::max(ret,(*it)->getMaxLevelOfParallelism());
60   return ret;
61 }
62
63 void NotSimpleCasePoint::getWeightRegardingDPL(ComplexWeight *weight)
64 {
65   ComplexWeight localWeight;
66   for(std::list<AbstractPoint *>::const_iterator it=_nodes.begin();it!=_nodes.end();it++)
67   {
68     (*it)->getWeightRegardingDPL(&localWeight);
69     weight->addWeight(&localWeight);
70     localWeight.setToZero();
71   }
72 }
73
74 void NotSimpleCasePoint::partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap) const
75 {
76   for(std::list<AbstractPoint *>::const_iterator it=_nodes.begin();it!=_nodes.end();it++)
77     (*it)->partitionRegardingDPL(pd,zeMap);
78 }
79
80 std::string NotSimpleCasePoint::getRepr() const
81 {
82   std::size_t sz(_nodes.size()),ii(0);
83   std::string ret("|");
84   for(std::list<AbstractPoint *>::const_iterator it=_nodes.begin();it!=_nodes.end();it++,ii++)
85     {
86       ret+=(*it)->getRepr();
87       if(ii!=sz-1)
88         ret+="^";
89     }
90   ret+="|";
91   return ret;
92 }
93
94 void NotSimpleCasePoint::accept(PointVisitor *pv)
95 {
96   pv->beginNotSimpleCasePoint(this);
97   for(auto it:_nodes)
98     it->accept(pv);
99   pv->endNotSimpleCasePoint(this);
100 }
101
102 AbstractPoint *NotSimpleCasePoint::expandNonSimpleCaseOn(NotSimpleCasePoint *pathologicalPt, const std::set<Node *>& uncatchedNodes)
103 {
104   throw YACS::Exception("NotSimpleCasePoint::expandNonSimpleCaseOn : ooops !");
105 }