gmap3.hpp 5.71 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 30 31
inline void GMap3::init()
{
	m_beta3 = addRelation("beta3") ;
}
Pierre Kraemer's avatar
Pierre Kraemer committed
32 33 34

inline GMap3::GMap3() : GMap2()
{
35
	init() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
36 37
}

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

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

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

Sylvain Thery's avatar
Sylvain Thery committed
55 56 57 58 59 60
inline void GMap3::update_topo_shortcuts()
{
	GMap2::update_topo_shortcuts();
	m_beta3 = getRelation("beta3");
}

Pierre Kraemer's avatar
Pierre Kraemer committed
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
/*! @name Basic Topological Operators
 * Access and Modification
 *************************************************************************/

inline Dart GMap3::newDart()
{
	Dart d = GMap2::newDart() ;
	(*m_beta3)[d.index] = d ;
	return d ;
}

inline Dart GMap3::beta3(Dart d)
{
	return (*m_beta3)[d.index] ;
}

template <int N>
inline Dart GMap3::beta(const Dart d)
{
	assert( (N > 0) || !"negative parameters not allowed in template multi-beta");
	if (N<10)
	{
		switch(N)
		{
		case 0 : return beta0(d) ;
		case 1 : return beta1(d) ;
		case 2 : return beta2(d) ;
		case 3 : return beta2(d) ;
		default : assert(!"Wrong multi-beta relation value") ;
		}
	}
	switch(N%10)
	{
	case 0 : return beta0(beta<N/10>(d)) ;
	case 1 : return beta1(beta<N/10>(d)) ;
	case 2 : return beta2(beta<N/10>(d)) ;
	case 3 : return beta3(beta<N/10>(d)) ;
	default : assert(!"Wrong multi-beta relation value") ;
	}
}

inline Dart GMap3::phi3(Dart d)
{
Pierre Kraemer's avatar
Pierre Kraemer committed
104
	return beta3(beta0(d)) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
}

template <int N>
inline Dart GMap3::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 ;
	}
}

Pierre Kraemer's avatar
Pierre Kraemer committed
130 131 132 133
inline Dart GMap3::alpha0(Dart d)
{
	return beta3(beta0(d)) ;
}
Pierre Kraemer's avatar
Pierre Kraemer committed
134

Pierre Kraemer's avatar
Pierre Kraemer committed
135 136 137 138 139 140 141 142 143 144 145 146 147 148
inline Dart GMap3::alpha1(Dart d)
{
	return beta3(beta1(d)) ;
}

inline Dart GMap3::alpha2(Dart d)
{
	return beta3(beta2(d)) ;
}

inline Dart GMap3::alpha_2(Dart d)
{
	return beta2(beta3(d)) ;
}
Pierre Kraemer's avatar
Pierre Kraemer committed
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164

inline void GMap3::beta3sew(Dart d, Dart e)
{
	assert((*m_beta3)[d.index] == d) ;
	assert((*m_beta3)[e.index] == e) ;
	(*m_beta3)[d.index] = e ;
	(*m_beta3)[e.index] = d ;
}

inline void GMap3::beta3unsew(Dart d)
{
	Dart e = (*m_beta3)[d.index] ;
	(*m_beta3)[d.index] = d ;
	(*m_beta3)[e.index] = e ;
}

Pierre Kraemer's avatar
Pierre Kraemer committed
165 166 167 168 169
/*! @name Topological Queries
 *  Return or set various topological information
 *************************************************************************/

inline bool GMap3::sameFace(Dart d, Dart e)
Pierre Kraemer's avatar
Pierre Kraemer committed
170
{
Pierre Kraemer's avatar
Pierre Kraemer committed
171
	return GMap2::sameFace(d, e) || GMap2::sameFace(beta3(d), e) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
172 173
}

Pierre Kraemer's avatar
Pierre Kraemer committed
174
inline bool GMap3::isBoundaryFace(Dart d)
Pierre Kraemer's avatar
Pierre Kraemer committed
175
{
Pierre Kraemer's avatar
Pierre Kraemer committed
176
	return isBoundaryMarked(d) || isBoundaryMarked(beta3(d));
Pierre Kraemer's avatar
Pierre Kraemer committed
177 178
}

Pierre Kraemer's avatar
Pierre Kraemer committed
179 180 181
/*! @name Cell Functors
 *  Apply functors to all darts of a cell
 *************************************************************************/
Pierre Kraemer's avatar
Pierre Kraemer committed
182

Pierre Kraemer's avatar
Pierre Kraemer committed
183 184 185 186
inline bool GMap3::foreach_dart_of_face(Dart d, FunctorType& f, unsigned int thread)
{
	return GMap2::foreach_dart_of_face(d, f, thread) || GMap2::foreach_dart_of_face(beta3(d), f, thread);
}
Pierre Kraemer's avatar
Pierre Kraemer committed
187

188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
inline bool GMap3::foreach_dart_of_volume(Dart d, FunctorType& f, unsigned int thread)
{
	return GMap2::foreach_dart_of_cc(d, f, thread);
}

inline bool GMap3::foreach_dart_of_oriented_volume(Dart d, FunctorType& f, unsigned int thread)
{
	return GMap2::foreach_dart_of_oriented_cc(d, f, thread);
}

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

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

inline bool GMap3::foreach_dart_of_face2(Dart d, FunctorType& f, unsigned int thread)
{
	return GMap2::foreach_dart_of_face(d, f, thread);
}

Pierre Kraemer's avatar
Pierre Kraemer committed
213
} // namespace CGoGN