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

namespace CGoGN
{

/// INLINE FUNCTIONS

30
inline void Map2::init()
Pierre Kraemer's avatar
Pierre Kraemer committed
31 32 33 34
{
	m_phi2 = addRelation("phi2") ;
}

35 36 37 38 39
inline Map2::Map2() : Map1()
{
	init() ;
}

Pierre Kraemer's avatar
Pierre Kraemer committed
40 41 42 43 44 45 46 47 48 49
inline std::string Map2::mapTypeName()
{
	return "Map2" ;
}

inline unsigned int Map2::dimension()
{
	return 2 ;
}

50 51 52
inline void Map2::clear(bool removeAttrib)
{
	Map1::clear(removeAttrib) ;
Sylvain Thery's avatar
Sylvain Thery committed
53 54
	if (removeAttrib)
		init() ;
55 56
}

Pierre Kraemer's avatar
Pierre Kraemer committed
57 58 59 60 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 Map2::newDart()
{
	Dart d = Map1::newDart() ;
	(*m_phi2)[d.index] = d ;
	return d ;
}

inline Dart Map2::phi2(Dart d)
{
	return (*m_phi2)[d.index] ;
}

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

inline Dart Map2::alpha0(Dart d)
{
	return phi2(d) ;
}

inline Dart Map2::alpha1(Dart d)
{
	return phi2(phi_1(d)) ;
}

Sylvain Thery's avatar
Sylvain Thery committed
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
// alpha1 avec bord: bye bye
//inline Dart Map2::alpha1(Dart d)
//{
//	Dart e = phi_1(d);
//	Dart f = phi2(e);
//
//	if (f != e)
//		return f;
//
//	f = d;
//	e = phi2(f);
//	while (e != f)
//	{
//		f = phi1(e);
//		e = phi2(f);
//	}
//	return f;
//}
Pierre Kraemer's avatar
Pierre Kraemer committed
122 123 124 125 126 127

inline Dart Map2::alpha_1(Dart d)
{
	return phi1(phi2(d)) ;
}

Sylvain Thery's avatar
Sylvain Thery committed
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
// alpha_1 avec bord : bye bye !!
//inline Dart Map2::alpha_1(Dart d)
//{
//	Dart e = phi2(d);
//
//	if (e != d)
//		return phi1(e);
//
//	e = d;
//	Dart f = phi_1(d);
//	while (phi2(f) != f)
//	{
//		e = phi2(f);
//		f = phi_1(e);
//	}
//	return e;
//}
Pierre Kraemer's avatar
Pierre Kraemer committed
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 181 182 183


inline void Map2::phi2sew(Dart d, Dart e)
{
	assert((*m_phi2)[d.index] == d) ;
	assert((*m_phi2)[e.index] == e) ;
	(*m_phi2)[d.index] = e ;
	(*m_phi2)[e.index] = d ;
}

inline void Map2::phi2unsew(Dart d)
{
	Dart e = (*m_phi2)[d.index] ;
	(*m_phi2)[d.index] = d ;
	(*m_phi2)[e.index] = e ;
}

/*! @name Generator and Deletor
 *  To generate or delete faces in a 2-map
 *************************************************************************/

inline void Map2::deleteFace(Dart d)
{
	deleteOrientedFace(d) ;
}

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

inline bool Map2::sameVertex(Dart d, Dart e)
{
	return sameOrientedVertex(d, e) ;
}

/*! @name Cell Functors
 *  Apply functors to all darts of a cell
 *************************************************************************/

Sylvain Thery's avatar
Sylvain Thery committed
184
inline bool Map2::foreach_dart_of_volume(Dart d, FunctorType& f, unsigned int thread)
Pierre Kraemer's avatar
Pierre Kraemer committed
185
{
Sylvain Thery's avatar
Sylvain Thery committed
186
	return foreach_dart_of_oriented_volume(d, f, thread);
Pierre Kraemer's avatar
Pierre Kraemer committed
187 188
}

Sylvain Thery's avatar
Sylvain Thery committed
189
inline bool Map2::foreach_dart_of_cc(Dart d, FunctorType& f, unsigned int thread)
Pierre Kraemer's avatar
Pierre Kraemer committed
190
{
Sylvain Thery's avatar
Sylvain Thery committed
191
	return foreach_dart_of_oriented_volume(d, f, thread);
Pierre Kraemer's avatar
Pierre Kraemer committed
192 193 194
}

} // namespace CGoGN