map3.h 10.4 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
48
49
50
51
52
53
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
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
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
237
238
239
240
241
242
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps  *
* version 0.1                                                                  *
* Copyright (C) 2009, IGG Team, LSIIT, University of Strasbourg                *
*                                                                              *
* 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.           *
*                                                                              *
* Web site: https://iggservis.u-strasbg.fr/CGoGN/                              *
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

#ifndef __MAP3_H__
#define __MAP3_H__

#include "Topology/map/map2.h"

namespace CGoGN
{

/*! \brief The class of dual 3-dimensional combinatorial maps:
 *  set of oriented volumes pairwise sewed by an adjacency relation.
 *  A dual 3-map represents close or open oriented 3-manifolds (volume subdivisions).
 *  - A dual 3-map is made of darts linked by the phi1 permutation
 * 	and/or the phi2 and phi3 one-to-one relation.
 *  - In this class darts are interpreted as oriented edges.
 *  - The phi1 relation defines oriented faces (see tMap1)
 *  and faces may have arbitrary size (degenerated faces are accepted).
 *  - The phi2 relation links oriented faces along oriented edges building
 *  oriented surfaces. A close oriented surface define an oriented volume.
 *  - Volume are linked along whole faces with the phi3 relation 
 *  - Faces that have no phi3-link are border faces. If there exists
 *  such edges the maps is open.
 *  - When every face is phi3-linked, the map is close. In this case
 *  some optimizations are enable that speed up the processing of cells.
 *  @param DART the type of dart used in the class
 */
class Map3 : public Map2
{
protected:
	AttribMultiVect<Dart>* m_phi3 ;

public:
	typedef Map2 ParentMap;

	Map3();

	virtual std::string mapTypeName();

	virtual unsigned int dimension();

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

	virtual Dart newDart();

	Dart phi3(Dart d);

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

	Dart alpha0(Dart d);

	Dart alpha1(Dart d);

	Dart alpha2(Dart d);

	Dart alpha_2(Dart d);

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 phi3sew(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 phi3unsew(Dart d);

	/*! @name Generator and Deletor
	 *  To generate or delete volumes in a 3-map
	 *************************************************************************/

public:

	//@{
	//! Delete an oriented volume
	/*! @param d a dart of the volume
	 */
	virtual void deleteOrientedVolume(Dart d);
	//@}

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

	//@{
	//! Sew two oriented volumes along their faces. 
	/*! The oriented faces should not be phi3-linked and have the same length
	 *  @param d a dart of the first volume
	 *  @param e a dart of the second volume
	 */
	virtual void sewVolumes(Dart d, Dart e);

	//! Unsew two oriented volumes along their faces.
	/*! @param d a dart of one volume
	 */
	virtual void unsewVolumes(Dart d);

	//! Merge to volume sewed by one face
	/*! @param d a dart of common face
	 */
	virtual bool mergeVolumes(Dart d);

	//! 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
	 *  @return the dart of the new edge lying in the vertex of d after the cut
	 */
	virtual void splitFace(Dart d, Dart e);

	//! Cut the edge of d
	/*! @param d a dart of the edge to cut
	 */
	virtual void cutEdge(Dart d);

	//! Sew a face e in the edge d
	/*! @param d dart from the edge
	 *  @param e dart from the face
	 */
	virtual void sewFace(Dart d, Dart e);

	//! Unsew a face d from an edge
	/*! \pre Dart d is a dart from the face to unsew
	 *  @param d the edge to unlink
	 */
	virtual void unsewFace(Dart d);

	//!
	/*! Flip the edge of d (rotation in phi1 order)
	 *  WARNING : works only if the edge is owned by exactly one or two volumes
	 *  @param d the edge to flip
	 */
	//virtual bool flipEdge(Dart d);

	//!
	/*! Flip the edge of d (rotation in phi_1 order)
	 *  WARNING : works only if the edge is owned by exactly one or two volumes
	 *  @param d the edge to flip
	 */
	//virtual bool flipBackEdge(Dart d);

	//!
	/*!
	 *
	 */
	virtual bool flipFace(Dart d);

    //! Insert a face in phi2 along the orbit phi<-1,2,-1>
    /*! The cardinality of <phi1>(nF) must be equal to the cardinality of <phi(-1,2,-1)>(d)
     *  @param d a dart where the face should be inserted
     *  @param e a dart from the face to insert
     */
	virtual void insertFace(Dart d, Dart e);

	//! 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 updated (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)
	 */
	virtual int collapseEdge(Dart d, bool delDegenerateFaces = true, bool delDegenerateVolumes = true);

	//!
	/*!
	 *
	 * @param
	 * @param
	 * @param
	 */
	virtual void collapseFace(Dart d, bool delDegenerateFaces = true, bool delDegenerateVolumes = true);

	//!
	/*!
	 *
	 * @param
	 * @param
	 * @param
	 */
	virtual void collapseVolume(Dart d, bool delDegenerateFaces = true, bool delDegenerateVolumes = true);

	/** Fusion two faces deleting the two edges after d and e
	 *  and their respective phi3 faces
	 *! \pre Dart d and e should belong to distinct faces
	 *  \pre Dart d and e should not be phi2-linked
	 *  \pre Dart d and e should not be phi3-linked
	 *  @param d a dart in the first face
	 *  @param e a dart in the second face
	 */
	virtual void mergeFaces(Dart d, Dart e);

	//!
	/*!
	 *
	 */
	virtual Dart cutSpike(Dart d);


	//!
	/*
	 *
	 */
	virtual int edgeDegree(Dart d);

	//!
	/* Tell if a face of the volume is on the boundary
	 *
	 */
	virtual bool isBoundaryVolume(Dart d);

243
244
245
246
	/**
	 *
	 */
	virtual bool isBoundaryVertex(Dart d);
Pierre Kraemer's avatar
Pierre Kraemer committed
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352

	//@}

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

	//@{
	/**
	* Apply a functor on each dart of a vertex
	* @param d a dart of the vertex
	* @param fonct the functor
	*/
	bool foreach_dart_of_vertex(Dart d, FunctorType& f);

	/**
	* Apply a functor on each dart of an edge
	* @param d a dart of the oriented edge
	* @param fonct the functor
	*/
	bool foreach_dart_of_edge(Dart d, FunctorType& f);

	bool foreach_dart_of_open_edge(Dart d, FunctorType& f);

	/**
	* Apply a functor on each dart of an oriented face
	* @param d a dart of the oriented face
	* @param fonct the functor
	*/
	bool foreach_dart_of_face(Dart d, FunctorType& f);

	/**
	* Apply a functor on each dart of an volume
	* @param d a dart of the volume
	* @param fonct the functor
	*/
	// TODO change to oriented volume to handle higher dimension ?
	bool foreach_dart_of_volume(Dart d, FunctorType& f)
	{
		return foreach_dart_of_oriented_volume(d,f);
	}

//	template<typename TMAP>
//	bool foreach_dart_of_parent_cell(int dim, Dart d, FunctorType& f);

	/**
	* Apply a functor on each dart of a cc
	* @param d a dart of the cc
	* @param fonct the functor
	*/
	bool foreach_dart_of_cc(Dart d, FunctorType& f);

	/**
	* Search one dart per volumes degree-connex to the volume of d
	* and apply a functor on this dart of a cc if selected by the functorselect
	* @param d a dart of the volume
	* @param degree degree of connexity : 0=vertex-connexity, 1=edge-connexity, 2=face-connexity
	* @param f the functor
	* @param s the selector
	*/
	bool foreach_connex_volume(Dart d, int degree, FunctorType& f, FunctorSelect& s);
	//@}

//	template<typename TMAP>
//	bool markOrbitOf(int dim, Dart d, Marker m);
//
//	template<typename TMAP>
//	bool unmarkOrbitOf(int dim, Dart d, Marker m);



	//TODO devrait disparaitre
	// pour les mêmes raisons que dans map2
	/**
	* Close map: add external faces to map which contain
	* dart with phi2 fixed point. Only topological operation
	* embeddings are not updated.
	* WARNING: all added dart are marked !!
	* @ return index of the marker which with addes darts are marked
	*/
	//virtual Marker closeMap();

	//TODO a mettre en algo
	/**
	* Reverse orientation of map (reverse orientation of all faces)
	* no dart created, each dart keeps its embedding, only changing phi1, phi2 and phi3
	*/
	void reverseOrientation();


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

	//@{
	// TODO devrait disparaitre
	// pour les mêmes raisons que dans map2
	//bool check();
	//@}
};

} // namespace CGoGN

#include "Topology/map/map3.hpp"

#endif