traversor3.h 10.7 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 __TRAVERSOR3_H__
#define __TRAVERSOR3_H__

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

namespace CGoGN
{
33 34 35 36 37 38
/**
 * class Marker for Traversor usefull to combine
 * several TraversorXY
 */
template <typename MAP, unsigned int ORBIT>
class MarkerForTraversor
Pierre Kraemer's avatar
Pierre Kraemer committed
39 40
{
private:
41 42 43
	MAP& m_map ;
	DartMarkerStore* m_dmark ;
	CellMarkerStore* m_cmark ;
Pierre Kraemer's avatar
Pierre Kraemer committed
44
public:
45 46 47 48 49 50 51 52
	MarkerForTraversor(MAP& map, bool forceDartMarker = false, unsigned int thread = 0) ;
	~MarkerForTraversor();
	DartMarkerStore* dmark();
	CellMarkerStore* cmark();
	void mark(Dart d);
	void unmark(Dart d);
	bool isMarked(Dart d);
} ;
Pierre Kraemer's avatar
Pierre Kraemer committed
53

54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
/**
 * Generic class Traversor (do not use directly)
 * Traverse all Y incident to X
 */
template <typename MAP, unsigned int ORBIT_X, unsigned int ORBIT_Y>
class Traversor3XY
{
private:
	MAP& m_map ;
	DartMarkerStore* m_dmark ;
	CellMarkerStore* m_cmark ;
	Dart m_current ;
	TraversorDartsOfOrbit<MAP> m_tradoo;
	bool m_allocated;
public:
	Traversor3XY(MAP& map, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) ;
	Traversor3XY(MAP& map, Dart dart, MarkerForTraversor<MAP,ORBIT_Y>& tmo, bool forceDartMarker = false, unsigned int thread = 0) ;
	~Traversor3XY();
Pierre Kraemer's avatar
Pierre Kraemer committed
72 73 74 75 76
	Dart begin() ;
	Dart end() ;
	Dart next() ;
} ;

77 78 79 80 81 82 83

/**
 * Generic class Traversor (do not use directly)
 * Traverse all X adjacent to X by an Y
 */
template <typename MAP, unsigned int ORB_X, unsigned int ORB_Y>
class Traversor3XXaY
Pierre Kraemer's avatar
Pierre Kraemer committed
84 85
{
private:
86 87 88 89 90 91 92
	MAP& m_map ;
	std::vector<Dart> m_vecDarts;
	std::vector<Dart>::iterator m_iter;
public:
	Traversor3XXaY(MAP& map, Dart dart, bool forceDartMarker = false, unsigned int thread = 0);

	Dart begin();
Pierre Kraemer's avatar
Pierre Kraemer committed
93

94 95 96 97 98 99 100 101 102 103 104 105 106 107
	Dart end();

	Dart next();
};




/**
 * Traverse vertices incident to volume
 */
template <typename MAP>
class Traversor3WV: public Traversor3XY<MAP,VOLUME,VERTEX>
{
Pierre Kraemer's avatar
Pierre Kraemer committed
108
public:
109 110
	Traversor3WV(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP,VOLUME,VERTEX>(m, dart, forceDartMarker, thread)	{}
};
Pierre Kraemer's avatar
Pierre Kraemer committed
111

112 113 114 115 116 117 118 119 120
/**
 * Traverse edges incident to volume
 */
template <typename MAP>
class Traversor3WE: public Traversor3XY<MAP,VOLUME,EDGE>
{
public:
	Traversor3WE(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP,VOLUME,EDGE>(m, dart, forceDartMarker, thread)	{}
};
Pierre Kraemer's avatar
Pierre Kraemer committed
121

122 123 124
/**
 * Traverse faces incident to volume
 */
Pierre Kraemer's avatar
Pierre Kraemer committed
125
template <typename MAP>
126
class Traversor3WF: public Traversor3XY<MAP,VOLUME,FACE>
Pierre Kraemer's avatar
Pierre Kraemer committed
127
{
128 129 130 131
public:
	Traversor3WF(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP,VOLUME,FACE>(m, dart, forceDartMarker, thread) {}
};

Pierre Kraemer's avatar
Pierre Kraemer committed
132

133 134 135 136 137 138
/**
 * Traverse vertices incident to face
 */
template <typename MAP>
class Traversor3FV: public Traversor3XY<MAP,FACE,VERTEX>
{
Pierre Kraemer's avatar
Pierre Kraemer committed
139
public:
140 141
	Traversor3FV(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP,FACE,VERTEX>(m, dart, forceDartMarker, thread)	{}
};
Pierre Kraemer's avatar
Pierre Kraemer committed
142

143 144 145 146 147 148 149 150 151
/**
 * Traverse edges incident to face
 */
template <typename MAP>
class Traversor3FE: public Traversor3XY<MAP,FACE,EDGE>
{
public:
	Traversor3FE(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP,FACE,EDGE>(m, dart, forceDartMarker, thread)	{}
};
Pierre Kraemer's avatar
Pierre Kraemer committed
152

153 154 155 156 157 158 159 160 161
/**
 * Traverse volumes incident to face
 */
template <typename MAP>
class Traversor3FW: public Traversor3XY<MAP,FACE,VOLUME>
{
public:
	Traversor3FW(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP,FACE,VOLUME>(m, dart, forceDartMarker, thread)	{}
};
Pierre Kraemer's avatar
Pierre Kraemer committed
162 163


164 165 166 167 168 169 170 171 172
/**
 * Traverse vertices incident to edge
 */
template <typename MAP>
class Traversor3EV: public Traversor3XY<MAP,EDGE,VERTEX>
{
public:
	Traversor3EV(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP,EDGE,VERTEX>(m, dart, forceDartMarker, thread)	{}
};
Pierre Kraemer's avatar
Pierre Kraemer committed
173

174 175 176 177 178 179 180 181 182
/**
 * Traverse faces incident to edge
 */
template <typename MAP>
class Traversor3EF: public Traversor3XY<MAP,EDGE,FACE>
{
public:
	Traversor3EF(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP,EDGE,FACE>(m, dart, forceDartMarker, thread)	{}
};
Pierre Kraemer's avatar
Pierre Kraemer committed
183

184 185 186 187 188 189 190 191 192
/**
 * Traverse volumes incident to edge
 */
template <typename MAP>
class Traversor3EW: public Traversor3XY<MAP,EDGE,VOLUME>
{
public:
	Traversor3EW(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP,EDGE,VOLUME>(m, dart, forceDartMarker, thread)	{}
};
Pierre Kraemer's avatar
Pierre Kraemer committed
193 194


195 196 197 198 199 200

/**
 * Traverse edges incident to vertex
 */
template <typename MAP>
class Traversor3VE: public Traversor3XY<MAP,VERTEX,EDGE>
201
{
202 203 204
public:
	Traversor3VE(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP,VERTEX,EDGE>(m, dart, forceDartMarker, thread)	{}
};
205

206 207 208 209 210 211
/**
 * Traverse faces incident to vertex
 */
template <typename MAP>
class Traversor3VF: public Traversor3XY<MAP,VERTEX,FACE>
{
212
public:
213 214
	Traversor3VF(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP,VERTEX,FACE>(m, dart, forceDartMarker, thread)	{}
};
215

216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318
/**
 * Traverse volumes incident to vertex
 */
template <typename MAP>
class Traversor3VW: public Traversor3XY<MAP,VERTEX,VOLUME>
{
public:
	Traversor3VW(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP,VERTEX,VOLUME>(m, dart, forceDartMarker, thread)	{}
};



/**
 * Traverse vertices adjacent to a vertex by an edge
 */
template <typename MAP>
class Traversor3VVaE: public Traversor3XXaY<MAP,VERTEX,EDGE>
{
public:
	Traversor3VVaE(MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP,VERTEX,EDGE>(m, d, forceDartMarker, thread)	{}
};

/**
 * Traverse vertices adjacent to a vertex by a face
 */
template <typename MAP>
class Traversor3VVaF: public Traversor3XXaY<MAP,VERTEX,FACE>
{
public:
	Traversor3VVaF(MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP,VERTEX,FACE>(m, d, forceDartMarker, thread)	{}
};

/**
 * Traverse vertices adjacent to a vertex by a volume
 */
template <typename MAP>
class Traversor3VVaW: public Traversor3XXaY<MAP,VERTEX,VOLUME>
{
public:
	Traversor3VVaW(MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP,VERTEX,VOLUME>(m, d, forceDartMarker, thread)	{}
};


/**
 * Traverse edges adjacent to an egde by a vertex
 */
template <typename MAP>
class Traversor3EEaV: public Traversor3XXaY<MAP,EDGE,VERTEX>
{
public:
	Traversor3EEaV(MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP,EDGE,VERTEX>(m, d, forceDartMarker, thread)	{}
};

/**
 * Traverse edges adjacent to an egde by a face
 */
template <typename MAP>
class Traversor3EEaF: public Traversor3XXaY<MAP,EDGE,FACE>
{
public:
	Traversor3EEaF(MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP,EDGE,FACE>(m, d, forceDartMarker, thread)	{}
};

/**
 * Traverse edges adjacent to an egde by a volume
 */
template <typename MAP>
class Traversor3EEaW: public Traversor3XXaY<MAP,EDGE,VOLUME>
{
public:
	Traversor3EEaW(MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP,EDGE,VOLUME>(m, d, forceDartMarker, thread)	{}
};


/**
 * Traverse faces adjacent to a face by a vertex
 */
template <typename MAP>
class Traversor3FFaV: public Traversor3XXaY<MAP,FACE,VERTEX>
{
public:
	Traversor3FFaV(MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP,FACE,VERTEX>(m, d, forceDartMarker, thread)	{}
};

/**
 * Traverse faces adjacent to a face by an edge
 */
template <typename MAP>
class Traversor3FFaE: public Traversor3XXaY<MAP,FACE,EDGE>
{
public:
	Traversor3FFaE(MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP,FACE,EDGE>(m, d, forceDartMarker, thread)	{}
};

/**
 * Traverse faces adjacent to a face by a volume
 */
template <typename MAP>
class Traversor3FFaW: public Traversor3XXaY<MAP,FACE,VOLUME>
{
public:
	Traversor3FFaW(MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP,FACE,VOLUME>(m, d, forceDartMarker, thread)	{}
};
Pierre Kraemer's avatar
Pierre Kraemer committed
319 320


321 322 323
/**
 * Traverse volumes adjacent to a volumee by a vertex
 */
324
template <typename MAP>
325
class Traversor3WWaV: public Traversor3XXaY<MAP,VOLUME,VERTEX>
326 327
{
public:
328
	Traversor3WWaV(MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP,VOLUME,VERTEX>(m, d, forceDartMarker, thread)	{}
329 330
};

331 332 333
/**
 * Traverse volumes adjacent to a volumee by an edge
 */
334
template <typename MAP>
335
class Traversor3WWaE: public Traversor3XXaY<MAP,VOLUME,EDGE>
336 337
{
public:
338
	Traversor3WWaE(MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP,VOLUME,EDGE>(m, d, forceDartMarker, thread)	{}
339 340
};

341 342 343
/**
 * Traverse volumes adjacent to a volumee by a face
 */
344
template <typename MAP>
345
class Traversor3WWaF: public Traversor3XXaY<MAP,VOLUME,FACE>
346 347
{
public:
348
	Traversor3WWaF(MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP,VOLUME,FACE>(m, d, forceDartMarker, thread)	{}
349 350
};

Pierre Kraemer's avatar
Pierre Kraemer committed
351 352 353 354 355 356

} // namespace CGoGN

#include "Topology/generic/traversor3.hpp"

#endif