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.

embeddedMap3.hpp 10.7 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
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

#include <vector>
#include <algorithm>

namespace CGoGN
{

template <typename MAP3>
void EmbeddedMap3<MAP3>::sewVolumes(Dart d, Dart e)
{
	//topological sewing
	MAP3::sewVolumes(d,e);

untereiner's avatar
untereiner committed
37
38
	//embed the vertex orbits from the oriented face with dart e
	//with vertex orbits value from oriented face with dart d
39
	if (MAP3::isOrbitEmbedded(VERTEX))
Pierre Kraemer's avatar
Pierre Kraemer committed
40
	{
untereiner's avatar
untereiner committed
41
		unsigned int vEmb1 = EMBNULL ;
Pierre Kraemer's avatar
Pierre Kraemer committed
42
43
		Dart dd = d ;
		do {
untereiner's avatar
untereiner committed
44
45
			vEmb1 = MAP3::getEmbedding(VERTEX, dd);
			MAP3::embedOrbit(VERTEX, dd, vEmb1) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
46
47
48
49
50
			dd = MAP3::phi1(dd) ;
		} while(dd != d) ;
	}

	//embed the new edge orbit with the old edge orbit value
untereiner's avatar
untereiner committed
51
	//for all the face
52
	if (MAP3::isOrbitEmbedded(EDGE))
Pierre Kraemer's avatar
Pierre Kraemer committed
53
	{
untereiner's avatar
untereiner committed
54
		unsigned int vEmb1 = EMBNULL ;
Pierre Kraemer's avatar
Pierre Kraemer committed
55
56
		Dart dd = d ;
		do {
57
58
			vEmb1 = MAP3::getEmbedding(EDGE, d);
			MAP3::embedOrbit(EDGE, d, vEmb1) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
59
60
61
			dd = MAP3::phi1(dd) ;
		} while(dd != d) ;
	}
untereiner's avatar
untereiner committed
62

untereiner's avatar
untereiner committed
63
	//embed the face orbit from the volume sewn
64
	if (MAP3::isOrbitEmbedded(FACE))
65
66
67
68
	{
		unsigned int vEmb1 = MAP3::getEmbedding(FACE, d);
		MAP3::embedOrbit(FACE, e, vEmb1) ;
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
69
70
71
72
73
}

template <typename MAP3>
void EmbeddedMap3<MAP3>::unsewVolumes(Dart d)
{
74
75
	Dart dd = MAP3::phi1(MAP3::phi3(d));

untereiner's avatar
untereiner committed
76
77
	MAP3::unsewVolumes(d);

78
79
80
81
82
	Dart ddd = d;
	do
	{
		if(MAP3::isOrbitEmbedded(VERTEX))
		{
83
			if(!MAP3::sameVertex(ddd,dd))
84
85
			{
				MAP3::embedNewCell(VERTEX, dd);
86
				MAP3::copyCell(VERTEX, dd, ddd);
87
88
			}
		}
Pierre Kraemer's avatar
Pierre Kraemer committed
89

90
		dd = MAP3::phi_1(dd);
Pierre Kraemer's avatar
Pierre Kraemer committed
91

92
93
		if(MAP3::isOrbitEmbedded(EDGE))
		{
94
			if(!MAP3::sameEdge(ddd,dd))
95
96
			{
				MAP3::embedNewCell(EDGE, dd);
97
				MAP3::copyCell(VERTEX, dd, ddd);
98
99
100
101
102
103
104
105
106
107
108
109
			}
		}

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


	if (MAP3::isOrbitEmbedded(FACE))
	{
		MAP3::embedNewCell(FACE, dd);
		MAP3::copyCell(FACE, dd, d);
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
110
111
112
113
114
115
}

template <typename MAP3>
bool EmbeddedMap3<MAP3>::mergeVolumes(Dart d)
{
	Dart d2 = MAP3::phi2(d);
untereiner's avatar
untereiner committed
116
	Dart a_2 = MAP3::phi3(MAP3::phi2(d));
Pierre Kraemer's avatar
Pierre Kraemer committed
117
118
119

	if(MAP3::mergeVolumes(d))
	{
120
		if (MAP3::isOrbitEmbedded(VOLUME))
Pierre Kraemer's avatar
Pierre Kraemer committed
121
		{
122
123
				unsigned int vEmb = MAP3::getEmbedding(VOLUME, d2);
				MAP3::embedOrbit(VOLUME, a_2, vEmb) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
124
125
126
127
128
129
130
131
132
133
		}
		return true;
	}
	return false;
}

template <typename MAP3>
void EmbeddedMap3<MAP3>::splitFace(Dart d, Dart e)
{
	MAP3::splitFace(d,e);
untereiner's avatar
untereiner committed
134

135
	if(MAP3::isOrbitEmbedded(VERTEX))
Pierre Kraemer's avatar
Pierre Kraemer committed
136
	{
untereiner's avatar
ihm3  
untereiner committed
137
138
		MAP3::copyDartEmbedding(VERTEX, MAP3::phi2(MAP3::phi_1(d)), d);
		MAP3::copyDartEmbedding(VERTEX, MAP3::phi2(MAP3::phi_1(e)), e);
untereiner's avatar
untereiner committed
139
140
141
142
143
144

		if(MAP3::phi3(d) != d)
		{
			Dart d3 = MAP3::phi3(d);
			Dart e3 = MAP3::phi3(e);

145
146
			MAP3::copyDartEmbedding(VERTEX, MAP3::phi1(d3), MAP3::phi1(MAP3::phi2(MAP3::phi1(d3))));
			MAP3::copyDartEmbedding(VERTEX, MAP3::phi1(e3), MAP3::phi1(MAP3::phi2(MAP3::phi1(e3))));
untereiner's avatar
untereiner committed
147
148
		}

Pierre Kraemer's avatar
Pierre Kraemer committed
149
150
	}

151
	if(MAP3::isOrbitEmbedded(FACE))
untereiner's avatar
untereiner committed
152
	{
153
154
		MAP3::embedNewCell(FACE, MAP3::phi2(MAP3::phi_1(d)));
		MAP3::copyCell(FACE, MAP3::phi2(MAP3::phi_1(d)), d);
untereiner's avatar
untereiner committed
155
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
156

157
	if(MAP3::isOrbitEmbedded(VOLUME))
Pierre Kraemer's avatar
Pierre Kraemer committed
158
	{
159
160
		MAP3::copyDartEmbedding(VOLUME, MAP3::phi_1(d),  d);
		MAP3::copyDartEmbedding(VOLUME, MAP3::phi2(MAP3::phi_1(d)),  d);
Pierre Kraemer's avatar
Pierre Kraemer committed
161

untereiner's avatar
untereiner committed
162
		if(MAP3::phi3(d) != d)
Pierre Kraemer's avatar
Pierre Kraemer committed
163
		{
untereiner's avatar
untereiner committed
164
165
			Dart d3 = MAP3::phi3(d);

166
167
			MAP3::copyDartEmbedding(VOLUME, MAP3::phi1(d3), d3);
			MAP3::copyDartEmbedding(VOLUME, MAP3::phi2(MAP3::phi1(d3)), d3);
Pierre Kraemer's avatar
Pierre Kraemer committed
168
169
170
171
172
173
174
175
176
177
		}

	}

}

template <typename MAP3>
void EmbeddedMap3<MAP3>::cutEdge(Dart d)
{
	MAP3::cutEdge(d);
untereiner's avatar
untereiner committed
178

179
180
181
182
183
184
185
	if(MAP3::isOrbitEmbedded(VERTEX))
	{
		Dart nd = MAP3::phi1(d) ;

		MAP3::embedNewCell(VERTEX, nd) ;
	}

186
	if(MAP3::isOrbitEmbedded(EDGE))
untereiner's avatar
untereiner committed
187
	{
Thomas's avatar
Thomas committed
188
189
190
191
		Dart nd = MAP3::phi1(d) ;

		MAP3::embedNewCell(EDGE, nd) ;
		MAP3::copyCell(EDGE, nd, d) ;
untereiner's avatar
untereiner committed
192

Thomas's avatar
Thomas committed
193
194
		unsigned int vEmb = MAP3::getEmbedding(EDGE, d);
		MAP3::embedOrbit(EDGE, d, vEmb) ;
untereiner's avatar
untereiner committed
195
196
	}

197
	if(MAP3::isOrbitEmbedded(FACE))
untereiner's avatar
untereiner committed
198
	{
Thomas's avatar
Thomas committed
199
200
201
202
203
204
205
206
207
208
209
210
		Dart f = d;
		do
		{
			Dart nd = MAP3::phi1(f) ;
			MAP3::copyDartEmbedding(FACE, nd, f);

			Dart f2 = MAP3::phi2(nd);
			if(f2!=nd)
			{
				Dart nd2 = MAP3::phi2(f);
				MAP3::copyDartEmbedding(FACE, nd2, f2);
			}
untereiner's avatar
untereiner committed
211

Thomas's avatar
Thomas committed
212
213
			f = MAP3::alpha2(f);
		} while(f != d);
untereiner's avatar
untereiner committed
214
215
	}

216
	if(MAP3::isOrbitEmbedded(VOLUME))
untereiner's avatar
untereiner committed
217
	{
Thomas's avatar
Thomas committed
218
		Dart f = d;
untereiner's avatar
untereiner committed
219
220
		do
		{
Thomas's avatar
Thomas committed
221
222
223
224
225
226
			Dart nd = MAP3::phi1(f) ;
			MAP3::copyDartEmbedding(VOLUME, nd, f);

			Dart nd2 = MAP3::phi2(f);
			if(f!=nd2)
				MAP3::copyDartEmbedding(VOLUME, nd2, f);
untereiner's avatar
untereiner committed
227
228

			f = MAP3::alpha2(f);
Thomas's avatar
Thomas committed
229
		} while(f != d);
untereiner's avatar
untereiner committed
230
	}
231

Pierre Kraemer's avatar
Pierre Kraemer committed
232
233
234
235
236
237
238
239
240
}


template <typename MAP3>
int EmbeddedMap3<MAP3>::collapseEdge(Dart d, bool delDegenerateFaces,
		bool delDegenerateVolumes)
{

	unsigned int vEmb = EMBNULL ;
241
	if(MAP3::isOrbitEmbedded(VERTEX))
Pierre Kraemer's avatar
Pierre Kraemer committed
242
	{
243
244
245
		vEmb = MAP3::getEmbedding(VERTEX, d) ;
		MAP3::embedOrbit(VERTEX,d,vEmb);
		MAP3::embedOrbit(VERTEX,MAP3::phi2(d),vEmb);
Pierre Kraemer's avatar
Pierre Kraemer committed
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
273
274
275
276
	}

	int nbCol = MAP3::collapseEdge(d,delDegenerateFaces,delDegenerateVolumes);

	return nbCol;
}

template <typename MAP3>
void EmbeddedMap3<MAP3>::collapseFace(Dart d, bool delDegenerateFaces,
		bool delDegenerateVolumes)
{
	//unsigned int degree = MAP3::faceDegree(d);
	//Dart dsave;

//	//si degree face = 3
//	if(degree == 3)
//	{
//		dsave = MAP3::phi3(MAP3::phi2(MAP3::phi1(d)));
//		dsave = MAP3::phi3(MAP3::phi2(MAP3::phi1(dsave)));
//		//ATTENTION : il faut trouver un brin de l'orbite sommet de d non modifie par l'operation !!
//	}
//	else if(degree > 3)
//	{
//		dsave = MAP3::phi1(MAP3::phi2(MAP3::phi1(d)));
//		dsave = MAP3::phi1(MAP3::phi2(MAP3::phi1(dsave)));
//	}
//	else
//		return;


//	unsigned int vEmb = EMBNULL ;
277
//	if(MAP3::isOrbitEmbedded(VERTEX))
Pierre Kraemer's avatar
Pierre Kraemer committed
278
//	{
279
//		vEmb = MAP3::getEmbedding(d, VERTEX) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
280
281
282
283
//	}

	MAP3::collapseFace(d,delDegenerateFaces,delDegenerateVolumes);

284
//	if(MAP3::isOrbitEmbedded(VERTEX))
Pierre Kraemer's avatar
Pierre Kraemer committed
285
//	{
286
//		MAP3::embedOrbit(VERTEX,dsave,vEmb);
Pierre Kraemer's avatar
Pierre Kraemer committed
287
288
289
290
//	}

}

untereiner's avatar
untereiner committed
291
292
//TODO collapseVolume

Pierre Kraemer's avatar
Pierre Kraemer committed
293
294
295
296
297
298
299
300
301
302
template <typename MAP3>
Dart EmbeddedMap3<MAP3>::cutSpike(Dart d)
{

	Dart e = MAP3::cutSpike(d);

	return e;
}


untereiner's avatar
untereiner committed
303
304
305
306
307
308
309
310
311
template <typename MAP3>
unsigned int EmbeddedMap3<MAP3>::closeHole(Dart d)
{
	unsigned int nbE = MAP3::closeHole(d);
	Dart dd = MAP3::phi2(d);
	Dart f = dd;

	do
	{
312
313
314
315
316
317
		if(MAP3::isOrbitEmbedded(VERTEX))
			MAP3::copyDartEmbedding(VERTEX,f, MAP3::phi1(MAP3::phi2(f)));
		if(MAP3::isOrbitEmbedded(EDGE))
			MAP3::copyDartEmbedding(EDGE, f, MAP3::phi2(f));
		if(MAP3::isOrbitEmbedded(VOLUME))
			MAP3::copyDartEmbedding(VOLUME, f, MAP3::phi2(f));
untereiner's avatar
untereiner committed
318
319
320
321
322
323
324

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

	return nbE;
}
Pierre Kraemer's avatar
Pierre Kraemer committed
325
326


untereiner's avatar
untereiner committed
327
328
329
330
331
332
333
334
335
template <typename MAP3>
void EmbeddedMap3<MAP3>::closeMap(DartMarker &marker)
{
	MAP3::closeMap(marker);

	for(Dart d = MAP3::begin() ; d != MAP3::end() ; MAP3::next(d))
	{
		if(marker.isMarked(d))
		{
336
			if(MAP3::isOrbitEmbedded(VERTEX))
untereiner's avatar
untereiner committed
337
			{
338
				MAP3::copyDartEmbedding(VERTEX, d, MAP3::phi1(MAP3::phi3(d)));
untereiner's avatar
untereiner committed
339
340
341
			}
		}
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
342

untereiner's avatar
untereiner committed
343
}
Pierre Kraemer's avatar
Pierre Kraemer committed
344

untereiner's avatar
ihm3  
untereiner committed
345
346
347
348
349
350
351
352
template <typename MAP3>
bool EmbeddedMap3<MAP3>::check()
{
	bool topo = MAP3::check() ;
	if (!topo)
		return false ;

	CGoGNout << "Check: embedding begin" << CGoGNendl ;
353
	DartMarker mv(*this);
untereiner's avatar
ihm3  
untereiner committed
354
355
	for(Dart d = MAP3::begin(); d != MAP3::end(); MAP3::next(d))
	{
356
		if(MAP3::isOrbitEmbedded(VERTEX))
357
		{
358
			if(!mv.isMarked(d))
359
			{
360
361
362
363
				mv.markOrbit(VERTEX, d);
				unsigned int emb = MAP3::getEmbedding(VERTEX, d);
				FunctorCheckEmbedding<MAP3> fce(*this, VERTEX, emb);
				MAP3::foreach_dart_of_orbit(VERTEX, d, fce);
364
365
366
			}
		}

367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
//		if (MAP3::isOrbitEmbedded(VERTEX))
//		{
//			if (MAP3::phi2(MAP3::phi_1(d)) != MAP3::phi_1(d) && MAP3::getEmbedding(VERTEX, d) != MAP3::getEmbedding(VERTEX, MAP3::phi2(MAP3::phi_1(d))))
//			{
//				CGoGNout << "Check: different embeddings on vertex" << CGoGNendl ;
//				return false ;
//			}
//
//			if(MAP3::phi3(d) != d && MAP3::getEmbedding(VERTEX, d) != MAP3::getEmbedding(VERTEX, MAP3::phi1(MAP3::phi3(d))))
//			{
//				CGoGNout << "Check: different embeddings on vertex in the 2 oriented faces" << CGoGNendl ;
//				CGoGNout << "Dart #" << d << CGoGNendl;
//				CGoGNout << "Emb(d) = " << MAP3::getEmbedding(VERTEX, d) << CGoGNendl;
//				CGoGNout << "Emb(phi32(d)) = " << MAP3::getEmbedding(VERTEX, MAP3::phi3(MAP3::phi2(d))) << CGoGNendl;
//				return false ;
//			}
//
//		}
//
//		if (MAP3::isOrbitEmbedded(EDGE))
//		{
//			if (MAP3::getEmbedding(EDGE, d) != MAP3::getEmbedding(EDGE, MAP3::phi2(d)))
//			{
//				CGoGNout << "Check: different embeddings on edge" << CGoGNendl ;
//				return false ;
//			}
//
//			if (MAP3::getEmbedding(EDGE, d) != MAP3::getEmbedding(EDGE, MAP3::phi3(d)))
//			{
//				CGoGNout << "Check: different embeddings on edge" << CGoGNendl ;
//				return false ;
//			}
//		}
//
//		if (MAP3::isOrbitEmbedded(FACE))
//		{
//			if (MAP3::getEmbedding(FACE, d) != MAP3::getEmbedding(FACE, MAP3::phi1(d)))
//			{
//				CGoGNout << "Check: different embeddings on face" << CGoGNendl ;
//				return false ;
//			}
//
//			if (MAP3::getEmbedding(FACE, d) != MAP3::getEmbedding(FACE, MAP3::phi3(d)))
//			{
//				CGoGNout << "Check: different embeddings on face" << CGoGNendl ;
//				return false ;
//			}
//		}
//
//		if (MAP3::isOrbitEmbedded(VOLUME))
//		{
//			if (MAP3::getEmbedding(VOLUME, d) != MAP3::getEmbedding(VOLUME, MAP3::phi1(d)))
//			{
//				CGoGNout << "Check: different embeddings in volume" << CGoGNendl ;
//				return false ;
//			}
//
//			if (MAP3::getEmbedding(VOLUME, d) != MAP3::getEmbedding(VOLUME, MAP3::phi2(d)))
//			{
//				CGoGNout << "Check: different embeddings in volume" << CGoGNendl ;
//				return false ;
//			}
//		}
untereiner's avatar
ihm3  
untereiner committed
430
431
432
433
434
	}
	CGoGNout << "Check: embedding ok" << CGoGNendl ;
	return true ;
}

Pierre Kraemer's avatar
Pierre Kraemer committed
435
} // namespace CGoGN