Moka controlers
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
parameter-operations.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-operations.hh"
27 using namespace std;
28 using namespace GMap3d;
29 //******************************************************************************
30 CParameterOperations::CParameterOperations(int ANbRef) :
31  CParameter(ANbRef),
32 
33  FRotateCells(true),
34  FScaleCells(true),
35  FTranslateCells(true),
36 
37  FInterpolationMerges(true),
38  FInterpolationSews (true),
39 
40  FSmoothMerges(true),
41  FSmoothSews (true),
42  FSmoothMethod(SPLINE_SMOOTH),
43 
44  FExtrusionCoef (1.0),
45  FExtrusionRevolutionAngle (360.0),
46  FExtrusionAdjacentSews (true),
47  FExtrusionInitialPositionMode (1),
48  FExtrusionInitialDirectionMode(1),
49  FExtrusionDirection (true),
50  FExtrusionScale (true),
51  FExtrusionPonderateSection (false),
52  FExtrusionRevolutionNbEdges (8)
53 {
54  FMeshNbSubdivisions[0] = 5;
55  FMeshNbSubdivisions[1] = 5;
56  FMeshNbSubdivisions[2] = 5;
57 
58  FRoundingDefaultCoefs[0] = 0.2;
59  FRoundingDefaultCoefs[1] = 0.2;
60  FRoundingDefaultCoefs[2] = 0.2;
61 }
62 //******************************************************************************
65  CParameter (AParam),
66 
67  FRotateCells (AParam.FRotateCells),
68  FScaleCells (AParam.FScaleCells),
69  FTranslateCells(AParam.FTranslateCells),
70 
71  FInterpolationMerges(AParam.FInterpolationMerges),
72  FInterpolationSews (AParam.FInterpolationSews),
73 
74  FSmoothMerges(AParam.FSmoothMerges),
75  FSmoothSews (AParam.FSmoothSews),
76  FSmoothMethod(AParam.FSmoothMethod),
77 
78  FExtrusionCoef (AParam.FExtrusionCoef),
79  FExtrusionRevolutionAngle (AParam.FExtrusionRevolutionAngle),
80  FExtrusionAdjacentSews (AParam.FExtrusionAdjacentSews),
81  FExtrusionInitialPositionMode (AParam.FExtrusionInitialPositionMode),
82  FExtrusionInitialDirectionMode(AParam.FExtrusionInitialDirectionMode),
83  FExtrusionDirection (AParam.FExtrusionDirection),
84  FExtrusionScale (AParam.FExtrusionScale),
85  FExtrusionPonderateSection (AParam.FExtrusionPonderateSection),
86  FExtrusionRevolutionNbEdges (AParam.FExtrusionRevolutionNbEdges)
87 {
88  FMeshNbSubdivisions[0] = AParam.FMeshNbSubdivisions[0];
89  FMeshNbSubdivisions[1] = AParam.FMeshNbSubdivisions[1];
90  FMeshNbSubdivisions[2] = AParam.FMeshNbSubdivisions[2];
91 
92  FRoundingDefaultCoefs[0] = AParam.FRoundingDefaultCoefs[0];
93  FRoundingDefaultCoefs[1] = AParam.FRoundingDefaultCoefs[1];
94  FRoundingDefaultCoefs[2] = AParam.FRoundingDefaultCoefs[2];
95 }
96 //******************************************************************************
98 {
99 }
100 //******************************************************************************
102 { return new CParameterOperations(*this); }
103 //******************************************************************************
104 void CParameterOperations::load(istream& /*AStream*/)
105 {}
106 //------------------------------------------------------------------------------
107 void CParameterOperations::save(ostream& /*AStream*/)
108 {}
109 //------------------------------------------------------------------------------
111 {}
112 //******************************************************************************
114 {
115  return PARAMETER_OPERATIONS;
116 }
117 //******************************************************************************
119 {
120  if ( FRotateCells!=ABool )
121  {
123  FRotateCells = ABool;
124  }
125 }
126 
128 {
129  return FRotateCells;
130 }
131 //------------------------------------------------------------------------------
133 {
134  if ( FScaleCells!=ABool )
135  {
137  FScaleCells = ABool;
138  }
139 }
140 
142 {
143  return FScaleCells;
144 }
145 //------------------------------------------------------------------------------
147 {
148  if ( FTranslateCells!=ABool )
149  {
151  FTranslateCells = ABool;
152  }
153 }
154 
156 {
157  return FTranslateCells;
158 }
159 //******************************************************************************
161 {
162  return FMeshNbSubdivisions[0];
163 }
164 
166 {
167  return FMeshNbSubdivisions[1];
168 }
169 
171 {
172  return FMeshNbSubdivisions[2];
173 }
174 
176 {
177  assert(0 < ASx);
178  FMeshNbSubdivisions[0] = ASx;
179 }
180 
182 {
183  assert(0 < ASy);
184  FMeshNbSubdivisions[1] = ASy;
185 }
186 
188 {
189  assert(0 < ASz);
190  FMeshNbSubdivisions[2] = ASz;
191 }
192 //------------------------------------------------------------------------------
194 { return FInterpolationMerges; }
195 
197 {
198  if ( FInterpolationMerges!=ABool )
199  {
201  FInterpolationMerges = ABool;
202  }
203 }
204 //------------------------------------------------------------------------------
206 {
207  if (isActiveInterpolationSews()) return FInterpolationSews;
208 
209  return false;
210 }
211 
213 {
214  if ( FInterpolationSews!=ABool && isActiveInterpolationSews() )
215  {
217  FInterpolationSews = ABool;
218  }
219 }
220 //------------------------------------------------------------------------------
222 { return !getInterpolationMerges(); }
223 //------------------------------------------------------------------------------
225 {
226  if (isActiveSmoothMerges()) return FSmoothMerges;
227 
228  return false;
229 }
230 
232 {
233  if ( FSmoothMerges!=ABool && isActiveSmoothMerges() )
234  {
236  FSmoothMerges = ABool;
237  }
238 }
239 //------------------------------------------------------------------------------
241 {
242  if (isActiveSmoothSews()) return FSmoothSews;
243 
244  return false;
245 }
246 
248 {
249  if ( FSmoothSews!=ABool && isActiveSmoothSews() )
250  {
252  FSmoothSews = ABool;
253  }
254 }
255 //------------------------------------------------------------------------------
257 { return FSmoothMethod; }
258 
260 {
261  assert(HERMITE_SMOOTH<=AValue && AValue<=SPLINE_SMOOTH );
262  if ( FSmoothMethod!=AValue )
263  {
265  FSmoothMethod = AValue;
266  }
267 }
268 //------------------------------------------------------------------------------
269 static const CTransformationMatrix * SMOOTH_MATRIX[] =
270 {
271  & HERMITE,
272  & BEZIER,
273  & OVERHAUSER,
274  & SPLINE
275 };
276 
277 const CTransformationMatrix & CParameterOperations::getMeshMatrix() const
278 {
279  return * SMOOTH_MATRIX[FSmoothMethod];
280 }
281 //------------------------------------------------------------------------------
282 static const bool CAN_MERGE[] =
283 {
284  /*HERMITE */ true ,
285  /*BEZIER */ false,
286  /*OVERHAUSER*/ true ,
287  /*SPLINE */ false
288 };
289 
290 static const bool CAN_SEW[] =
291 {
292  /*HERMITE */ true ,
293  /*BEZIER */ false,
294  /*OVERHAUSER*/ true ,
295  /*SPLINE */ true
296 };
297 //------------------------------------------------------------------------------
299 {
300  assert(HERMITE_SMOOTH<=FSmoothMethod && FSmoothMethod<=SPLINE_SMOOTH );
301 
302  return CAN_MERGE[FSmoothMethod];
303 }
305 {
306  assert(HERMITE_SMOOTH<=FSmoothMethod && FSmoothMethod<=SPLINE_SMOOTH );
307 
308  return CAN_SEW[FSmoothMethod] && !getSmoothMerges();
309 }
310 //******************************************************************************
312 {
313  return FExtrusionCoef;
314 }
315 
317 {
318  FExtrusionCoef = ACoef;
319 }
320 //------------------------------------------------------------------------------
322 {
323  return FExtrusionRevolutionAngle;
324 }
325 
327 {
328  FExtrusionRevolutionAngle = AAngle;
329 }
330 //------------------------------------------------------------------------------
332 { return FExtrusionAdjacentSews; }
333 
335 {
336  if ( FExtrusionAdjacentSews!=ABool )
337  {
339  FExtrusionAdjacentSews = ABool;
340  }
341 }
342 //------------------------------------------------------------------------------
344 { return FExtrusionInitialPositionMode; }
345 
347 {
348  if ( FExtrusionInitialPositionMode!=AValue )
349  {
351  FExtrusionInitialPositionMode = AValue;
352  }
353 }
354 //------------------------------------------------------------------------------
356 { return FExtrusionInitialDirectionMode; }
357 
359 {
360  if ( FExtrusionInitialDirectionMode!=AValue )
361  {
363  FExtrusionInitialDirectionMode = AValue;
364  }
365 }
366 //------------------------------------------------------------------------------
368 { return FExtrusionDirection; }
369 
371 {
372  if ( FExtrusionDirection!=ABool )
373  {
375  FExtrusionDirection = ABool;
376  }
377 }
378 //------------------------------------------------------------------------------
380 { return FExtrusionScale; }
381 
383 {
384  if ( FExtrusionScale!=ABool )
385  {
387  FExtrusionScale = ABool;
388  }
389 }
390 //------------------------------------------------------------------------------
392 { return FExtrusionPonderateSection; }
393 
395 {
396  if ( FExtrusionPonderateSection!=ABool )
397  {
399  FExtrusionPonderateSection = ABool;
400  }
401 }
402 //------------------------------------------------------------------------------
404 { return FExtrusionRevolutionNbEdges; }
405 
407 {
408  if ( FExtrusionRevolutionNbEdges!=AValue )
409  {
411  FExtrusionRevolutionNbEdges = AValue;
412  }
413 }
414 //******************************************************************************
416 {
417  return FRoundingDefaultCoefs[0];
418 }
419 //------------------------------------------------------------------------------
421 {
422  FRoundingDefaultCoefs[0] = ACoef;
423 }
424 //------------------------------------------------------------------------------
426 {
427  return FRoundingDefaultCoefs[1];
428 }
429 //------------------------------------------------------------------------------
431 {
432  FRoundingDefaultCoefs[1] = ACoef;
433 }
434 //------------------------------------------------------------------------------
436 {
437  return FRoundingDefaultCoefs[2];
438 }
439 //------------------------------------------------------------------------------
441 {
442  FRoundingDefaultCoefs[2] = ACoef;
443 }
444 //******************************************************************************