gmap3.h 8.73 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
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

#ifndef __GMAP3_H__
#define __GMAP3_H__

#include "Topology/gmap/gmap2.h"

namespace CGoGN
{

/**
Pierre Kraemer's avatar
Pierre Kraemer committed
34
* The class of 3-GMap
Pierre Kraemer's avatar
Pierre Kraemer committed
35 36 37 38
*/
class GMap3 : public GMap2
{
protected:
39
	AttributeMultiVector<Dart>* m_beta3 ;
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 GMap2 ParentMap;

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

	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
	/*! @name Basic Topological Operators
	 * Access and Modification
	 *************************************************************************/

	virtual Dart newDart();

	Dart beta3(Dart d);

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

	Dart phi3(Dart d);

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

	Dart alpha0(Dart d);

	Dart alpha1(Dart d);

	Dart alpha2(Dart d);

	Dart alpha_2(Dart d);

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

	void beta3unsew(Dart d);

Pierre Kraemer's avatar
Pierre Kraemer committed
83
public:
84
	/*! @name Generator and Deletor
Pierre Kraemer's avatar
Pierre Kraemer committed
85
	 *  To generate or delete volumes in a 3-G-map
86
	 *************************************************************************/
Pierre Kraemer's avatar
Pierre Kraemer committed
87 88

	//@{
89 90 91
	//! Delete a volume erasing all its darts.
	/*! The phi3-links around the volume are removed
	 *  @param d a dart of the volume
Pierre Kraemer's avatar
Pierre Kraemer committed
92
	 */
93
	void deleteVolume(Dart d);
Pierre Kraemer's avatar
Pierre Kraemer committed
94 95 96 97 98 99

	//! Fill a hole with a volume
	/*! \pre Dart d is boundary marked
	 *  @param d a dart of the volume to fill
	 */
	virtual void fillHole(Dart d) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
100 101 102
	//@}

	/*! @name Topological Operators
Pierre Kraemer's avatar
Pierre Kraemer committed
103
	 *  Topological operations on 3-G-maps
Pierre Kraemer's avatar
Pierre Kraemer committed
104 105 106
	 *************************************************************************/

	//@{
Pierre Kraemer's avatar
Pierre Kraemer committed
107 108 109 110 111 112 113 114
	//! Delete the vertex of d
	/*! All the faces around the vertex are merged into one face
	 *  @param d a dart of the vertex to delete
	 *  @return true if the deletion has been executed, false otherwise
	 */
	virtual Dart deleteVertex(Dart d);

	//! Cut the edge of d (all darts around edge orbit are cut)
115
	/*! @param d a dart of the edge to cut
Pierre Kraemer's avatar
Pierre Kraemer committed
116
	 */
117
	virtual void cutEdge(Dart d);
118

Pierre Kraemer's avatar
Pierre Kraemer committed
119 120 121 122 123
	//! Uncut the edge of d (all darts around edge orbit are uncut)
	/*! @param d a dart of the edge to uncut
	 */
	virtual bool uncutEdge(Dart d);

124 125 126 127 128 129
	//! Split a face inserting an edge between two vertices
	/*! \pre Dart d and e should belong to the same face and be distinct
	 *  @param d dart of first vertex
	 *  @param e dart of second vertex
	 */
	virtual void splitFace(Dart d, Dart e);
Pierre Kraemer's avatar
Pierre Kraemer committed
130

131
	//! Sew two oriented volumes along their faces.
Pierre Kraemer's avatar
Pierre Kraemer committed
132
	/*! The oriented faces should not be beta3-linked and have the same degree
133 134
	 *  @param d a dart of the first volume
	 *  @param e a dart of the second volume
Pierre Kraemer's avatar
Pierre Kraemer committed
135
	 *  @param withBoundary: if false, volumes must have beta3 fixed points (only for construction: import/primitives)
Thomas's avatar
Thomas committed
136
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
137
	virtual void sewVolumes(Dart d, Dart e, bool withBoundary = true);
Thomas's avatar
Thomas committed
138

139 140
	//! unsew two oriented volumes along their faces.
	/*! @param d a dart of one volume
Thomas's avatar
Thomas committed
141
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
142
	virtual void unsewVolumes(Dart d);
Thomas's avatar
Thomas committed
143

144 145
	//! merge to volume sewed by one face
	/*! @param d a dart of common face
Thomas's avatar
Thomas committed
146
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
147
	virtual bool mergeVolumes(Dart d);
148

Pierre Kraemer's avatar
Pierre Kraemer committed
149 150 151 152 153
	//! Split a volume into two volumes along a edge path
	/*! @param vd a vector of darts
	 */
	virtual void splitVolume(std::vector<Dart>& vd);
	//@}
Thomas's avatar
Thomas committed
154

155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
	/*! @name Topological Queries
	 *  Return or set various topological information
	 *************************************************************************/

	//@{
	//! Test if dart d and e belong to the same oriented vertex
	/*! @param d a dart
	 *  @param e a dart
	 */
	bool sameOrientedVertex(Dart d, Dart e) ;

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

172 173 174 175 176 177 178 179
	//! Compute the number of edges of the vertex of d
	/*! @param d a dart
	 */
	unsigned int vertexDegree(Dart d) ;

	//! Tell if the vertex of d is on the boundary
	/*! @param d a dart
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
180
	virtual bool isBoundaryVertex(Dart d) ;
181

182 183 184 185 186 187 188 189 190 191 192 193
	//! Test if dart d and e belong to the same oriented edge
	/*! @param d a dart
	 *  @param e a dart
	 */
	bool sameOrientedEdge(Dart d, Dart e) ;

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

194 195 196
	//! Compute the number of volumes around the edge of d
	/*! @param d a dart
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
197 198 199 200 201 202 203 204 205 206 207 208
	unsigned int edgeDegree(Dart d) ;

	/**
	 * tell if the edge of d is on the boundary of the map
	 */
	bool isBoundaryEdge(Dart d) ;

	/**
	 * find the dart of edge that belong to the boundary
	 * return NIL if the edge is not on the boundary
	 */
	Dart findBoundaryFaceOfEdge(Dart d) ;
209

210 211 212 213
	//!Test if dart d and e belong to the same oriented face
	/*! @param d a dart
	 *  @param e a dart
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
214
	bool sameOrientedFace(Dart d, Dart e) ;
215 216 217 218 219

	//!Test if dart d and e belong to the same oriented face
	/*! @param d a dart
	 *  @param e a dart
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
220
	bool sameFace(Dart d, Dart e) ;
221

Pierre Kraemer's avatar
Pierre Kraemer committed
222 223 224 225
	//! Test if the face is on the boundary
	/*! @param d a dart from the face
	 */
	bool isBoundaryFace(Dart d) ;
Thomas's avatar
Thomas committed
226

Pierre Kraemer's avatar
Pierre Kraemer committed
227 228 229 230 231 232 233
	//! Tell if a face of the volume is on the boundary
	/*  @param d a dart
	 */
	bool isBoundaryVolume(Dart d) ;

	virtual bool check() ;
	//@}
234

Pierre Kraemer's avatar
Pierre Kraemer committed
235 236 237 238 239 240
	/*! @name Cell Functors
	 *  Apply functors to all darts of a cell
	 *************************************************************************/

	//@{
	/**
241 242 243 244
	* Apply a functor on each dart of a vertex
	* @param d a dart of the face
	* @param fonct functor obj ref
	*/
Pierre Kraemer's avatar
Pierre Kraemer committed
245
	bool foreach_dart_of_oriented_vertex(Dart d, FunctorType& fonct, unsigned int thread = 0);
246 247 248

	/**
	* Apply a functor on each dart of a vertex
Pierre Kraemer's avatar
Pierre Kraemer committed
249 250 251
	* @param d a dart of the face
	* @param fonct functor obj ref
	*/
Pierre Kraemer's avatar
Pierre Kraemer committed
252
	bool foreach_dart_of_vertex(Dart d, FunctorType& fonct, unsigned int thread = 0);
Pierre Kraemer's avatar
Pierre Kraemer committed
253 254 255 256 257 258

	/**
	* Apply a functor on each dart of an edge
	* @param d a dart of the oriented face
	* @param fonct functor obj ref
	*/
Pierre Kraemer's avatar
Pierre Kraemer committed
259
	bool foreach_dart_of_edge(Dart d, FunctorType& fonct, unsigned int thread = 0);
Pierre Kraemer's avatar
Pierre Kraemer committed
260 261 262 263 264

	//! Apply a functor on every dart of a face
	/*! @param d a dart of the volume
	 *  @param f the functor to apply
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
265
	bool foreach_dart_of_face(Dart d, FunctorType& fonct, unsigned int thread = 0);
Pierre Kraemer's avatar
Pierre Kraemer committed
266 267 268 269 270 271

	/**
	* Apply a functor on each dart of a cc
	* @param d a dart of the cc
	* @param fonct functor obj ref
	*/
Pierre Kraemer's avatar
Pierre Kraemer committed
272
	bool foreach_dart_of_cc(Dart d, FunctorType& fonct, unsigned int thread = 0);
Pierre Kraemer's avatar
Pierre Kraemer committed
273
	//@}
Pierre Kraemer's avatar
Pierre Kraemer committed
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293

	/*! @name Close map after import or creation
	 *  These functions must be used with care, generally only by import algorithms
	 *************************************************************************/

	//@{
	//! Close a topological hole (a sequence of connected fixed point of phi3). DO NOT USE, only for import/creation algorithm
	/*! \pre dart d MUST be fixed point of phi3 relation
	 *  Add a volume to the map that closes the hole.
	 *  @param d a dart of the hole (with phi3(d)==d)
	 *  @param forboundary tag the created face as boundary (default is true)
	 *  @return the degree of the created volume
	 */
	virtual unsigned int closeHole(Dart d, bool forboundary = true);

	//! Close the map removing topological holes: DO NOT USE, only for import/creation algorithm
	/*! Add volumes to the map that close every existing hole.
	 *  These faces are marked as boundary.
	 */
	void closeMap();
Pierre Kraemer's avatar
Pierre Kraemer committed
294 295 296 297 298 299 300
};

} // namespace CGoGN

#include "Topology/gmap/gmap3.hpp"

#endif