Moka kernel
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
gmg-sew.cc
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 #include "g-map-generic.hh"
26 using namespace GMap3d;
27 //******************************************************************************
28 int CGMapGeneric::getSewDimension(CDart * ADart1, CDart * ADart2)
29 {
30  assert(ADart1!=NULL && ADart2!=NULL);
31 
32  for (int dim=0; dim<=3; ++dim)
33  if (canSew(ADart1, ADart2, dim) &&
34  !isSameOrbit(ADart1, ADart2, ORBIT_INF[dim]))
35  return dim;
36 
37  return 4;
38 }
39 //******************************************************************************
40 bool CGMapGeneric::intuitiveSew(CDart * ADart1, CDart * ADart2)
41 {
42  assert(ADart1!=NULL && ADart2!=NULL);
43 
44  int dim = getSewDimension(ADart1, ADart2);
45 
46  if (dim!=4)
47  sew(ADart1, ADart2, dim);
48 
49  return dim!=4;
50 }
51 //******************************************************************************
52 int CGMapGeneric::multiSew(CDart * ADart1, int AMarkNumber1,
53  CDart * ADart2, int ADimension)
54 {
55  assert(ADart1 != NULL && ADart2 != NULL);
56  assert(2 <= ADimension && ADimension <= 3);
57 
58  if (!isFree(ADart1, ADimension) || !isFree(ADart2, ADimension))
59  return 0;
60 
61  int nbSewed = 0;
62  int treated = getNewMark();
63 
64  markCopy(AMarkNumber1, treated);
65  negateMaskMark(treated);
66 
67  CCoverage * cov1 =
68  getBasicDynamicCoverage(ADart1, ORBIT_BORDER[ADimension], treated);
69 
70  for (; cov1->cont(); ++(*cov1))
71  {
72 
73  }
74 
75  delete cov1;
76 
77  unmarkAll(treated);
78  freeMark(treated);
79 
80  return nbSewed;
81 }
82 //******************************************************************************