Coupure prévue mardi 3 Août au matin pour maintenance du serveur. Nous faisons au mieux pour que celle-ci soit la plus brève possible.

gmap2.h 11 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 __GMAP2_H__
#define __GMAP2_H__

#include "Topology/gmap/gmap1.h"

namespace CGoGN
{

/**
* The class of 2-GMap
*/
class GMap2 : public GMap1
{
protected:
39
	AttributeMultiVector<Dart>* m_beta2 ;
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 GMap1 ParentMap;

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

	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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
	virtual int getDartsPerTriangle();

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

	virtual Dart newDart();

	Dart beta2(Dart d);

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

	Dart phi2(Dart d);

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

	Dart alpha0(Dart d);

	Dart alpha1(Dart d);

	Dart alpha_1(Dart d);

	void beta2sew(Dart d, Dart e);

	void beta2unsew(Dart d);

	void phi2sew(Dart d, Dart e);

	void phi2unsew(Dart d);

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

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

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

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

109
110
111
112
113
114
115
	//! Delete the vertex of d (works only for internal vertices)
	/*! 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 bool deleteVertex(Dart d) ;

116
117
118
119
120
121
122
123
124
125
126
127
128
129
	//! Insert an edge after a dart in the vertex orbit
	/*! \pre Dart d and e MUST be different and belong to distinct face
	 *  \pre Dart e must be phi2-linked with its phi_1 dart
	 *  @param d dart of the vertex
	 *  @param e dart of the edge
	 */
	virtual void insertEdgeInVertex(Dart d, Dart e);

	//! Remove an edge from a vertex orbit
	/*! \pre Dart d must be phi2 sewn
	 *  @param d the dart of the edge to remove from the vertex
	 */
	virtual void removeEdgeFromVertex(Dart d);

Pierre Kraemer's avatar
Pierre Kraemer committed
130
131
132
133
134
	//! Cut the edge of d and its opposite edge if it exists
	/*! @param d a dart of the edge to cut
	 */
	virtual void cutEdge(Dart d);

135
136
137
138
139
	//! Undo the cut of the edge of d and its opposite edge if it exists
	/*! @param d a dart of the edge to uncut
	 */
	virtual void uncutEdge(Dart d);

Pierre Kraemer's avatar
Pierre Kraemer committed
140
141
142
143
144
145
146
147
	//! Collapse an edge (that is deleted) possibly merging its vertices
	/*! If delDegenerateFaces is true, the method checks that no degenerate
	 *  faces are build (faces with less than 3 edges). If it occurs the faces
	 *  are deleted and the adjacencies are upadted (see deleteIfDegenerated).
	 *  \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)
148
	 *  @return a dart of the resulting vertex
Pierre Kraemer's avatar
Pierre Kraemer committed
149
	 */
150
	virtual Dart collapseEdge(Dart d, bool delDegenerateFaces = true);
Pierre Kraemer's avatar
Pierre Kraemer committed
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167

	/**
	 * Flip the edge of d. (rotation in phi1 order)
	 * Works only for non-border edges.
	 * @param d a dart of the edge to flip
	 * @return true if the flip has been executed, false otherwise
	 */
	virtual bool flipEdge(Dart d);

	/**
	 * Flip the edge of d. (rotation in phi_1 order)
	 * Works only for non-border edges.
	 * @param d a dart of the edge to flip
	 * @return true if the flip has been executed, false otherwise
	 */
	virtual bool flipBackEdge(Dart d);

thomas's avatar
thomas committed
168
	//! Sew two faces along an edge (pay attention to the orientation !)
Pierre Kraemer's avatar
Pierre Kraemer committed
169
170
171
172
173
174
	/*! \pre Darts d & e MUST be fixed point of phi2 relation
	 *  @param d a dart of the first face
	 *  @param e a dart of the second face
	 */
	virtual void sewFaces(Dart d, Dart e);

thomas's avatar
thomas committed
175
	//! Unsew two faces along an edges
Pierre Kraemer's avatar
Pierre Kraemer committed
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
	 /*! @param d a dart of one face
	 */
	virtual void unsewFaces(Dart d);

	//! Delete an oriented face if and only if it has one or two edges
	/*! If the face is phi2-linked to two distinct adjacent faces,
	 *  then those two faces are phi2-linked
	 *  @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.
	/*! Works only for non-border edges.
	 *  \warning Darts d & phi2(d) no longer exist after the call
	 *  @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 d1 and d2
	 * d1 and d2 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.
	 *  The faces adjacent to the two given faces are pairwise phi2-linked
	 *  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
	 */
	virtual bool mergeVolumes(Dart d, Dart e);

	//! Close a topological hole (a sequence of connected fixed point of phi2).
	/*! \pre dart d MUST be fixed point of phi2 relation
	 *  Add a face to the map that closes the hole.
	 *  The darts of this face are marked with holeMarker.
	 *  @param d a dart of the hole (with phi2(d)==d)
	 *  @return the degree of the created face
	 */
	virtual unsigned int closeHole(Dart d);

237
238
239
240
241
242
	//! Close the map removing topological holes.
	/*! Add faces to the map that close every existing hole.
	 *  These faces are marked.
	 *  \warning The embeddings of vertices are not updated
	 *  @param marker
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
243
244
245
246
247
248
249
	void closeMap(DartMarker& marker);
	//@}

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

250
	//@{
Thomas's avatar
Thomas committed
251
252
253
254
255
256
	//! 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);

Pierre Kraemer's avatar
Pierre Kraemer committed
257
258
259
260
261
262
	//! 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);

263
264
265
266
267
268
269
270
271
272
	/**
	 * compute the number of edges of the vertex of d
	 */
	unsigned int vertexDegree(Dart d) ;

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

Thomas's avatar
Thomas committed
273
274
275
276
277
278
279
280
281
282
	//! Test if dart d and e belong to the same oriented volume
	/*! @param d a dart
	 *  @param e a dart
	 */
	bool sameOrientedVolume(Dart d, Dart e);

	//! Test if dart d and e belong to the same volume
	/*! @param d a dart
	 *  @param e a dart
	 */
283
284
	bool sameVolume(Dart d, Dart e);

Pierre Kraemer's avatar
Pierre Kraemer committed
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
	/**
	 * Check if map is complete
	 */
	/* TODO devrait disparaitre :
	 * Le test doit être fait à l'import. Ensuite closeMap doit être
	 * utilisé pour fermer la carte si des faces ouvertes sont générées
	 */
	virtual bool check();
	//@}

	/*! @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
305
	bool foreach_dart_of_oriented_vertex(Dart d, FunctorType& fonct, unsigned int thread=0);
Pierre Kraemer's avatar
Pierre Kraemer committed
306
307
308
309
310
311

	/**
	* 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
312
	bool foreach_dart_of_vertex(Dart d, FunctorType& fonct, unsigned int thread=0);
Pierre Kraemer's avatar
Pierre Kraemer committed
313
314
315
316
317
318

	/**
	* 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
319
	bool foreach_dart_of_edge(Dart d, FunctorType& fonct, unsigned int thread=0);
Pierre Kraemer's avatar
Pierre Kraemer committed
320
321
322
323
324

	//! 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
325
	bool foreach_dart_of_oriented_volume(Dart d, FunctorType& fonct, unsigned int thread=0);
Pierre Kraemer's avatar
Pierre Kraemer committed
326
327
328
329
330

	//! 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
331
	bool foreach_dart_of_volume(Dart d, FunctorType& fonct, unsigned int thread=0);
Pierre Kraemer's avatar
Pierre Kraemer committed
332
333
334
335
336
337

	/**
	* 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
338
	bool foreach_dart_of_cc(Dart d, FunctorType& fonct, unsigned int thread=0);
Thomas's avatar
Thomas committed
339
340
341
342
343
344
345

	//!
	/*! TODO Ajout a valider
	 * restreint aux complexes simpliciaux
	 * Apply a functor on the all darts in the set of the link from orbit
	 */
	bool foreach_dart_of_link(Dart d, unsigned int orbit, FunctorType& f, unsigned int thread=0);
Pierre Kraemer's avatar
Pierre Kraemer committed
346
347
348
349
350
351
352
353
	//@}
};

} // namespace CGoGN

#include "Topology/gmap/gmap2.hpp"

#endif