Moka controlers
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
precompile-sew.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 "precompile-sew.hh"
27 #include "parameter-gmap-vertex.hh"
28 #include "parameter-sew.hh"
29 #include <cassert>
30 using namespace GMap3d;
31 //******************************************************************************
33  CParameterSew * AParameterSew) :
34  FParameterGMapV (AParameterGMapV),
35  FParameterSew (AParameterSew)
36 {
37  assert(FParameterGMapV!=NULL && FParameterSew!=NULL);
38 
39  FParameterGMapV->addPrecompileToUpdate(this);
40  FParameterSew->addPrecompileToUpdate(this);
41 }
42 //******************************************************************************
44  CPrecompile (APrecompile),
45  FParameterGMapV (APrecompile.FParameterGMapV),
46  FParameterSew (static_cast<CParameterSew*>
47  (APrecompile.FParameterSew->copy()))
48 {
49  assert(FParameterGMapV!=NULL && FParameterSew!=NULL);
50 
51  FParameterGMapV->addPrecompileToUpdate(this);
52  FParameterSew->addPrecompileToUpdate(this);
53 }
54 //******************************************************************************
56 {
57  FParameterGMapV->removePrecompileToUpdate(this);
58  FParameterSew->removePrecompileToUpdate(this);
59 }
60 //******************************************************************************
62 { return new CPrecompileSew(*this); }
63 //******************************************************************************
65 {
66  switch (AParameter->getType())
67  {
69  setGMapVertex(static_cast<CParameterGMapVertex *>(AParameter));
70  break;
71  case PARAMETER_SEW: setSew(static_cast<CParameterSew *>(AParameter));
72  break;
73  }
74 }
75 //******************************************************************************
77 { return FParameterSew; }
78 //******************************************************************************
80 {
81  assert(AParameterGMapV != NULL);
82  AParameterGMapV->addPrecompileToUpdate(this);
83  FParameterGMapV->removePrecompileToUpdate(this);
84  FParameterGMapV = AParameterGMapV;
85  setToUpdate();
86 }
87 //******************************************************************************
89 {
90  assert(ASew != NULL);
91  ASew->addPrecompileToUpdate(this);
92  FParameterSew->removePrecompileToUpdate(this);
93  FParameterSew = ASew;
94  setToUpdate();
95 }
96 //******************************************************************************
98 { return PRECOMPILE_SEW; }
99 //******************************************************************************
100 #define WEIGHTING(k, v1,v2) ( (1-(k)) * (v1) + (k) * (v2) )
101 //******************************************************************************
102 void CPrecompileSew::drawSewsI(int AIndice, int AMark)
103 {
104  assert(0<=AIndice && AIndice<=3);
105 
106  CDynamicCoverageAll it(FParameterGMapV->getMap());
107  CDart *dart, *darti;
108  CVertex e,m;
109 
110  float kw; kw= FParameterSew->getSewPosCoef(AIndice);
111 
112  for (; it.cont(); ++it)
113  {
114  dart= *it;
115  if (!FParameterGMapV->getMap()->isMarked(dart,AMark))
116  {
117  FParameterGMapV->getMap()->setMark(dart , AMark);
118 
119  if (!FParameterGMapV->getMap()->isFree(dart,AIndice))
120  {
121  darti= FParameterGMapV->getMap()->alpha(dart,AIndice);
122  FParameterGMapV->getMap()->setMark(darti, AMark);
123  if (AIndice==0)
124  {
125  m= (FParameterGMapV->getDrawingMap()->
126  getBurstVertex(FParameterGMapV->getDartWithEmbedding(dart)) +
127  FParameterGMapV->getDrawingMap()->
128  getBurstVertex(FParameterGMapV->getDartWithEmbedding(darti)))/2;
129 
130  e= WEIGHTING(kw, m, FParameterGMapV->getDrawingMap()->
131  computeBurstExtremity
132  (FParameterGMapV->getDartWithEmbedding(dart)));
133  PLOT(&e);
134  e= WEIGHTING(kw, m, FParameterGMapV->getDrawingMap()->
135  computeBurstExtremity
136  (FParameterGMapV->getDartWithEmbedding(darti)));
137  PLOT(&e);
138  }
139  else
140  {
141  e= WEIGHTING(kw,
142  FParameterGMapV->getDrawingMap()->
143  getBurstVertex
144  (FParameterGMapV->getDartWithEmbedding(dart)),
145  FParameterGMapV->getDrawingMap()->
146  computeBurstExtremity
147  (FParameterGMapV->getDartWithEmbedding(dart)));
148  PLOT(&e);
149  e= WEIGHTING(kw,
150  FParameterGMapV->getDrawingMap()->
151  getBurstVertex
152  (FParameterGMapV->getDartWithEmbedding(darti)),
153  FParameterGMapV->getDrawingMap()->
154  computeBurstExtremity
155  (FParameterGMapV->getDartWithEmbedding(darti)));
156  PLOT(&e);
157  }
158  }
159  }
160  }
161 }
162 //******************************************************************************
164 {
165  int mark = FParameterGMapV->getMap()->getNewMark();
166 
167  for (int i=0; i<=3; ++i)
168  if (FParameterSew->getDisplayAlpha(i))
169  {
170  glColor3fv (FParameterSew->getCLSew(i));
171  glLineWidth(FParameterSew->getLWSew(i));
172  glBegin(GL_LINES);
173  drawSewsI(i,mark);
174  glEnd();
175  FParameterGMapV->getMap()->negateMaskMark(mark);
176  }
177 
178  glEnd();
179 
180  FParameterGMapV->getMap()->freeMark(mark);
181 }
182 //******************************************************************************
183 #undef WEIGHTING
184 //******************************************************************************