Version: 8.3.0
SetOfPoints.cxx
Go to the documentation of this file.
1 // Copyright (C) 2015-2016 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 "SetOfPoints.hxx"
21 #include "BagPoint.hxx"
22 #include "LinkedBlocPoint.hxx"
23 #include "ForkBlocPoint.hxx"
24 #include "ElementaryPoint.hxx"
25 #include "Exception.hxx"
26 
27 #include <algorithm>
28 
29 using namespace YACS::ENGINE;
30 
31 SetOfPoints::SetOfPoints(const std::list<Node *>& nodes):_bp(0)
32 {
33  std::list<AbstractPoint *> nodes2;
34  for(std::list<Node *>::const_iterator it=nodes.begin();it!=nodes.end();it++)
35  {
36  nodes2.push_back(new ElementaryPoint(*it));
37  }
38  _bp=new BagPoint(nodes2,0);
39 }
40 
42 {
43  if(!_bp)
44  return;
45  delete _bp;
46 }
47 
49 {
50  while(_bp->size()>1)
51  {
52  bool somethingDone(false);
53  _bp->deal1(somethingDone);
54  if(somethingDone)
55  continue;
56  _bp->deal2(somethingDone);
57  if(somethingDone)
58  continue;
59  _bp->deal2Bis(somethingDone);
60  if(somethingDone)
61  continue;
62  _bp->deal2Ter(somethingDone);
63  if(!somethingDone)
64  throw Exception("SetOfPoints::simplify : not implemented yet !");
65  }
66 }
67 
68 std::string SetOfPoints::getRepr() const
69 {
70  return _bp->getRepr();
71 }
72 
74 {
75  if(node==0)
76  return 0;
77  return _bp->findPointWithNode(node);
78 }
79 
80 const std::list<AbstractPoint *>& SetOfPoints::getListOfPoints() const
81 {
82  return _bp->getListOfPoints();
83 }
84 
86 {
87  return _bp->getMaxLevelOfParallelism();
88 }