embeddedMap3.hpp 7.55 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
/*******************************************************************************
* 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                                        *
*                                                                              *
*******************************************************************************/

#include <vector>
#include <algorithm>

namespace CGoGN
{

template <typename MAP3>
void EmbeddedMap3<MAP3>::sewVolumes(Dart d, Dart e)
{
	unsigned int vEmb1 = EMBNULL ;

untereiner's avatar
untereiner committed
36
37
38
39
40
	if(MAP3::isOrbitEmbedded(VERTEX_ORBIT))
	{

	}

Pierre Kraemer's avatar
Pierre Kraemer committed
41
42
43
44
45
46
47
48
	//topological sewing
	MAP3::sewVolumes(d,e);

	//embed the new vertex orbit (with the new cell) with old vertex orbit value
	if (MAP3::isOrbitEmbedded(VERTEX_ORBIT))
	{
		Dart dd = d ;
		do {
Pierre Kraemer's avatar
Pierre Kraemer committed
49
			vEmb1 = MAP3::getEmbedding(VERTEX_ORBIT, d);
Pierre Kraemer's avatar
Pierre Kraemer committed
50
51
52
53
54
55
56
57
58
59
60
61
62
63
			MAP3::embedOrbit(VERTEX_ORBIT, d, vEmb1) ;
			dd = MAP3::phi1(dd) ;
		} while(dd != d) ;
	}

	//embed the new edge orbit with the old edge orbit value
	if (MAP3::isOrbitEmbedded(EDGE_ORBIT))
	{
		Dart dd = d ;
		do {
			MAP3::copyDartEmbedding(EDGE_ORBIT, e, d) ;
			dd = MAP3::phi1(dd) ;
		} while(dd != d) ;
	}
untereiner's avatar
untereiner committed
64

untereiner's avatar
untereiner committed
65

Pierre Kraemer's avatar
Pierre Kraemer committed
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
}

template <typename MAP3>
void EmbeddedMap3<MAP3>::unsewVolumes(Dart d)
{
	unsigned int vEmb1 = EMBNULL ;

	Dart dd = d ;
	do {
		//embed the vertex in the dart of the two volumes for the face
//		if (MAP3::isOrbitEmbedded(VERTEX_ORBIT))
//		{
//			Dart e = MAP3::alpha1(dd);
//
//			vEmb1 = MAP3::getEmbedding(dd, VERTEX_ORBIT) ;
//			MAP3::setDartEmbedding(VERTEX_ORBIT, dd, vEmb1);
//
//			if(e != MAP3::phi1(dd))
//			{
//				MAP3::embedNewCell(VERTEX_ORBIT, e);
//				MAP3::copyCell(VERTEX_ORBIT, e, dd);
//			}
//		}

		if(MAP3::isOrbitEmbedded(EDGE_ORBIT))
		{
			Dart e = MAP3::phi3(dd);

Pierre Kraemer's avatar
Pierre Kraemer committed
94
			vEmb1 = MAP3::getEmbedding(EDGE_ORBIT, dd);
Pierre Kraemer's avatar
Pierre Kraemer committed
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

			MAP3::setDartEmbedding(EDGE_ORBIT, dd, vEmb1) ;

			if(e != dd)
			{
				MAP3::embedNewCell(EDGE_ORBIT, e);
				MAP3::copyCell(EDGE_ORBIT, e, d);
			}
		}

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

	MAP3::unsewVolumes(d);
}

template <typename MAP3>
bool EmbeddedMap3<MAP3>::mergeVolumes(Dart d)
{
	unsigned int fEmb = EMBNULL;
	unsigned int eEmb = EMBNULL;

	Dart d2 = MAP3::phi2(d);
	Dart a2 = MAP3::alpha2(d);

	if (MAP3::isOrbitEmbedded(VOLUME_ORBIT))
	{
Pierre Kraemer's avatar
Pierre Kraemer committed
122
		fEmb = MAP3::getEmbedding(VOLUME_ORBIT, d);
Pierre Kraemer's avatar
Pierre Kraemer committed
123
124
125
126
127
128
		if(fEmb != EMBNULL)
			MAP3::setDartEmbedding(VOLUME_ORBIT, d2, fEmb) ;
	}

	if (MAP3::isOrbitEmbedded(EDGE_ORBIT))
	{
Pierre Kraemer's avatar
Pierre Kraemer committed
129
		eEmb = MAP3::getEmbedding(EDGE_ORBIT, d);
Pierre Kraemer's avatar
Pierre Kraemer committed
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
		if(eEmb != EMBNULL)
			MAP3::setDartEmbedding(EDGE_ORBIT, a2, eEmb);
	}


	if(MAP3::mergeVolumes(d))
	{
		if (MAP3::isOrbitEmbedded(VOLUME_ORBIT))
		{
			MAP3::embedOrbit(VOLUME_ORBIT, d2, fEmb) ;
		}

		if (MAP3::isOrbitEmbedded(EDGE_ORBIT))
		{
			MAP3::embedOrbit(EDGE_ORBIT, a2, eEmb);
		}

		return true;
	}
	return false;
}

template <typename MAP3>
void EmbeddedMap3<MAP3>::splitFace(Dart d, Dart e)
{
	MAP3::splitFace(d,e);
untereiner's avatar
untereiner committed
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172

	if(MAP3::isOrbitEmbedded(VERTEX_ORBIT))
	{
		MAP3::copyDartEmbedding(VERTEX_ORBIT, MAP3::phi2(MAP3::phi_1(d)),  d);
		MAP3::copyDartEmbedding(VERTEX_ORBIT, MAP3::phi2(MAP3::phi_1(e)),  e);

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

			MAP3::copyDartEmbedding(VERTEX_ORBIT, MAP3::phi1(d3), MAP3::phi1(MAP3::phi2(MAP3::phi1(d3))));
			MAP3::copyDartEmbedding(VERTEX_ORBIT, MAP3::phi1(e3), MAP3::phi1(MAP3::phi2(MAP3::phi1(e3))));
		}

	}

untereiner's avatar
untereiner committed
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
	if(MAP3::isOrbitEmbedded(VOLUME_ORBIT))
	{
		MAP3::copyDartEmbedding(VOLUME_ORBIT, MAP3::phi_1(d),  d);
		MAP3::copyDartEmbedding(VOLUME_ORBIT, MAP3::phi2(MAP3::phi_1(d)),  d);

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

			MAP3::copyDartEmbedding(VOLUME_ORBIT, MAP3::phi1(d3), d3);
			MAP3::copyDartEmbedding(VOLUME_ORBIT, MAP3::phi2(MAP3::phi1(d3)), d3);
		}

	}

Pierre Kraemer's avatar
Pierre Kraemer committed
188
189
190
191
192
}

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

Pierre Kraemer's avatar
Pierre Kraemer committed
194
	MAP3::cutEdge(d);
untereiner's avatar
untereiner committed
195

untereiner's avatar
untereiner committed
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
	if(MAP3::isOrbitEmbedded(VOLUME_ORBIT))
	{
		Dart demb = d;
		if(MAP3::phi3(demb) == demb)
			demb = MAP3::phi2(demb);

		Dart f = demb;
		do
		{
			MAP3::copyDartEmbedding(VOLUME_ORBIT, MAP3::phi1(f), f);
			MAP3::copyDartEmbedding(VOLUME_ORBIT, MAP3::phi2(f), MAP3::phi2(MAP3::phi1(f)));

			f = MAP3::alpha2(f);
		}
		while(f != demb);
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
212
213
214
215
216
217
218
219
220
221
222
}


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

	unsigned int vEmb = EMBNULL ;
	if(MAP3::isOrbitEmbedded(VERTEX_ORBIT))
	{
Pierre Kraemer's avatar
Pierre Kraemer committed
223
		vEmb = MAP3::getEmbedding(VERTEX_ORBIT, d) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
224
225
226
227
228
229
230
231
232
233
234
235
236
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
273
274
275
276
277
278
279
280
		MAP3::embedOrbit(VERTEX_ORBIT,d,vEmb);
		MAP3::embedOrbit(VERTEX_ORBIT,MAP3::phi2(d),vEmb);
	}

	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 ;
//	if(MAP3::isOrbitEmbedded(VERTEX_ORBIT))
//	{
//		vEmb = MAP3::getEmbedding(d, VERTEX_ORBIT) ;
//	}

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

//	if(MAP3::isOrbitEmbedded(VERTEX_ORBIT))
//	{
//		MAP3::embedOrbit(VERTEX_ORBIT,dsave,vEmb);
//	}

}

template <typename MAP3>
Dart EmbeddedMap3<MAP3>::cutSpike(Dart d)
{

	Dart e = MAP3::cutSpike(d);

	return e;
}


untereiner's avatar
untereiner committed
281
282
283
284
285
286
287
288
289
290
291
292
293
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
	{
		if(MAP3::isOrbitEmbedded(VERTEX_ORBIT))
			MAP3::copyDartEmbedding(VERTEX_ORBIT,f, MAP3::phi1(MAP3::phi2(f)));
		if(MAP3::isOrbitEmbedded(EDGE_ORBIT))
			MAP3::copyDartEmbedding(EDGE_ORBIT, f, MAP3::phi2(f));
untereiner's avatar
untereiner committed
294
295
		if(MAP3::isOrbitEmbedded(VOLUME_ORBIT))
			MAP3::copyDartEmbedding(VOLUME_ORBIT, f, MAP3::phi2(f));
untereiner's avatar
untereiner committed
296
297
298
299
300
301
302

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

	return nbE;
}
Pierre Kraemer's avatar
Pierre Kraemer committed
303
304
305


} // namespace CGoGN