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 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();
Sylvain Thery's avatar
Sylvain Thery committed
66 67 68
	m_phi2 = getRelation("phi2");
}

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>::newDart()
Pierre Kraemer's avatar
Pierre Kraemer committed
75 76
{
	Dart d = Map1::newDart() ;
77
	(*m_phi2)[dartIndex(d)] = d ;
78 79 80 81 82 83 84 85 86 87
//	if(m_isMultiRes)
//	{
//		pushLevel() ;
//		for(unsigned int i = m_mrCurrentLevel + 1;  i < m_mrDarts.size(); ++i)
//		{
//			setCurrentLevel(i) ;
//			(*m_phi2)[dartIndex(d)] = d ;
//		}
//		popLevel() ;
//	}
Pierre Kraemer's avatar
Pierre Kraemer committed
88 89 90
	return d ;
}

91 92
template <class MAP>
inline Dart Map2<MAP>::phi2(Dart d) const
Pierre Kraemer's avatar
Pierre Kraemer committed
93
{
94
	return MAP::getInvolution<0>(d);
Pierre Kraemer's avatar
Pierre Kraemer committed
95 96
}

97
template <class MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
98
template <int N>
99
inline Dart Map2<MAP>::phi(Dart d) const
Pierre Kraemer's avatar
Pierre Kraemer committed
100 101 102 103 104 105
{
	assert( (N > 0) || !"negative parameters not allowed in template multi-phi");
	if (N < 10)
	{
		switch(N)
		{
106
			case 1 : return ParentMap::phi1(d) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
107 108 109 110 111 112 113 114 115 116 117 118
			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 ;
	}
}

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

125 126
template <class MAP>
inline Dart Map2<MAP>::alpha1(Dart d) const
Pierre Kraemer's avatar
Pierre Kraemer committed
127 128 129 130
{
	return phi2(phi_1(d)) ;
}

131 132
template <class MAP>
inline Dart Map2<MAP>::alpha_1(Dart d) const
Pierre Kraemer's avatar
Pierre Kraemer committed
133 134 135 136
{
	return phi1(phi2(d)) ;
}

137 138
template <class MAP>
inline Dart Map2<MAP>::phi2_1(Dart d) const
139 140 141 142
{
	return phi2(phi_1(d)) ;
}

143 144
template <class MAP>
inline Dart Map2<MAP>::phi12(Dart d) const
145 146 147 148
{
	return phi1(phi2(d)) ;
}

149 150
template <class MAP>
inline void Map2<MAP>::phi2sew(Dart d, Dart e)
Pierre Kraemer's avatar
Pierre Kraemer committed
151
{
152
	MAP::involutionSew<0>(d,e);
Pierre Kraemer's avatar
Pierre Kraemer committed
153 154
}

155 156
template <class MAP>
inline void Map2<MAP>::phi2unsew(Dart d)
Pierre Kraemer's avatar
Pierre Kraemer committed
157
{
158
	MAP::involutionUnsew<0>(d);
Pierre Kraemer's avatar
Pierre Kraemer committed
159 160 161 162 163 164
}

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

Sylvain Thery's avatar
Sylvain Thery committed
165
inline bool Map2::sameVertex(Dart d, Dart e) const
Pierre Kraemer's avatar
Pierre Kraemer committed
166 167 168 169
{
	return sameOrientedVertex(d, e) ;
}

Sylvain Thery's avatar
Sylvain Thery committed
170
inline bool Map2::sameEdge(Dart d, Dart e) const
Pierre Kraemer's avatar
Pierre Kraemer committed
171 172 173 174
{
	return d == e || phi2(d) == e ;
}

Sylvain Thery's avatar
Sylvain Thery committed
175
inline bool Map2::isBoundaryEdge(Dart d) const
untereiner's avatar
untereiner committed
176
{
Thery Sylvain's avatar
Thery Sylvain committed
177
	return isBoundaryMarked2(d) || isBoundaryMarked2(phi2(d));
untereiner's avatar
untereiner committed
178 179
}

Sylvain Thery's avatar
Sylvain Thery committed
180
inline bool Map2::sameOrientedFace(Dart d, Dart e) const
181 182 183 184
{
	return Map1::sameCycle(d, e) ;
}

Sylvain Thery's avatar
Sylvain Thery committed
185
inline bool Map2::sameFace(Dart d, Dart e) const
186 187 188 189
{
	return sameOrientedFace(d, e) ;
}

Sylvain Thery's avatar
Sylvain Thery committed
190
inline unsigned int Map2::faceDegree(Dart d) const
191 192 193 194
{
	return Map1::cycleDegree(d) ;
}

195

Sylvain Thery's avatar
Sylvain Thery committed
196
inline int Map2::checkFaceDegree(Dart d, unsigned int le) const
197 198 199 200 201
{
	return Map1::checkCycleDegree(d,le) ;
}


Sylvain Thery's avatar
Sylvain Thery committed
202
inline bool Map2::sameVolume(Dart d, Dart e) const
203 204 205 206
{
	return sameOrientedVolume(d, e) ;
}

Pierre Kraemer's avatar
Pierre Kraemer committed
207 208 209 210
/*! @name Cell Functors
 *  Apply functors to all darts of a cell
 *************************************************************************/

Sylvain Thery's avatar
Sylvain Thery committed
211
inline bool Map2::foreach_dart_of_face(Dart d, FunctorType& f, unsigned int thread) const
Pierre Kraemer's avatar
Pierre Kraemer committed
212
{
213
	return Map1::foreach_dart_of_cc(d, f, thread);
Pierre Kraemer's avatar
Pierre Kraemer committed
214 215
}

Sylvain Thery's avatar
Sylvain Thery committed
216
inline bool Map2::foreach_dart_of_volume(Dart d, FunctorType& f, unsigned int thread) const
Pierre Kraemer's avatar
Pierre Kraemer committed
217 218 219
{
	return foreach_dart_of_cc(d, f, thread);
}
220

Sylvain Thery's avatar
Sylvain Thery committed
221
inline bool Map2::foreach_dart_of_vertex1(Dart d, FunctorType& f, unsigned int thread) const
222 223 224 225
{
	return Map1::foreach_dart_of_vertex(d,f,thread);
}

Sylvain Thery's avatar
Sylvain Thery committed
226
inline bool Map2::foreach_dart_of_edge1(Dart d, FunctorType& f, unsigned int thread) const
Pierre Kraemer's avatar
Pierre Kraemer committed
227
{
228
	return Map1::foreach_dart_of_edge(d,f,thread);
Pierre Kraemer's avatar
Pierre Kraemer committed
229 230 231
}

} // namespace CGoGN