Moka kernel
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
gmv-direct-info.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-vertex.hh"
26 using namespace GMap3d;
27 //******************************************************************************
29  int ADirectInfoIndex,
30  TOrbit AOrbitUsed)
31 {
32  if (AOrbitUsed==ORBIT_NONE)
33  {
34  for (CDynamicCoverageAll it(this); it.cont(); ++it)
35  if (isMarked(*it, AMarkNumber))
36  setDirectInfo(*it, ADirectInfoIndex, new TCoordinate);
37  }
38  else
39  {
40  assert(isOrbitUsed(AOrbitUsed));
41  int treated = getNewMark();
42 
43  for (CDynamicCoverageAll it(this); it.cont(); ++it)
44  if (!isMarked(*it, treated))
45  {
46  if (isMarked(*it, AMarkNumber))
47  {
48  CDart * owner = getEmbeddingOwner(*it, AOrbitUsed);
49  assert(owner!=NULL);
50 
51  setDirectInfo(owner, ADirectInfoIndex, new TCoordinate);
52 
53  markOrbit(owner, AOrbitUsed, treated);
54  }
55  else
56  setMark(*it, treated);
57  }
58 
59  negateMaskMark(treated);
60  freeMark(treated);
61  }
62 }
63 //******************************************************************************
65  int ADirectInfoIndex,
66  TOrbit AOrbitUsed)
67 {
68  assert(ADart!=NULL);
69 
70  int mark = getNewMark();
71 
72  markOrbit(ADart, AOrbit, mark);
73  allocCoordToDirectInfo(mark, ADirectInfoIndex, AOrbitUsed);
74  unmarkOrbit(ADart, AOrbit, mark);
75 
76  freeMark(mark);
77 }
78 //******************************************************************************
80  int ADirectInfoNumber)
81 {
82  int treated = getNewMark();
83 
84  for (CDynamicCoverageAll it(this); it.cont(); ++it)
85  if (!isMarked(*it, treated))
86  {
87  if (isMarked(*it, AMarkNumber))
88  for (CDynamicCoverageVertex cov(this, *it); cov.cont(); ++cov)
89  {
90  setMark(*cov, treated);
91 
92  if (isOrbitUsed(*cov, ORBIT_VERTEX))
93  (*cov)->setDirectInfo(ADirectInfoNumber,
94  new CVertex(* getVertex(*cov)));
95 
96  else
97  (*cov)->setDirectInfo(ADirectInfoNumber, NULL);
98  }
99  else
100  {
101  setMark(*it, treated);
102  (*it)->setDirectInfo(ADirectInfoNumber, NULL);
103  }
104  }
105 
106  negateMaskMark(treated);
107  freeMark(treated);
108 }
109 //******************************************************************************
110 void CGMapVertex::deleteDuplicatedVertex(int ADirectInfoNumber)
111 {
112  for (CDynamicCoverageAll it(this); it.cont(); ++it)
113  delete getDirectInfoAsVertex(*it, ADirectInfoNumber);
114 }
115 //******************************************************************************
116 void CGMapVertex::updateDirectInfoWithVertex(int ADirectInfoNumber)
117 {
118  CDynamicCoverageAll it(this);
119 
120  for (; it.cont(); ++it)
121  if ((*it)->getDirectInfo(ADirectInfoNumber) != NULL)
122  * getDirectInfoAsVertex(*it, ADirectInfoNumber) = * getVertex(*it);
123 }
124 //******************************************************************************
126 {
127  int treated= getNewMark();
128 
129  for (CDynamicCoverageAll it(this); it.cont(); ++it)
130  if (!isMarked(*it, treated))
131  {
132  CAttributeVertex* vertex = getVertex(*it);
133 
134  if (vertex!=NULL)
135  for (CDynamicCoverageVertex cov(this, *it); cov.cont(); ++cov)
136  {
137  setMark(*cov,treated);
138  (*cov)->setDirectInfo(ADirectInfoIndex, vertex);
139  }
140  }
141 
142  negateMaskMark(treated);
143  freeMark(treated);
144 }
145 //******************************************************************************
147  CDart* ADart)
148 {
149  assert(ADart!=NULL);
150 
151  CAttributeVertex* vertex = findVertex(ADart);
152 
153  assert(vertex!=NULL);
154 
155  for (CDynamicCoverageVertex cov(this, ADart); cov.cont(); ++cov)
156  (*cov)->setDirectInfo(ADirectInfoIndex, vertex);
157 }
158 //******************************************************************************
160  CDart* ADart, TOrbit AOrbit)
161 {
162  int treated= getNewMark();
163  TOrbit orbit= AND_ORBIT(AOrbit,ORBIT_VERTEX);
164 
165  CCoverage* it=getDynamicCoverage(ADart,AOrbit);
166 
167  for (; it->cont(); ++(*it))
168  if (!isMarked(**it, treated))
169  {
170  CAttributeVertex* vertex = findVertex(**it);
171 
172  if (vertex!=NULL)
173  {
174  CCoverage* it2 = getDynamicCoverage(**it, orbit);
175  for (; it2->cont(); ++(*it2))
176  {
177  setMark(**it2,treated);
178  (**it2)->setDirectInfo(ADirectInfoIndex, vertex);
179  }
180 
181  delete it2;
182  }
183  }
184 
185  delete it;
186 
187  unmarkOrbit(ADart, AOrbit, treated);
188  freeMark(treated);
189 }
190 //******************************************************************************