Moka kernel
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
g-map-basic.hh
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 #ifndef G_MAP_BASIC_HH
26 #define G_MAP_BASIC_HH
27 //******************************************************************************
28 #include "kernel-types.hh"
29 #include "inline-macro.hh"
30 
31 #include <bitset>
32 //******************************************************************************
33 namespace GMap3d
34 {
35  class CDart;
36 
49  class CGMapBasic
50  {
51  public:
52  // @name Constructeur et destructeur
53  // @{
54 
56  CGMapBasic();
57 
59  virtual ~CGMapBasic();
60 
61  // @}
62  // @name Réinitialisation de la carte
63  // @{
64 
70  void randomizeDarts();
71 
76  void removeAllDarts();
77 
83  virtual void empty();
84 
85  // @}
86  // @name Gestion des champs direct-info
87  // @{
88 
94  int getNewDirectInfo();
95 
102  void freeDirectInfo(int ADirectIndex);
103 
111  void* getDirectInfo(CDart* ADart, int ADirectIndex) const;
112 
121  void setDirectInfo(CDart* ADart, int ADirectIndex, void* APointer);
122 
123  // @}
124  // @name Accès au premier brin de liste des brins de la carte.
125  // @{
126 
132  CDart* getFirstDart() const;
133 
139  void setFirstDart(CDart* ADart);
140 
141  // @}
142  // @name Gestion des marques
143  // @{
144 
150  int getNewMark();
151 
160  bool getMaskMark(int AMarkNumber) const;
161 
168  void freeMark(int AMarkNumber);
169 
178  void negateMaskMark(int AMarkNumber);
179 
188  bool isWholeMapUnmarked(int AMarkNumber);
189 
197  int getNbUsedMarks() const;
198 
208  bool isMarked(const CDart* ADart, int AMarkNumber) const;
209 
219  void setMarkTo(CDart* ADart, int AMarkNumber, bool AState);
220 
228  void setMark(CDart* ADart, int AMarkNumber);
229 
237  void unsetMark(CDart* ADart, int AMarkNumber);
238 
246  void setMarks(CDart* ADart, const std::bitset<NB_MARKS> & AMarks) const;
247 
255  std::bitset<NB_MARKS> getMarks(CDart* ADart) const;
256 
257  // @}
258  // @name Gestion des orbites utilisées pour les plongements
259  // @{
260 
269  bool isOrbitUsed(TOrbit AOrbit) const;
270 
279  void setOrbitUsed(TOrbit AOrbit);
280 
290  void unsetOrbitUsed(TOrbit AOrbit);
291 
301  bool isOrbitUsed(CDart* ADart, TOrbit AOrbit) const;
302 
303  // @}
304  // @name Création et suppression de brins
305  // @{
306 
316  virtual CDart* newDart();
317 
327  virtual void delDart(CDart* ADart);
328 
335  CDart* addMapDart();
336 
343  void delMapDart(CDart* ADart);
344 
345  // @}
346 
361  // @{
362  bool isFree0(const CDart* ADart) const;
363  bool isFree1(const CDart* ADart) const;
364  bool isFree2(const CDart* ADart) const;
365  bool isFree3(const CDart* ADart) const;
366  // @}
367 
375  bool isFree(const CDart* ADart, int ADimension) const;
376 
381  // @{
382  CDart* alpha0(const CDart* ADart) const;
383  CDart* alpha1(const CDart* ADart) const;
384  CDart* alpha2(const CDart* ADart) const;
385  CDart* alpha3(const CDart* ADart) const;
386  // @}
387 
393  CDart* alpha(const CDart* ADart, int ADimension) const;
394 
401  // @{
402  void linkAlpha0(CDart* ADart1, CDart* ADart2);
403  void linkAlpha1(CDart* ADart1, CDart* ADart2);
404  void linkAlpha2(CDart* ADart1, CDart* ADart2);
405  void linkAlpha3(CDart* ADart1, CDart* ADart2);
406  // @}
407 
415  void linkAlpha(CDart* ADart1, CDart* ADart2, int ADimension);
416 
422  // @{
423  void unlinkAlpha0(CDart* ADart);
424  void unlinkAlpha1(CDart* ADart);
425  void unlinkAlpha2(CDart* ADart);
426  void unlinkAlpha3(CDart* ADart);
427  // @}
428 
436  void unlinkAlpha(CDart* ADart, int ADimension);
437 
438  protected:
439  // @name Champs protégés :
440  // @{
441 
444 
446  std::bitset<NB_MARKS> FUsedMarks;
447 
449  std::bitset<NB_MARKS> FMaskMarks;
450 
453 
455  std::bitset<16> FUsedOrbits;
456 
458  std::bitset<NB_DIRECT_INFO> FUsedDirectInfo;
459 
462 
463  // @}
464 
465  protected:
466  /* Add the dart ADart in the double linked list of darts.
467  */
468  void addDartInList(CDart* ADart);
469 
470  /* Remove the dart ADart from the double linked list of darts.
471  */
472  void removeDartInList(CDart* ADart);
473 
474 
475  private:
476  // @name Champs privés :
477  // @{
478 
480  int FNbUsedMarks;
481 
483  int FNbUsedDirectInfos;
484 
485 #ifndef NDEBUG
486 
487  int FMaxNbUsedMarks;
488 
490  int FMaxNbUsedDirectInfos;
491 #endif // NDEBUG
492 
493  // @}
494  };
495 
496 } // namespace GMap3d
497 //******************************************************************************
498 #include INCLUDE_INLINE("g-map-basic.icc")
499 //******************************************************************************
500 #endif // G_MAP_BASIC_HH
501 //******************************************************************************