Création d'un compte pour un collaborateur extérieur au laboratoire depuis l'intranet ICube : https://intranet.icube.unistra.fr/fr/labs/member/profile

traversor3.hpp 6.63 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps  *
* version 0.1                                                                  *
* Copyright (C) 2009-2011, IGG Team, LSIIT, University of Strasbourg           *
*                                                                              *
* This library is free software; you can redistribute it and/or modify it      *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your     *
* option) any later version.                                                   *
*                                                                              *
* This library is distributed in the hope that it will be useful, but WITHOUT  *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or        *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License  *
* for more details.                                                            *
*                                                                              *
* You should have received a copy of the GNU Lesser General Public License     *
* along with this library; if not, write to the Free Software Foundation,      *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.           *
*                                                                              *
* Web site: http://cgogn.u-strasbg.fr/                                         *
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/
24
#include "Utils/static_assert.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
25
26
27
28

namespace CGoGN
{

29
30
31
//**********************
// Marker for traversor
//**********************
Pierre Kraemer's avatar
Pierre Kraemer committed
32

33
34
template <typename MAP>
MarkerForTraversor<MAP>::MarkerForTraversor(MAP& map, unsigned int orbit, bool forceDartMarker, unsigned int thread) :
35
36
	m_map(map),
	m_dmark(NULL),
37
38
	m_cmark(NULL),
	m_orbit(orbit)
Pierre Kraemer's avatar
Pierre Kraemer committed
39
{
40
41
	if(!forceDartMarker && map.isOrbitEmbedded(m_orbit))
		m_cmark = new CellMarkerStore(map, m_orbit, thread) ;
42
43
	else
		m_dmark = new DartMarkerStore(map, thread) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
44
45
}

46

47
48
template <typename MAP>
MarkerForTraversor<MAP>::~MarkerForTraversor()
Pierre Kraemer's avatar
Pierre Kraemer committed
49
{
50
51
52
53
	if (m_cmark)
		delete m_cmark;
	if (m_dmark)
		delete m_dmark;
Pierre Kraemer's avatar
Pierre Kraemer committed
54
55
}

56
57
template <typename MAP>
void MarkerForTraversor<MAP>::mark(Dart d)
Pierre Kraemer's avatar
Pierre Kraemer committed
58
{
59
60
61
	if (m_cmark)
		m_cmark->mark(d);
	else
62
		m_dmark->markOrbit(m_orbit,d);
Pierre Kraemer's avatar
Pierre Kraemer committed
63
64
}

65

66
67
template <typename MAP>
void MarkerForTraversor<MAP>::unmark(Dart d)
68
{
69
70
	if (m_cmark)
		m_cmark->unmark(d);
71
	else
72
		m_dmark->unmarkOrbit(m_orbit,d);
73
74
}

75
76
template <typename MAP>
bool MarkerForTraversor<MAP>::isMarked(Dart d)
77
{
78
79
80
	if (m_cmark)
		return m_cmark->isMarked(d);
	return m_dmark->isMarked(d);
81
82
}

83
84
template <typename MAP>
CellMarkerStore* MarkerForTraversor<MAP>::cmark()
85
{
86
	return m_cmark;
87
88
}

89
90
template <typename MAP>
DartMarkerStore* MarkerForTraversor<MAP>::dmark()
91
92
93
94
95
96
97
98
99
100
101
{
	return m_dmark;
}



//**************************************
// Traversor cellX Y incident to cell X
//**************************************


102
103
template <typename MAP>
Traversor3XY<MAP>::Traversor3XY(MAP& map, Dart dart, unsigned int orbX, unsigned int orbY, bool forceDartMarker, unsigned int thread) :
104
105
106
107
//	Traversor3MarkOnly<MAP,ORBIT_Y>(map, forceDartMarker, thread, true),
	m_map(map),
	m_dmark(NULL),
	m_cmark(NULL),
108
109
110
	m_tradoo(map,orbX,dart,thread),
	m_orbx(orbX),
	m_orby(orbY),
111
112
	m_allocated(true),
	m_first(true)
113
{
114
115
	if(!forceDartMarker && map.isOrbitEmbedded(orbY))
		m_cmark = new CellMarkerStore(map, orbY, thread) ;
116
117
118
119
	else
		m_dmark = new DartMarkerStore(map, thread) ;
}

120
121
template <typename MAP>
Traversor3XY<MAP>::Traversor3XY(MAP& map, Dart dart, unsigned int orbX, unsigned int orbY, MarkerForTraversor<MAP>& tmo, bool forceDartMarker, unsigned int thread) :
122
	m_map(map),
123
124
125
	m_tradoo(map,orbX,dart,thread),
	m_orbx(orbX),
	m_orby(orbY),
126
127
	m_allocated(false),
	m_first(true)
128
129
130
131
132
{
	m_cmark = tmo.cmark();
	m_dmark = tmo.dmark();
}

133
134
template <typename MAP>
Traversor3XY<MAP>::~Traversor3XY()
135
136
137
138
139
140
141
142
143
144
{
	if (m_allocated)
	{
		if (m_cmark)
			delete m_cmark;
		if (m_dmark)
			delete m_dmark;
	}
}

145
146
template <typename MAP>
Dart Traversor3XY<MAP>::begin()
147
{
148
	if (!m_first)
149
	{
150
151
152
153
		if (m_cmark)
			m_cmark->unmarkAll();
		else
			m_dmark->unmarkAll();
154
	}
155
156
157
158
159
	m_first=false;

	m_current = m_tradoo.begin() ;
	// for the case of beginning with a given MarkerForTraversor
	if (!m_allocated)
160
	{
161
162
163
164
165
166
167
168
169
170
		if (m_cmark)
		{
			while ((m_current != NIL) && m_cmark->isMarked(m_current))
				m_current = m_tradoo.next();
		}
		else
		{
			while ((m_current != NIL) && m_dmark->isMarked(m_current))
				m_current = m_tradoo.next();
		}
171
172
173
174
	}
	return m_current;
}

175
176
template <typename MAP>
Dart Traversor3XY<MAP>::end()
177
178
179
180
{
	return NIL ;
}

181
182
template <typename MAP>
Dart Traversor3XY<MAP>::next()
183
{
184
	if(m_current != NIL)
185
	{
186
		if (m_cmark)
187
		{
188
189
190
191
			m_cmark->mark(m_current);
			m_current = m_tradoo.next();
			while ((m_current != NIL) && m_cmark->isMarked(m_current))
				m_current = m_tradoo.next();
192
193
194
		}
		else
		{
195
			if (m_orbx==VOLUME)
196
197
198
			{
				// if allocated we are in a local traversal of volume so we can mark only darts of volume
				if (m_allocated)
199
					m_dmark->markOrbit(MAP::ORBIT_IN_PARENT(m_orby), m_current);
200
				else
201
					m_dmark->markOrbit(m_orby, m_current); // here we need to mark all the darts
202
203
			}
			else
204
				m_dmark->markOrbit(m_orby, m_current);
205
206
207
			m_current = m_tradoo.next();
			while ((m_current != NIL) && m_dmark->isMarked(m_current))
				m_current = m_tradoo.next();
208
209
		}
	}
210
211
212
213
214
215
216
217
218
219
	return m_current ;
}



//*********************************************
// Traversor cellX to cellX adjacent by cell Y
//*********************************************


220
221
template <typename MAP>
Traversor3XXaY<MAP>::Traversor3XXaY(MAP& map, Dart dart, unsigned int orbX, unsigned int orbY, bool forceDartMarker, unsigned int thread):
222
223
	m_map(map)
{
224
	MarkerForTraversor<MAP> mk(map,orbX,forceDartMarker,thread);
225
226
	mk.mark(dart);

227
	Traversor3XY<MAP> traAdj(map, dart, orbX, orbY, forceDartMarker, thread);
228
229
	for (Dart d = traAdj.begin(); d!=traAdj.end(); d=traAdj.next())
	{
230
		Traversor3XY<MAP> traInci(map, d, orbY, orbX, mk, forceDartMarker, thread);
231
232
233
234
235
236
		for (Dart e = traInci.begin(); e!=traInci.end(); e=traInci.next())
			m_vecDarts.push_back(e);
	}
	m_vecDarts.push_back(NIL);
}

237
238
template <typename MAP>
Dart Traversor3XXaY<MAP>::begin()
239
{
240
	m_iter = m_vecDarts.begin();
241
242
243
	return *m_iter;
}

244
245
template <typename MAP>
Dart Traversor3XXaY<MAP>::end()
246
247
{
	return NIL;
248
249
250
}


251
252
template <typename MAP>
Dart Traversor3XXaY<MAP>::next()
253
254
255
256
257
258
{
	if (*m_iter != NIL)
		m_iter++;
	return *m_iter ;
}

259

Pierre Kraemer's avatar
Pierre Kraemer committed
260
} // namespace CGoGN