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