Moka controlers
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
parameter-creation.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-creation.hh"
27 #include "vertex.hh"
28 #include <cassert>
29 using namespace std;
30 using namespace GMap3d;
31 //******************************************************************************
32 #define DEFAULT_SPHERE_NB_MERIDIANS (12)
33 #define DEFAULT_SPHERE_NB_PARALLELS ( 6)
34 
35 #define DEFAULT_CYLINDER_NB_MERIDIANS (10)
36 #define DEFAULT_CYLINDER_NB_PARALLELS ( 4)
37 
38 #define DEFAULT_PYRAMID_NB_MERIDIANS ( 8)
39 #define DEFAULT_PYRAMID_NB_PARALLELS ( 8)
40 
41 #define DEFAULT_TORUS_NB_MERIDIANS (12)
42 #define DEFAULT_TORUS_NB_PARALLELS ( 6)
43 //******************************************************************************
44 CParameterCreation::CParameterCreation(int ANbRef) :
45  CParameter (ANbRef),
46  FPolygonNbEdges (6),
47  FMeshDimension (3),
48  FMeshSubdivisionDimension(0),
49  FCreatedFaces (CUBE_ALL),
50  FCylinderNbMeridians (DEFAULT_CYLINDER_NB_MERIDIANS),
51  FCylinderNbParallels (DEFAULT_CYLINDER_NB_PARALLELS),
52  FCylinderClosedUp (true),
53  FCylinderClosedDown (true),
54  FPyramidNbMeridians (DEFAULT_PYRAMID_NB_MERIDIANS),
55  FPyramidNbParallels (DEFAULT_PYRAMID_NB_PARALLELS),
56  FPyramidClosed (true),
57  FSphereNbMeridians (DEFAULT_SPHERE_NB_MERIDIANS),
58  FSphereNbParallels (DEFAULT_SPHERE_NB_PARALLELS),
59  FTorusNbMeridians (DEFAULT_TORUS_NB_MERIDIANS),
60  FTorusNbParallels (DEFAULT_TORUS_NB_PARALLELS),
61  FTorusRadiusRapport (0.5)
62 {
63  // Maillages :
64  FMeshNbSubdivisions[0] = 3;
65  FMeshNbSubdivisions[1] = 3;
66  FMeshNbSubdivisions[2] = 3;
67 }
68 //******************************************************************************
70  CParameter (AParam),
71  FPolygonNbEdges (AParam.FPolygonNbEdges),
72  FMeshDimension (AParam.FMeshDimension),
73  FMeshSubdivisionDimension(AParam.FMeshSubdivisionDimension),
74  FCreatedFaces (AParam.FCreatedFaces),
75  FCylinderNbMeridians (AParam.FCylinderNbMeridians),
76  FCylinderNbParallels (AParam.FCylinderNbParallels),
77  FCylinderClosedUp (AParam.FCylinderClosedUp),
78  FCylinderClosedDown (AParam.FCylinderClosedDown),
79  FPyramidNbMeridians (AParam.FPyramidNbMeridians),
80  FPyramidNbParallels (AParam.FPyramidNbParallels),
81  FPyramidClosed (AParam.FPyramidClosed),
82  FSphereNbMeridians (AParam.FSphereNbMeridians),
83  FSphereNbParallels (AParam.FSphereNbParallels),
84  FTorusNbMeridians (AParam.FTorusNbMeridians),
85  FTorusNbParallels (AParam.FTorusNbParallels),
86  FTorusRadiusRapport (AParam.FTorusRadiusRapport)
87 {
88  FMeshNbSubdivisions[0] = AParam.FMeshNbSubdivisions[0];
89  FMeshNbSubdivisions[1] = AParam.FMeshNbSubdivisions[1];
90  FMeshNbSubdivisions[2] = AParam.FMeshNbSubdivisions[2];
91 }
92 //******************************************************************************
94 {}
95 //******************************************************************************
97 { return new CParameterCreation(*this); }
98 //******************************************************************************
100 { return FPolygonNbEdges; }
101 //******************************************************************************
103 {
104  assert(ANbEdges >= 2);
105 
106  if ( FPolygonNbEdges!=ANbEdges )
107  {
109  FPolygonNbEdges= ANbEdges;
110  }
111 }
112 //******************************************************************************
114 {
115  return FMeshNbSubdivisions[0];
116 }
117 //******************************************************************************
119 {
120  return FMeshNbSubdivisions[1];
121 }
122 //******************************************************************************
124 {
125  return FMeshNbSubdivisions[2];
126 }
127 //******************************************************************************
129 {
130  assert(ASx > 0);
131  if ( FMeshNbSubdivisions[0]!=ASx )
132  {
134  FMeshNbSubdivisions[0]= ASx;
135  }
136 }
137 //******************************************************************************
139 {
140  assert(ASy > 0);
141  if ( FMeshNbSubdivisions[1]!=ASy )
142  {
144  FMeshNbSubdivisions[1]= ASy;
145  }
146 }
147 //******************************************************************************
149 {
150  assert(ASz > 0);
151  if ( FMeshNbSubdivisions[2]!=ASz )
152  {
154  FMeshNbSubdivisions[2] = ASz;
155  }
156 }
157 //******************************************************************************
159 {
160  return FMeshDimension;
161 }
162 //******************************************************************************
164 {
165  assert(1 <= ADimension && ADimension <= 3);
166 
167  if ( FMeshDimension!=ADimension )
168  {
170  FMeshDimension= ADimension;
171 
172  if (FMeshDimension < FMeshSubdivisionDimension)
173  FMeshSubdivisionDimension= FMeshDimension;
174  }
175 }
176 //******************************************************************************
178 {
179  return FMeshSubdivisionDimension;
180 }
181 //******************************************************************************
183 {
184  assert(0 <= ADimension && ADimension <= 3);
185 
186  if ( FMeshSubdivisionDimension!=ADimension )
187  {
189  FMeshSubdivisionDimension= ADimension;
190 
191  if (FMeshDimension < FMeshSubdivisionDimension)
192  FMeshDimension= FMeshSubdivisionDimension;
193  }
194 }
195 //******************************************************************************
197 {
198  return FMeshSubdivisionDimension < 3;
199 }
200 //******************************************************************************
202 {
203  return FCreatedFaces;
204 }
205 //******************************************************************************
206 bool CParameterCreation::getMeshCreatedFace(unsigned char AFace) const
207 {
208  assert(AFace == CUBE_X1 || AFace == CUBE_X2 ||
209  AFace == CUBE_Y1 || AFace == CUBE_Y2 ||
210  AFace == CUBE_Z1 || AFace == CUBE_Z2);
211 
212  return FCreatedFaces & AFace;
213 }
214 //******************************************************************************
215 void CParameterCreation::setMeshCreatedFaces(unsigned char AFaces)
216 {
217  assert(AFaces <= CUBE_ALL);
218  if ( FCreatedFaces!=AFaces )
219  {
221  FCreatedFaces= AFaces;
222  }
223 }
224 //******************************************************************************
225 void CParameterCreation::setMeshCreatedFace(unsigned char AFace, bool AValue)
226 {
227  assert(AFace == CUBE_X1 || AFace == CUBE_X2 ||
228  AFace == CUBE_Y1 || AFace == CUBE_Y2 ||
229  AFace == CUBE_Z1 || AFace == CUBE_Z2);
230 
232  if (AValue)
233  FCreatedFaces |= AFace;
234  else
235  FCreatedFaces &= ~ AFace;
236 }
237 //******************************************************************************
239 {
240  return FCylinderNbMeridians;
241 }
242 //******************************************************************************
244 {
245  assert(ANb > 0);
246  if ( FCylinderNbMeridians!=ANb )
247  {
249  FCylinderNbMeridians = ANb;
250  }
251 }
252 //******************************************************************************
254 {
255  return FCylinderNbParallels;
256 }
257 //******************************************************************************
259 {
260  assert(ANb > 0);
261  if ( FCylinderNbParallels!=ANb )
262  {
264  FCylinderNbParallels= ANb;
265  }
266 }
267 //******************************************************************************
269 {
270  return FCylinderClosedUp;
271 }
272 //******************************************************************************
274 {
275  if ( FCylinderClosedUp!= AClosed )
276  {
278  FCylinderClosedUp= AClosed;
279  }
280 }
281 //******************************************************************************
283 {
284  return FCylinderClosedDown;
285 }
286 //******************************************************************************
288 {
289  if ( FCylinderClosedDown!=AClosed )
290  {
292  FCylinderClosedDown= AClosed;
293  }
294 }
295 //******************************************************************************
297 {
298  return FPyramidNbMeridians;
299 }
300 //******************************************************************************
302 {
303  assert(ANb > 0);
304  if ( FPyramidNbMeridians!=ANb )
305  {
307  FPyramidNbMeridians= ANb;
308  }
309 }
310 //******************************************************************************
312 {
313  return FPyramidNbParallels;
314 }
315 //******************************************************************************
317 {
318  assert(ANb > 0);
319  if ( FPyramidNbParallels!=ANb )
320  {
322  FPyramidNbParallels= ANb;
323  }
324 }
325 //******************************************************************************
327 {
328  return FPyramidClosed;
329 }
330 //******************************************************************************
332 {
333  if ( FPyramidClosed!=AClosed )
334  {
336  FPyramidClosed= AClosed;
337  }
338 }
339 //******************************************************************************
341 {
342  return FSphereNbMeridians;
343 }
344 //******************************************************************************
346 {
347  assert(ANb > 0);
348  if ( FSphereNbMeridians!=ANb )
349  {
351  FSphereNbMeridians= ANb;
352  }
353 }
354 //******************************************************************************
356 {
357  return FSphereNbParallels;
358 }
359 //******************************************************************************
361 {
362  assert(ANb > 0);
363  if ( FSphereNbParallels!=ANb )
364  {
366  FSphereNbParallels= ANb;
367  }
368 }
369 //******************************************************************************
371 {
372  return FTorusNbMeridians;
373 }
374 //******************************************************************************
376 {
377  assert(ANb > 0);
378  if ( FTorusNbMeridians!=ANb )
379  {
381  FTorusNbMeridians= ANb;
382  }
383 }
384 //******************************************************************************
386 {
387  return FTorusNbParallels;
388 }
389 //******************************************************************************
391 {
392  assert(ANb > 0);
393  if ( FTorusNbParallels!=ANb )
394  {
396  FTorusNbParallels= ANb;
397  }
398 }
399 //******************************************************************************
401 {
402  return FTorusRadiusRapport;
403 }
404 //******************************************************************************
406 {
407  assert(0.0 <= AValue && AValue <= 1.0);
408  if ( FTorusRadiusRapport!=AValue )
409  {
411  FTorusRadiusRapport= AValue;
412  }
413 }
414 //******************************************************************************
415 void CParameterCreation::save(ostream& /*AStream*/)
416 {}
417 //------------------------------------------------------------------------------
418 void CParameterCreation::load(istream& /*AStream*/)
419 {}
420 //------------------------------------------------------------------------------
422 {}
423 //******************************************************************************
425 { return PARAMETER_CREATION; }
426 //******************************************************************************