map2.h 17.8 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.
 */
Pierre Kraemer's avatar
Pierre Kraemer committed
48
49
template <typename MAP_IMPL>
class Map2 : public Map1<MAP_IMPL>
Pierre Kraemer's avatar
Pierre Kraemer committed
50
{
51
protected:
52
53
54
	// protected copy constructor to prevent the copy of map
	Map2(const Map2<MAP_IMPL>& m):Map1<MAP_IMPL>(m) {}

55
56
	void init() ;

Pierre Kraemer's avatar
Pierre Kraemer committed
57
public:
Pierre Kraemer's avatar
Pierre Kraemer committed
58
59
	typedef MAP_IMPL IMPL;
	typedef Map1<MAP_IMPL> ParentMap;
Pierre Kraemer's avatar
Pierre Kraemer committed
60

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

Pierre Kraemer's avatar
Pierre Kraemer committed
63
64
	static const unsigned int IN_PARENT = 5 ;

65
66
67
	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
68
69
	static const unsigned int DIMENSION = 2 ;

Pierre Kraemer's avatar
Pierre Kraemer committed
70
71
	Map2();

72
	virtual std::string mapTypeName() const;
Pierre Kraemer's avatar
Pierre Kraemer committed
73

74
	virtual unsigned int dimension() const;
Pierre Kraemer's avatar
Pierre Kraemer committed
75

76
77
	virtual void clear(bool removeAttrib);

Pierre Kraemer's avatar
Pierre Kraemer committed
78
79
	virtual unsigned int getNbInvolutions() const;
	virtual unsigned int getNbPermutations() const;
Sylvain Thery's avatar
Sylvain Thery committed
80

Pierre Kraemer's avatar
Pierre Kraemer committed
81
82
83
84
	/*! @name Basic Topological Operators
	 * Access and Modification
	 *************************************************************************/

Sylvain Thery's avatar
Sylvain Thery committed
85
	Dart phi2(Dart d) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
86
87

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

Sylvain Thery's avatar
Sylvain Thery committed
90
	Dart alpha0(Dart d) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
91

Sylvain Thery's avatar
Sylvain Thery committed
92
	Dart alpha1(Dart d) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
93

Sylvain Thery's avatar
Sylvain Thery committed
94
	Dart alpha_1(Dart d) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
95

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

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

Pierre Kraemer's avatar
Pierre Kraemer committed
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
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);

121
public:
Pierre Kraemer's avatar
Pierre Kraemer committed
122
123
124
125
126
	/*! @name Generator and Deletor
	 *  To generate or delete faces in a 2-map
	 *************************************************************************/

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

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

140
141
	//! Delete the face of d
	/*! @param d a dart of the face
142
	 *  @param withBoundary create or extend boundary face instead of fixed points (default true)
143
	 */
144
	void deleteFace(Dart d) ;
145

untereiner's avatar
untereiner committed
146
147
148
	//! Delete a connected component of the map
	/*! @param d a dart of the connected component
	 */
149
	void deleteCC(Dart d) ;
untereiner's avatar
untereiner committed
150

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

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

	/*! @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
	 */
174
	void splitVertex(Dart d, Dart e);
Pierre Kraemer's avatar
Pierre Kraemer committed
175

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

Pierre Kraemer's avatar
Pierre Kraemer committed
184
	//! Cut the edge of d by inserting a new vertex
Pierre Kraemer's avatar
Pierre Kraemer committed
185
	/*! @param d a dart of the edge to cut
Pierre Kraemer's avatar
Pierre Kraemer committed
186
	 *  @return a dart of the new vertex
Pierre Kraemer's avatar
Pierre Kraemer committed
187
	 */
188
	Dart cutEdge(Dart d);
Pierre Kraemer's avatar
Pierre Kraemer committed
189

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

196
	//! Collapse an edge (that is deleted) by merging its vertices
Pierre Kraemer's avatar
Pierre Kraemer committed
197
	/*! If delDegenerateFaces is true, the method checks that no degenerate
198
	 *  faces are built (faces with less than 3 edges). If it occurs the faces
Pierre Kraemer's avatar
Pierre Kraemer committed
199
200
201
	 *  are deleted and the adjacencies are updated (see collapseDegeneratedFace).
	 *  @param d a dart in the deleted edge
	 *  @param delDegenerateFaces a boolean (default to true)
202
	 *  @return a dart of the resulting vertex
Pierre Kraemer's avatar
Pierre Kraemer committed
203
	 */
204
	Dart collapseEdge(Dart d, bool delDegenerateFaces = true);
Pierre Kraemer's avatar
Pierre Kraemer committed
205
206

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

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

untereiner's avatar
untereiner committed
222
223
224
225
226
227
	//!
	/*!
	 *
	 */
	void swapEdges(Dart d, Dart e);

228
229
230
	 //	 *  @param d dart of the vertex
	 //	 *  @param e dart of the edge
	 //	 */
231
	void insertEdgeInVertex(Dart d, Dart e);
232
233
234
235
236
237
	 //
	 //	//! 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
	 //	 */
238
	bool removeEdgeFromVertex(Dart d);
239

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

248
249
250
	//! 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
251
	 */
252
	virtual void unsewFaces(Dart d, bool withBoundary = true);
Sylvain Thery's avatar
Sylvain Thery committed
253

Pierre Kraemer's avatar
Pierre Kraemer committed
254
	//! Delete an oriented face if and only if it has one or two edges
255
256
	/*! If the face is sewed to two distinct adjacent faces,
	 *  then those two faces are sewed
Pierre Kraemer's avatar
Pierre Kraemer committed
257
258
259
260
261
262
263
264
265
266
	 *  @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
	 */
267
	void splitFace(Dart d, Dart e);
Pierre Kraemer's avatar
Pierre Kraemer committed
268
269

	//! Merge the two faces incident to the edge of d.
270
271
	/*! 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
272
273
274
	 *  @param d a dart in the first face
	 *  @return true if the merge has been executed, false otherwise
	 */
275
	bool mergeFaces(Dart d);
Pierre Kraemer's avatar
Pierre Kraemer committed
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291

	/**
	 * 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.
292
	 *  The faces adjacent to the two given faces are pairwise sewed
Pierre Kraemer's avatar
Pierre Kraemer committed
293
294
295
296
297
298
299
	 *  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
	 */
300
	bool mergeVolumes(Dart d, Dart e, bool deleteFace = true);
301
302
303

	//! Split a surface into two disconnected surfaces along a edge path
	/*! @param vd a vector of darts
304
305
	 *  @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)
306
	 */
307
	void splitSurface(std::vector<Dart>& vd, bool firstSideClosed = true, bool secondSideClosed = true);
Pierre Kraemer's avatar
Pierre Kraemer committed
308
309
310
311
312
313
314
	//@}

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

	//@{
Pierre Kraemer's avatar
Pierre Kraemer committed
315
316
317
	//! Test if vertices v1 and v2 represent the same oriented vertex
	/*! @param v1 a vertex
	 *  @param v2 a vertex
Pierre Kraemer's avatar
Pierre Kraemer committed
318
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
319
	bool sameOrientedVertex(Vertex v1, Vertex v2) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
320

Pierre Kraemer's avatar
Pierre Kraemer committed
321
322
323
	//! Test if vertices v1 and v2 represent the same vertex
	/*! @param v1 a vertex
	 *  @param v2 a vertex
324
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
325
	bool sameVertex(Vertex v1, Vertex v2) const;
326

Pierre Kraemer's avatar
Pierre Kraemer committed
327
328
	//! Compute the number of edges of the vertex v
	/*! @param v a vertex
329
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
330
	unsigned int vertexDegree(Vertex v) const;
331

Pierre Kraemer's avatar
Pierre Kraemer committed
332
333
	//! Check number of edges of the vertex v with given parameter
	/*! @param v a vertex
334
	 *	@param vd degree to compare with
Pierre Kraemer's avatar
Pierre Kraemer committed
335
	 *  @return negative/null/positive if vertex degree is less/equal/greater than given degree
336
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
337
	int checkVertexDegree(Vertex v, unsigned int vd) const;
338

Pierre Kraemer's avatar
Pierre Kraemer committed
339
340
	//! Tell if the vertex v is on the boundary of the map
	/*! @param v a vertex
341
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
342
	bool isBoundaryVertex(Vertex v) const;
343

Pierre Kraemer's avatar
Pierre Kraemer committed
344
	/**
Pierre Kraemer's avatar
Pierre Kraemer committed
345
	 * find the dart of vertex v that belongs to the boundary
Pierre Kraemer's avatar
Pierre Kraemer committed
346
	 * return NIL if the vertex is not on the boundary
Pierre Kraemer's avatar
Pierre Kraemer committed
347
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
348
	Dart findBoundaryEdgeOfVertex(Vertex v) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
349

Pierre Kraemer's avatar
Pierre Kraemer committed
350
351
352
	//! Test if edges e1 and e2 represent the same edge
	/*! @param e1 an edge
	 *  @param e2 an edge
353
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
354
	bool sameEdge(Edge e1, Edge e2) const;
355

Pierre Kraemer's avatar
Pierre Kraemer committed
356
	/**
Pierre Kraemer's avatar
Pierre Kraemer committed
357
	 * tell if the edge e is on the boundary of the map
Pierre Kraemer's avatar
Pierre Kraemer committed
358
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
359
	bool isBoundaryEdge(Edge e) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
360

Pierre Kraemer's avatar
Pierre Kraemer committed
361
362
363
	//! Test if faces f1 and f2 represent the same oriented face
	/*! @param f1 a face
	 *  @param f2 a face
untereiner's avatar
untereiner committed
364
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
365
	bool sameOrientedFace(Face f1, Face f2) const;
untereiner's avatar
untereiner committed
366

Pierre Kraemer's avatar
Pierre Kraemer committed
367
368
369
	//! Test if faces f1 and f2 represent the same face
	/*! @param f1 a face
	 *  @param f2 a face
Pierre Kraemer's avatar
Pierre Kraemer committed
370
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
371
	bool sameFace(Face f1, Face f2) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
372

373
	/**
Pierre Kraemer's avatar
Pierre Kraemer committed
374
	 * compute the number of edges of the face f
375
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
376
	unsigned int faceDegree(Face f) const;
Sylvain Thery's avatar
Sylvain Thery committed
377

Pierre Kraemer's avatar
Pierre Kraemer committed
378
379
380
381
	//! Check number of edges of the face f with given parameter
	/*! @param f a face
	 *	@param fd degree to compare with
	 *  @return negative/null/positive if face degree is less/equal/greater than given degree
382
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
383
	int checkFaceDegree(Face f, unsigned int fd) const;
384

Pierre Kraemer's avatar
Pierre Kraemer committed
385
	/**
Pierre Kraemer's avatar
Pierre Kraemer committed
386
	 * tell if the face f is incident to the boundary of the map
Pierre Kraemer's avatar
Pierre Kraemer committed
387
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
388
	bool isFaceIncidentToBoundary(Face f) const;
389

390
	/**
Pierre Kraemer's avatar
Pierre Kraemer committed
391
392
	 * find the dart of face f that belongs to the boundary
	 * return NIL if the face is not incident to the boundary
393
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
394
	Dart findBoundaryEdgeOfFace(Face f) const;
395

Pierre Kraemer's avatar
Pierre Kraemer committed
396
	//! Test if volumes v1 and v2 represent the same oriented volume
Pierre Kraemer's avatar
Pierre Kraemer committed
397
398
399
	/*! @param d a dart
	 *  @param e a dart
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
400
	bool sameOrientedVolume(Vol v1, Vol v2) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
401

Pierre Kraemer's avatar
Pierre Kraemer committed
402
	//! Test if volumes v1 and v2 represent the same volume
403
	/*! @param d a dart
404
	 *  @param e a dart
Pierre Kraemer's avatar
Pierre Kraemer committed
405
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
406
	bool sameVolume(Vol v1, Vol v2) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
407

Pierre Kraemer's avatar
Pierre Kraemer committed
408
	//! Compute the number of faces in the volume v
409
	/*! @param d a dart
Pierre Kraemer's avatar
Pierre Kraemer committed
410
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
411
	unsigned int volumeDegree(Vol v) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
412

Pierre Kraemer's avatar
Pierre Kraemer committed
413
414
	//! Check number of faces of the volume v with given parameter
	/*! @param v a volume
415
	 *	@param vd degree to compare with
Pierre Kraemer's avatar
Pierre Kraemer committed
416
	 *  @return negative/null/positive if volume degree is less/equal/greater than given degree
417
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
418
	int checkVolumeDegree(Vol v, unsigned int vd) const;
419

Pierre Kraemer's avatar
Pierre Kraemer committed
420
421
422
423
424
	// 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
425
	bool isTriangular() const;
Pierre Kraemer's avatar
Pierre Kraemer committed
426

Pierre Kraemer's avatar
Pierre Kraemer committed
427
	// TODO a mettre en algo
Pierre Kraemer's avatar
Pierre Kraemer committed
428
429
	/**
	 * Check if map is complete
Pierre Kraemer's avatar
Pierre Kraemer committed
430
	 * Should be executed after import
Pierre Kraemer's avatar
Pierre Kraemer committed
431
	 */
Sylvain Thery's avatar
Sylvain Thery committed
432
	virtual bool check() const;
untereiner's avatar
untereiner committed
433
434

	/**
435
	 * Check if a serie of edges is an oriented simple close path
untereiner's avatar
untereiner committed
436
437
	 */
	virtual bool checkSimpleOrientedPath(std::vector<Dart>& vd);
Pierre Kraemer's avatar
Pierre Kraemer committed
438
439
440
441
442
443
	//@}

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

444
	//@{
445
446
447
448
	//! Apply a function on every dart of an orbit
	/*! @param c a cell
	 *  @param f a function
	 */
449
450
//	template <unsigned int ORBIT, typename FUNC>
//	void foreach_dart_of_orbit(Cell<ORBIT> c, FUNC f, unsigned int thread = 0) const ;
451
	template <unsigned int ORBIT, typename FUNC>
452
	void foreach_dart_of_orbit(Cell<ORBIT> c, const FUNC& f, unsigned int thread = 0) const ;
453

Pierre Kraemer's avatar
Pierre Kraemer committed
454
455
456
457
	//! Apply a functor on every dart of a vertex
	/*! @param d a dart of the vertex
	 *  @param f the functor to apply
	 */
458
	template <typename FUNC>
459
	void foreach_dart_of_vertex(Dart d, const FUNC& f, unsigned int thread = 0) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
460

untereiner's avatar
untereiner committed
461
	//! Apply a functor on every dart of an edge
Pierre Kraemer's avatar
Pierre Kraemer committed
462
463
464
	/*! @param d a dart of the edge
	 *  @param f the functor to apply
	 */
465
	template <typename FUNC>
466
	void foreach_dart_of_edge(Dart d, const FUNC& f, unsigned int thread = 0) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
467

468
	//! Apply a functor on every dart of a face
469
470
471
	/*! @param d a dart of the volume
	 *  @param f the functor to apply
	 */
472
	template <typename FUNC>
473
	void foreach_dart_of_face(Dart d, const FUNC& f, unsigned int thread = 0) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
474

475
	//! Apply a functor on every dart of a volume
Pierre Kraemer's avatar
Pierre Kraemer committed
476
477
478
	/*! @param d a dart of the volume
	 *  @param f the functor to apply
	 */
479
	template <typename FUNC>
480
	void foreach_dart_of_volume(Dart d, const FUNC& f, unsigned int thread = 0) const;
481
482
483
484
485

	//! 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
	 */
486
	template <typename FUNC>
487
	void foreach_dart_of_vertex1(Dart d, const FUNC& f, unsigned int thread = 0) const;
488
489
490
491
492

	//! 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
	 */
493
	template <typename FUNC>
494
	void foreach_dart_of_edge1(Dart d, const FUNC& f, unsigned int thread = 0) const;
495
496
497
498
499
500

	//! Apply a functor on every dart of a connected component
	/*! @param d a dart of the connected component
	 *  @param f the functor to apply
	 */
	template <typename FUNC>
501
	void foreach_dart_of_cc(Dart d, const FUNC& f, unsigned int thread = 0) const;
502

Pierre Kraemer's avatar
Pierre Kraemer committed
503
	//@}
Sylvain Thery's avatar
Sylvain Thery committed
504

Pierre Kraemer's avatar
Pierre Kraemer committed
505
506
507
508
	/*! @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
509
	//@{
510
511
512
513
514
	/**
	 * create a face of map1 marked as boundary
	 */
	Dart newBoundaryCycle(unsigned int nbE);

515
	//! 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
516
517
518
	/*! \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)
519
	 *  @param forboundary tag the created face as boundary (default is true)
Sylvain Thery's avatar
Sylvain Thery committed
520
521
	 *  @return the degree of the created face
	 */
522
	virtual unsigned int closeHole(Dart d, bool forboundary = true);
Sylvain Thery's avatar
Sylvain Thery committed
523

524
	//! Close the map removing topological holes: DO NOT USE, only for import/creation algorithm
Sylvain Thery's avatar
Sylvain Thery committed
525
	/*! Add faces to the map that close every existing hole.
526
	 *  These faces are marked as boundary.
527
	 *  @return the number of closed holes
Sylvain Thery's avatar
Sylvain Thery committed
528
	 */
529
	unsigned int closeMap(bool forboundary = true);
Pierre Kraemer's avatar
Pierre Kraemer committed
530
	//@}
untereiner's avatar
untereiner committed
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546

	/*! @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
547
548
549
550
551
552
553
};

} // namespace CGoGN

#include "Topology/map/map2.hpp"

#endif