traversorCell.h 7.48 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
24
25
26
27
28
/*******************************************************************************
* 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                                        *
*                                                                              *
*******************************************************************************/

#ifndef __TRAVERSOR_CELL_H__
#define __TRAVERSOR_CELL_H__

#include "Topology/generic/dart.h"
29
#include "Topology/generic/dartmarker.h"
30
#include "Topology/generic/cellmarker.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
31
32
33

namespace CGoGN
{
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
//
//template <typename MAP>
//class TraversorCell
//{
//private:
//	MAP& m ;
//	unsigned int m_orbit ;
//	DartMarker* dmark ;
//	CellMarker* cmark ;
//	Dart current ;
//	bool firstTraversal ;
//	const FunctorSelect& m_good ;
//
//public:
//	TraversorCell(MAP& map, unsigned int orbit, const FunctorSelect& good = allDarts, bool forceDartMarker = false, unsigned int thread = 0) :
//		m(map), m_orbit(orbit), dmark(NULL), cmark(NULL), current(NIL), firstTraversal(true), m_good(good)
//	{
//		if(!forceDartMarker && map.isOrbitEmbedded(m_orbit))
//			cmark = new CellMarker(map, m_orbit, thread) ;
//		else
//			dmark = new DartMarker(map, thread) ;
//	}
//
//	~TraversorCell()
//	{
//		if(dmark)
//			delete dmark ;
//		else
//			delete cmark ;
//	}
//
//	Dart begin()
//	{
//		if(!firstTraversal)
//		{
//			if(dmark)
//				dmark->unmarkAll() ;
//			else
//				cmark->unmarkAll() ;
//		}
//
//		current = m.begin() ;
//		while(current != m.end() && (m.isBoundaryMarked(current) || !m_good(current)))
//			m.next(current) ;
//
//		if(current == m.end())
//			current = NIL ;
//		else
//		{
//			if(dmark)
//				dmark->markOrbit(m_orbit, current) ;
//			else
//				cmark->mark(current) ;
//		}
//
//		firstTraversal = false ;
//		return current ;
//	}
//
//	Dart end() { return NIL ; }
//
//	Dart next()
//	{
//		if(current != NIL)
//		{
//			bool ismarked ;
//			if(dmark)
//				ismarked = dmark->isMarked(current) ;
//			else
//				ismarked = cmark->isMarked(current) ;
//
//			while(current != NIL && (ismarked || m.isBoundaryMarked(current) || !m_good(current)))
//			{
//				m.next(current) ;
//				if(current == m.end())
//					current = NIL ;
//				else
//				{
//					if(dmark)
//						ismarked = dmark->isMarked(current) ;
//					else
//						ismarked = cmark->isMarked(current) ;
//				}
//			}
//
//			if(current != NIL)
//			{
//				if(dmark)
//					dmark->markOrbit(m_orbit, current) ;
//				else
//					cmark->mark(current) ;
//			}
//		}
//		return current ;
//	}
//
//	void mark(Dart d)
//	{
//		if(dmark)
//			dmark->markOrbit(m_orbit, d) ;
//		else
//			cmark->mark(d) ;
//	}
//} ;
//
//template <typename MAP>
//class TraversorV : public TraversorCell<MAP>
//{
//public:
//	TraversorV(MAP& m, const FunctorSelect& good = allDarts, unsigned int thread = 0) : TraversorCell<MAP>(m, VERTEX, good, thread)
//	{}
//};
//
//template <typename MAP>
//class TraversorE : public TraversorCell<MAP>
//{
//public:
//	TraversorE(MAP& m, const FunctorSelect& good = allDarts, unsigned int thread = 0) : TraversorCell<MAP>(m, EDGE, good, thread)
//	{}
//};
//
////template <typename MAP>
////class TraversorOF : public TraversorCell<MAP>
////{
////public:
////	TraversorOF(MAP& m, const FunctorSelect& good = allDarts, unsigned int thread = 0) : TraversorCell<MAP>(m, ORIENTED_FACE, good, thread)
////	{}
////};
//
//
//template <typename MAP>
//class TraversorF : public TraversorCell<MAP>
//{
//public:
//	TraversorF(MAP& m, const FunctorSelect& good = allDarts, unsigned int thread = 0) : TraversorCell<MAP>(m, FACE, good, thread)
//	{}
//};
//
//template <typename MAP>
//class TraversorW : public TraversorCell<MAP>
//{
//public:
//	TraversorW(MAP& m, const FunctorSelect& good = allDarts, unsigned int thread = 0) : TraversorCell<MAP>(m, VOLUME, good, thread)
//	{}
//};
//
//
//
//template <typename MAP>
//class TraversorDartsOfOrbit
//{
//private:
//	std::vector<Dart>::iterator m_current;
//	std::vector<Dart> m_vd;
//
//public:
//	TraversorDartsOfOrbit(MAP& map, unsigned int orbit, Dart d, unsigned int thread = 0)
//	{
//		m_vd.reserve(16);
//		FunctorStoreNotBoundary<MAP> fs(map,m_vd);
//		map.foreach_dart_of_orbit(orbit, d, fs, thread);
//		m_vd.push_back(NIL);
//		m_current=m_vd.begin();
//	}
//
//	Dart begin()
//	{
//		m_current=m_vd.begin();
//		return *m_current;
//	}
//
//	Dart end(){ return NIL;}
//
//	Dart next()
//	{
//		if (*m_current != NIL)
//			m_current++;
//		return *m_current;
//	}
//} ;



Pierre Kraemer's avatar
Pierre Kraemer committed
217

Sylvain Thery's avatar
Sylvain Thery committed
218
template <typename MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
219
220
221
222
class TraversorCell
{
private:
	MAP& m ;
223
	unsigned int m_orbit ;
224
225
	DartMarker* dmark ;
	CellMarker* cmark ;
Pierre Kraemer's avatar
Pierre Kraemer committed
226
	Dart current ;
227
	bool firstTraversal ;
Pierre Kraemer's avatar
Pierre Kraemer committed
228
	const FunctorSelect& m_good ;
Pierre Kraemer's avatar
Pierre Kraemer committed
229
230

public:
231
232
233
234
235
236
237
238
239
240
241
	TraversorCell(MAP& map, unsigned int orbit, const FunctorSelect& good = allDarts, bool forceDartMarker = false, unsigned int thread = 0) ;

	~TraversorCell() ;

	Dart begin() ;

	Dart end() ;

	Dart next() ;

	void mark(Dart d);
Pierre Kraemer's avatar
Pierre Kraemer committed
242
243
244
} ;

template <typename MAP>
Sylvain Thery's avatar
Sylvain Thery committed
245
class TraversorV : public TraversorCell<MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
246
247
{
public:
Pierre Kraemer's avatar
Pierre Kraemer committed
248
	TraversorV(MAP& m, const FunctorSelect& good = allDarts, unsigned int thread = 0) : TraversorCell<MAP>(m, VERTEX, good, thread)
249
	{}
Pierre Kraemer's avatar
Pierre Kraemer committed
250
};
Pierre Kraemer's avatar
Pierre Kraemer committed
251
252

template <typename MAP>
Sylvain Thery's avatar
Sylvain Thery committed
253
class TraversorE : public TraversorCell<MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
254
255
{
public:
Pierre Kraemer's avatar
Pierre Kraemer committed
256
	TraversorE(MAP& m, const FunctorSelect& good = allDarts, unsigned int thread = 0) : TraversorCell<MAP>(m, EDGE, good, thread)
257
	{}
Pierre Kraemer's avatar
Pierre Kraemer committed
258
};
Pierre Kraemer's avatar
Pierre Kraemer committed
259

untereiner's avatar
untereiner committed
260

Pierre Kraemer's avatar
Pierre Kraemer committed
261
template <typename MAP>
Sylvain Thery's avatar
Sylvain Thery committed
262
class TraversorF : public TraversorCell<MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
263
264
{
public:
Pierre Kraemer's avatar
Pierre Kraemer committed
265
	TraversorF(MAP& m, const FunctorSelect& good = allDarts, unsigned int thread = 0) : TraversorCell<MAP>(m, FACE, good, thread)
266
	{}
Pierre Kraemer's avatar
Pierre Kraemer committed
267
};
Pierre Kraemer's avatar
Pierre Kraemer committed
268
269

template <typename MAP>
Sylvain Thery's avatar
Sylvain Thery committed
270
class TraversorW : public TraversorCell<MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
271
272
{
public:
Pierre Kraemer's avatar
Pierre Kraemer committed
273
	TraversorW(MAP& m, const FunctorSelect& good = allDarts, unsigned int thread = 0) : TraversorCell<MAP>(m, VOLUME, good, thread)
274
	{}
Pierre Kraemer's avatar
Pierre Kraemer committed
275
};
Pierre Kraemer's avatar
Pierre Kraemer committed
276

277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295


template <typename MAP>
class TraversorDartsOfOrbit
{
private:
	std::vector<Dart>::iterator m_current;
	std::vector<Dart> m_vd;

public:
	TraversorDartsOfOrbit(MAP& map, unsigned int orbit, Dart d, unsigned int thread = 0) ;

	Dart begin() ;

	Dart end() ;

	Dart next() ;
} ;

Pierre Kraemer's avatar
Pierre Kraemer committed
296
297
} // namespace CGoGN

298
299
#include "Topology/generic/traversorCell.hpp"

Pierre Kraemer's avatar
Pierre Kraemer committed
300
#endif