Salome HOME
Copyright update 2021
[modules/yacs.git] / src / engine / ElementaryPoint.cxx
1 // Copyright (C) 2015-2021  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 "ElementaryPoint.hxx"
21 #include "PointVisitor.hxx"
22 #include "NotSimpleCasePoint.hxx"
23 #include "ForkBlocPoint.hxx"
24 #include "Node.hxx"
25
26 using namespace YACS::ENGINE;
27
28 ElementaryPoint::~ElementaryPoint()
29 {
30 }
31
32 AbstractPoint *ElementaryPoint::findPointWithNode(Node *node)
33 {
34   if(node==_node)
35     return this;
36   else
37     return nullptr;
38 }
39
40 bool ElementaryPoint::contains(Node *node) const
41 {
42   return _node==node;
43 }
44
45 bool ElementaryPoint::anyOf(const std::set<Node *>& nodes) const
46 {
47   return nodes.find(_node)!=nodes.end();
48 }
49
50 AbstractPoint *ElementaryPoint::deepCopy(AbstractPoint *father) const
51 {
52   AbstractPoint *ret(new ElementaryPoint(_node));
53   ret->setFather(father);
54   return ret;
55 }
56
57 Node *ElementaryPoint::getFirstNode()
58 {
59   return _node;
60 }
61
62 Node *ElementaryPoint::getLastNode()
63 {
64   return _node;
65 }
66
67 int ElementaryPoint::getNumberOfNodes() const
68 {
69   return 1;
70 }
71
72 int ElementaryPoint::getMaxLevelOfParallelism() const
73 {
74   return _node->getMaxLevelOfParallelism();
75 }
76
77 void ElementaryPoint::getWeightRegardingDPL(ComplexWeight *weight)
78 {
79   _node->getWeightRegardingDPL(weight);
80 }
81
82 void ElementaryPoint::partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap) const
83 {
84   _node->partitionRegardingDPL(pd,zeMap);
85 }
86
87 std::string ElementaryPoint::getRepr() const
88 {
89   return _node->getName();
90 }
91
92 void ElementaryPoint::accept(PointVisitor *pv)
93 {
94   pv->beginElementaryPoint(this);
95   pv->endElementaryPoint(this);
96 }
97
98 AbstractPoint *ElementaryPoint::expandNonSimpleCaseOn(NotSimpleCasePoint *pathologicalPt, const std::set<Node *>& uncatchedNodes)
99 {
100   if(uncatchedNodes.find(_node)!=uncatchedNodes.end())
101     return this;
102   else
103     {
104       std::list<AbstractPoint *> l;
105       AbstractPoint *p0(this->deepCopy(getFather())),*p1(pathologicalPt->getUnique()->deepCopy(getFather()));
106       l.push_back(p0);
107       l.push_back(p1);
108       AbstractPoint *ret(new ForkBlocPoint(l,getFather()));
109       p0->setFather(ret); p1->setFather(ret);
110       return ret;
111     }
112 }
113
114 std::string ElementaryPoint::getNodeName() const
115 {
116   return _node->getName();
117 }