gmap0.hpp 3.83 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 <class MAP>
inline void GMap0<MAP>::init()
Pierre Kraemer's avatar
Pierre Kraemer committed
32
{
Pierre Kraemer's avatar
Pierre Kraemer committed
33
	MAP::addInvolution() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
34 35
}

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

Pierre Kraemer's avatar
Pierre Kraemer committed
42 43
template <class MAP>
inline std::string GMap0<MAP>::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 <class MAP>
inline unsigned int GMap0<MAP>::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 <class MAP>
inline void GMap0<MAP>::clear(bool removeAttrib)
56
{
Pierre Kraemer's avatar
Pierre Kraemer committed
57
	MAP::clear(removeAttrib) ;
Thery Sylvain's avatar
Thery Sylvain committed
58 59
	if (removeAttrib)
		init() ;
60 61
}

Pierre Kraemer's avatar
Pierre Kraemer committed
62 63
template <class MAP>
inline void GMap0<MAP>::update_topo_shortcuts()
Sylvain Thery's avatar
Sylvain Thery committed
64
{
Pierre Kraemer's avatar
Pierre Kraemer committed
65 66
	MAP::update_topo_shortcuts();
//	m_beta0 = getRelation("beta0");
Sylvain Thery's avatar
Sylvain Thery committed
67 68
}

Pierre Kraemer's avatar
Pierre Kraemer committed
69 70 71 72
/*! @name Basic Topological Operators
 * Access and Modification
 *************************************************************************/

Pierre Kraemer's avatar
Pierre Kraemer committed
73 74
template <class MAP>
inline Dart GMap0<MAP>::beta0(Dart d) const
Pierre Kraemer's avatar
Pierre Kraemer committed
75
{
76
	return MAP::template getInvolution<0>(d);
Pierre Kraemer's avatar
Pierre Kraemer committed
77 78
}

Pierre Kraemer's avatar
Pierre Kraemer committed
79 80
template <class MAP>
inline void GMap0<MAP>::beta0sew(Dart d, Dart e)
Pierre Kraemer's avatar
Pierre Kraemer committed
81
{
82
	MAP::template involutionSew<0>(d,e);
Pierre Kraemer's avatar
Pierre Kraemer committed
83 84
}

Pierre Kraemer's avatar
Pierre Kraemer committed
85 86
template <class MAP>
inline void GMap0<MAP>::beta0unsew(Dart d)
Pierre Kraemer's avatar
Pierre Kraemer committed
87
{
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
	MAP::template involutionUnsew<0>(d);
}

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

template <class MAP>
Dart GMap0<MAP>::newEdge()
{
	Dart d1 = this->newDart();
	Dart d2 = this->newDart();
	beta0sew(d1,d2);
	return d1;
}

template <class MAP>
void GMap0<MAP>::deleteEdge(Dart d)
{
	this->deleteDart(beta0(d));
	this->deleteDart(d);
Pierre Kraemer's avatar
Pierre Kraemer committed
109 110 111 112 113 114
}

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

Pierre Kraemer's avatar
Pierre Kraemer committed
115 116
template <class MAP>
inline bool GMap0<MAP>::foreach_dart_of_vertex(Dart d, FunctorType& f, unsigned int /*thread*/) const
Pierre Kraemer's avatar
Pierre Kraemer committed
117 118 119 120
{
	return f(d) ;
}

Pierre Kraemer's avatar
Pierre Kraemer committed
121 122
template <class MAP>
inline bool GMap0<MAP>::foreach_dart_of_edge(Dart d, FunctorType& f, unsigned int /*thread*/) const
Pierre Kraemer's avatar
Pierre Kraemer committed
123 124 125 126 127 128 129 130
{
	if (f(d)) return true;
	Dart d1 = beta0(d);
	if (d1 != d) return f(d1);
	return false;
}

} // namespace CGoGN