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 5.09 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
{
Pierre Kraemer's avatar
Pierre Kraemer committed
32
33
34
35
36
	quickTraversal = map.template getQuickTraversal<ORBIT>() ;
	if(quickTraversal != NULL)
	{
		cont = &(m.template getAttributeContainer<ORBIT>()) ;
	}
37
	else
Pierre Kraemer's avatar
Pierre Kraemer committed
38
39
40
41
42
43
	{
		if(!forceDartMarker && map.template isOrbitEmbedded<ORBIT>())
			cmark = new CellMarker<ORBIT>(map, thread) ;
		else
			dmark = new DartMarker(map, thread) ;
	}
44
45
}

46
47
template <typename MAP, unsigned int ORBIT>
TraversorCell<MAP, ORBIT>::~TraversorCell()
48
{
Pierre Kraemer's avatar
Pierre Kraemer committed
49
50
51
52
53
54
55
	if(quickTraversal == NULL)
	{
		if(dmark)
			delete dmark ;
		else
			delete cmark ;
	}
56
57
}

58
59
template <typename MAP, unsigned int ORBIT>
Dart TraversorCell<MAP, ORBIT>::begin()
60
{
Pierre Kraemer's avatar
Pierre Kraemer committed
61
	if(quickTraversal != NULL)
62
	{
Pierre Kraemer's avatar
Pierre Kraemer committed
63
64
		qCurrent = cont->begin() ;
		current = (*quickTraversal)[qCurrent] ;
65
66
67
	}
	else
	{
Pierre Kraemer's avatar
Pierre Kraemer committed
68
69
70
71
72
73
74
75
76
77
78
79
80
81
		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 ;
82
		else
Pierre Kraemer's avatar
Pierre Kraemer committed
83
84
85
86
87
88
89
90
		{
			if(dmark)
				dmark->markOrbit<ORBIT>(current) ;
			else
				cmark->mark(current) ;
		}

		firstTraversal = false ;
91
92
93
94
95
	}

	return current ;
}

96
97
template <typename MAP, unsigned int ORBIT>
Dart TraversorCell<MAP, ORBIT>::end()
Pierre Kraemer's avatar
Pierre Kraemer committed
98
99
100
{
	return NIL ;
}
101

102
103
template <typename MAP, unsigned int ORBIT>
Dart TraversorCell<MAP, ORBIT>::next()
104
105
106
{
	if(current != NIL)
	{
Pierre Kraemer's avatar
Pierre Kraemer committed
107
108
109
110
111
		if(quickTraversal != NULL)
		{
			cont->next(qCurrent) ;
			current = (*quickTraversal)[qCurrent] ;
		}
112
113
		else
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
114
			if(dmark)
115
			{
116
117
				bool ismarked = dmark->isMarked(current) ;
				while(current != NIL && (ismarked || m.isBoundaryMarked(current) || !m_good(current)))
Pierre Kraemer's avatar
Pierre Kraemer committed
118
				{
119
120
121
					m.next(current) ;
					if(current == m.end())
						current = NIL ;
Pierre Kraemer's avatar
Pierre Kraemer committed
122
					else
123
						ismarked = dmark->isMarked(current) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
124
				}
125
126
				if(current != NIL)
					dmark->markOrbit<ORBIT>(current) ;
127
			}
128
			else
Pierre Kraemer's avatar
Pierre Kraemer committed
129
			{
130
131
132
133
134
135
136
137
138
139
				bool ismarked = cmark->isMarked(current) ;
				while(current != NIL && (ismarked || m.isBoundaryMarked(current) || !m_good(current)))
				{
					m.next(current) ;
					if(current == m.end())
						current = NIL ;
					else
						ismarked = cmark->isMarked(current) ;
				}
				if(current != NIL)
Pierre Kraemer's avatar
Pierre Kraemer committed
140
141
					cmark->mark(current) ;
			}
142
143
144
145
146
		}
	}
	return current ;
}

147
148
template <typename MAP, unsigned int ORBIT>
void TraversorCell<MAP, ORBIT>::skip(Dart d)
149
150
{
	if(dmark)
151
		dmark->markOrbit<ORBIT>(d) ;
152
153
154
155
156
	else
		cmark->mark(d) ;
}


157
158
template <typename MAP, unsigned int ORBIT>
TraversorDartsOfOrbit<MAP, ORBIT>::TraversorDartsOfOrbit(MAP& map, Dart d, unsigned int thread)
159
160
{
	m_vd.reserve(16);
Pierre Kraemer's avatar
Pierre Kraemer committed
161
	FunctorStoreNotBoundary<MAP> fs(map, m_vd);
Pierre Kraemer's avatar
Pierre Kraemer committed
162
	map.template foreach_dart_of_orbit<ORBIT>(d, fs, thread);
163
164
165
	m_vd.push_back(NIL);
}

166
167
template <typename MAP, unsigned int ORBIT>
Dart TraversorDartsOfOrbit<MAP, ORBIT>::begin()
168
{
Pierre Kraemer's avatar
Pierre Kraemer committed
169
	m_current = m_vd.begin();
170
171
172
	return *m_current;
}

173
174
template <typename MAP, unsigned int ORBIT>
Dart TraversorDartsOfOrbit<MAP, ORBIT>::end()
175
176
177
{
	return NIL;
}
178

179
180
template <typename MAP, unsigned int ORBIT>
Dart TraversorDartsOfOrbit<MAP, ORBIT>::next()
181
182
183
184
185
186
{
	if (*m_current != NIL)
		m_current++;
	return *m_current;
}

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