map2.hpp 5.79 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
{

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

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

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

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

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

60 61
template <class MAP>
inline void Map2<MAP>::update_topo_shortcuts()
Sylvain Thery's avatar
Sylvain Thery committed
62
{
63
	ParentMap::update_topo_shortcuts();
64
//	m_phi2 = getRelation("phi2");
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
 *************************************************************************/

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

77
template <class MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
78
template <int N>
79
inline Dart Map2<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
			case 1 : return this->phi1(d) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
87 88 89 90 91 92 93 94 95 96 97 98
			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 ;
	}
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

197 198
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
199
{
200
	return ParentMap::foreach_dart_of_cc(d, f, thread);
Pierre Kraemer's avatar
Pierre Kraemer committed
201 202
}

203 204
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
205 206 207
{
	return foreach_dart_of_cc(d, f, thread);
}
208

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

215 216
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
217
{
218
	return ParentMap::foreach_dart_of_edge(d,f,thread);
Pierre Kraemer's avatar
Pierre Kraemer committed
219 220 221
}

} // namespace CGoGN