gmap1.h 6.61 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 30 31 32 33 34 35
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

#ifndef __GMAP1_H__
#define __GMAP1_H__

#include "Topology/gmap/gmap0.h"

namespace CGoGN
{

/**
* The class of 1-GMap
*/
Pierre Kraemer's avatar
Pierre Kraemer committed
36 37
template <class MAP>
class GMap1 : public GMap0<MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
38 39
{
protected:
40 41
	void init() ;

Pierre Kraemer's avatar
Pierre Kraemer committed
42
public:
Pierre Kraemer's avatar
Pierre Kraemer committed
43
	typedef GMap0<MAP> ParentMap;
Thomas's avatar
Thomas committed
44

45 46
	static const unsigned int DIMENSION = 1 ;

Pierre Kraemer's avatar
Pierre Kraemer committed
47 48
	GMap1();

49
	virtual std::string mapTypeName() const;
Pierre Kraemer's avatar
Pierre Kraemer committed
50

51
	virtual unsigned int dimension() const;
Pierre Kraemer's avatar
Pierre Kraemer committed
52

53 54
	virtual void clear(bool removeAttrib);

Sylvain Thery's avatar
Sylvain Thery committed
55 56
	virtual void update_topo_shortcuts();

Pierre Kraemer's avatar
Pierre Kraemer committed
57 58 59 60
	/*! @name Basic Topological Operators
	 * Access and Modification
	 *************************************************************************/

Sylvain Thery's avatar
Sylvain Thery committed
61
	Dart beta1(const Dart d) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
62 63

	template <int N>
Sylvain Thery's avatar
Sylvain Thery committed
64
	Dart beta(const Dart d) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
65

Sylvain Thery's avatar
Sylvain Thery committed
66
	Dart phi1(const Dart d) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
67

Sylvain Thery's avatar
Sylvain Thery committed
68
	Dart phi_1(const Dart d) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
69 70

	template <int N>
Sylvain Thery's avatar
Sylvain Thery committed
71
	Dart phi(const Dart d) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
72

Sylvain Thery's avatar
Sylvain Thery committed
73
	Dart alpha1(const Dart d) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
74

Sylvain Thery's avatar
Sylvain Thery committed
75
	Dart alpha_1(const Dart d) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
76

77
protected:
Pierre Kraemer's avatar
Pierre Kraemer committed
78 79 80 81
	void beta1sew(Dart d, Dart e);

	void beta1unsew(Dart d);

82
public:
Pierre Kraemer's avatar
Pierre Kraemer committed
83 84 85 86 87 88
	/*! @name Constructors and Destructors
	 *  To generate or delete cells in a 1-G-map
	 *************************************************************************/

	//@{
	/**
89 90
	* create a new face
	* @param nbEdges the number of sides of face
Pierre Kraemer's avatar
Pierre Kraemer committed
91 92
	* @return a dart of the edge
	*/
93
	Dart newCycle(unsigned int nbEdges);
94

Pierre Kraemer's avatar
Pierre Kraemer committed
95 96 97
	//! Delete a face erasing all its darts
	/*! @param d a dart of the face
	 */
98
	void deleteCycle(Dart d) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
99 100 101 102 103 104 105 106 107
	//@}

	/*! @name Topological Operators
	 *  Topological operations on 1-G-maps
	 *************************************************************************/

	//@{
	//! Cut an edge inserting a new dart between d and its successor in the face
	/*! @param d the edge to cut
108
	 *  @return a dart of the new vertex
Pierre Kraemer's avatar
Pierre Kraemer committed
109 110
	 * \image hmtl map1_cutEdge.png
	 */
111
	Dart cutEdge(Dart d);
Pierre Kraemer's avatar
Pierre Kraemer committed
112

Pierre Kraemer's avatar
Pierre Kraemer committed
113 114 115 116 117
	//! Undo the cut of the edge of d
	/*! @param d a dart of the edge to uncut
	 */
	void uncutEdge(Dart d);

Pierre Kraemer's avatar
Pierre Kraemer committed
118 119 120 121 122 123 124 125 126 127 128
	//! Collapse an edge of a face
	/*!  \warning Dart d no longer exists after the call
	 *  @param d the edge
	 */
	void collapseEdge(Dart d);

	//! Split a face between vertices d and e
	/*! \pre Dart d and e MUST be different and belong to the same face
	 *  @param d first dart in the face
	 *  @param e second dart in the face
	 */
129
	void splitCycle(Dart d, Dart e);
Pierre Kraemer's avatar
Pierre Kraemer committed
130 131 132 133 134 135 136

	//! Merge the two faces of d and e, darts d & e disappear
	/*! \pre Dart d and e MUST belong to distinct faces
	 *  \warning Darts d and e no longer exist after the call
	 *  @param d a dart in the first face
	 *  @param e a dart in the second face
	 */
137
	void mergeCycles(Dart d, Dart e);
138 139 140 141 142 143

	//! Link two faces by adding an edge between two vertices
	/*! \pre Dart d and e MUST be different and belong to distinct face
	 *  @param d first dart in the face
	 *  @param e second dart in the face
	 */
144
	void linkCycles(Dart d, Dart e);
Pierre Kraemer's avatar
Pierre Kraemer committed
145 146 147 148 149 150 151 152 153 154 155
	//@}

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

	//@{
	//! Test if dart d and e belong to the same oriented face
	/*! @param d a dart
	 *  @param e a dart
	 */
Sylvain Thery's avatar
Sylvain Thery committed
156
	bool sameOrientedCycle(Dart d, Dart e) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
157 158 159 160 161

	//! Test if dart d and e belong to the same face
	/*! @param d a dart
	 *  @param e a dart
	 */
Sylvain Thery's avatar
Sylvain Thery committed
162
	bool sameCycle(Dart d, Dart e) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
163 164 165 166 167

	//! Length of a face (its number of oriented edges)
	/*! @param d a dart of the face
	 *  @return the length of the face
	 */
Sylvain Thery's avatar
Sylvain Thery committed
168
	unsigned int cycleDegree(Dart d) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
169

170 171 172 173 174
	//! Check the Length of a cycle (its number of oriented edges)
	/*! @param d a dart of the cycle
	 *  @param le the length to compare
	 *  @return  negative/null/positive if face degree is less/equal/greater than given degree
	 */
Sylvain Thery's avatar
Sylvain Thery committed
175
	 int checkCycleDegree(Dart d, unsigned int le) const;
176

Pierre Kraemer's avatar
Pierre Kraemer committed
177 178 179 180
	/**
	 * check if the face of d is a triangle
	 * @return a boolean indicating if the face is a triangle
	 */
Sylvain Thery's avatar
Sylvain Thery committed
181
	bool isCycleTriangle(Dart d) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
182 183 184 185 186 187 188 189
	//@}

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

	//@{
	/**
190 191
	* Apply a functor on each dart of a vertex
	* @param d a dart of the vertex
Pierre Kraemer's avatar
Pierre Kraemer committed
192 193
	* @param fonct functor obj ref
	*/
Sylvain Thery's avatar
Sylvain Thery committed
194
	bool foreach_dart_of_vertex(Dart d, FunctorType& fonct, unsigned int thread=0) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
195 196 197

	/**
	* Apply a functor on each dart of an edge
198
	* @param d a dart of the edge
Pierre Kraemer's avatar
Pierre Kraemer committed
199 200
	* @param fonct functor obj ref
	*/
Sylvain Thery's avatar
Sylvain Thery committed
201
	bool foreach_dart_of_edge(Dart d, FunctorType& fonct, unsigned int thread=0) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
202 203

	/**
204 205
	* Apply a functor on each dart of an oriented cc (face)
	* @param d a dart of the oriented cc
Pierre Kraemer's avatar
Pierre Kraemer committed
206 207
	* @param fonct functor obj ref
	*/
Sylvain Thery's avatar
Sylvain Thery committed
208
	bool foreach_dart_of_oriented_cc(Dart d, FunctorType& f, unsigned int thread=0) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
209

210 211
	//! Apply a functor on every dart of a cc (face)
	/*! @param d a dart of the cc
Pierre Kraemer's avatar
Pierre Kraemer committed
212 213
	 *  @param f the functor to apply
	 */
Sylvain Thery's avatar
Sylvain Thery committed
214
	bool foreach_dart_of_cc(Dart d, FunctorType& fonct, unsigned int thread=0) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
215 216 217 218 219 220 221 222
	//@}
};

} // namespace CGoGN

#include "Topology/gmap/gmap1.hpp"

#endif