traversor2.h 6.64 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
1 2 3
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps  *
* version 0.1                                                                  *
4
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg           *
Pierre Kraemer's avatar
Pierre Kraemer committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
*                                                                              *
* 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.           *
*                                                                              *
20
* Web site: http://cgogn.unistra.fr/                                           *
Pierre Kraemer's avatar
Pierre Kraemer committed
21 22 23 24 25 26 27 28
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

#ifndef __TRAVERSOR2_H__
#define __TRAVERSOR2_H__

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

namespace CGoGN
{
33

Pierre Kraemer's avatar
Pierre Kraemer committed
34 35 36 37
/*******************************************************************************
					VERTEX CENTERED TRAVERSALS
*******************************************************************************/

Pierre Kraemer's avatar
Pierre Kraemer committed
38 39
// Traverse the edges incident to a given vertex
template <typename MAP>
40
class Traversor2VE: public Traversor<MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
41 42 43 44 45
{
private:
	MAP& m ;
	Dart start ;
	Dart current ;
Sylvain Thery's avatar
Sylvain Thery committed
46 47
	std::vector<Dart>* m_QLT;
	std::vector<Dart>::iterator m_ItDarts;
Pierre Kraemer's avatar
Pierre Kraemer committed
48
public:
Pierre Kraemer's avatar
Pierre Kraemer committed
49 50 51 52 53
	Traversor2VE(MAP& map, Dart dart) ;

	Dart begin() ;
	Dart end() ;
	Dart next() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
54 55 56 57
} ;

// Traverse the faces incident to a given vertex
template <typename MAP>
58
class Traversor2VF : public Traversor<MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
59 60 61 62 63
{
private:
	MAP& m ;
	Dart start ;
	Dart current ;
Sylvain Thery's avatar
Sylvain Thery committed
64 65
	std::vector<Dart>* m_QLT;
	std::vector<Dart>::iterator m_ItDarts;
Pierre Kraemer's avatar
Pierre Kraemer committed
66
public:
Pierre Kraemer's avatar
Pierre Kraemer committed
67 68 69 70 71
	Traversor2VF(MAP& map, Dart dart) ;

	Dart begin() ;
	Dart end() ;
	Dart next() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
72 73 74 75
} ;

// Traverse the vertices adjacent to a given vertex through sharing a common edge
template <typename MAP>
76
class Traversor2VVaE : public Traversor<MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
77 78 79 80 81
{
private:
	MAP& m ;
	Dart start ;
	Dart current ;
Sylvain Thery's avatar
Sylvain Thery committed
82 83
	std::vector<Dart>* m_QLT;
	std::vector<Dart>::iterator m_ItDarts;
Pierre Kraemer's avatar
Pierre Kraemer committed
84
public:
Pierre Kraemer's avatar
Pierre Kraemer committed
85 86 87 88 89
	Traversor2VVaE(MAP& map, Dart dart) ;

	Dart begin() ;
	Dart end() ;
	Dart next() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
90 91 92 93
} ;

// Traverse the vertices adjacent to a given vertex through sharing a common face
template <typename MAP>
94
class Traversor2VVaF : public Traversor<MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
95 96 97 98 99 100 101
{
private:
	MAP& m ;
	Dart start ;
	Dart current ;

	Dart stop ;
Sylvain Thery's avatar
Sylvain Thery committed
102 103
	std::vector<Dart>* m_QLT;
	std::vector<Dart>::iterator m_ItDarts;
Pierre Kraemer's avatar
Pierre Kraemer committed
104
public:
Pierre Kraemer's avatar
Pierre Kraemer committed
105 106 107 108 109
	Traversor2VVaF(MAP& map, Dart dart) ;

	Dart begin() ;
	Dart end() ;
	Dart next() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
110 111 112 113 114 115 116 117
} ;

/*******************************************************************************
					EDGE CENTERED TRAVERSALS
*******************************************************************************/

// Traverse the vertices incident to a given edge
template <typename MAP>
118
class Traversor2EV : public Traversor<MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
119 120 121 122 123
{
private:
	MAP& m ;
	Dart start ;
	Dart current ;
Sylvain Thery's avatar
Sylvain Thery committed
124 125
	std::vector<Dart>* m_QLT;
	std::vector<Dart>::iterator m_ItDarts;
Pierre Kraemer's avatar
Pierre Kraemer committed
126
public:
Pierre Kraemer's avatar
Pierre Kraemer committed
127 128 129 130 131
	Traversor2EV(MAP& map, Dart dart) ;

	Dart begin() ;
	Dart end() ;
	Dart next() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
132 133 134 135
} ;

// Traverse the faces incident to a given edge
template <typename MAP>
136
class Traversor2EF : public Traversor<MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
137 138 139 140 141
{
private:
	MAP& m ;
	Dart start ;
	Dart current ;
Sylvain Thery's avatar
Sylvain Thery committed
142 143
	std::vector<Dart>* m_QLT;
	std::vector<Dart>::iterator m_ItDarts;
Pierre Kraemer's avatar
Pierre Kraemer committed
144
public:
Pierre Kraemer's avatar
Pierre Kraemer committed
145 146 147 148 149
	Traversor2EF(MAP& map, Dart dart) ;

	Dart begin() ;
	Dart end() ;
	Dart next() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
150 151 152 153
} ;

// Traverse the edges adjacent to a given edge through sharing a common vertex
template <typename MAP>
154
class Traversor2EEaV : public Traversor<MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
155 156 157 158 159 160 161
{
private:
	MAP& m ;
	Dart start ;
	Dart current ;

	Dart stop1, stop2 ;
Sylvain Thery's avatar
Sylvain Thery committed
162 163
	std::vector<Dart>* m_QLT;
	std::vector<Dart>::iterator m_ItDarts;
Pierre Kraemer's avatar
Pierre Kraemer committed
164
public:
Pierre Kraemer's avatar
Pierre Kraemer committed
165 166 167 168 169
	Traversor2EEaV(MAP& map, Dart dart) ;

	Dart begin() ;
	Dart end() ;
	Dart next() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
170 171 172 173
} ;

// Traverse the edges adjacent to a given edge through sharing a common face
template <typename MAP>
174
class Traversor2EEaF : public Traversor<MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
175 176 177 178 179 180 181
{
private:
	MAP& m ;
	Dart start ;
	Dart current ;

	Dart stop1, stop2 ;
Sylvain Thery's avatar
Sylvain Thery committed
182 183
	std::vector<Dart>* m_QLT;
	std::vector<Dart>::iterator m_ItDarts;
Pierre Kraemer's avatar
Pierre Kraemer committed
184
public:
Pierre Kraemer's avatar
Pierre Kraemer committed
185 186 187 188 189
	Traversor2EEaF(MAP& map, Dart dart) ;

	Dart begin() ;
	Dart end() ;
	Dart next() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
190 191 192 193 194 195 196 197
} ;

/*******************************************************************************
					FACE CENTERED TRAVERSALS
*******************************************************************************/

// Traverse the vertices incident to a given face
template <typename MAP>
198
class Traversor2FV : public Traversor<MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
199 200 201 202 203
{
private:
	MAP& m ;
	Dart start ;
	Dart current ;
Sylvain Thery's avatar
Sylvain Thery committed
204 205
	std::vector<Dart>* m_QLT;
	std::vector<Dart>::iterator m_ItDarts;
Pierre Kraemer's avatar
Pierre Kraemer committed
206
public:
Pierre Kraemer's avatar
Pierre Kraemer committed
207 208 209 210 211
	Traversor2FV(MAP& map, Dart dart) ;

	Dart begin() ;
	Dart end() ;
	Dart next() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
212 213
} ;

214 215

// Traverse the edges incident to a given face (equivalent to vertices)
Pierre Kraemer's avatar
Pierre Kraemer committed
216
template <typename MAP>
Sylvain Thery's avatar
Sylvain Thery committed
217
class Traversor2FE: public Traversor2FV<MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
218 219
{
public:
220
	Traversor2FE(MAP& map, Dart dart):Traversor2FV<MAP>(map,dart){}
Pierre Kraemer's avatar
Pierre Kraemer committed
221 222 223 224
} ;

// Traverse the faces adjacent to a given face through sharing a common vertex
template <typename MAP>
225
class Traversor2FFaV : public Traversor<MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
226 227 228 229 230 231 232
{
private:
	MAP& m ;
	Dart start ;
	Dart current ;

	Dart stop ;
Sylvain Thery's avatar
Sylvain Thery committed
233 234
	std::vector<Dart>* m_QLT;
	std::vector<Dart>::iterator m_ItDarts;
Pierre Kraemer's avatar
Pierre Kraemer committed
235
public:
Pierre Kraemer's avatar
Pierre Kraemer committed
236 237 238 239 240
	Traversor2FFaV(MAP& map, Dart dart) ;

	Dart begin() ;
	Dart end() ;
	Dart next() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
241 242
} ;

Pierre Kraemer's avatar
Pierre Kraemer committed
243 244
// Traverse the faces adjacent to a given face through sharing a common edge
template <typename MAP>
245
class Traversor2FFaE : public Traversor<MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
246 247 248 249 250
{
private:
	MAP& m ;
	Dart start ;
	Dart current ;
Sylvain Thery's avatar
Sylvain Thery committed
251 252
	std::vector<Dart>* m_QLT;
	std::vector<Dart>::iterator m_ItDarts;
Pierre Kraemer's avatar
Pierre Kraemer committed
253
public:
Pierre Kraemer's avatar
Pierre Kraemer committed
254 255 256 257 258
	Traversor2FFaE(MAP& map, Dart dart) ;

	Dart begin() ;
	Dart end() ;
	Dart next() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
259 260
} ;

Pierre Kraemer's avatar
Pierre Kraemer committed
261 262
} // namespace CGoGN

Pierre Kraemer's avatar
Pierre Kraemer committed
263 264
#include "Topology/generic/traversor2.hpp"

Pierre Kraemer's avatar
Pierre Kraemer committed
265
#endif