Moka kernel
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
gmg-simplification.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 #include <stack>
27 using namespace GMap3d;
28 using namespace std;
29 //******************************************************************************
31 {
32  int mark = getNewMark();
33  negateMaskMark(mark);
34  int nb = deleteMarkedFlatFaces(mark);
35  negateMaskMark(mark);
36  freeMark(mark);
37  return nb;
38 }
39 //------------------------------------------------------------------------------
41 {
42  return contractMarkedCells(AMarkNumber, 2, true);
43 }
44 //******************************************************************************
46 {
47  int mark = getNewMark();
48  negateMaskMark(mark);
49  int nb = deleteMarkedFlatVolumes(mark);
50  negateMaskMark(mark);
51  freeMark(mark);
52  return nb;
53 }
54 //------------------------------------------------------------------------------
56 {
57  return contractMarkedCells(AMarkNumber, 3, true);
58 }
59 //------------------------------------------------------------------------------
61 {
62  int toDelete = getNewMark();
63  int nb = 0;
64  std::stack<CDart*> FToTreat; // Pile des arêtes à traiter
65  CDart* current = NULL;
66 
67  markIncidentCells(ORBIT_EDGE, AMarkNumber);
68 
69  CDynamicCoverageAll it(this);
70  while (it.cont())
71  {
72  while (! FToTreat.empty())
73  {
74  current = FToTreat.top();
75  FToTreat.pop();
76 
77  if (isMarked(current, AMarkNumber) && !isMarked(current, toDelete))
78  {
79  if (alpha12(current) == alpha21(current))
80  FToTreat.push(alpha1(current));
81 
82  if (alpha012(current) == alpha021(current))
83  FToTreat.push(alpha01(current));
84 
85  remove(current, 1, false);
86  markOrbit(current, ORBIT_EDGE, toDelete);
87  ++nb;
88  }
89  }
90 
91  if (isMarked(*it, AMarkNumber) && !isMarked(*it, toDelete) &&
92  alpha1(*it) == alpha2(*it))
93  {
94  if (alpha12(*it) == alpha21(*it))
95  FToTreat.push(alpha1(*it));
96 
97  if (alpha012(*it) == alpha021(*it))
98  FToTreat.push(alpha01(*it));
99 
100  remove(*it, 1, false);
101  markOrbit(*it, ORBIT_EDGE, toDelete);
102  ++nb;
103  }
104 
105  ++it;
106  }
107 
108  for (it.reinit(); it.cont();)
109  {
110  if (isMarked(*it, toDelete))
111  delMapDart(it++);
112  else
113  ++it;
114  }
115 
116  freeMark(toDelete);
117  return nb;
118 }
119 //------------------------------------------------------------------------------
121 {
122  int mark = getNewMark();
123  negateMaskMark(mark);
124  int nb = removeMarkedDanglingEdges(mark);
125  negateMaskMark(mark);
126  freeMark(mark);
127  return nb;
128 }
129 //******************************************************************************