Moka kernel
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
gmg-thickening.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 #define DUP1(D) (getDirectInfoAsDart(D, ADirectInfoIndex1))
29 #define DUP2(D) (getDirectInfoAsDart(D, ADirectInfoIndex2))
30 //******************************************************************************
32  int ADirectInfoIndex1,
33  int ADirectInfoIndex2)
34 {
35  int nbThickened = 0;
36  int dup = getNewMark();
37 
38  CDynamicCoverageAll it(this);
39 
40  // Duplication des brins:
41  for (; it.cont(); ++it)
42  if (isMarked(*it, AMarkNumber))
43  {
44  CDart * newDart;
45 
46  newDart = addMapDart();
47  setMark(newDart, dup);
48  (*it)->setDirectInfo(ADirectInfoIndex1, newDart);
49 
50  newDart->setDirectInfo(ADirectInfoIndex1, *it);
51  newDart->setDirectInfo(ADirectInfoIndex2, NULL);
52 
53  newDart = addMapDart();
54  setMark(newDart, dup);
55  (*it)->setDirectInfo(ADirectInfoIndex2, newDart);
56 
57  newDart->setDirectInfo(ADirectInfoIndex1, NULL);
58  newDart->setDirectInfo(ADirectInfoIndex2, *it);
59 
60  ++nbThickened;
61  }
62 
63  // Coutures:
64  for (it.reinit(); it.cont(); ++it)
65  if (isMarked(*it, AMarkNumber))
66  {
67  if (!isFree0(*it) && isMarked(alpha0(*it), AMarkNumber))
68  linkAlpha0(DUP1(*it), DUP2(alpha0(*it)));
69 
70  if (!isFree1(*it) && isMarked(alpha1(*it), AMarkNumber))
71  linkAlpha1(DUP1(*it), DUP2(alpha1(*it)));
72  }
73 
74  for (it.reinit(); it.cont(); ++it)
75  if (isMarked(*it, AMarkNumber))
76  {
77  if (!isFree2(*it) && isMarked(alpha2(*it), AMarkNumber) &&
78  canSew2(DUP1(*it), DUP2(alpha2(*it))))
79  topoSew2(DUP1(*it), DUP2(alpha2(*it)));
80 
81  if (!isFree3(*it) && isMarked(alpha3(*it), AMarkNumber) &&
82  canSew3(DUP1(*it), DUP2(alpha3(*it))))
83  topoSew3(DUP1(*it), DUP2(alpha3(*it)));
84  }
85 
86  // Duplication des plongements:
87  int treated = getNewMark();
88 
89  for (int i=ORBIT_0; i<=ORBIT_0123; ++i)
90  if (isOrbitUsed(TOrbit(i)))
91  {
92  // Duplication pour l'orbite i:
93  for (it.reinit(); it.cont(); ++it)
94  if (!isMarked(*it, treated))
95  {
96  if (isMarked(*it, AMarkNumber))
97  {
98  CDart * owner = getEmbeddingOwner(*it, TOrbit(i));
99  assert(owner!=NULL);
100 
101  CEmbedding * E = owner->getEmbedding(TOrbit(i));
102  assert(E!=NULL);
103 
104  CCoverage * cov = getDynamicCoverage(*it, TOrbit(i));
105  assert(cov!=NULL);
106 
107  for (; cov->cont(); setMark(**cov, treated), ++(*cov))
108  if (isMarked(**cov, AMarkNumber))
109  {
110  if (!isMarked(DUP1(**cov), treated))
111  {
112  DUP1(**cov)->addEmbedding(E->copy());
113  markOrbit(DUP1(**cov), TOrbit(i), treated);
114  unmarkOrbit(DUP1(**cov), TOrbit(i), dup);
115  }
116 
117  if (!isMarked(DUP2(**cov), treated))
118  {
119  DUP2(**cov)->addEmbedding(E->copy());
120  markOrbit(DUP2(**cov), TOrbit(i), treated);
121  unmarkOrbit(DUP2(**cov), TOrbit(i), dup);
122  }
123  }
124 
125  delete cov;
126  }
127  else
128  if (!isMarked(*it, dup))
129  setMark(*it, treated);
130  }
131 
132  // Démarquage:
133  negateMaskMark(treated);
134  }
135 
136  freeMark(treated);
137  freeMark(dup);
138 
139  return nbThickened;
140 }
141 //******************************************************************************
142 #undef DUP1
143 #undef DUP2
144 //******************************************************************************