map2.hpp 5.81 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 28 29
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

namespace CGoGN
{

/// INLINE FUNCTIONS

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

36 37
template <class MAP>
inline Map2<MAP>::Map2() : Map1<MAP>()
38 39 40 41
{
	init() ;
}

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

48 49
template <class MAP>
inline unsigned int Map2<MAP>::dimension() const
Pierre Kraemer's avatar
Pierre Kraemer committed
50 51 52 53
{
	return 2 ;
}

54 55
template <class MAP>
inline void Map2<MAP>::clear(bool removeAttrib)
56
{
57
	ParentMap::clear(removeAttrib) ;
Sylvain Thery's avatar
Sylvain Thery committed
58 59
	if (removeAttrib)
		init() ;
60 61
}

62 63
template <class MAP>
inline void Map2<MAP>::update_topo_shortcuts()
Sylvain Thery's avatar
Sylvain Thery committed
64
{
65
	ParentMap::update_topo_shortcuts();
66
//	m_phi2 = getRelation("phi2");
Sylvain Thery's avatar
Sylvain Thery committed
67 68
}

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

73 74
template <class MAP>
inline Dart Map2<MAP>::phi2(Dart d) const
Pierre Kraemer's avatar
Pierre Kraemer committed
75
{
76
	return MAP::getInvolution<0>(d);
Pierre Kraemer's avatar
Pierre Kraemer committed
77 78
}

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

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

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

113 114
template <class MAP>
inline Dart Map2<MAP>::alpha_1(Dart d) const
Pierre Kraemer's avatar
Pierre Kraemer committed
115 116 117 118
{
	return phi1(phi2(d)) ;
}

119 120
template <class MAP>
inline Dart Map2<MAP>::phi2_1(Dart d) const
121
{
122
	return phi2(this->phi_1(d)) ;
123 124
}

125 126
template <class MAP>
inline Dart Map2<MAP>::phi12(Dart d) const
127 128 129 130
{
	return phi1(phi2(d)) ;
}

131 132
template <class MAP>
inline void Map2<MAP>::phi2sew(Dart d, Dart e)
Pierre Kraemer's avatar
Pierre Kraemer committed
133
{
134
	MAP::involutionSew<0>(d,e);
Pierre Kraemer's avatar
Pierre Kraemer committed
135 136
}

137 138
template <class MAP>
inline void Map2<MAP>::phi2unsew(Dart d)
Pierre Kraemer's avatar
Pierre Kraemer committed
139
{
140
	MAP::involutionUnsew<0>(d);
Pierre Kraemer's avatar
Pierre Kraemer committed
141 142 143 144 145 146
}

/*! @name Topological Queries
 *  Return or set various topological information
 *************************************************************************/

147 148
template <class MAP>
inline bool Map2<MAP>::sameVertex(Dart d, Dart e) const
Pierre Kraemer's avatar
Pierre Kraemer committed
149 150 151 152
{
	return sameOrientedVertex(d, e) ;
}

153 154
template <class MAP>
inline bool Map2<MAP>::sameEdge(Dart d, Dart e) const
Pierre Kraemer's avatar
Pierre Kraemer committed
155 156 157 158
{
	return d == e || phi2(d) == e ;
}

159 160
template <class MAP>
inline bool Map2<MAP>::isBoundaryEdge(Dart d) const
untereiner's avatar
untereiner committed
161
{
162
	return this->isBoundaryMarked2(d) || this->isBoundaryMarked2(phi2(d));
untereiner's avatar
untereiner committed
163 164
}

165 166
template <class MAP>
inline bool Map2<MAP>::sameOrientedFace(Dart d, Dart e) const
167
{
168
	return ParentMap::sameCycle(d, e) ;
169 170
}

171 172
template <class MAP>
inline bool Map2<MAP>::sameFace(Dart d, Dart e) const
173 174 175 176
{
	return sameOrientedFace(d, e) ;
}

177 178
template <class MAP>
inline unsigned int Map2<MAP>::faceDegree(Dart d) const
179
{
180
	return ParentMap::cycleDegree(d) ;
181 182
}

183 184
template <class MAP>
inline int Map2<MAP>::checkFaceDegree(Dart d, unsigned int le) const
185
{
186
	return ParentMap::checkCycleDegree(d,le) ;
187 188
}

189 190
template <class MAP>
inline bool Map2<MAP>::sameVolume(Dart d, Dart e) const
191 192 193 194
{
	return sameOrientedVolume(d, e) ;
}

Pierre Kraemer's avatar
Pierre Kraemer committed
195 196 197 198
/*! @name Cell Functors
 *  Apply functors to all darts of a cell
 *************************************************************************/

199 200
template <class MAP>
inline bool Map2<MAP>::foreach_dart_of_face(Dart d, FunctorType& f, unsigned int thread) const
Pierre Kraemer's avatar
Pierre Kraemer committed
201
{
202
	return ParentMap::foreach_dart_of_cc(d, f, thread);
Pierre Kraemer's avatar
Pierre Kraemer committed
203 204
}

205 206
template <class MAP>
inline bool Map2<MAP>::foreach_dart_of_volume(Dart d, FunctorType& f, unsigned int thread) const
Pierre Kraemer's avatar
Pierre Kraemer committed
207 208 209
{
	return foreach_dart_of_cc(d, f, thread);
}
210

211 212
template <class MAP>
inline bool Map2<MAP>::foreach_dart_of_vertex1(Dart d, FunctorType& f, unsigned int thread) const
213
{
214
	return ParentMap::foreach_dart_of_vertex(d,f,thread);
215 216
}

217 218
template <class MAP>
inline bool Map2<MAP>::foreach_dart_of_edge1(Dart d, FunctorType& f, unsigned int thread) const
Pierre Kraemer's avatar
Pierre Kraemer committed
219
{
220
	return ParentMap::foreach_dart_of_edge(d,f,thread);
Pierre Kraemer's avatar
Pierre Kraemer committed
221 222 223
}

} // namespace CGoGN