Version: 9.16.0
BlocPoint.cxx
Go to the documentation of this file.
1// Copyright (C) 2015-2026 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 "BlocPoint.hxx"
21#include "Node.hxx"
23
24#include <algorithm>
25
26using namespace YACS::ENGINE;
27
28BlocPoint::BlocPoint(const std::list<AbstractPoint *>& nodes, AbstractPoint *father):AbstractPoint(father),_nodes(nodes)
29{
30 for(std::list<AbstractPoint *>::const_iterator it=_nodes.begin();it!=_nodes.end();it++)
31 (*it)->setFather(this);
32}
33
35{
36 const std::list<AbstractPoint *>& nodesToIterateOn(other.getListOfPoints());
37 for(auto it : nodesToIterateOn)
38 {
39 _nodes.push_back(it->deepCopy(this));
40 }
41}
42
44{
45 std::list<AbstractPoint *>::iterator it(std::find(_nodes.begin(),_nodes.end(),node));
46 if(it==_nodes.end())
47 throw YACS::Exception("BlocPoint::getOutPoint : node not in this !");
48 _nodes.erase(it);
49 node->setFather(NULL);
50}
51
53{
54 for(std::list<AbstractPoint *>::iterator it=_nodes.begin();it!=_nodes.end();it++)
55 {
56 AbstractPoint *ret((*it)->findPointWithNode(node));
57 if(ret)
58 return AbstractPoint::GetDirectSonOf(this,ret);
59 }
60 return 0;
61}
62
64{
65 OutGate *oug(node->getOutGate());
66 std::list<InGate *> fl(oug->edSetInGate());
67 if(fl.size()>=1)
68 {
69 AbstractPoint *ret(0);
70 IsCommonDirectSonOf(this,fl,ret);
71 return ret;
72 }
73 else
74 return 0;
75}
76
78{
79 InGate *ing(node->getInGate());
80 std::list<OutGate *> bl(ing->getBackLinks());
81 if(bl.size()>=1)
82 {
83 AbstractPoint *ret(0);
84 IsCommonDirectSonOf(this,bl,ret);
85 return ret;
86 }
87 else
88 return 0;
89}
90
91bool BlocPoint::contains(Node *node) const
92{
93 for(auto it : _nodes)
94 {
95 if(it->contains(node))
96 return true;
97 }
98 return false;
99}
100
101bool BlocPoint::anyOf(const std::set<Node *>& nodes) const
102{
103 for(auto it : nodes)
104 {
105 if(this->contains(it))
106 return true;
107 }
108 return false;
109}
110
112{
113 if(_nodes.size()!=1)
114 throw YACS::Exception("BlocPoint::getUnique : invalid call !");
115 else
116 {
117 AbstractPoint *ret(*_nodes.begin());
118 if(!ret)
119 throw YACS::Exception("BlocPoint::getUnique : Ooops !");
120 return ret;
121 }
122}
123
125{
126 if(_nodes.size()!=1)
127 throw YACS::Exception("BlocPoint::getUnique const : invalid call !");
128 else
129 {
130 AbstractPoint *ret(*_nodes.begin());
131 if(!ret)
132 throw YACS::Exception("BlocPoint::getUnique : Ooops !");
133 return ret;
134 }
135}
136
138{
139 AbstractPoint *ret(getUnique());
140 getOutPoint(ret);
141 return ret;
142}
143
145{
146 int ret(0);
147 for(std::list<AbstractPoint *>::const_iterator it=_nodes.begin();it!=_nodes.end();it++)
148 ret+=(*it)->getNumberOfNodes();
149 return ret;
150}
151
153{
154 for(std::list<AbstractPoint *>::iterator it=_nodes.begin();it!=_nodes.end();it++)
155 delete *it;
156}
157
159{
160 std::size_t i(0);
161 std::for_each(_nodes.begin(),_nodes.end(),[&i](AbstractPoint *elt) { if(!dynamic_cast<NotSimpleCasePoint *>(elt)) i++; });
162 return i>1;
163}
164
166{
167 std::size_t i(0);
168 std::for_each(_nodes.begin(),_nodes.end(),[&i](AbstractPoint *elt) { if(dynamic_cast<NotSimpleCasePoint *>(elt)) i++; });
169 return i>0;
170}
static bool IsCommonDirectSonOf(AbstractPoint *refFather, const std::list< OutGate * > &outgs, AbstractPoint *&ret)
void setFather(AbstractPoint *father)
static AbstractPoint * GetDirectSonOf(AbstractPoint *refFather, AbstractPoint *sonOrLittleSon)
AbstractPoint * getUniqueAndReleaseIt()
Definition: BlocPoint.cxx:137
AbstractPoint * getNodeB4(Node *node)
Definition: BlocPoint.cxx:77
AbstractPoint * getNodeAfter(Node *node)
Definition: BlocPoint.cxx:63
void deepCopyFrom(const BlocPoint &other)
Definition: BlocPoint.cxx:34
AbstractPoint * getUnique()
Definition: BlocPoint.cxx:111
void getOutPoint(AbstractPoint *node)
Definition: BlocPoint.cxx:43
bool anyOf(const std::set< Node * > &nodes) const override
Definition: BlocPoint.cxx:101
int getNumberOfNodes() const
Definition: BlocPoint.cxx:144
bool presenceOfNonSimpleCase() const
Definition: BlocPoint.cxx:165
bool contains(Node *node) const override
Definition: BlocPoint.cxx:91
AbstractPoint * findPointWithNode(Node *node)
Definition: BlocPoint.cxx:52
std::list< AbstractPoint * > _nodes
Definition: BlocPoint.hxx:35
bool internalContinueForSimplify() const
Definition: BlocPoint.cxx:158
const std::list< AbstractPoint * > & getListOfPoints() const
Definition: BlocPoint.hxx:46
std::list< OutGate * > getBackLinks()
Definition: InGate.cxx:134
Base class for all nodes.
Definition: Node.hxx:70
OutGate * getOutGate()
Definition: Node.hxx:124
InGate * getInGate()
Definition: Node.hxx:123
std::list< InGate * > edSetInGate() const
Definition: OutGate.cxx:112