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
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
/*******************************************************************************
* 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>::deleteOrientedVolume(Dart d)
{
//	DartMarkerStore mark(*this);		// Lock a marker
//
//	std::vector<Dart> visitedFaces;		// Faces that are traversed
//	visitedFaces.reserve(16);
//	visitedFaces.push_back(d);			// Start with the face of d
//	std::vector<Dart>::iterator face;
//
//	//For every face added to the list
//	for (face = visitedFaces.begin(); face != visitedFaces.end(); ++face)
//	{
//		if (!mark.isMarked(*face))		// Face has not been visited yet
//		{
//			Dart dNext = *face ;
//
//			do
//			{
//				mark.mark(dNext);					// Mark
//
//				unsigned int vEmb1 = EMBNULL;		//Manage the embedding
//				if(MAP3::isOrbitEmbedded(VERTEX_ORBIT))
//				{
//					vEmb1 = MAP3::getDartEmbedding(VERTEX_ORBIT, dNext);
//					MAP3::embedOrbit(VERTEX_ORBIT, d, vEmb1) ; //alpha1 peut ne pas fonctionner
//				}
//
//				if(MAP3::isOrbitEmbedded(EDGE_ORBIT))
//				{
//					vEmb1 = MAP3::getDartEmbedding(EDGE_ORBIT, dNext);
//					MAP3::setDartEmbedding(VERTEX_ORBIT, MAP3::alpha2(dNext), vEmb1);
//				}
//
//				Dart adj = MAP3::phi2(dNext);				// Get adjacent face
//				if (adj != dNext && !mark.isMarked(adj))
//					visitedFaces.push_back(adj);	// Add it
//				dNext = MAP3::phi1(dNext);
//			} while(dNext != *face);
//		}
//	}

	MAP3::deleteOrientedVolume(d);
}

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

	//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
89
			vEmb1 = MAP3::getEmbedding(VERTEX_ORBIT, d);
Pierre Kraemer's avatar
Pierre Kraemer committed
90
91
92
93
94
95
96
97
98
99
100
101
102
103
			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
104

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

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

			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
161
		fEmb = MAP3::getEmbedding(VOLUME_ORBIT, d);
Pierre Kraemer's avatar
Pierre Kraemer committed
162
163
164
165
166
167
		if(fEmb != EMBNULL)
			MAP3::setDartEmbedding(VOLUME_ORBIT, d2, fEmb) ;
	}

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

template <typename MAP3>
void EmbeddedMap3<MAP3>::cutEdge(Dart d)
{
//	unsigned int dEmb = EMBNULL ;
//	unsigned int fEmb = EMBNULL;
//
//	if (MAP3::isOrbitEmbedded(VERTEX_ORBIT))
//	{
//		dEmb = MAP3::getEmbedding(d, VERTEX_ORBIT) ;
//	}
//
//	Dart f = MAP3::phi1(d) ;
	MAP3::cutEdge(d);
//	Dart e = MAP3::phi1(d);
//
//	if (MAP3::isOrbitEmbedded(VERTEX_ORBIT))
//	{
//		fEmb = MAP3::getEmbedding(f, VERTEX_ORBIT);
//
//
//		MAP3::setDartEmbedding(EDGE_ORBIT, d, dEmb) ;
//		MAP3::embedNewCell(EDGE_ORBIT, e) ;
//		MAP3::copyCell(EDGE_ORBIT, e, d) ;
//	}
}


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
233
		vEmb = MAP3::getEmbedding(VERTEX_ORBIT, d) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
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
281
282
283
284
285
286
287
288
289
290
291
292
293
		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;
}




} // namespace CGoGN