gmap0.hpp 4.08 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

Pierre Kraemer's avatar
Pierre Kraemer committed
30 31
template <typename MAP_IMPL>
inline void GMap0<MAP_IMPL>::init()
Pierre Kraemer's avatar
Pierre Kraemer committed
32
{
Pierre Kraemer's avatar
Pierre Kraemer committed
33
	MAP_IMPL::addInvolution() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
34 35
}

Pierre Kraemer's avatar
Pierre Kraemer committed
36 37
template <typename MAP_IMPL>
inline GMap0<MAP_IMPL>::GMap0() : MapCommon<MAP_IMPL>()
38 39 40 41
{
	init() ;
}

Pierre Kraemer's avatar
Pierre Kraemer committed
42 43
template <typename MAP_IMPL>
inline std::string GMap0<MAP_IMPL>::mapTypeName() const
Pierre Kraemer's avatar
Pierre Kraemer committed
44 45 46 47
{
	return "GMap0";
}

Pierre Kraemer's avatar
Pierre Kraemer committed
48 49
template <typename MAP_IMPL>
inline unsigned int GMap0<MAP_IMPL>::dimension() const
Pierre Kraemer's avatar
Pierre Kraemer committed
50 51 52 53
{
	return 0;
}

Pierre Kraemer's avatar
Pierre Kraemer committed
54 55
template <typename MAP_IMPL>
inline void GMap0<MAP_IMPL>::clear(bool removeAttrib)
56
{
Pierre Kraemer's avatar
Pierre Kraemer committed
57
	MAP_IMPL::clear(removeAttrib) ;
Thery Sylvain's avatar
Thery Sylvain committed
58 59
	if (removeAttrib)
		init() ;
60 61
}

Pierre Kraemer's avatar
Pierre Kraemer committed
62
template <typename MAP_IMPL>
Pierre Kraemer's avatar
Pierre Kraemer committed
63
inline unsigned int GMap0<MAP_IMPL>::getNbInvolutions() const
Sylvain Thery's avatar
Sylvain Thery committed
64
{
Pierre Kraemer's avatar
Pierre Kraemer committed
65 66 67 68 69 70 71
	return 1;
}

template <typename MAP_IMPL>
inline unsigned int GMap0<MAP_IMPL>::getNbPermutations() const
{
	return 0;
Sylvain Thery's avatar
Sylvain Thery committed
72 73
}

Pierre Kraemer's avatar
Pierre Kraemer committed
74 75 76 77
/*! @name Basic Topological Operators
 * Access and Modification
 *************************************************************************/

Pierre Kraemer's avatar
Pierre Kraemer committed
78 79
template <typename MAP_IMPL>
inline Dart GMap0<MAP_IMPL>::beta0(Dart d) const
Pierre Kraemer's avatar
Pierre Kraemer committed
80
{
Pierre Kraemer's avatar
Pierre Kraemer committed
81
	return MAP_IMPL::template getInvolution<0>(d);
Pierre Kraemer's avatar
Pierre Kraemer committed
82 83
}

Pierre Kraemer's avatar
Pierre Kraemer committed
84 85
template <typename MAP_IMPL>
inline void GMap0<MAP_IMPL>::beta0sew(Dart d, Dart e)
Pierre Kraemer's avatar
Pierre Kraemer committed
86
{
Pierre Kraemer's avatar
Pierre Kraemer committed
87
	MAP_IMPL::template involutionSew<0>(d,e);
Pierre Kraemer's avatar
Pierre Kraemer committed
88 89
}

Pierre Kraemer's avatar
Pierre Kraemer committed
90 91
template <typename MAP_IMPL>
inline void GMap0<MAP_IMPL>::beta0unsew(Dart d)
Pierre Kraemer's avatar
Pierre Kraemer committed
92
{
Pierre Kraemer's avatar
Pierre Kraemer committed
93
	MAP_IMPL::template involutionUnsew<0>(d);
94 95 96 97 98 99
}

/*! @name Constructors and Destructors
 *  To generate or delete edges in a 0-G-map
 *************************************************************************/

Pierre Kraemer's avatar
Pierre Kraemer committed
100 101
template <typename MAP_IMPL>
Dart GMap0<MAP_IMPL>::newEdge()
102 103 104 105 106 107 108
{
	Dart d1 = this->newDart();
	Dart d2 = this->newDart();
	beta0sew(d1,d2);
	return d1;
}

Pierre Kraemer's avatar
Pierre Kraemer committed
109 110
template <typename MAP_IMPL>
void GMap0<MAP_IMPL>::deleteEdge(Dart d)
111 112 113
{
	this->deleteDart(beta0(d));
	this->deleteDart(d);
Pierre Kraemer's avatar
Pierre Kraemer committed
114 115 116 117 118 119
}

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

Pierre Kraemer's avatar
Pierre Kraemer committed
120
template <typename MAP_IMPL>
121
inline void GMap0<MAP_IMPL>::foreach_dart_of_vertex(Dart d, std::function<void (Dart)> f, unsigned int /*thread*/) const
Pierre Kraemer's avatar
Pierre Kraemer committed
122
{
123
	f(d) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
124 125
}

Pierre Kraemer's avatar
Pierre Kraemer committed
126
template <typename MAP_IMPL>
127
inline void GMap0<MAP_IMPL>::foreach_dart_of_edge(Dart d, std::function<void (Dart)> f, unsigned int /*thread*/) const
Pierre Kraemer's avatar
Pierre Kraemer committed
128
{
129
	f(d);
Pierre Kraemer's avatar
Pierre Kraemer committed
130
	Dart d1 = beta0(d);
131 132
	if (d1 != d)
		f(d1);
Pierre Kraemer's avatar
Pierre Kraemer committed
133 134 135
}

} // namespace CGoGN