gmap1.h 6.68 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 35 36 37 38
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

#ifndef __GMAP1_H__
#define __GMAP1_H__

#include "Topology/gmap/gmap0.h"

namespace CGoGN
{

/**
* The class of 1-GMap
*/
class GMap1 : public GMap0
{
protected:
39
	AttributeMultiVector<Dart>* m_beta1 ;
Pierre Kraemer's avatar
Pierre Kraemer committed
40

41 42
	void init() ;

Pierre Kraemer's avatar
Pierre Kraemer committed
43
public:
Thomas's avatar
Thomas committed
44 45
	typedef GMap0 ParentMap;

Pierre Kraemer's avatar
Pierre Kraemer committed
46 47 48 49 50 51
	GMap1();

	virtual std::string mapTypeName();

	virtual unsigned int dimension();

52 53
	virtual void clear(bool removeAttrib);

Pierre Kraemer's avatar
Pierre Kraemer committed
54 55 56 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
	virtual int getDartsPerTriangle();

	/*! @name Basic Topological Operators
	 * Access and Modification
	 *************************************************************************/

	virtual Dart newDart();

	Dart beta1(const Dart d);

	template <int N>
	Dart beta(const Dart d);

	Dart phi1(const Dart d);

	Dart phi_1(const Dart d);

	template <int N>
	Dart phi(const Dart d);

	Dart alpha1(const Dart d);

	Dart alpha_1(const Dart d);

	void beta1sew(Dart d, Dart e);

	void beta1unsew(Dart d);

	void phi1sew(Dart d, Dart e);

	void phi1unsew(Dart d);

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

	//@{
	/**
	* create a face
	* @param n the number of sides of face
94
	* @param withBoundary not used, for compatibility with Map
Pierre Kraemer's avatar
Pierre Kraemer committed
95 96
	* @return a dart of the edge
	*/
97
	Dart newFace(unsigned int n, bool withBoundary=true);
Pierre Kraemer's avatar
Pierre Kraemer committed
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115

	//! Delete a face erasing all its darts
	/*! @param d a dart of the face
	 */
	void deleteFace(Dart d) ;

	/**
	 * destroy an edge
	 * @param d a dart of the edge
	 */
	void deleteEdge(Dart d);
	//@}

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

	//@{
116 117 118 119 120 121 122
	//! Link two vertices belonging to distinct faces (add an edge between the 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
	 */
	void linkVertices(Dart d, Dart e);

Pierre Kraemer's avatar
Pierre Kraemer committed
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 181 182 183 184 185 186 187 188 189 190
	//! Cut an edge inserting a new dart between d and its successor in the face
	/*! @param d the edge to cut
	 * \image hmtl map1_cutEdge.png
	 */
	void cutEdge(Dart d);

	//! 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
	 */
	void splitFace(Dart d, Dart e);

	//! 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
	 */
	void mergeFaces(Dart d, Dart e);
	//@}

	/*! @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
	 */
	bool sameOrientedFace(Dart d, Dart e) ;

	//! Test if dart d and e belong to the same face
	/*! @param d a dart
	 *  @param e a dart
	 */
	bool sameFace(Dart d, Dart e) ;

	//! Length of a face (its number of oriented edges)
	/*! @param d a dart of the face
	 *  @return the length of the face
	 */
	unsigned int faceDegree(Dart d);

	/**
	 * check if the face of d is a triangle
	 * @return a boolean indicating if the face is a triangle
	 */
	bool isFaceTriangle(Dart d);
	//@}

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

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

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

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

	//! Apply a functor on every dart of a face
	/*! @param d a dart of the face
	 *  @param f the functor to apply
	 */
Sylvain Thery's avatar
Sylvain Thery committed
211
	bool foreach_dart_of_face(Dart d, FunctorType& fonct, unsigned int thread=0);
Pierre Kraemer's avatar
Pierre Kraemer committed
212 213 214 215 216

	//! Apply a functor on every dart of a volume
	/*! @param d a dart of the volume
	 *  @param f the functor to apply
	 */
Sylvain Thery's avatar
Sylvain Thery committed
217
	bool foreach_dart_of_volume(Dart d, FunctorType& fonct, unsigned int thread=0);
Pierre Kraemer's avatar
Pierre Kraemer committed
218 219 220 221 222 223

	/**
	* Apply a functor on each dart of a cc
	* @param d a dart of the cc
	* @param fonct functor obj ref
	*/
Sylvain Thery's avatar
Sylvain Thery committed
224
	bool foreach_dart_of_cc(Dart d, FunctorType& fonct, unsigned int thread=0);
Pierre Kraemer's avatar
Pierre Kraemer committed
225 226 227 228 229 230 231 232
	//@}
};

} // namespace CGoGN

#include "Topology/gmap/gmap1.hpp"

#endif