Moka kernel
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
gmg-stop-up.cc
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 #include "g-map-generic.hh"
26 using namespace GMap3d;
27 //******************************************************************************
28 void CGMapGeneric::stopUp(CDart * ADart, int ADim)
29 {
30  int treated= getNewMark();
31 
32  CStaticBorderCoverage cov(this, ADart, ADim);
33 
34  for (; cov.cont(); ++cov)
35  {
36  CDart * n = addMapDart();
37  linkAlpha(*cov,n,ADim);
38 
39  for (int i=0; i<=3; ++i)
40  if ((i<ADim-1 || i>ADim+1) && isMarked(alpha(*cov,i), treated))
41  linkAlpha(n, alpha(alpha(*cov,i),ADim), i);
42 
43  if (ADim==0)
44  linkAlpha0(n, *cov);
45  else
46  {
47  CDart * tmp = alpha(*cov, ADim-1);
48 
49  while (!isMarked(tmp,treated) &&
50  !isFree(tmp,ADim) &&
51  !isFree(alpha(tmp,ADim),ADim-1) &&
52  tmp!=alpha(*cov,ADim))
53  tmp = alpha(alpha(tmp,ADim),ADim-1);
54 
55  if (isMarked(tmp,treated))
56  linkAlpha(n,alpha(tmp,ADim),ADim-1);
57  }
58 
59  setMark(*cov,treated);
60  }
61 
62  for (cov.reinit(); cov.cont(); ++cov)
63  unsetMark(*cov,treated);
64 
65  freeMark(treated);
66 }
67 //******************************************************************************
68 int CGMapGeneric::stopUpMarkedBorders(int AMarkNumber, int ADim)
69 {
70  assert(ADim>=0 && ADim<=3);
71  int nbStoppedUp = 0;
72  CDynamicCoverageAll it(this);
73 
74  for (; it.cont(); ++it)
75  if (isMarked(*it,AMarkNumber) && getBorderDimension(*it)==ADim)
76  {
77  stopUp(*it,ADim);
78  ++nbStoppedUp;
79  }
80 
81  return nbStoppedUp;
82 }
83 //******************************************************************************
85 {
86  CDynamicCoverageAll it(this);
87  int nbStoppedUp = 0;
88  int treated = getNewMark();
89  int memo = getNewMark();
90 
91  for (int dim=0; dim<=3; ++dim)
92  {
93  for (it.reinit(); it.cont(); ++it)
94  if (isMarked(*it,AMarkNumber) &&
95  !isMarked(*it, treated) && isFree(*it, dim))
96  {
97  markOrbit(*it, ORBIT_INF [dim<3 ? dim+1 : 3], memo);
98  markOrbit(*it, ORBIT_BORDER[dim], treated);
99  stopUp(*it,dim);
100  ++nbStoppedUp;
101  }
102 
103  markMove(memo, treated);
104  }
105 
106  freeMark(memo);
107  unmarkAll(treated);
108  freeMark(treated);
109 
110  return nbStoppedUp;
111 }
112 //******************************************************************************