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

traversorCell.hpp 4.44 KB
Newer Older
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           *
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/                                           *
21
22
23
24
25
26
27
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

namespace CGoGN
{

28
29
30
template <typename MAP, unsigned int ORBIT>
TraversorCell<MAP, ORBIT>::TraversorCell(MAP& map, const FunctorSelect& good, bool forceDartMarker, unsigned int thread) :
	m(map), dmark(NULL), cmark(NULL), current(NIL), firstTraversal(true), m_good(good)
31
{
32
33
	if(!forceDartMarker && map.isOrbitEmbedded(ORBIT))
		cmark = new CellMarker<ORBIT>(map, thread) ;
34
35
36
37
	else
		dmark = new DartMarker(map, thread) ;
}

38
39
template <typename MAP, unsigned int ORBIT>
TraversorCell<MAP, ORBIT>::~TraversorCell()
40
41
42
43
44
45
46
{
	if(dmark)
		delete dmark ;
	else
		delete cmark ;
}

47
48
template <typename MAP, unsigned int ORBIT>
Dart TraversorCell<MAP, ORBIT>::begin()
49
50
51
52
53
54
55
56
57
58
59
{
	if(!firstTraversal)
	{
		if(dmark)
			dmark->unmarkAll() ;
		else
			cmark->unmarkAll() ;
	}

	current = m.begin() ;
	while(current != m.end() && (m.isBoundaryMarked(current) || !m_good(current)))
60
		m.next(current) ;
61
62
63
64
65
66

	if(current == m.end())
		current = NIL ;
	else
	{
		if(dmark)
67
			dmark->markOrbit<ORBIT>(current) ;
68
69
70
71
72
73
74
75
		else
			cmark->mark(current) ;
	}

	firstTraversal = false ;
	return current ;
}

76
77
template <typename MAP, unsigned int ORBIT>
Dart TraversorCell<MAP, ORBIT>::end()
Pierre Kraemer's avatar
Pierre Kraemer committed
78
79
80
{
	return NIL ;
}
81

82
83
template <typename MAP, unsigned int ORBIT>
Dart TraversorCell<MAP, ORBIT>::next()
84
85
86
87
88
89
90
91
92
93
94
{
	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)))
		{
95
			m.next(current) ;
96
97
98
99
100
101
102
103
104
105
106
107
108
109
			if(current == m.end())
				current = NIL ;
			else
			{
				if(dmark)
					ismarked = dmark->isMarked(current) ;
				else
					ismarked = cmark->isMarked(current) ;
			}
		}

		if(current != NIL)
		{
			if(dmark)
110
				dmark->markOrbit<ORBIT>(current) ;
111
112
113
114
115
116
117
			else
				cmark->mark(current) ;
		}
	}
	return current ;
}

118
119
template <typename MAP, unsigned int ORBIT>
void TraversorCell<MAP, ORBIT>::skip(Dart d)
120
121
{
	if(dmark)
122
		dmark->markOrbit<ORBIT>(d) ;
123
124
125
126
127
	else
		cmark->mark(d) ;
}


128
129
template <typename MAP, unsigned int ORBIT>
TraversorDartsOfOrbit<MAP, ORBIT>::TraversorDartsOfOrbit(MAP& map, Dart d, unsigned int thread)
130
131
{
	m_vd.reserve(16);
Pierre Kraemer's avatar
Pierre Kraemer committed
132
	FunctorStoreNotBoundary<MAP> fs(map, m_vd);
133
	map.foreach_dart_of_orbit<ORBIT>(d, fs, thread);
134
135
136
	m_vd.push_back(NIL);
}

137
138
template <typename MAP, unsigned int ORBIT>
Dart TraversorDartsOfOrbit<MAP, ORBIT>::begin()
139
{
Pierre Kraemer's avatar
Pierre Kraemer committed
140
	m_current = m_vd.begin();
141
142
143
	return *m_current;
}

144
145
template <typename MAP, unsigned int ORBIT>
Dart TraversorDartsOfOrbit<MAP, ORBIT>::end()
146
147
148
{
	return NIL;
}
149

150
151
template <typename MAP, unsigned int ORBIT>
Dart TraversorDartsOfOrbit<MAP, ORBIT>::next()
152
153
154
155
156
157
{
	if (*m_current != NIL)
		m_current++;
	return *m_current;
}

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