Moka kernel
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
gmg-triangulation.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 //******************************************************************************
29 {
30  assert(ADart!=NULL);
31  insertVertex(ADart);
32  return alpha0(ADart);
33 }
34 //******************************************************************************
36 {
37  assert(ADart!=NULL);
38 
39  int treated = getNewMark();
40 
41  CStaticCoverage01 it(this, ADart);
42 
43  for (; it.cont(); setMark(*it, treated), ++it)
44  {
45  CDart * n1 = addMapDart();
46  CDart * n2 = addMapDart(); linkAlpha0(n1,n2);
47 
48  CDart * nn1 = NULL, * nn2 = NULL, * d3;
49 
50  if (isFree3(*it))
51  d3=NULL;
52  else
53  {
54  d3=alpha3(*it);
55  nn1=addMapDart();
56  nn2=addMapDart(); linkAlpha0(nn1,nn2);
57  linkAlpha3(n1,nn1);
58  linkAlpha3(n2,nn2);
59  }
60 
61  if (!isFree0(*it) && isMarked(alpha0(*it), treated))
62  {
63  linkAlpha1(n2,alpha010(*it));
64  if (d3!=NULL) linkAlpha1(nn2,alpha010(d3));
65  }
66 
67  if (!isFree1(*it) && isMarked(alpha1(*it), treated))
68  {
69  topoSew2(n1,alpha1(alpha1(*it)));
70  if (d3!=NULL) topoSew2(nn1,alpha1(alpha1(d3)));
71  }
72 
73  linkAlpha1(*it,n1);
74  if (d3!=NULL) linkAlpha1(d3,nn1);
75  }
76 
77  for (it.reinit(); it.cont(); ++it)
78  unsetMark(*it, treated);
79 
80  freeMark(treated);
81 
82  return alpha10(ADart);
83 }
84 //******************************************************************************
86 {
87  assert(ADart!=NULL);
88 
89  int treated = getNewMark();
90 
91  CStaticCoverage012 it(this, ADart);
92 
93  for (; it.cont(); setMark(*it, treated), ++it)
94  {
95  CDart * n1= addMapDart();
96  CDart * n2= addMapDart();
97  CDart * d2= addMapDart();
98 
99  linkAlpha0(n1,n2);
100  linkAlpha1(d2,n1);
101 
102  if (!isFree0(*it) && isMarked(alpha0(*it),treated))
103  {
104  linkAlpha0(d2,alpha02 (*it));
105  linkAlpha1(n2,alpha0210(*it));
106  }
107 
108  if (!isFree1(*it) && isMarked(alpha1(*it),treated))
109  {
110  linkAlpha2(n1,alpha121 (*it));
111  linkAlpha2(n2,alpha1210(*it));
112  }
113 
114  if (!isFree2(*it) && isMarked(alpha2(*it),treated))
115  {
116  linkAlpha3(n1,alpha21 (alpha2(*it)));
117  linkAlpha3(n2,alpha210(alpha2(*it)));
118  linkAlpha3(d2,alpha2 (alpha2(*it)));
119  }
120 
121  linkAlpha2(*it,d2);
122  }
123 
124  for (it.reinit(); it.cont(); ++it)
125  unsetMark(*it, treated);
126 
127  freeMark(treated);
128 
129  return alpha210(ADart);
130 }
131 //******************************************************************************
133 {
134  assert(ADart!=NULL);
135  assert(ADim>0 && ADim<=3);
136 
137  switch (ADim)
138  {
139  case 1: return triangulateEdge(ADart);
140  case 2: return triangulateFace(ADart);
141  case 3: return triangulateVolume(ADart);
142  }
143 
144  return NULL; // pour éviter un warning à la compilation...
145 }
146 //******************************************************************************
147 int CGMapGeneric::triangulateMarkedCells(int AMarkNumber, int ADim)
148 {
149  assert(ADim>=1 && ADim<=3);
150 
151  int nbTriangulated = 0;
152  int treated = getNewMark();
153 
154  for (CDynamicCoverageAll it(this); it.cont(); ++it)
155  if (isMarked(*it, AMarkNumber) && !isMarked(*it, treated))
156  {
157  markOrbit(*it, ORBIT_CELL[ADim], treated);
158  triangulate(*it, ADim);
159  ++nbTriangulated;
160  }
161 
162  unmarkAll(treated);
163  freeMark(treated);
164 
165  return nbTriangulated;
166 }
167 //******************************************************************************