Moka controlers
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
parameter-gmap-vertex.cc
Go to the documentation of this file.
1 /*
2  * lib-controler-gmap : Le contrôleur de 3-G-cartes, surcouche de lib-controler.
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-controler-gmap
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 "controler-gmap-types.hh"
26 #include "parameter-gmap-vertex.hh"
27 #include <cassert>
28 using namespace std;
29 using namespace GMap3d;
30 //******************************************************************************
31 CParameterGMapVertex::CParameterGMapVertex(CGMapVertex* AGMap, int ANbRef) :
32  CParameter (ANbRef),
33  FMap (AGMap),
34  FMapEmbedding (NULL),
35  FDirectIndex (-1),
36  FChanged (false),
37  FPartialChanged (false),
38  FMarkPartialChanged(-1),
39  FBlocked (false),
40  FModeSimplification(false)
41 {
42  FRemovedMark[0]=-1; FRemovedMark[1]=-1; FRemovedMark[2]=-1;
43 }
44 //******************************************************************************
47  FMap (AParam.FMap),
48  FMapEmbedding (AParam.FMapEmbedding),
49  FDirectIndex (AParam.FDirectIndex),
50  FChanged (false),
51  FPartialChanged (false),
52  FMarkPartialChanged(-1),
53  FBlocked (false),
54  FModeSimplification(false)
55 {
56  FRemovedMark[0]=AParam.FRemovedMark[0];
57  FRemovedMark[1]=AParam.FRemovedMark[1];
58  FRemovedMark[2]=AParam.FRemovedMark[2];
59 }
60 //******************************************************************************
62 {}
63 //******************************************************************************
65 { return new CParameterGMapVertex(*this); }
66 //******************************************************************************
67 void CParameterGMapVertex::save(ostream& AStream)
68 {}
69 //------------------------------------------------------------------------------
70 void CParameterGMapVertex::load(istream& AStream)
71 {}
72 //------------------------------------------------------------------------------
74 {}
75 //******************************************************************************
76 CGMapVertex* CParameterGMapVertex::getMap() const
77 { return FMap; }
78 //------------------------------------------------------------------------------
79 void CParameterGMapVertex::setMap(CGMapVertex* AMap)
80 {
81  if ( AMap!=FMap )
82  {
83  FMap = AMap;
84  setChanged();
85  }
86 }
87 //------------------------------------------------------------------------------
89 { return FMapEmbedding; }
90 //------------------------------------------------------------------------------
92 {
93  if ( FModeSimplification ) return FMapEmbedding;
94  return FMap;
95 }
96 //******************************************************************************
98 { return FChanged; }
99 //------------------------------------------------------------------------------
101 {
102  if ( !FChanged )
103  {
104  FChanged = true;
106  }
107 }
108 //------------------------------------------------------------------------------
110 {
111  FChanged = false;
112  FPartialChanged = false;
113 }
114 //******************************************************************************
116 { return FPartialChanged; }
117 //------------------------------------------------------------------------------
119 {
120  if ( !FPartialChanged && !FChanged )
121  {
122  FPartialChanged = true;
124  }
125 }
126 //------------------------------------------------------------------------------
128 { FPartialChanged = false; }
129 //******************************************************************************
131 { return FBlocked; }
132 //------------------------------------------------------------------------------
134 { FBlocked = true; }
135 //------------------------------------------------------------------------------
137 {
138  if ( FBlocked )
139  {
140  FBlocked = false;
142  }
143 }
144 //******************************************************************************
146 { return FModeSimplification; }
147 //------------------------------------------------------------------------------
149 {
150  if ( !FModeSimplification )
151  {
152  FModeSimplification = true;
153  FMapEmbedding = new CGMapVertex;
154  FDirectIndex = FMap->getNewDirectInfo();
155 
156  FRemovedMark[0] = FMapEmbedding->getNewMark();
157  FRemovedMark[1] = FMapEmbedding->getNewMark();
158  FRemovedMark[2] = FMapEmbedding->getNewMark();
159 
160  // We copy FMap into the new map FMapEmbedding.
161  int mark = FMap->getNewMark();
162  FMap->negateMaskMark(mark);
163  FMap->duplicateMarkedDarts(mark,FMapEmbedding,FDirectIndex);
164 
165  FMapEmbedding->setBurstMethod(FMap->getBurstMethod());
166  FMapEmbedding->setBurstCoef (0, FMap->getBurstCoef(0));
167  FMapEmbedding->setBurstCoef (1, FMap->getBurstCoef(1));
168  FMapEmbedding->setBurstCoef (2, FMap->getBurstCoef(2));
169  FMapEmbedding->setBurstCoef (3, FMap->getBurstCoef(3));
170  FMapEmbedding->updateAllBurstDarts();
171 
172  FMap->negateMaskMark(mark);
173  FMap->freeMark(mark);
174  }
175 }
176 //------------------------------------------------------------------------------
178 {
179  if ( FModeSimplification )
180  {
181  FModeSimplification = false;
182  FMap->freeDirectInfo(FDirectIndex);
183 
184  FMapEmbedding->freeMark(FRemovedMark[0]);
185  FMapEmbedding->freeMark(FRemovedMark[1]);
186  FMapEmbedding->freeMark(FRemovedMark[2]);
187 
188  delete FMapEmbedding; FMapEmbedding=NULL;
190  }
191 }
192 //------------------------------------------------------------------------------
194 {
195  if ( FModeSimplification )
196  {
197  assert(FMap->getDirectInfoAsDart(ADart, FDirectIndex)!=NULL);
198  return FMap->getDirectInfoAsDart(ADart, FDirectIndex);
199  }
200 
201  return ADart;
202 }
203 //------------------------------------------------------------------------------
204 int CParameterGMapVertex::getMarkRemoved(unsigned int ADim) const
205 {
206  assert(ADim<3);
207  return FRemovedMark[ADim];
208 }
209 //------------------------------------------------------------------------------
211 {
212  for (int i=0;i<3;++i)
213  if (FMapEmbedding->isMarked(ADart,FRemovedMark[i])) return true;
214  return false;
215 }
216 //******************************************************************************
217 void CParameterGMapVertex::setBurstMethod(TBurstMethod AMethod)
218 {
219  if (AMethod != getBurstMethod())
220  {
221  FMap->setBurstMethod(AMethod);
222  if (FMapEmbedding!=NULL) FMapEmbedding->setBurstMethod(AMethod);
223 
224  FChanged = true;
226  }
227 }
228 //------------------------------------------------------------------------------
230 { return FMap->getBurstMethod(); }
231 //******************************************************************************
233 { return FMarkPartialChanged; }
234 //------------------------------------------------------------------------------
236 { FMarkPartialChanged = AValue; }
237 //******************************************************************************
239 { return PARAMETER_GMAP_VERTEX; }
240 //******************************************************************************