Création d'un compte pour un collaborateur extérieur au laboratoire depuis l'intranet ICube : https://intranet.icube.unistra.fr/fr/labs/member/profile

embeddedGMap3.cpp 9.46 KB
Newer Older
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
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps  *
* version 0.1                                                                  *
* Copyright (C) 2009-2011, 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: http://cgogn.u-strasbg.fr/                                         *
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

#include <vector>
#include <algorithm>

#include "Topology/gmap/embeddedGMap3.h"

namespace CGoGN
{

void EmbeddedGMap3::sewVolumes(Dart d, Dart e)
{
	//topological sewing
	GMap3::sewVolumes(d,e);

	//embed the vertex orbits from the oriented face with dart e
	//with vertex orbits value from oriented face with dart d
	if (isOrbitEmbedded(VERTEX))
	{
		unsigned int vEmb1 = EMBNULL ;
		Dart dd = d ;
		do {
			vEmb1 = getEmbedding(VERTEX, dd);
			embedOrbit(VERTEX, dd, vEmb1) ;
			dd = phi1(dd) ;
		} while(dd != d) ;
	}

	//embed the new edge orbit with the old edge orbit value
	//for all the face
	if (isOrbitEmbedded(EDGE))
	{
		unsigned int vEmb1 = EMBNULL ;
		Dart dd = d ;
		do {
			vEmb1 = getEmbedding(EDGE, d);
			embedOrbit(EDGE, d, vEmb1) ;
			dd = phi1(dd) ;
		} while(dd != d) ;
	}

	//embed the face orbit from the volume sewn
	if (isOrbitEmbedded(FACE))
Thomas's avatar
Thomas committed
66
67
68
69
	{
		unsigned int vEmb = getEmbedding(FACE, d);
		embedOrbit(FACE, e, vEmb) ;
	}
70
71
72
73
}

void EmbeddedGMap3::unsewVolumes(Dart d)
{
Thomas's avatar
Thomas committed
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
	Dart dd = phi1(phi3(d));

	if(phi3(d)!=d)
	{
		GMap3::unsewVolumes(d);

		Dart ddd = d;
		do
		{
			if(isOrbitEmbedded(VERTEX))
			{
				if(!sameVertex(ddd,dd))
				{
					embedNewCell(VERTEX, ddd);
					copyCell(VERTEX, ddd, dd);
				}
			}

			dd = phi_1(dd);

			if(isOrbitEmbedded(EDGE))
			{
				if(!sameEdge(ddd,dd))
				{
					embedNewCell(EDGE, dd);
99
					copyCell(EDGE, dd, ddd);
Thomas's avatar
Thomas committed
100
101
102
103
104
105
106
107
108
109
110
111
112
				}
			}

			ddd = phi1(ddd);
		} while(ddd!=d);


		if (isOrbitEmbedded(FACE))
		{
			embedNewCell(FACE, dd);
			copyCell(FACE, dd, d);
		}
	}
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
}

bool EmbeddedGMap3::mergeVolumes(Dart d)
{
	Dart d2 = phi2(d);
	Dart a_2 = phi3(phi2(d));

	if(GMap3::mergeVolumes(d))
	{
		if (isOrbitEmbedded(VOLUME))
		{
				unsigned int vEmb = getEmbedding(VOLUME, d2);
				embedOrbit(VOLUME, a_2, vEmb) ;
		}
		return true;
	}
	return false;
}

void EmbeddedGMap3::splitFace(Dart d, Dart e)
{
	GMap3::splitFace(d,e);

	if(isOrbitEmbedded(VERTEX))
	{
Thomas's avatar
Thomas committed
138
139
		unsigned int vEmb = getEmbedding(VERTEX, d);
		embedOrbit(VERTEX,phi2(phi_1(d)),vEmb);
140

Thomas's avatar
Thomas committed
141
142
		vEmb = getEmbedding(VERTEX, e);
		embedOrbit(VERTEX,phi2(phi_1(e)),vEmb);
143
144
145
146
147
148
	}

	if(isOrbitEmbedded(FACE))
	{
		embedNewCell(FACE, phi2(phi_1(d)));
		copyCell(FACE, phi2(phi_1(d)), d);
Thomas's avatar
Thomas committed
149
150
151
152
153
154

		copyDartEmbedding(FACE, phi_1(d),  d);
		copyDartEmbedding(FACE, beta0(phi_1(d)),  beta0(d));

		copyDartEmbedding(FACE, beta3(phi_1(d)),  beta3(d));
		copyDartEmbedding(FACE, beta3(beta0(phi_1(d))),  beta3(beta0(d)));
155
156
157
158
159
	}

	if(isOrbitEmbedded(VOLUME))
	{
		copyDartEmbedding(VOLUME, phi_1(d),  d);
Thomas's avatar
Thomas committed
160
		copyDartEmbedding(VOLUME, beta0(phi_1(d)),  beta0(d));
161
		copyDartEmbedding(VOLUME, phi2(phi_1(d)),  d);
Thomas's avatar
Thomas committed
162
		copyDartEmbedding(VOLUME, beta0(phi2(phi_1(d))),  beta0(d));
163
164
165
166
167
168

		if(phi3(d) != d)
		{
			Dart d3 = phi3(d);

			copyDartEmbedding(VOLUME, phi1(d3), d3);
Thomas's avatar
Thomas committed
169
			copyDartEmbedding(VOLUME, beta0(phi1(d3)), beta0(d3));
170
			copyDartEmbedding(VOLUME, phi2(phi1(d3)), d3);
Thomas's avatar
Thomas committed
171
			copyDartEmbedding(VOLUME, beta0(phi2(phi1(d3))), beta0(d3));
172
173
174
175
176
177
178
179
180
181
		}
	}
}

void EmbeddedGMap3::cutEdge(Dart d)
{
	GMap3::cutEdge(d);

	if(isOrbitEmbedded(EDGE))
	{
Thomas's avatar
Thomas committed
182
		Dart nd = phi1(d);
183

Thomas's avatar
Thomas committed
184
185
		embedNewCell(EDGE, nd);
		copyCell(EDGE, nd, d);
186
187

		unsigned int vEmb = getEmbedding(EDGE, d);
Thomas's avatar
Thomas committed
188
		embedOrbit(EDGE, d, vEmb);
189
190
191
192
193
194
195
	}

	if(isOrbitEmbedded(FACE))
	{
		Dart f = d;
		do
		{
Thomas's avatar
Thomas committed
196
197
198
			Dart nd = phi1(f);
			unsigned int fEmb = getEmbedding(FACE, f);
			embedOrbit(FACE, nd, fEmb);
199
200
201
202
203

			Dart f2 = phi2(nd);
			if(f2!=nd)
			{
				Dart nd2 = phi2(f);
Thomas's avatar
Thomas committed
204
205
				unsigned int fEmb2 = getEmbedding(FACE, f2);
				embedOrbit(FACE, nd2, fEmb2);
206
207
208
209
210
211
212
213
			}

			f = alpha2(f);
		} while(f != d);
	}

	if(isOrbitEmbedded(VOLUME))
	{
Thomas's avatar
Thomas committed
214
215
216
217
218
219
220
221
//		Dart f = d;
//		do
//		{
//			unsigned int fEmb2 = getEmbedding(VOLUME, d);
//			embedOrbit(VOLUME, d, fEmb2);
//			f = alpha2(f);
//		} while(f != d);

222
223
224
		Dart f = d;
		do
		{
Thomas's avatar
Thomas committed
225
			Dart nd = phi1(f);
226
			copyDartEmbedding(VOLUME, nd, f);
227
			copyDartEmbedding(VOLUME, beta1(nd), f);
Thomas's avatar
Thomas committed
228
			copyDartEmbedding(VOLUME, beta2(nd), f);
229
			copyDartEmbedding(VOLUME, beta1(beta2(nd)), f);
230

Thomas's avatar
Thomas committed
231
232
233
234
235
236
//			Dart nd2 = beta2(nd);
//			if(f!=nd2)
//			{
//				copyDartEmbedding(VOLUME, nd2, f);
//				copyDartEmbedding(VOLUME, beta0(nd2), f);
//			}
237
238
239
240
241
242
243
244
245
246
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

			f = alpha2(f);
		} while(f != d);
	}
}

//int EmbeddedGMap3::collapseEdge(Dart d, bool delDegenerateFaces,
//		bool delDegenerateVolumes)
//{
//	int nbCol = GMap3::collapseEdge(d,delDegenerateFaces,delDegenerateVolumes);
//
//	return nbCol;
//}

//void EmbeddedGMap3::collapseFace(Dart d, bool delDegenerateFaces,
//		bool delDegenerateVolumes)
//{
//	GMap3::collapseFace(d,delDegenerateFaces,delDegenerateVolumes);
//
////	if(isOrbitEmbedded(VERTEX))
////	{
////		embedOrbit(VERTEX,dsave,vEmb);
////	}
//}

//TODO collapseVolume

unsigned int EmbeddedGMap3::closeHole(Dart d)
{
	unsigned int nbE = GMap3::closeHole(d);
	Dart dd = phi2(d);
	Dart f = dd;

	do
	{
		if(isOrbitEmbedded(VERTEX))
Thomas's avatar
Thomas committed
273
		{
274
			copyDartEmbedding(VERTEX,f, phi1(phi2(f)));
Thomas's avatar
Thomas committed
275
276
			copyDartEmbedding(VERTEX,beta1(f), beta1(phi1(phi2(f))));
		}
277
		if(isOrbitEmbedded(EDGE))
Thomas's avatar
Thomas committed
278
		{
279
			copyDartEmbedding(EDGE, f, phi2(f));
Thomas's avatar
Thomas committed
280
281
			copyDartEmbedding(EDGE, beta0(f), beta0(phi2(f)));
		}
282
		if(isOrbitEmbedded(VOLUME))
Thomas's avatar
Thomas committed
283
		{
284
			copyDartEmbedding(VOLUME, f, phi2(f));
Thomas's avatar
Thomas committed
285
286
			copyDartEmbedding(VOLUME, beta0(f), beta0(phi2(f)));
		}
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305

		f = phi1(f);
	}
	while(dd != f);

	return nbE;
}

void EmbeddedGMap3::closeMap(DartMarker &marker)
{
	GMap3::closeMap(marker);

	for(Dart d = begin() ; d != end() ; next(d))
	{
		if(marker.isMarked(d))
		{
			if(isOrbitEmbedded(VERTEX))
			{
				copyDartEmbedding(VERTEX, d, phi1(phi3(d)));
Thomas's avatar
Thomas committed
306
				copyDartEmbedding(VERTEX, beta0(d), beta0(phi1(phi3(d))));
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
			}
		}
	}
}

bool EmbeddedGMap3::check()
{
	bool topo = GMap3::check() ;
	if (!topo)
		return false ;

	CGoGNout << "Check: embedding begin" << CGoGNendl ;
	for(Dart d = begin(); d != end(); next(d))
	{
		if (isOrbitEmbedded(VERTEX))
		{
Thomas's avatar
Thomas committed
323
			if (getEmbedding(VERTEX, d) != getEmbedding(VERTEX, beta1(d)))
324
			{
325
				CGoGNout << "Check: different embeddings on vertex (1)" << CGoGNendl ;
326
327
328
				return false ;
			}

Thomas's avatar
Thomas committed
329
330
			if (getEmbedding(VERTEX, d) != getEmbedding(VERTEX, beta2(d)))
			{
331
				CGoGNout << "Check: different embeddings on vertex (2)" << CGoGNendl ;
Thomas's avatar
Thomas committed
332
333
				return false ;
			}
334

Thomas's avatar
Thomas committed
335
336
			if (getEmbedding(VERTEX, d) != getEmbedding(VERTEX, beta3(d)))
			{
337
				CGoGNout << "Check: different embeddings on vertex (3)" << CGoGNendl ;
Thomas's avatar
Thomas committed
338
339
				return false ;
			}
340
341
		}

Thomas's avatar
Thomas committed
342
343
344
345
		if (isOrbitEmbedded(EDGE))
		{
			if (getEmbedding(EDGE, d) != getEmbedding(EDGE, beta0(d)))
			{
346
				CGoGNout << "Check: different embeddings on edge (0)" << CGoGNendl ;
Thomas's avatar
Thomas committed
347
348
349
350
351
				return false ;
			}

			if (getEmbedding(EDGE, d) != getEmbedding(EDGE, beta2(d)))
			{
352
				CGoGNout << "Check: different embeddings on edge (1)" << CGoGNendl ;
Thomas's avatar
Thomas committed
353
354
355
356
357
				return false ;
			}

			if (getEmbedding(EDGE, d) != getEmbedding(EDGE, beta3(d)))
			{
358
				CGoGNout << "Check: different embeddings on edge (2)" << CGoGNendl ;
Thomas's avatar
Thomas committed
359
360
361
362
363
364
365
366
				return false ;
			}
		}

		if (isOrbitEmbedded(FACE))
		{
			if (getEmbedding(FACE, d) != getEmbedding(FACE, beta0(d)))
			{
367
				CGoGNout << "Check: different embeddings on face (0)" << CGoGNendl ;
Thomas's avatar
Thomas committed
368
369
370
371
372
				return false ;
			}

			if (getEmbedding(FACE, d) != getEmbedding(FACE, beta1(d)))
			{
373
				CGoGNout << "Check: different embeddings on face (1)" << CGoGNendl ;
Thomas's avatar
Thomas committed
374
375
376
377
378
379
380
381
				return false ;
			}
		}

		if (isOrbitEmbedded(VOLUME))
		{
			if (getEmbedding(VOLUME, d) != getEmbedding(VOLUME, beta0(d)))
			{
382
				CGoGNout << "Check: different embeddings in volume (0)" << CGoGNendl ;
Thomas's avatar
Thomas committed
383
384
385
386
387
				return false ;
			}

			if (getEmbedding(VOLUME, d) != getEmbedding(VOLUME, beta1(d)))
			{
388
				CGoGNout << "Check: different embeddings in volume (1)" << CGoGNendl ;
Thomas's avatar
Thomas committed
389
390
391
392
393
				return false ;
			}

			if (getEmbedding(VOLUME, d) != getEmbedding(VOLUME, beta2(d)))
			{
394
				CGoGNout << "Check: different embeddings in volume (2)" << CGoGNendl ;
Thomas's avatar
Thomas committed
395
396
397
				return false ;
			}
		}
398
399
400
401
402
403
	}
	CGoGNout << "Check: embedding ok" << CGoGNendl ;
	return true ;
}

} // namespace CGoGN