map3.hpp 5.51 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
24
25
26
27
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

namespace CGoGN
{

Pierre Kraemer's avatar
Pierre Kraemer committed
28
29
template <class MAP>
inline void Map3<MAP>::init()
Pierre Kraemer's avatar
Pierre Kraemer committed
30
{
Pierre Kraemer's avatar
Pierre Kraemer committed
31
	MAP::addInvolution() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
32
33
}

Pierre Kraemer's avatar
Pierre Kraemer committed
34
35
template <class MAP>
inline Map3<MAP>::Map3() : Map2<MAP>()
36
37
38
39
{
	init() ;
}

Pierre Kraemer's avatar
Pierre Kraemer committed
40
41
template <class MAP>
inline std::string Map3<MAP>::mapTypeName() const
Pierre Kraemer's avatar
Pierre Kraemer committed
42
43
44
45
{
	return "Map3";
}

Pierre Kraemer's avatar
Pierre Kraemer committed
46
47
template <class MAP>
inline unsigned int Map3<MAP>::dimension() const
Pierre Kraemer's avatar
Pierre Kraemer committed
48
49
50
51
{
	return 3;
}

Pierre Kraemer's avatar
Pierre Kraemer committed
52
53
template <class MAP>
inline void Map3<MAP>::clear(bool removeAttrib)
54
{
Pierre Kraemer's avatar
Pierre Kraemer committed
55
	ParentMap::clear(removeAttrib) ;
Sylvain Thery's avatar
Sylvain Thery committed
56
57
	if (removeAttrib)
		init() ;
58
59
}

Pierre Kraemer's avatar
Pierre Kraemer committed
60
61
template <class MAP>
inline void Map3<MAP>::update_topo_shortcuts()
Sylvain Thery's avatar
Sylvain Thery committed
62
{
Pierre Kraemer's avatar
Pierre Kraemer committed
63
64
	ParentMap::update_topo_shortcuts();
//	m_phi3 = getRelation("phi3");
Sylvain Thery's avatar
Sylvain Thery committed
65
66
}

Pierre Kraemer's avatar
Pierre Kraemer committed
67
68
69
70
/*! @name Basic Topological Operators
 * Access and Modification
 *************************************************************************/

Pierre Kraemer's avatar
Pierre Kraemer committed
71
72
template <class MAP>
inline Dart Map3<MAP>::phi3(Dart d) const
Pierre Kraemer's avatar
Pierre Kraemer committed
73
{
Pierre Kraemer's avatar
Pierre Kraemer committed
74
	return MAP::getInvolution<1>(d);
Pierre Kraemer's avatar
Pierre Kraemer committed
75
76
}

Pierre Kraemer's avatar
Pierre Kraemer committed
77
template <class MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
78
template <int N>
Pierre Kraemer's avatar
Pierre Kraemer committed
79
inline Dart Map3<MAP>::phi(Dart d) const
Pierre Kraemer's avatar
Pierre Kraemer committed
80
81
82
83
84
85
{
	assert( (N >0) || !"negative parameters not allowed in template multi-phi");
	if (N<10)
	{
		switch(N)
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
86
87
88
89
			case 1 : return this->phi1(d) ;
			case 2 : return this->phi2(d) ;
			case 3 : return phi3(d) ;
			default : assert(!"Wrong multi-phi relation value") ; return d ;
Pierre Kraemer's avatar
Pierre Kraemer committed
90
91
92
93
		}
	}
	switch(N%10)
	{
Pierre Kraemer's avatar
Pierre Kraemer committed
94
95
96
97
		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 ;
Pierre Kraemer's avatar
Pierre Kraemer committed
98
99
100
	}
}

Pierre Kraemer's avatar
Pierre Kraemer committed
101
102
template <class MAP>
inline Dart Map3<MAP>::alpha0(Dart d) const
Pierre Kraemer's avatar
Pierre Kraemer committed
103
104
105
106
{
	return phi3(d) ;
}

Pierre Kraemer's avatar
Pierre Kraemer committed
107
108
template <class MAP>
inline Dart Map3<MAP>::alpha1(Dart d) const
Pierre Kraemer's avatar
Pierre Kraemer committed
109
{
Pierre Kraemer's avatar
Pierre Kraemer committed
110
	return phi3(this->phi_1(d)) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
111
112
}

Pierre Kraemer's avatar
Pierre Kraemer committed
113
114
template <class MAP>
inline Dart Map3<MAP>::alpha2(Dart d) const
Pierre Kraemer's avatar
Pierre Kraemer committed
115
{
Pierre Kraemer's avatar
Pierre Kraemer committed
116
	return phi3(this->phi2(d));
Pierre Kraemer's avatar
Pierre Kraemer committed
117
118
}

Pierre Kraemer's avatar
Pierre Kraemer committed
119
120
template <class MAP>
inline Dart Map3<MAP>::alpha_2(Dart d) const
Pierre Kraemer's avatar
Pierre Kraemer committed
121
{
untereiner's avatar
untereiner committed
122
	return phi2(phi3(d));
Pierre Kraemer's avatar
Pierre Kraemer committed
123
124
}

Pierre Kraemer's avatar
Pierre Kraemer committed
125
126
template <class MAP>
inline void Map3<MAP>::phi3sew(Dart d, Dart e)
Pierre Kraemer's avatar
Pierre Kraemer committed
127
{
Pierre Kraemer's avatar
Pierre Kraemer committed
128
	MAP::involutionSew<1>(d,e);
Pierre Kraemer's avatar
Pierre Kraemer committed
129
130
}

Pierre Kraemer's avatar
Pierre Kraemer committed
131
132
template <class MAP>
inline void Map3<MAP>::phi3unsew(Dart d)
Pierre Kraemer's avatar
Pierre Kraemer committed
133
{
Pierre Kraemer's avatar
Pierre Kraemer committed
134
	MAP::involutionUnsew<1>(d);
Pierre Kraemer's avatar
Pierre Kraemer committed
135
136
}

untereiner's avatar
untereiner committed
137
138
139
/*! @name Topological Queries
 *  Return or set various topological information
 *************************************************************************/
Pierre Kraemer's avatar
Pierre Kraemer committed
140

Pierre Kraemer's avatar
Pierre Kraemer committed
141
142
template <class MAP>
inline bool Map3<MAP>::sameEdge(Dart d, Dart e) const
untereiner's avatar
untereiner committed
143
{
Pierre Kraemer's avatar
Pierre Kraemer committed
144
	return ParentMap::sameOrientedEdge(d, e) || ParentMap::sameOrientedEdge(this->phi2(d), e) ;
untereiner's avatar
untereiner committed
145
146
}

Pierre Kraemer's avatar
Pierre Kraemer committed
147
148
template <class MAP>
inline bool Map3<MAP>::sameFace(Dart d, Dart e) const
untereiner's avatar
untereiner committed
149
{
Pierre Kraemer's avatar
Pierre Kraemer committed
150
	return ParentMap::sameOrientedFace(d, e) || ParentMap::sameOrientedFace(phi3(d), e) ;
untereiner's avatar
untereiner committed
151
}
Pierre Kraemer's avatar
Pierre Kraemer committed
152

Pierre Kraemer's avatar
Pierre Kraemer committed
153
154
template <class MAP>
inline bool Map3<MAP>::isBoundaryFace(Dart d) const
untereiner's avatar
untereiner committed
155
{
Pierre Kraemer's avatar
Pierre Kraemer committed
156
	return this->isBoundaryMarked3(d) || this->isBoundaryMarked3(phi3(d));
untereiner's avatar
untereiner committed
157
158
159
160
161
162
}

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

Pierre Kraemer's avatar
Pierre Kraemer committed
163
164
template <class MAP>
inline bool Map3<MAP>::foreach_dart_of_face(Dart d, FunctorType& f, unsigned int thread) const
untereiner's avatar
untereiner committed
165
{
Pierre Kraemer's avatar
Pierre Kraemer committed
166
	return ParentMap::foreach_dart_of_face(d, f, thread) || ParentMap::foreach_dart_of_face(phi3(d), f, thread);
167
168
}

Pierre Kraemer's avatar
Pierre Kraemer committed
169
170
template <class MAP>
inline bool Map3<MAP>::foreach_dart_of_volume(Dart d, FunctorType& f, unsigned int thread) const
171
{
Pierre Kraemer's avatar
Pierre Kraemer committed
172
	return ParentMap::foreach_dart_of_cc(d, f, thread);
173
174
}

Pierre Kraemer's avatar
Pierre Kraemer committed
175
176
template <class MAP>
inline bool Map3<MAP>::foreach_dart_of_vertex2(Dart d, FunctorType& f, unsigned int thread) const
177
{
Pierre Kraemer's avatar
Pierre Kraemer committed
178
	return ParentMap::foreach_dart_of_vertex(d, f, thread);
179
180
}

Pierre Kraemer's avatar
Pierre Kraemer committed
181
182
template <class MAP>
inline bool Map3<MAP>::foreach_dart_of_edge2(Dart d, FunctorType& f, unsigned int thread) const
183
{
Pierre Kraemer's avatar
Pierre Kraemer committed
184
	return ParentMap::foreach_dart_of_edge(d, f, thread);
185
186
}

Pierre Kraemer's avatar
Pierre Kraemer committed
187
188
template <class MAP>
inline bool Map3<MAP>::foreach_dart_of_face2(Dart d, FunctorType& f, unsigned int thread) const
189
{
Pierre Kraemer's avatar
Pierre Kraemer committed
190
	return ParentMap::foreach_dart_of_face(d, f, thread);
untereiner's avatar
untereiner committed
191
192
193
}

} // namespace CGoGN