Moka libraries
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
mg-selection.cc
Go to the documentation of this file.
1 /*
2  * lib-mesh : Opérations de maillage et lissage.
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-mesh
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 "mesh-generic.hh"
26 #include "g-map-generic.hh"
27 #include <cassert>
28 using namespace GMap3d;
29 //******************************************************************************
30 #define SUCC(DART) ((((CGMapGeneric*) FMap)->*succ)(DART))
31 //------------------------------------------------------------------------------
32 CDart* CMeshGeneric::markTopoSquareIMeshed(int ADim, CDart* ADart,
33  int ASx, int ASy,
34  int AMarkNumberX, int AMarkNumberY,
35  int AReturnedDart)
36 {
37  assert(ADim>=0 && ADim<=2);
38  assert(ADart!=NULL);
39  assert(ASx>0);
40  assert(ASy>0);
41  assert(isTopoSquareIMeshed(ADim, ADart, ASx,ASy));
42  assert(AMarkNumberX>0);
43  assert(AMarkNumberY>0);
44  assert(AReturnedDart>=1 && AReturnedDart<=3);
45 
46  CDart* returned = NULL;
47 
48  if (ADim==0)
49  ASx = ASy = 1;
50 
51  CDart* (CGMapGeneric::* succ) (CDart*) const =
52  ADim<2 ? & CGMapGeneric::alpha01 : & CGMapGeneric::alpha0121;
53 
54  CDart* current = ADart;
55 
56  for (int round=0; round<2; ++round)
57  {
58  FMap->markOrbit(current, ORBIT_23, AMarkNumberX);
59 
60  for (int i=1; i<ASx; ++i)
61  current = SUCC(current);
62 
63  current = FMap->alpha0(current);
64  FMap->markOrbit(current, ORBIT_23, AMarkNumberX);
65 
66  if (round==0 && AReturnedDart==1)
67  returned = current;
68 
69  if (round==1 && AReturnedDart==2)
70  returned = current;
71 
72  current = FMap->alpha1(current);
73 
74  FMap->markOrbit(current, ORBIT_23, AMarkNumberY);
75  for (int j=1; j<ASy; ++j)
76  current = SUCC(current);
77 
78  current = FMap->alpha0(current);
79 
80  FMap->markOrbit(current, ORBIT_23, AMarkNumberY);
81 
82  current = FMap->alpha1(current);
83 
84  if (round==0 && AReturnedDart==3)
85  returned = current;
86  }
87 
88  return returned;
89 }
90 //******************************************************************************
91 void CMeshGeneric::markTopoCubeIMeshed(int ADim, CDart* ADart,
92  int ASx, int ASy, int ASz,
93  int AMarkNumberX,
94  int AMarkNumberY,
95  int AMarkNumberZ)
96 {
97  assert(ADim>=0 && ADim<=3);
98  assert(ADart!=NULL);
99  assert(ASx>0);
100  assert(ASy>0);
101  assert(ASz>0);
102  assert(isTopoCubeIMeshed(ADim, ADart, ASx,ASy,ASz));
103  assert(AMarkNumberX>0);
104  assert(AMarkNumberY>0);
105  assert(AMarkNumberZ>0);
106 
107  if (ADim==0)
108  ASx = ASy = ASz = 1;
109 
110  CDart* current;
111 
112  current = markTopoSquareIMeshed(ADim, ADart,
113  ASx,ASy, AMarkNumberX,AMarkNumberY, 3);
114  /* --- */ markTopoSquareIMeshed(ADim, FMap->alpha12(current),
115  ASy,ASz, AMarkNumberY,AMarkNumberZ );
116 
117  current = markTopoSquareIMeshed(ADim, FMap->alpha12(ADart),
118  ASy,ASz, AMarkNumberY,AMarkNumberZ, 3);
119  /* --- */ markTopoSquareIMeshed(ADim, FMap->alpha12(current),
120  ASz,ASx, AMarkNumberZ,AMarkNumberX );
121 
122  current = markTopoSquareIMeshed(ADim, FMap->alpha1212(ADart),
123  ASz,ASx, AMarkNumberZ,AMarkNumberX, 3);
124  /* --- */ markTopoSquareIMeshed(ADim, FMap->alpha12(current),
125  ASx,ASy, AMarkNumberX,AMarkNumberY );
126 }
127 //------------------------------------------------------------------------------
128 #undef SUCC
129 //******************************************************************************