Moka kernel
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
gmg-degree.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 int CGMapGeneric::degree(CDart * ADart, int ACellDim, int ABoundingCell)
29 {
30  assert(ADart!=NULL);
31  assert(0<=ACellDim && ACellDim<3);
32  assert(0<ABoundingCell && ABoundingCell<=4);
33  assert(ACellDim<ABoundingCell);
34 
35  TOrbit countOrbit =
36  AND_ORBIT(ORBIT_CELL[ACellDim], ORBIT_CELL[ACellDim+1]);
37 
38  TOrbit boundingOrbit =
39  AND_ORBIT(ORBIT_CELL[ACellDim], ORBIT_CELL[ABoundingCell]);
40 
41  countOrbit = AND_ORBIT(countOrbit, ORBIT_CELL[ABoundingCell]);
42 
43  int nbIncident = 0;
44  int treated = getNewMark();
45 
46  CCoverage * cov = getDynamicCoverage(ADart, boundingOrbit);
47  for (; cov->cont(); ++(*cov))
48  if (!isMarked(**cov, treated))
49  {
50  ++nbIncident;
51  markOrbit(**cov, countOrbit, treated);
52  }
53  delete cov;
54 
55  unmarkOrbit(ADart, boundingOrbit, treated);
56  freeMark(treated);
57 
58  assert(nbIncident!=0);
59 
60  return nbIncident;
61 }
62 //******************************************************************************
63 bool CGMapGeneric::isLocalDegreeTwoSup(CDart * ADart, int ACellDim)
64 {
65  assert(ADart!=NULL);
66  assert(0<=ACellDim && ACellDim<=3);
67 
68  if ( ACellDim==2 ) return true;
69  if ( ACellDim==3 ) return false;
70 
71  // Optimisation possible surement pour l'arete mais pas pour le sommet ????
72  // TOrbit halfCell = (ACellDim == 1 ? ORBIT_23 : ORBIT_13);
73  CCoverage* cov = getDynamicCoverage(ADart, ORBIT_CELL[ACellDim]);
74  bool res = true;
75 
76  while (res && cov->cont())
77  {
78  if ( alpha(alpha(**cov, ACellDim+1), ACellDim+2)!=
79  alpha(alpha(**cov, ACellDim+2), ACellDim+1) )
80  res = false;
81 
82  ++(*cov);
83  }
84 
85  delete cov;
86 
87  return res;
88 }
89 //******************************************************************************
90 bool CGMapGeneric::isLocalDegreeTwoInf(CDart * ADart, int ACellDim)
91 {
92  assert(ADart!=NULL);
93  assert(0<=ACellDim && ACellDim<=3);
94 
95  if ( ACellDim==1 ) return true;
96  if ( ACellDim==0 ) return false;
97 
98  CCoverage* cov = getDynamicCoverage(ADart, ORBIT_CELL[ACellDim]);
99  bool res = true;
100 
101  while (res && cov->cont())
102  {
103  if ( alpha(alpha(**cov, ACellDim-1), ACellDim-2)!=
104  alpha(alpha(**cov, ACellDim-2), ACellDim-1) )
105  res = false;
106 
107  ++(*cov);
108  }
109 
110  delete cov;
111 
112  return res;
113 
114 }
115 //******************************************************************************