traversorCell.h 3.95 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
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/
24

Pierre Kraemer's avatar
Pierre Kraemer committed
25 26 27 28
#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"
31
#include "Topology/generic/traversorGen.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
32 33 34 35

namespace CGoGN
{

36 37 38 39 40 41 42 43 44 45 46 47 48
/// Macro for simple syntax traversal (can be nested)
/// parameters:
///   - cell type
///   - name of iterator variable (automatically declared)
///   - map type
///   - map used
///
/// Ex: FOR_ALL_CELLS(VERTEX, di, myMap) { ... }
///
#define FOR_ALL_CELLS(ORBIT, NAME_ITER, MAP_TYPE, MAP_PARAM) TraversorCell<MAP_TYPE, (ORBIT)>  NAME_ITER_TraversalMacroLocalLoop(MAP_PARAM); \
	for (Dart NAME_ITER = NAME_ITER_TraversalMacroLocalLoop.begin(); NAME_ITER != NAME_ITER_TraversalMacroLocalLoop.end(); NAME_ITER = NAME_ITER_TraversalMacroLocalLoop.next())


49
template <typename MAP, unsigned int ORBIT>
Sylvain Thery's avatar
Sylvain Thery committed
50
class TraversorCell //: public Traversor<MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
51 52
{
private:
Sylvain Thery's avatar
Sylvain Thery committed
53
	const MAP& m ;
Pierre Kraemer's avatar
Pierre Kraemer committed
54

Sylvain Thery's avatar
Sylvain Thery committed
55
	const AttributeContainer* cont ;
Pierre Kraemer's avatar
Pierre Kraemer committed
56
	unsigned int qCurrent ;
Pierre Kraemer's avatar
Pierre Kraemer committed
57

58
	DartMarker* dmark ;
59
	CellMarker<ORBIT>* cmark ;
Sylvain Thery's avatar
Sylvain Thery committed
60
	const AttributeMultiVector<Dart>* quickTraversal ;
Pierre Kraemer's avatar
Pierre Kraemer committed
61

Pierre Kraemer's avatar
Pierre Kraemer committed
62
	Dart current ;
63
	bool firstTraversal ;
Pierre Kraemer's avatar
Pierre Kraemer committed
64 65

public:
Sylvain Thery's avatar
Sylvain Thery committed
66
	TraversorCell(const MAP& map, bool forceDartMarker = false, unsigned int thread = 0) ;
67 68 69

	~TraversorCell() ;

70
	inline Dart begin() ;
71

72
	inline Dart end() ;
73

74
	inline Dart next() ;
75

76
	inline void skip(Dart d);
Pierre Kraemer's avatar
Pierre Kraemer committed
77 78
} ;

79 80


Pierre Kraemer's avatar
Pierre Kraemer committed
81
template <typename MAP>
82
class TraversorV : public TraversorCell<MAP, VERTEX>
Pierre Kraemer's avatar
Pierre Kraemer committed
83 84
{
public:
Sylvain Thery's avatar
Sylvain Thery committed
85
	TraversorV(const MAP& m, unsigned int thread = 0) : TraversorCell<MAP, VERTEX>(m, false, thread)
86
	{}
Pierre Kraemer's avatar
Pierre Kraemer committed
87
};
Pierre Kraemer's avatar
Pierre Kraemer committed
88 89

template <typename MAP>
90
class TraversorE : public TraversorCell<MAP, EDGE>
Pierre Kraemer's avatar
Pierre Kraemer committed
91 92
{
public:
Sylvain Thery's avatar
Sylvain Thery committed
93
	TraversorE(const MAP& m, unsigned int thread = 0) : TraversorCell<MAP, EDGE>(m, false, thread)
94
	{}
Pierre Kraemer's avatar
Pierre Kraemer committed
95
};
Pierre Kraemer's avatar
Pierre Kraemer committed
96 97

template <typename MAP>
98
class TraversorF : public TraversorCell<MAP, FACE>
Pierre Kraemer's avatar
Pierre Kraemer committed
99 100
{
public:
Sylvain Thery's avatar
Sylvain Thery committed
101
	TraversorF(const MAP& m, unsigned int thread = 0) : TraversorCell<MAP, FACE>(m, false, thread)
102
	{}
Pierre Kraemer's avatar
Pierre Kraemer committed
103
};
Pierre Kraemer's avatar
Pierre Kraemer committed
104 105

template <typename MAP>
106
class TraversorW : public TraversorCell<MAP, VOLUME>
Pierre Kraemer's avatar
Pierre Kraemer committed
107 108
{
public:
Sylvain Thery's avatar
Sylvain Thery committed
109
	TraversorW(const MAP& m, unsigned int thread = 0) : TraversorCell<MAP, VOLUME>(m, false, thread)
110
	{}
Pierre Kraemer's avatar
Pierre Kraemer committed
111
};
Pierre Kraemer's avatar
Pierre Kraemer committed
112 113 114

} // namespace CGoGN

115 116
#include "Topology/generic/traversorCell.hpp"

Pierre Kraemer's avatar
Pierre Kraemer committed
117
#endif