Salome HOME
Merge from BR_V5_DEV 16Feb09
[modules/med.git] / src / INTERP_KERNEL / Geometric2D / AbstractEdge.cxx
1 //  Copyright (C) 2007-2008  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.
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 #include "AbstractEdge.hxx"
20 #include "ComposedEdge.hxx"
21 #include "ElementaryEdge.hxx"
22
23 using namespace INTERP_KERNEL;
24
25 IteratorOnComposedEdge::IteratorOnComposedEdge():_list_handle(0)
26 {
27 }
28
29 IteratorOnComposedEdge::IteratorOnComposedEdge(ComposedEdge *compEdges):_list_handle(compEdges->getListBehind()) 
30 {
31   first(); 
32 }
33
34 void IteratorOnComposedEdge::operator=(const IteratorOnComposedEdge& other)
35 {
36   _deep_it=other._deep_it;
37   _list_handle=other._list_handle;
38 }
39
40 void IteratorOnComposedEdge::last()
41 {
42   _deep_it=_list_handle->end();
43   _deep_it--;
44 }
45
46 void IteratorOnComposedEdge::nextLoop()
47 {
48   _deep_it++;
49   if(_deep_it==_list_handle->end())
50     first();
51 }
52
53 void IteratorOnComposedEdge::previousLoop()
54 {
55   if(_deep_it!=_list_handle->begin())
56     _deep_it--;
57   else
58     last();
59 }
60
61 bool IteratorOnComposedEdge::goToNextInOn(bool direction, int& i, int nbMax)
62 {
63   TypeOfEdgeLocInPolygon loc=current()->getLoc();
64   if(direction)
65     {
66       while(loc==FULL_OUT_1 && i<nbMax)
67         {
68           nextLoop(); i++;
69           loc=current()->getLoc();
70         }
71       if(i==nbMax)
72         return false;
73       return true;
74     }
75   else
76     {
77       while(loc==FULL_OUT_1 && i<nbMax)
78         {
79           previousLoop(); i++;
80           loc=current()->getLoc();
81         }
82       if(i==nbMax)
83         return false;
84       while(loc!=FULL_OUT_1 && i<nbMax)
85         {
86           previousLoop(); i++;
87           loc=current()->getLoc();
88         }
89       nextLoop(); i--;
90       return true;
91     }
92 }
93
94 void IteratorOnComposedEdge::assignMySelfToAllElems(ComposedEdge *elems)
95 {
96   std::list<ElementaryEdge *> *myList=elems->getListBehind();
97   for(std::list<ElementaryEdge *>::iterator iter=myList->begin();iter!=myList->end();iter++)
98     (*iter)->getIterator()=(*this);
99 }
100
101 void IteratorOnComposedEdge::insertElemEdges(ComposedEdge *elems, bool changeMySelf)
102 {
103   std::list<ElementaryEdge *> *myListToInsert=elems->getListBehind();
104   std::list<ElementaryEdge *>::iterator iter=myListToInsert->begin();
105   *_deep_it=*iter;
106   _deep_it++;
107   iter++;
108   int sizeOfMyList=myListToInsert->size();
109   _list_handle->insert(_deep_it,iter,myListToInsert->end());
110   if(!changeMySelf)
111     {
112       for(int i=0;i<sizeOfMyList;i++)
113         _deep_it--;
114     }
115 }
116