Moka kernel
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
dynamic-coverage-real-face.hh
Go to the documentation of this file.
1 /*
2  * lib-gmapkernel : Un noyau de 3-G-cartes et des opérations.
3  * Copyright (C) 2004, Moka Team, Université de Poitiers, Laboratoire SIC
4  * http://www.sic.sp2mi.univ-poitiers.fr/
5  * Copyright (C) 2009, Guillaume Damiand, CNRS, LIRIS,
6  * guillaume.damiand@liris.cnrs.fr, http://liris.cnrs.fr/
7  *
8  * This file is part of lib-gmapkernel
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU Lesser General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  */
23 
24 //******************************************************************************
25 #ifndef DYNAMIC_COVERAGE_REAL_FACE_HH
26 #define DYNAMIC_COVERAGE_REAL_FACE_HH
27 //******************************************************************************
28 #include "coverage.hh"
29 #include "inline-macro.hh"
30 
31 #include <list>
32 #include <queue>
33 #include <stack>
34 //******************************************************************************
35 namespace GMap3d
36 {
37  class CDart;
38  class CGMapBasic;
39 
40  //----------------------------------------------------------------------------
48  {
49  private:
50  // @name Champs privés
51  // @{
52 
54  CDart* FDart1;
56  CDart* FDartCurrent;
57 
59  int FFictiveMark;
60 
70  bool FFirstDirection;
71 
76  bool FNextTryA0;
77 
79  bool FA3Exist;
80 
82  bool FFirstBorder;
83 
85  TOperationState FPrevOp;
86 
87  // @}
88 
89  public:
90  // @name Constructeur et destructeurs
91  // @{
92 
94  CDynamicCoverageRealFace(CGMapBasic* AGMap, const CDart* ADart, int AMark);
96  virtual ~CDynamicCoverageRealFace();
97 
98  // @}
99 
100  // @name Opérateurs de parcours (voir CCoverage)
101  // @{
102 
103  void reinit();
104  void operator++();
105  CDart* operator++(int);
106  bool cont();
107  CDart* operator*();
109  int type() const;
110 
111  // @}
112  };
113 
114 } // namespace GMap3d
115 
116 //******************************************************************************
117 //******************************************************************************
118 //******************************************************************************
119 //- INLINE CODE
120 //******************************************************************************
121 //******************************************************************************
122 //******************************************************************************
123 
124 //******************************************************************************
125 #include "g-map-basic.hh"
126 #include "dart.hh"
127 
128 #include <cassert>
129 //******************************************************************************
130 namespace GMap3d
131 {
132 //******************************************************************************
133 // CDynamicCoverageRealFace
134 //******************************************************************************
135 inline
137 {
138  FDartCurrent = FDart1;
139  FNextTryA0 = true;
140  FFirstBorder = true;
141  FFirstDirection = true;
142  FPrevOp = OP_NONE;
143 }
144 //******************************************************************************
145 inline
147 CDynamicCoverageRealFace(CGMapBasic* AGMap, const CDart* ADart1, int AMark) :
148  CCoverage (AGMap),
149  FDart1 ((CDart*) ADart1),
150  FFictiveMark(AMark)
151 {
152  FA3Exist = !FMap->isFree3(ADart1);
153  reinit();
154 }
155 //******************************************************************************
156 inline
158 {
159 }
160 //******************************************************************************
161 inline
163 {
164  return FPrevOp != OP_END;
165 }
166 //******************************************************************************
167 inline
169 {
170  assert(cont());
171 
172  if ( FA3Exist && FPrevOp!=OP_ALPHA3 )
173  {
174  FDartCurrent = FMap->alpha3(FDartCurrent);
175  FFirstBorder = !FFirstBorder;
176  FPrevOp = OP_ALPHA3;
177  }
178  else
179  {
180  int nextAlpha = 0;
181  // 1) On passe au brin suivant de la face
182  if ( !FNextTryA0 ) nextAlpha=1;
183 
184  if ( FMap->isFree(FDartCurrent, nextAlpha) )
185  {
186  if ( !FFirstDirection || FMap->isFree1(FDart1) )
187  FPrevOp = OP_END; // Fin du parcours.
188  else
189  {
190  FDartCurrent = FMap->alpha1(FDart1); // On fait le jump.
191  FFirstDirection = false;
192  FNextTryA0 = true;
193  FPrevOp = OP_JUMP;
194  }
195  }
196  else
197  {
198  FDartCurrent = FMap->alpha(FDartCurrent, nextAlpha);
199  FNextTryA0 = !FNextTryA0;
200  FPrevOp = (nextAlpha==0?OP_ALPHA0:OP_ALPHA1);
201  }
202 
203  if ( FPrevOp!=OP_END )
204  {
205  // 2) Si ce brin appartient à une arête fictive, on va tourner autour du
206  // sommet jusqu'a tomber sur une arête réelle.
207  while ( FMap->isMarked(FDartCurrent, FFictiveMark) && // C'est une arête fictive
208  !FMap->isFree2(FDartCurrent) && // si c'est un brin du bord
209  !FMap->isFree1(FMap->alpha2(FDartCurrent)) )
210  {
211  FDartCurrent = FMap->alpha1(FMap->alpha2(FDartCurrent));
212  }
213 
214  // 3) Si on est toujours sur une arête fictive, il faut re-essayer de jumper
215  if ( FMap->isMarked(FDartCurrent, FFictiveMark) )
216  {
217  if ( !FFirstDirection || FMap->isFree1(FDart1) )
218  FPrevOp = OP_END; // Fin du parcours.
219  else
220  {
221  FDartCurrent = FMap->alpha1(FDart1); // On fait le jump.
222  FFirstDirection = false;
223  FNextTryA0 = true;
224  FPrevOp = OP_JUMP;
225  }
226  }
227  }
228  }
229 
230  if ( FDartCurrent==FDart1 )
231  FPrevOp = OP_END;
232 }
233 //******************************************************************************
234 inline
236 {
237  return FPrevOp;
238 }
239 //******************************************************************************
240 inline
242 {
243  assert(cont());
244  return FDartCurrent;
245 }
246 //******************************************************************************
247 inline
249 {
250  CDart* tmp = operator*();
251 
252  operator++();
253  return tmp;
254 }
255 //******************************************************************************
256 inline
258 {
259  return COVERAGE_REAL_FACE;
260 }
261 //******************************************************************************
262 } // namespace GMap3d
263 //******************************************************************************
264 #endif // DYNAMIC_COVERAGE_REAL_FACE_HH
265 //******************************************************************************