map3.hpp 5.47 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-2011, 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.u-strasbg.fr/                                         *
Pierre Kraemer's avatar
Pierre Kraemer committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

#include <list>
#include <set>
#include <map>
#include <vector>

namespace CGoGN
{

/// INLINE FUNCTIONS

35
inline void Map3::init()
Pierre Kraemer's avatar
Pierre Kraemer committed
36 37 38 39
{
	m_phi3 = addRelation("phi3") ;
}

40 41 42 43 44
inline Map3::Map3() : Map2()
{
	init() ;
}

Pierre Kraemer's avatar
Pierre Kraemer committed
45 46 47 48 49 50 51 52 53 54
inline std::string Map3::mapTypeName()
{
	return "Map3";
}

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

55 56 57
inline void Map3::clear(bool removeAttrib)
{
	Map2::clear(removeAttrib) ;
Sylvain Thery's avatar
Sylvain Thery committed
58 59
	if (removeAttrib)
		init() ;
60 61
}

Pierre Kraemer's avatar
Pierre Kraemer committed
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 104 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 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
/*! @name Basic Topological Operators
 * Access and Modification
 *************************************************************************/

inline Dart Map3::newDart()
{
	Dart d = Map2::newDart() ;
	(*m_phi3)[d.index] = d ;
	return d ;
}

inline Dart Map3::phi3(Dart d)
{
	return (*m_phi3)[d.index] ;
}

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

/*
 * N'a pas de sens dans une 3-carte, n'est pas une permutation
 */
inline Dart Map3::alpha0(Dart d)
{
	return phi3(d) ;
}

/*
 * idem
 */
inline Dart Map3::alpha1(Dart d)
{
	return phi1(phi3(d)) ;
}

#ifdef NO_BOUND_MAP
inline Dart Map3::alpha2(Dart d)
{
	return phi2(phi3(d));
}
#else
inline Dart Map3::alpha2(Dart d)
{
	Dart e = phi2(d);
	Dart f = phi3(e);

	if (f != e)
		return f;

	f = d;
	e = phi3(f);
	while (e != f)
	{
		f = phi2(e);
		e = phi3(f);
	}
	return f;
}
#endif

#ifdef NO_BOUND_MAP
inline Dart Map3::alpha_2(Dart d)
{
	return phi3(phi2(d));
}
#else
inline Dart Map3::alpha_2(Dart d)
{
	Dart e = phi3(d);

	if (e != d)
		return phi2(e);

	e = d;
	Dart f = phi2(d);
	while (phi3(f) != f)
	{
		e = phi3(f);
		f = phi2(e);
	}
	return e;
}
#endif

inline void Map3::phi3sew(Dart d, Dart e)
{
	assert((*m_phi3)[d.index] == d) ;
	assert((*m_phi3)[e.index] == e) ;
	(*m_phi3)[d.index] = e ;
	(*m_phi3)[e.index] = d ;
}

inline void Map3::phi3unsew(Dart d)
{
	Dart e = (*m_phi3)[d.index] ;
	(*m_phi3)[d.index] = d ;
	(*m_phi3)[e.index] = e ;
}

181 182 183 184 185
inline bool Map3::foreach_dart_of_vertex(Dart d, FunctorType& f, unsigned int thread)
{
	return foreach_dart_of_oriented_vertex(d, f, thread);
}

Pierre Kraemer's avatar
Pierre Kraemer committed
186 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 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
//template<typename TMAP>
//bool Map3::foreach_dart_of_parent_cell(int dim, Dart d, FunctorType& f)
//{
//	switch(dim)
//		{
//			case  0: return this->TMAP::foreach_dart_of_vertex(d,f);
//			case  1: return this->TMAP::foreach_dart_of_edge(d,f);
//			case  2: return this->TMAP::foreach_dart_of_face(d,f);
//			case -1: return this->TMAP::foreach_dart_of_cc(d,f);
//	}
//	return false;
//}
//
//template<typename TMAP>
//bool Map3::markOrbitOf(int dim, Dart d, Marker m)
//{
//	FunctorMark<Map3> fmark(*this, m);
//	switch(dim)
//		{
//			case  0: return this->TMAP::foreach_dart_of_vertex(d,fmark);
//			case  1: return this->TMAP::foreach_dart_of_edge(d,fmark);
//			case  2: return this->TMAP::foreach_dart_of_face(d,fmark);
//			case -1: return this->TMAP::foreach_dart_of_cc(d,fmark);
//	}
//	return false;
//}
//
//template<typename TMAP>
//bool Map3::unmarkOrbitOf(int dim, Dart d, Marker m)
//{
//	FunctorUnmark<Map3> fumark(*this, m);
//	switch(dim)
//		{
//			case  0: return this->TMAP::foreach_dart_of_vertex(d,fumark);
//			case  1: return this->TMAP::foreach_dart_of_edge(d,fumark);
//			case  2: return this->TMAP::foreach_dart_of_face(d,fumark);
//			case -1: return this->TMAP::foreach_dart_of_cc(d,fumark);
//	}
//	return false;
//}

} // namespace CGoGN