map2.h 17.5 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 36 37 38 39 40 41 42 43 44 45 46 47
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

#ifndef __MAP2_H__
#define __MAP2_H__

#include "Topology/map/map1.h"

namespace CGoGN
{

/*! \brief The class of dual 2-dimensional combinatorial maps:
 *  set of oriented faces pairwise sewed by an adjacency relation.
 *  A dual 2-map represents close or open oriented 2-manifolds (surfaces).
 *  - A dual 2-map is made of darts linked by the phi1 permutation
 * 	and/or the phi2 one-to-one relation.
 *  - In this class darts are interpreted as oriented edges.
 *  - The phi1 relation defines oriented faces (see Map1)
 *  and faces may have arbitrary size (degenerated faces are accepted).
 *  - The phi2 relation links oriented faces along oriented edges.
 *  A set of phi2-linked faces represents a surface 
 *  - Edges that have no phi2-link are border edges. If there exists
 *  such edges the map is open.
 *  - When every edge is phi2-linked, the map is closed. In this case
 *  some optimizations are enabled that speed up the processing of vertices.
 */
48 49
template <class MAP>
class Map2 : public Map1<MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
50
{
51
protected:
52 53
	void init() ;

Pierre Kraemer's avatar
Pierre Kraemer committed
54
public:
55
	typedef Map1<MAP> ParentMap;
Pierre Kraemer's avatar
Pierre Kraemer committed
56

Pierre Kraemer's avatar
Pierre Kraemer committed
57
	inline static unsigned int ORBIT_IN_PARENT(unsigned int o) { return o+5; }
58

Pierre Kraemer's avatar
Pierre Kraemer committed
59 60
	static const unsigned int IN_PARENT = 5 ;

61 62 63
	static const unsigned int VERTEX_OF_PARENT = VERTEX+5;
	static const unsigned int EDGE_OF_PARENT = EDGE+5;

Pierre Kraemer's avatar
Pierre Kraemer committed
64 65
	static const unsigned int DIMENSION = 2 ;

Pierre Kraemer's avatar
Pierre Kraemer committed
66 67
	Map2();

68
	virtual std::string mapTypeName() const;
Pierre Kraemer's avatar
Pierre Kraemer committed
69

70
	virtual unsigned int dimension() const;
Pierre Kraemer's avatar
Pierre Kraemer committed
71

72 73
	virtual void clear(bool removeAttrib);

Sylvain Thery's avatar
Sylvain Thery committed
74 75
	virtual void update_topo_shortcuts();

Pierre Kraemer's avatar
merges  
Pierre Kraemer committed
76
	virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew);
77

Pierre Kraemer's avatar
Pierre Kraemer committed
78 79 80 81
	/*! @name Basic Topological Operators
	 * Access and Modification
	 *************************************************************************/

Sylvain Thery's avatar
Sylvain Thery committed
82
	Dart phi2(Dart d) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
83 84

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

Sylvain Thery's avatar
Sylvain Thery committed
87
	Dart alpha0(Dart d) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
88

Sylvain Thery's avatar
Sylvain Thery committed
89
	Dart alpha1(Dart d) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
90

Sylvain Thery's avatar
Sylvain Thery committed
91
	Dart alpha_1(Dart d) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
92

93 94 95
	/**
	 * prefer phi2_1 to alpha1 in algo if your want it to work in Map2 of Map3
	 */
Sylvain Thery's avatar
Sylvain Thery committed
96
	Dart phi2_1(Dart d) const;
97 98 99 100

	/**
	 * prefer phi21 to alpha_1 in algo if your want it to work in Map2 of Map3
	 */
Sylvain Thery's avatar
Sylvain Thery committed
101
	Dart phi12(Dart d) const;
102

Pierre Kraemer's avatar
Pierre Kraemer committed
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
protected:
	//! Link dart d with dart e by an involution
	/*  @param d,e the darts to link
	 *	- Before:	d->d and e->e
	 *	- After:	d->e and e->d
	 */
	void phi2sew(Dart d, Dart e);

	//! Unlink the current dart by an involution
	/*  @param d the dart to unlink
	 * - Before:	d->e and e->d
	 * - After:		d->d and e->e
	 */
	void phi2unsew(Dart d);

118
public:
119

120 121
	void rdfi(Dart t, DartMarker& m1, DartMarker& m2);

untereiner's avatar
untereiner committed
122 123 124

	//void propagateDartRelation(Dart d) ;

Pierre Kraemer's avatar
Pierre Kraemer committed
125 126 127 128 129
	/*! @name Generator and Deletor
	 *  To generate or delete faces in a 2-map
	 *************************************************************************/

	//@{
130
	//! Create an new polyline of nbEdges, i.e 2*nbEdges darts pairwise sewn by phi2
David Cazier's avatar
David Cazier committed
131 132 133 134 135
	/*! @param nbEdges the number of edges
	 *  @return return a dart of the face
	 */
	virtual Dart newPolyLine(unsigned int nbEdges) ;

136 137
	//! Create an new face of nbEdges
	/*! @param nbEdges the number of edges
138
	 *  @param withBoundary create the face and its boundary (default true)
139 140
	 *  @return return a dart of the face
	 */
141
	virtual Dart newFace(unsigned int nbEdges, bool withBoundary = true) ;
142

143 144
	//! Delete the face of d
	/*! @param d a dart of the face
145
	 *  @param withBoundary create or extend boundary face instead of fixed points (default true)
146
	 */
147
	virtual void deleteFace(Dart d, bool withBoundary = true) ;
148

untereiner's avatar
untereiner committed
149 150 151 152 153
	//! Delete a connected component of the map
	/*! @param d a dart of the connected component
	 */
	virtual void deleteCC(Dart d) ;

154 155 156 157 158
	//! Fill a hole with a face
	/*! \pre Dart d is boundary marked
	 *  @param d a dart of the face to fill
	 */
	virtual void fillHole(Dart d) ;
159 160 161 162 163 164

	//! Open the mesh Transforming a face in a hole
	/*! \pre Dart d is NOT boundary marked
	 *  @param d a dart of the face filled
	 */
	virtual void createHole(Dart d) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
165 166 167 168 169 170 171 172 173 174 175 176 177 178
	//@}

	/*! @name Topological Operators
	 *  Topological operations on 2-maps
	 *************************************************************************/

	//@{
	//! Split a vertex v between d and e inserting an edge after d and e
	/*! \pre Darts d & e MUST belong to the same vertex
	 *  @param d first dart in vertex v
	 *  @param e second dart in vertex v
	 */
	virtual void splitVertex(Dart d, Dart e);

Pierre Kraemer's avatar
Pierre Kraemer committed
179
	//! Delete the vertex of d (works only for internal vertices)
Pierre Kraemer's avatar
Pierre Kraemer committed
180 181
	/*! Does not create a hole -> all the faces
	 * 	around the vertex are merged into one face
Pierre Kraemer's avatar
Pierre Kraemer committed
182
	 *  @param d a dart of the vertex to delete
183
	 *  @return a dart of the resulting face (NIL if the deletion has not been executed)
Pierre Kraemer's avatar
Pierre Kraemer committed
184
	 */
185
	virtual Dart deleteVertex(Dart d);
Pierre Kraemer's avatar
Pierre Kraemer committed
186

Pierre Kraemer's avatar
Pierre Kraemer committed
187
	//! Cut the edge of d by inserting a new vertex
Pierre Kraemer's avatar
Pierre Kraemer committed
188
	/*! @param d a dart of the edge to cut
Pierre Kraemer's avatar
Pierre Kraemer committed
189
	 *  @return a dart of the new vertex
Pierre Kraemer's avatar
Pierre Kraemer committed
190
	 */
David Cazier's avatar
David Cazier committed
191
	virtual Dart cutEdge(Dart d);
Pierre Kraemer's avatar
Pierre Kraemer committed
192

Pierre Kraemer's avatar
Pierre Kraemer committed
193
	//! Undo the cut of the edge of d
Pierre Kraemer's avatar
Pierre Kraemer committed
194
	/*! @param d a dart of the edge to uncut
195
	 *  @return true if the uncut has been executed, false otherwise
Pierre Kraemer's avatar
Pierre Kraemer committed
196
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
197
	virtual bool uncutEdge(Dart d);
Pierre Kraemer's avatar
Pierre Kraemer committed
198

Pierre Kraemer's avatar
Pierre Kraemer committed
199 200
	//! Collapse an edge (that is deleted) possibly merging its vertices
	/*! If delDegenerateFaces is true, the method checks that no degenerate
201
	 *  faces are built (faces with less than 3 edges). If it occurs the faces
Pierre Kraemer's avatar
Pierre Kraemer committed
202 203 204 205 206
	 *  are deleted and the adjacencies are updated (see collapseDegeneratedFace).
	 *  \warning This may produce two distinct vertices if the edge
	 *  was the only link between two border faces
	 *  @param d a dart in the deleted edge
	 *  @param delDegenerateFaces a boolean (default to true)
207
	 *  @return a dart of the resulting vertex
Pierre Kraemer's avatar
Pierre Kraemer committed
208
	 */
209
	virtual Dart collapseEdge(Dart d, bool delDegenerateFaces = true);
Pierre Kraemer's avatar
Pierre Kraemer committed
210 211

	/**
212
	 * Flip the edge of d (rotation in phi1 order)
213
	 * WARNING : Works only for non-border edges
Pierre Kraemer's avatar
Pierre Kraemer committed
214 215 216 217 218 219
	 * @param d a dart of the edge to flip
	 * @return true if the flip has been executed, false otherwise
	 */
	virtual bool flipEdge(Dart d);

	/**
220
	 * Flip the edge of d (rotation in phi_1 order)
221
	 * WARNING : Works only for non-border edges
Pierre Kraemer's avatar
Pierre Kraemer committed
222
	 * @param d a dart of the edge to flip
Pierre Kraemer's avatar
Pierre Kraemer committed
223
	 * @return true if the flipBack has been executed, false otherwise
Pierre Kraemer's avatar
Pierre Kraemer committed
224 225 226
	 */
	virtual bool flipBackEdge(Dart d);

untereiner's avatar
untereiner committed
227 228 229 230 231 232
	//!
	/*!
	 *
	 */
	void swapEdges(Dart d, Dart e);

233 234 235
	 //	 *  @param d dart of the vertex
	 //	 *  @param e dart of the edge
	 //	 */
236
	virtual void insertEdgeInVertex(Dart d, Dart e);
237 238 239 240 241 242
	 //
	 //	//! Remove an edge from a vertex orbit
	 //	/*! \pre Dart d must be phi2 sewed
	 //	 *  @param d the dart of the edge to remove from the vertex
	 //	 * @return true if the removal has been executed, false otherwise
	 //	 */
243
	virtual bool removeEdgeFromVertex(Dart d);
244

Pierre Kraemer's avatar
Pierre Kraemer committed
245
	//! Sew two oriented faces along oriented edges
Pierre Kraemer's avatar
Pierre Kraemer committed
246
	/*! \pre Edges of darts d & e MUST be boundary edges
Pierre Kraemer's avatar
Pierre Kraemer committed
247 248
	 *  @param d a dart of the first face
	 *  @param e a dart of the second face
249
	 *  @param withBoundary: if false, faces must have phi2 fixed points (only for construction: import/primitives)
Pierre Kraemer's avatar
Pierre Kraemer committed
250
	 */
251
	virtual void sewFaces(Dart d, Dart e, bool withBoundary = true);
Pierre Kraemer's avatar
Pierre Kraemer committed
252

253 254 255
	//! Unsew two oriented faces
	/*! \pre Edge of dart d MUST NOT be a boundary edge
	 *  @param d a dart of a face
Pierre Kraemer's avatar
Pierre Kraemer committed
256
	 */
257
	virtual void unsewFaces(Dart d, bool withBoundary = true);
Sylvain Thery's avatar
Sylvain Thery committed
258

Pierre Kraemer's avatar
Pierre Kraemer committed
259
	//! Delete an oriented face if and only if it has one or two edges
260 261
	/*! If the face is sewed to two distinct adjacent faces,
	 *  then those two faces are sewed
Pierre Kraemer's avatar
Pierre Kraemer committed
262 263 264 265 266 267 268 269 270 271 272 273 274
	 *  @param d a dart of the face
	 *  @return true if the collapse has been executed, false otherwise
	 */
	virtual bool collapseDegeneratedFace(Dart d);

	//! Split a face f between d and e inserting an edge between vertices d & e
	/*! \pre Darts d & e MUST belong to the same face
	 *  @param d first dart in face f
	 *  @param e second dart in face f
	 */
	virtual void splitFace(Dart d, Dart e);

	//! Merge the two faces incident to the edge of d.
275 276
	/*! Works only for non-boundary edges.
	 *  \warning Darts of the edge of d no longer exist after the call
Pierre Kraemer's avatar
Pierre Kraemer committed
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296
	 *  @param d a dart in the first face
	 *  @return true if the merge has been executed, false otherwise
	 */
	virtual bool mergeFaces(Dart d);

	/**
	 * Extract a pair of sewed triangles and sew their adjacent faces
	 * d is a dart of the common edge of the pair of triangles
	 */
	void extractTrianglePair(Dart d) ;

	/**
	 * Insert a pair of sewed triangles in a vertex by exploding the edges of v1 and v2
	 * v1 and v2 belong to the same vertex
	 * d is a dart of the common edge of the pair of triangles
	 */
	void insertTrianglePair(Dart d, Dart v1, Dart v2) ;

	//! Merge two volumes along two faces.
	/*! Works only if the two faces have the same number of edges.
297
	 *  The faces adjacent to the two given faces are pairwise sewed
Pierre Kraemer's avatar
Pierre Kraemer committed
298 299 300 301 302 303 304
	 *  then the 2 faces are deleted.
	 *  If the two faces belong to different surfaces, the surfaces are merged,
	 *  else a handle is created that increases the genus of the surface.
	 *  @param d a dart of the first face
	 *  @param e a dart of the second face
	 *  @return true if the merge has been executed, false otherwise
	 */
305
	virtual bool mergeVolumes(Dart d, Dart e, bool deleteFace = true);
306 307 308

	//! Split a surface into two disconnected surfaces along a edge path
	/*! @param vd a vector of darts
309 310
	 *  @param firstSideOpen : if false, one of the 2 sides of the surface remains closed (no hole)
	 *  @param secondSideOpen : if false, the other side of the surface remains closed (no hole)
311
	 */
312
	virtual void splitSurface(std::vector<Dart>& vd, bool firstSideClosed = true, bool secondSideClosed = true);
Pierre Kraemer's avatar
Pierre Kraemer committed
313 314 315 316 317 318 319 320 321 322 323
	//@}

	/*! @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
	 */
Sylvain Thery's avatar
Sylvain Thery committed
324
	bool sameOrientedVertex(Dart d, Dart e) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
325

326 327 328 329
	//! Test if dart d and e belong to the same vertex
	/*! @param d a dart
	 *  @param e a dart
	 */
Sylvain Thery's avatar
Sylvain Thery committed
330
	bool sameVertex(Dart d, Dart e) const;
331 332 333 334

	//! Compute the number of edges of the vertex of d
	/*! @param d a dart
	 */
Sylvain Thery's avatar
Sylvain Thery committed
335
	unsigned int vertexDegree(Dart d) const;
336

337 338 339 340 341
	//! Check number of edges of the vertex of d with given parameter
	/*! @param d a dart
	 *	@param vd degree to compare with
	 *  @return  negative/null/positive if vertex degree is less/equal/greater than given degree
	 */
Sylvain Thery's avatar
Sylvain Thery committed
342
	int checkVertexDegree(Dart d, unsigned int vd) const;
343

344 345 346
	//! Tell if the vertex of d is on the boundary of the map
	/*! @param d a dart
	 */
Sylvain Thery's avatar
Sylvain Thery committed
347
	bool isBoundaryVertex(Dart d) const;
348

Pierre Kraemer's avatar
Pierre Kraemer committed
349
	/**
Pierre Kraemer's avatar
Pierre Kraemer committed
350 351
	 * find the dart of vertex that belong to the boundary
	 * return NIL if the vertex is not on the boundary
Pierre Kraemer's avatar
Pierre Kraemer committed
352
	 */
Sylvain Thery's avatar
Sylvain Thery committed
353
	Dart findBoundaryEdgeOfVertex(Dart d) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
354

355 356 357 358
	/**
	 * find the dart of edge that belong to the boundary
	 * return NIL if the face is not on the boundary
	 */
Sylvain Thery's avatar
Sylvain Thery committed
359
	Dart findBoundaryEdgeOfFace(Dart d) const;
360

Pierre Kraemer's avatar
Pierre Kraemer committed
361 362 363
	//! Test if dart d and e belong to the same edge
	/*! @param d a dart
	 *  @param e a dart
364
	 */
Sylvain Thery's avatar
Sylvain Thery committed
365
	bool sameEdge(Dart d, Dart e) const;
366

Pierre Kraemer's avatar
Pierre Kraemer committed
367
	/**
Pierre Kraemer's avatar
Pierre Kraemer committed
368
	 * tell if the edge of d is on the boundary of the map
Pierre Kraemer's avatar
Pierre Kraemer committed
369
	 */
Sylvain Thery's avatar
Sylvain Thery committed
370
	bool isBoundaryEdge(Dart d) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
371

untereiner's avatar
bla  
untereiner committed
372
	//! Test if dart d and e belong to the same oriented face
untereiner's avatar
untereiner committed
373 374 375
	/*! @param d a dart
	 *  @param e a dart
	 */
Sylvain Thery's avatar
Sylvain Thery committed
376
	bool sameOrientedFace(Dart d, Dart e) const;
untereiner's avatar
untereiner committed
377

Pierre Kraemer's avatar
Pierre Kraemer committed
378 379 380 381
	//! 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
382
	bool sameFace(Dart d, Dart e) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
383

384
	/**
Pierre Kraemer's avatar
Pierre Kraemer committed
385
	 * compute the number of edges of the face of d
386
	 */
Sylvain Thery's avatar
Sylvain Thery committed
387
	unsigned int faceDegree(Dart d) const;
Sylvain Thery's avatar
Sylvain Thery committed
388

389 390 391 392 393
	//! Check number of edges of the face of d with given parameter
	/*! @param d a dart
	 *	@param vd degree to compare with
	 *  @return  negative/null/positive if vertex degree is less/equal/greater than given degree
	 */
Sylvain Thery's avatar
Sylvain Thery committed
394
	int checkFaceDegree(Dart d, unsigned int le) const;
395

Pierre Kraemer's avatar
Pierre Kraemer committed
396 397 398
	/**
	 * tell if the face of d is on the boundary of the map
	 */
Sylvain Thery's avatar
Sylvain Thery committed
399
	bool isBoundaryFace(Dart d) const;
400 401

	//! Test if dart d and e belong to the same oriented volume
Pierre Kraemer's avatar
Pierre Kraemer committed
402 403 404
	/*! @param d a dart
	 *  @param e a dart
	 */
Sylvain Thery's avatar
Sylvain Thery committed
405
	bool sameOrientedVolume(Dart d, Dart e) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
406

407
	//! Test if dart d and e belong to the same volume
408
	/*! @param d a dart
409
	 *  @param e a dart
Pierre Kraemer's avatar
Pierre Kraemer committed
410
	 */
Sylvain Thery's avatar
Sylvain Thery committed
411
	bool sameVolume(Dart d, Dart e) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
412

413 414
	//! Compute the number of faces in the volume of d
	/*! @param d a dart
Pierre Kraemer's avatar
Pierre Kraemer committed
415
	 */
Sylvain Thery's avatar
Sylvain Thery committed
416
	unsigned int volumeDegree(Dart d) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
417

418 419 420 421 422
	//! Check number of faces of the volume of d with given parameter
	/*! @param d a dart
	 *	@param vd degree to compare with
	 *  @return  negative/null/positive if volume degree is less/equal/greater than given degree
	 */
Sylvain Thery's avatar
Sylvain Thery committed
423
	int checkVolumeDegree(Dart d, unsigned int volDeg)const;
424

Pierre Kraemer's avatar
Pierre Kraemer committed
425 426 427 428 429
	// TODO a mettre en algo
	/**
	 * check if the mesh is triangular or not
	 * @return a boolean indicating if the mesh is triangular
	 */
Sylvain Thery's avatar
Sylvain Thery committed
430
	bool isTriangular() const;
Pierre Kraemer's avatar
Pierre Kraemer committed
431

Pierre Kraemer's avatar
Pierre Kraemer committed
432
	// TODO a mettre en algo
Pierre Kraemer's avatar
Pierre Kraemer committed
433 434
	/**
	 * Check if map is complete
Pierre Kraemer's avatar
Pierre Kraemer committed
435
	 * Should be executed after import
Pierre Kraemer's avatar
Pierre Kraemer committed
436
	 */
Sylvain Thery's avatar
Sylvain Thery committed
437
	virtual bool check() const;
untereiner's avatar
untereiner committed
438 439 440 441 442

	/**
	 * Check if a serie of darts is an oriented simple close path
	 */
	virtual bool checkSimpleOrientedPath(std::vector<Dart>& vd);
Pierre Kraemer's avatar
Pierre Kraemer committed
443 444 445 446 447 448
	//@}

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

449
	//@{
Pierre Kraemer's avatar
Pierre Kraemer committed
450 451 452 453
	//! Apply a functor on every dart of a vertex
	/*! @param d a dart of the vertex
	 *  @param f the functor to apply
	 */
Sylvain Thery's avatar
Sylvain Thery committed
454
	bool foreach_dart_of_vertex(Dart d, FunctorType& f, unsigned int thread = 0) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
455

untereiner's avatar
untereiner committed
456
	//! Apply a functor on every dart of an edge
Pierre Kraemer's avatar
Pierre Kraemer committed
457 458 459
	/*! @param d a dart of the edge
	 *  @param f the functor to apply
	 */
Sylvain Thery's avatar
Sylvain Thery committed
460
	bool foreach_dart_of_edge(Dart d, FunctorType& f, unsigned int thread = 0) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
461

462
	//! Apply a functor on every dart of an face
463 464 465
	/*! @param d a dart of the volume
	 *  @param f the functor to apply
	 */
Sylvain Thery's avatar
Sylvain Thery committed
466
	bool foreach_dart_of_face(Dart d, FunctorType& f, unsigned int thread = 0) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
467

Pierre Kraemer's avatar
Pierre Kraemer committed
468 469 470 471
	//! Apply a functor on every dart of an face
	/*! @param d a dart of the volume
	 *  @param f the functor to apply
	 */
Sylvain Thery's avatar
Sylvain Thery committed
472
	bool foreach_dart_of_volume(Dart d, FunctorType& f, unsigned int thread = 0) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
473

Pierre Kraemer's avatar
Pierre Kraemer committed
474 475 476 477
	//! Apply a functor on every dart of a connected component
	/*! @param d a dart of the connected component
	 *  @param f the functor to apply
	 */
Sylvain Thery's avatar
Sylvain Thery committed
478
	bool foreach_dart_of_cc(Dart d, FunctorType& f, unsigned int thread = 0) const;
479 480 481 482 483

	//! Apply a functor on every dart of a vertex of map1 representing the face of d
	/*! @param d a dart of the vertex
	 *  @param f the functor to apply
	 */
Sylvain Thery's avatar
Sylvain Thery committed
484
	bool foreach_dart_of_vertex1(Dart d, FunctorType& f, unsigned int thread = 0) const;
485 486 487 488 489

	//! Apply a functor on every dart of an edge of map1 representing the face of d
	/*! @param d a dart of the edge
	 *  @param f the functor to apply
	 */
Sylvain Thery's avatar
Sylvain Thery committed
490
	bool foreach_dart_of_edge1(Dart d, FunctorType& f, unsigned int thread = 0) const;
491

Pierre Kraemer's avatar
Pierre Kraemer committed
492
	//@}
Sylvain Thery's avatar
Sylvain Thery committed
493

Pierre Kraemer's avatar
Pierre Kraemer committed
494 495 496 497
	/*! @name Close map after import or creation
	 *  These functions must be used with care, generally only by import algorithms
	 *************************************************************************/

Sylvain Thery's avatar
Sylvain Thery committed
498
	//@{
499 500 501 502 503
	/**
	 * create a face of map1 marked as boundary
	 */
	Dart newBoundaryCycle(unsigned int nbE);

504
	//! Close a topological hole (a sequence of connected fixed point of phi2). DO NOT USE, only for import/creation algorithm
Sylvain Thery's avatar
Sylvain Thery committed
505 506 507
	/*! \pre dart d MUST be fixed point of phi2 relation
	 *  Add a face to the map that closes the hole.
	 *  @param d a dart of the hole (with phi2(d)==d)
508
	 *  @param forboundary tag the created face as boundary (default is true)
Sylvain Thery's avatar
Sylvain Thery committed
509 510
	 *  @return the degree of the created face
	 */
511
	virtual unsigned int closeHole(Dart d, bool forboundary = true);
Sylvain Thery's avatar
Sylvain Thery committed
512

513
	//! Close the map removing topological holes: DO NOT USE, only for import/creation algorithm
Sylvain Thery's avatar
Sylvain Thery committed
514
	/*! Add faces to the map that close every existing hole.
515
	 *  These faces are marked as boundary.
516
	 *  @return the number of closed holes
Sylvain Thery's avatar
Sylvain Thery committed
517
	 */
518
	unsigned int closeMap(bool forboundary = true);
Pierre Kraemer's avatar
Pierre Kraemer committed
519
	//@}
untereiner's avatar
untereiner committed
520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536


	/*! @name Compute dual
	 * These functions compute the dual mesh
	 *************************************************************************/

	//@{
	//! Reverse the orientation of the map
	/*!
	 */
	void reverseOrientation();

	//! Dual mesh computation (open or closed)
	/*! Crop the infinite faces of open meshes
	 */
	void computeDual();
	//@}
Pierre Kraemer's avatar
Pierre Kraemer committed
537 538 539 540 541 542 543
};

} // namespace CGoGN

#include "Topology/map/map2.hpp"

#endif