1 // Copyright (C) 2015-2021 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 "BlocPoint.hxx"
22 #include "NotSimpleCasePoint.hxx"
26 using namespace YACS::ENGINE;
28 BlocPoint::BlocPoint(const std::list<AbstractPoint *>& nodes, AbstractPoint *father):AbstractPoint(father),_nodes(nodes)
30 for(std::list<AbstractPoint *>::const_iterator it=_nodes.begin();it!=_nodes.end();it++)
31 (*it)->setFather(this);
34 void BlocPoint::deepCopyFrom(const BlocPoint& other)
36 const std::list<AbstractPoint *>& nodesToIterateOn(other.getListOfPoints());
37 for(auto it : nodesToIterateOn)
39 _nodes.push_back(it->deepCopy(this));
43 void BlocPoint::getOutPoint(AbstractPoint *node)
45 std::list<AbstractPoint *>::iterator it(std::find(_nodes.begin(),_nodes.end(),node));
47 throw YACS::Exception("BlocPoint::getOutPoint : node not in this !");
49 node->setFather(NULL);
52 AbstractPoint *BlocPoint::findPointWithNode(Node *node)
54 for(std::list<AbstractPoint *>::iterator it=_nodes.begin();it!=_nodes.end();it++)
56 AbstractPoint *ret((*it)->findPointWithNode(node));
58 return AbstractPoint::GetDirectSonOf(this,ret);
63 AbstractPoint *BlocPoint::getNodeAfter(Node *node)
65 OutGate *oug(node->getOutGate());
66 std::list<InGate *> fl(oug->edSetInGate());
69 AbstractPoint *ret(0);
70 IsCommonDirectSonOf(this,fl,ret);
77 AbstractPoint *BlocPoint::getNodeB4(Node *node)
79 InGate *ing(node->getInGate());
80 std::list<OutGate *> bl(ing->getBackLinks());
83 AbstractPoint *ret(0);
84 IsCommonDirectSonOf(this,bl,ret);
91 bool BlocPoint::contains(Node *node) const
95 if(it->contains(node))
101 bool BlocPoint::anyOf(const std::set<Node *>& nodes) const
105 if(this->contains(it))
111 AbstractPoint *BlocPoint::getUnique()
114 throw YACS::Exception("BlocPoint::getUnique : invalid call !");
117 AbstractPoint *ret(*_nodes.begin());
119 throw YACS::Exception("BlocPoint::getUnique : Ooops !");
124 const AbstractPoint *BlocPoint::getUnique() const
127 throw YACS::Exception("BlocPoint::getUnique const : invalid call !");
130 AbstractPoint *ret(*_nodes.begin());
132 throw YACS::Exception("BlocPoint::getUnique : Ooops !");
137 AbstractPoint *BlocPoint::getUniqueAndReleaseIt()
139 AbstractPoint *ret(getUnique());
144 int BlocPoint::getNumberOfNodes() const
147 for(std::list<AbstractPoint *>::const_iterator it=_nodes.begin();it!=_nodes.end();it++)
148 ret+=(*it)->getNumberOfNodes();
152 BlocPoint::~BlocPoint()
154 for(std::list<AbstractPoint *>::iterator it=_nodes.begin();it!=_nodes.end();it++)
158 bool BlocPoint::internalContinueForSimplify() const
161 std::for_each(_nodes.begin(),_nodes.end(),[&i](AbstractPoint *elt) { if(!dynamic_cast<NotSimpleCasePoint *>(elt)) i++; });
165 bool BlocPoint::presenceOfNonSimpleCase() const
168 std::for_each(_nodes.begin(),_nodes.end(),[&i](AbstractPoint *elt) { if(dynamic_cast<NotSimpleCasePoint *>(elt)) i++; });