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

map3.hpp 5.35 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-2011, 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.u-strasbg.fr/                                         *
Pierre Kraemer's avatar
Pierre Kraemer committed
21
22
23
24
25
26
27
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

namespace CGoGN
{

28
inline void Map3::init()
Pierre Kraemer's avatar
Pierre Kraemer committed
29
30
31
32
{
	m_phi3 = addRelation("phi3") ;
}

33
34
35
36
37
inline Map3::Map3() : Map2()
{
	init() ;
}

Pierre Kraemer's avatar
Pierre Kraemer committed
38
39
40
41
42
43
44
45
46
47
inline std::string Map3::mapTypeName()
{
	return "Map3";
}

inline unsigned int Map3::dimension()
{
	return 3;
}

48
49
50
inline void Map3::clear(bool removeAttrib)
{
	Map2::clear(removeAttrib) ;
Sylvain Thery's avatar
Sylvain Thery committed
51
52
	if (removeAttrib)
		init() ;
53
54
}

Sylvain Thery's avatar
Sylvain Thery committed
55
56
57
58
59
60
inline void Map3::update_topo_shortcuts()
{
	Map2::update_topo_shortcuts();
	m_phi3 = getRelation("phi3");
}

Pierre Kraemer's avatar
Pierre Kraemer committed
61
62
63
64
65
66
67
/*! @name Basic Topological Operators
 * Access and Modification
 *************************************************************************/

inline Dart Map3::newDart()
{
	Dart d = Map2::newDart() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
68
69
70
71
72
73
74
75
76
77
78
	(*m_phi3)[dartIndex(d)] = d ;
	if(m_isMultiRes)
	{
		pushLevel() ;
		for(unsigned int i = m_mrCurrentLevel + 1;  i < m_mrDarts.size(); ++i)
		{
			setCurrentLevel(i) ;
			(*m_phi3)[dartIndex(d)] = d ;
		}
		popLevel() ;
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
79
80
81
82
83
	return d ;
}

inline Dart Map3::phi3(Dart d)
{
84
85
	unsigned int d_index = dartIndex(d);
	return (*m_phi3)[d_index] ;
Pierre Kraemer's avatar
Pierre Kraemer committed
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
}

template <int N>
inline Dart Map3::phi(Dart d)
{
	assert( (N >0) || !"negative parameters not allowed in template multi-phi");
	if (N<10)
	{
		switch(N)
		{
		case 1 : return phi1(d) ;
		case 2 : return phi2(d) ;
		case 3 : return phi3(d) ;
		default : assert(!"Wrong multi-phi relation value") ; return d ;
		}
	}
	switch(N%10)
	{
	case 1 : return phi1(phi<N/10>(d)) ;
	case 2 : return phi2(phi<N/10>(d)) ;
	case 3 : return phi3(phi<N/10>(d)) ;
	default : assert(!"Wrong multi-phi relation value") ; return d ;
	}
}

inline Dart Map3::alpha0(Dart d)
{
	return phi3(d) ;
}

inline Dart Map3::alpha1(Dart d)
{
118
	return phi3(phi_1(d)) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
119
120
121
122
}

inline Dart Map3::alpha2(Dart d)
{
untereiner's avatar
untereiner committed
123
	return phi3(phi2(d));
Pierre Kraemer's avatar
Pierre Kraemer committed
124
125
126
127
}

inline Dart Map3::alpha_2(Dart d)
{
untereiner's avatar
untereiner committed
128
	return phi2(phi3(d));
Pierre Kraemer's avatar
Pierre Kraemer committed
129
130
131
132
}

inline void Map3::phi3sew(Dart d, Dart e)
{
133
134
135
136
137
138
	unsigned int d_index = dartIndex(d);
	unsigned int e_index = dartIndex(e);
	assert((*m_phi3)[d_index] == d) ;
	assert((*m_phi3)[e_index] == e) ;
	(*m_phi3)[d_index] = e ;
	(*m_phi3)[e_index] = d ;
Pierre Kraemer's avatar
Pierre Kraemer committed
139
140
141
142
}

inline void Map3::phi3unsew(Dart d)
{
143
144
145
146
147
	unsigned int d_index = dartIndex(d);
	Dart e = (*m_phi3)[d_index] ;
	(*m_phi3)[d_index] = d ;
	unsigned int e_index = dartIndex(e);
	(*m_phi3)[e_index] = e ;
Pierre Kraemer's avatar
Pierre Kraemer committed
148
149
}

untereiner's avatar
untereiner committed
150
151
152
/*! @name Topological Queries
 *  Return or set various topological information
 *************************************************************************/
Pierre Kraemer's avatar
Pierre Kraemer committed
153

untereiner's avatar
untereiner committed
154
155
156
157
158
159
160
161
162
inline bool Map3::sameEdge(Dart d, Dart e)
{
	return sameOrientedEdge(d, e) || sameOrientedEdge(phi2(d), e) ;
}

inline bool Map3::sameFace(Dart d, Dart e)
{
	return Map2::sameOrientedFace(d, e) || Map2::sameOrientedFace(phi3(d), e) ;
}
Pierre Kraemer's avatar
Pierre Kraemer committed
163

untereiner's avatar
untereiner committed
164
165
166
167
168
169
170
171
172
173
174
inline bool Map3::isBoundaryFace(Dart d)
{
	return isBoundaryMarked(d) || isBoundaryMarked(phi3(d));
}

/*! @name Cell Functors
 *  Apply functors to all darts of a cell
 *************************************************************************/

inline bool Map3::foreach_dart_of_face(Dart d, FunctorType& f, unsigned int thread)
{
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
	return Map2::foreach_dart_of_face(d, f, thread) || Map2::foreach_dart_of_face(phi3(d), f, thread);
}

inline bool Map3::foreach_dart_of_volume(Dart d, FunctorType& f, unsigned int thread)
{
	return Map2::foreach_dart_of_cc(d, f, thread);
}

inline bool Map3::foreach_dart_of_vertex2(Dart d, FunctorType& f, unsigned int thread)
{
	return Map2::foreach_dart_of_vertex(d, f, thread);
}

inline bool Map3::foreach_dart_of_edge2(Dart d, FunctorType& f, unsigned int thread)
{
	return Map2::foreach_dart_of_edge(d, f, thread);
}

inline bool Map3::foreach_dart_of_face2(Dart d, FunctorType& f, unsigned int thread)
{
	return Map2::foreach_dart_of_face(d, f, thread);
untereiner's avatar
untereiner committed
196
197
198
}

} // namespace CGoGN