cell.cpp 28.7 KB
Newer Older
Kirill Terekhov's avatar
Kirill Terekhov committed
1
2
3
4
5
6
7
#include "inmost.h"
#if defined(USE_MESH)

namespace INMOST
{
	
	
Kirill Terekhov's avatar
Kirill Terekhov committed
8
	bool Cell::CheckEdgeOrder() const
Kirill Terekhov's avatar
Kirill Terekhov committed
9
	{
Kirill Terekhov's avatar
Kirill Terekhov committed
10
		assert(GetHandleElementType(GetHandle())==CELL);
Kirill Terekhov's avatar
Kirill Terekhov committed
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
		Mesh * m = GetMeshLink();
		if( Element::GetGeometricDimension(m->GetGeometricType(GetHandle())) == 2 )
		{
			if( !m->HideMarker() )
			{
				HandleType last, first;
				adj_type const & lc = m->LowConn(GetHandle());
				if( lc.size() < 3 ) return false;
				HandleType q = lc[0]; //edge 0
				adj_type const & qlc = m->LowConn(q);
				first = qlc[0]; //node 0
				last = qlc[1]; //node 1
				HandleType r = lc[1]; //edge 1
				adj_type & rlc = m->LowConn(r);
				if( first == rlc[0] || first == rlc[1] )
				{
					HandleType temp = first;
					first = last;
					last = temp;
				}
				else if ( !(last == rlc[0] || last == rlc[1]) )
					return false;
				adj_type::size_type it = 1, iend = lc.size()-1;
				while(it < iend) //loop over edges
				{
					adj_type const & ilc = m->LowConn(lc[it]);
					if( last == ilc[0] ) last = ilc[1];
					else if( last == ilc[1] ) last = ilc[0];
					else return false;
					++it;
				}
			}
			else
			{
				MarkerType hm = m->HideMarker();
				HandleType first, last;
				enumerator i = ENUMUNDEF, k = ENUMUNDEF, k1 = ENUMUNDEF, k2;
				adj_type const & lc = m->LowConn(GetHandle());
				if( m->Count(lc.data(),lc.size(),hm) < 3 ) return false;
				i = m->getNext(lc.data(),static_cast<enumerator>(lc.size()),i,hm);
				HandleType q = lc[i]; //edge 0
				adj_type const & qlc = m->LowConn(q);
				k = m->getNext(qlc.data(),static_cast<enumerator>(qlc.size()),k,hm);
				first = qlc[k]; //node 0
				k = m->getNext(qlc.data(),static_cast<enumerator>(qlc.size()),k,hm);
				last = qlc[k]; //node 1
				i = m->getNext(lc.data(),static_cast<enumerator>(lc.size()),i,hm);
				HandleType r = lc[i]; //edge 1
				adj_type const & rlc = m->LowConn(r);
				k1 = m->getNext(rlc.data(),static_cast<enumerator>(rlc.size()),k1,hm);
				k2 = m->getNext(rlc.data(),static_cast<enumerator>(rlc.size()),k1,hm);
				if( first == rlc[k1] || first == rlc[k2] )
				{
					HandleType temp = first;
					first = last;
					last = temp;
				}
				else if ( !(last == rlc[k1] || last == rlc[k2]) )
					return false;
				adj_type::size_type it = 1, iend = lc.size()-1;
71
				while(it != iend)
Kirill Terekhov's avatar
Kirill Terekhov committed
72
				{
73
74
75
76
77
78
79
80
81
82
					if( !m->GetMarker(lc[it],hm) ) //loop over edges
					{
						adj_type const & ilc = m->LowConn(lc[it]);
						k1 = ENUMUNDEF; 
						k1 = m->getNext(ilc.data(),static_cast<enumerator>(ilc.size()),k1,hm);
						k2 = m->getNext(ilc.data(),static_cast<enumerator>(ilc.size()),k1,hm);
						if( last == ilc[k1] ) last = ilc[k2];
						else if( last == ilc[k2] ) last = ilc[k1];
						else return false;
					}
Kirill Terekhov's avatar
Kirill Terekhov committed
83
84
85
86
					++it;
				}
			}
		}
Kirill Terekhov's avatar
Kirill Terekhov committed
87
88
89
		return true;
	}
	
Kirill Terekhov's avatar
Kirill Terekhov committed
90
	bool Cell::FixEdgeOrder() const
Kirill Terekhov's avatar
Kirill Terekhov committed
91
	{
Kirill Terekhov's avatar
Kirill Terekhov committed
92
		assert(GetHandleElementType(GetHandle())==CELL);
Kirill Terekhov's avatar
Kirill Terekhov committed
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
		Mesh * m = GetMeshLink();
		if( Element::GetGeometricDimension(m->GetGeometricType(GetHandle())) == 2 )
		{
			if( !m->HideMarker() )
			{
				HandleType last, first;
				adj_type & lc = m->LowConn(GetHandle());
				if( lc.size() < 3 ) return false;
				HandleType q = lc[0]; //edge 0
				adj_type const & qlc = m->LowConn(q);
				if( qlc.size() != 2 ) return false;
				first = qlc[0]; //node 0
				last = qlc[1]; //node 1
				HandleType r = lc[1]; //edge 1
				adj_type & rlc = m->LowConn(r);
				if( rlc.size() != 2 ) return false;
				if( first == rlc[0] || first == rlc[1] )
				{
					HandleType temp = first;
					first = last;
					last = temp;
				}
				else if ( !(last == rlc[0] || last == rlc[1]) )
				{
					adj_type::size_type jt = 2, jend = lc.size();
					while(jt < jend)
					{
						adj_type const & ilc = m->LowConn(lc[jt]);
						if( ilc.size() != 2 ) return false;
						if( first == ilc[0] || first == ilc[1] )
						{
							HandleType temp = lc[1];
							lc[1] = lc[jt];
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
126
							lc[jt] = temp;
Kirill Terekhov's avatar
Kirill Terekhov committed
127
128
129
130
131
132
133
134
135
							temp = first;
							first = last;
							last = temp;
							break;
						}
						else if( last == ilc[0] || last == ilc[1] )
						{
							HandleType temp = lc[1];
							lc[1] = lc[jt];
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
136
							lc[jt] = temp;
Kirill Terekhov's avatar
Kirill Terekhov committed
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
							break;
						}
						++jt;
					}
					if( jt == jend ) return false; //no matching edge
				}
				adj_type::size_type it = 1, iend = lc.size()-1;
				while(it < iend) //loop over edges
				{
					adj_type const & ilc = m->LowConn(lc[it]);
					if( ilc.size() != 2 ) return false;
					if( last == ilc[0] ) 
					{
						last = ilc[1];
						++it;
					}
					else if( last == ilc[1] ) 
					{
						last = ilc[0];
						++it;
					}
					else //search for the connected edge and swap with current
					{
						adj_type::size_type jt = it+1, jend = lc.size();
						while(jt < jend)
						{
							adj_type const & ilc = m->LowConn(lc[jt]);
							if( ilc.size() != 2 ) return false;
							if( last == ilc[0] || last == ilc[1] )
							{
								HandleType temp = lc[it];
								lc[it] = lc[jt];
								lc[jt] = temp;
								break;
							}
						}
						if( jt == jend ) return false; //no matching edge
					}
				}
				//check that the loop is closed
				adj_type const & ilc = m->LowConn(lc[iend]);
				if( ilc.size() != 2 ) return false;
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
179
				if( !( (ilc[0] == last && ilc[1] == first) || (ilc[0] == first && ilc[1] == last) ) )
Kirill Terekhov's avatar
Kirill Terekhov committed
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
					return false;
			}
			else
			{
				HandleType first, last;
				enumerator i = ENUMUNDEF, k = ENUMUNDEF, k1 = ENUMUNDEF, k2;
				MarkerType hm = m->HideMarker();
				adj_type & lc = m->LowConn(GetHandle());
				if( m->Count(lc.data(),lc.size(),hm) < 3 ) return false;
				i = m->getNext(lc.data(),static_cast<enumerator>(lc.size()),i,hm);
				HandleType q = lc[i]; //edge 0
				adj_type const & qlc = m->LowConn(q);
				if(m->Count(qlc.data(),qlc.size(),hm)!=2) return false;
				k = m->getNext(qlc.data(),static_cast<enumerator>(qlc.size()),k,hm);
				first = qlc[k]; //node 0
				k = m->getNext(qlc.data(),static_cast<enumerator>(qlc.size()),k,hm);
				last = qlc[k]; //node 1
				i = m->getNext(lc.data(),static_cast<enumerator>(lc.size()),i,hm);
				HandleType r = lc[i]; //edge 1
				adj_type const & rlc = m->LowConn(r);
				if(m->Count(rlc.data(),rlc.size(),hm)!=2) return false;
				k1 = m->getNext(rlc.data(),static_cast<enumerator>(rlc.size()),k1,hm);
				k2 = m->getNext(rlc.data(),static_cast<enumerator>(rlc.size()),k1,hm);
				if( first == rlc[k1] || first == rlc[k2] )
				{
					HandleType temp = first;
					first = last;
					last = temp;
				}
				else if( !(last == rlc[k1] || last == rlc[k2]) )
				{
					adj_type::size_type jt = i+1, jend = lc.size();
212
					while(jt < jend)
Kirill Terekhov's avatar
Kirill Terekhov committed
213
					{
214
						if( !m->GetMarker(lc[jt],hm) ) //loop over edges
Kirill Terekhov's avatar
Kirill Terekhov committed
215
						{
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
							adj_type const & ilc = m->LowConn(lc[jt]);
							if( m->Count(ilc.data(),ilc.size(),hm) != 2 ) return false;
							k1 = ENUMUNDEF; 
							k1 = m->getNext(ilc.data(),static_cast<enumerator>(ilc.size()),k1,hm);
							k2 = m->getNext(ilc.data(),static_cast<enumerator>(ilc.size()),k1,hm);
							if( first == ilc[k1] || first == ilc[k2] )
							{
								HandleType temp = lc[i];
								lc[i] = lc[jt];
								lc[jt] = temp;
								temp = first;
								first = last;
								last = temp;
								break;
							}
							else if( last == ilc[k1] || last == ilc[k2] )
							{
								HandleType temp = lc[i];
								lc[i] = lc[jt];
								lc[jt] = temp;
								break;
							}
Kirill Terekhov's avatar
Kirill Terekhov committed
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
						}
						++jt;
					}
					if( jt == jend ) return false; //no matching edge
				}
				adj_type::size_type it = i, iend = lc.size()-1;
				while(it != iend) if( !m->GetMarker(lc[it],hm) ) //loop over edges
				{
					adj_type const & ilc = m->LowConn(lc[it]);
					if(m->Count(ilc.data(),ilc.size(),hm)!=2) return false;
					k1 = ENUMUNDEF; 
					k1 = m->getNext(ilc.data(),static_cast<enumerator>(ilc.size()),k1,hm);
					k2 = m->getNext(ilc.data(),static_cast<enumerator>(ilc.size()),k1,hm);
					if( last == ilc[k1] ) 
					{
						last = ilc[k2];
						++it;
					}
					else if( last == ilc[k2] )
					{
						last = ilc[k1];
						++it;
					}
					else//search for the connected edge and swap with current
					{
						adj_type::size_type jt = it+1, jend = lc.size();
						while(jt < jend) if( !m->GetMarker(lc[jt],hm) ) //loop over edges
						{
							adj_type const & ilc = m->LowConn(lc[jt]);
							if(m->Count(ilc.data(),ilc.size(),hm)!=2) return false;
							k1 = ENUMUNDEF; 
							k1 = m->getNext(ilc.data(),static_cast<enumerator>(ilc.size()),k1,hm);
							k2 = m->getNext(ilc.data(),static_cast<enumerator>(ilc.size()),k1,hm);
							if( last == ilc[k1] || last == ilc[k2] )
							{
								HandleType temp = lc[it];
								lc[it] = lc[jt];
								lc[jt] = temp;
								break;
							}
						}
						if( jt == jend ) return false; //no matching edge
					}
281
				} else ++it;
Kirill Terekhov's avatar
Kirill Terekhov committed
282
283
284
285
286
287
				//check that the loop is closed
				adj_type const & ilc = m->LowConn(lc[iend]);
				if(m->Count(ilc.data(),ilc.size(),hm)!=2) return false;
				k1 = ENUMUNDEF; 
				k1 = m->getNext(ilc.data(),static_cast<enumerator>(ilc.size()),k1,hm);
				k2 = m->getNext(ilc.data(),static_cast<enumerator>(ilc.size()),k1,hm);
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
288
				if( !( (ilc[k1] == last && ilc[k2] == first) || (ilc[k1] == first && ilc[k2] == last) ) )
Kirill Terekhov's avatar
Kirill Terekhov committed
289
290
291
					return false;
			}
		}
292
		return true;
Kirill Terekhov's avatar
Kirill Terekhov committed
293
294
	}
	
Kirill Terekhov's avatar
Kirill Terekhov committed
295
	ElementArray<Node> Cell::getNodes() const
Kirill Terekhov's avatar
Kirill Terekhov committed
296
	{
Kirill Terekhov's avatar
Kirill Terekhov committed
297
298
		assert(GetHandleElementType(GetHandle())==CELL);
		Mesh * m = GetMeshLink();
299
		ElementArray<Node> ret(m);
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
		MarkerType mrk = m->CreatePrivateMarker();
		HandleType hc = GetHandle();
		if( !m->HideMarker() )
		{
			Element::adj_type & lc = m->LowConn(hc);
			for(Element::adj_type::size_type i = 0; i < lc.size(); i++) //iterate over faces
			{
				Element::adj_type & ilc = m->LowConn(lc[i]);
				for(Element::adj_type::size_type j = 0; j < ilc.size(); j++) //iterate over face edges
				{
					Element::adj_type & jlc = m->LowConn(ilc[j]);
					for(Element::adj_type::size_type k = 0; k < jlc.size(); k++) //iterator over edge nodes
					{
						if( !m->GetPrivateMarker(jlc[k],mrk) )
						{
							m->SetPrivateMarker(jlc[k],mrk);
							ret.push_back(jlc[k]);
						}
					}
				}
			}
		}
		else
		{
			MarkerType hm = m->HideMarker();
			Element::adj_type & lc = m->LowConn(hc);
			for(Element::adj_type::size_type i = 0; i < lc.size(); i++) if( !m->GetMarker(lc[i],hm) )  //iterate over faces
			{
				Element::adj_type & ilc = m->LowConn(lc[i]);
				for(Element::adj_type::size_type j = 0; j < ilc.size(); j++) if( !m->GetMarker(ilc[j],hm) ) //iterate over face edges
				{
					Element::adj_type & jlc = m->LowConn(ilc[j]);
					for(Element::adj_type::size_type k = 0; k < jlc.size(); k++) if( !m->GetMarker(jlc[k],hm) ) //iterator over edge nodes
					{
						if( !m->GetPrivateMarker(jlc[k], mrk) )
						{
							m->SetPrivateMarker(jlc[k],mrk);
							ret.push_back(jlc[k]);
						}
					}
				}
			}
		}
		ret.RemPrivateMarker(mrk);
		m->ReleasePrivateMarker(mrk);
345
		return ret;
Kirill Terekhov's avatar
Kirill Terekhov committed
346
	}
Kirill Terekhov's avatar
Kirill Terekhov committed
347
348


Kirill Terekhov's avatar
Kirill Terekhov committed
349
	ElementArray<Node> Cell::getNodes(MarkerType mask, bool invert) const
Kirill Terekhov's avatar
Kirill Terekhov committed
350
	{
Kirill Terekhov's avatar
Kirill Terekhov committed
351
352
		assert(GetHandleElementType(GetHandle())==CELL);
		Mesh * m = GetMeshLink();
353
354
355
		ElementArray<Node> ret(m);
		MarkerType mrk = m->CreatePrivateMarker();
		HandleType hc = GetHandle();
356
		if( isPrivate(mask) )
Kirill Terekhov's avatar
Kirill Terekhov committed
357
		{
358
359
360
361
362
363
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
			if( !m->HideMarker() )
			{
				Element::adj_type & lc = m->LowConn(hc);
				for(Element::adj_type::size_type i = 0; i < lc.size(); i++) //iterate over faces
				{
					Element::adj_type & ilc = m->LowConn(lc[i]);
					for(Element::adj_type::size_type j = 0; j < ilc.size(); j++) //iterate over face edges
					{
						Element::adj_type & jlc = m->LowConn(ilc[j]);
						for(Element::adj_type::size_type k = 0; k < jlc.size(); k++) //iterator over edge nodes
						{
							if( (invert ^ m->GetPrivateMarker(jlc[k],mask)) && !m->GetPrivateMarker(jlc[k],mrk) )
							{
								m->SetPrivateMarker(jlc[k],mrk);
								ret.push_back(jlc[k]);
							}
						}
					}
				}
			}
			else
			{
				MarkerType hm = m->HideMarker();
				Element::adj_type & lc = m->LowConn(hc);
				for(Element::adj_type::size_type i = 0; i < lc.size(); i++) if( !m->GetMarker(lc[i],hm) )  //iterate over faces
				{
					Element::adj_type & ilc = m->LowConn(lc[i]);
					for(Element::adj_type::size_type j = 0; j < ilc.size(); j++) if( !m->GetMarker(ilc[j],hm) ) //iterate over face edges
					{
						Element::adj_type & jlc = m->LowConn(ilc[j]);
						for(Element::adj_type::size_type k = 0; k < jlc.size(); k++) if( !m->GetMarker(jlc[k],hm) ) //iterator over edge nodes
						{
							if( (invert ^ m->GetPrivateMarker(jlc[k],mask)) && !m->GetPrivateMarker(jlc[k], mrk) )
							{
								m->SetPrivateMarker(jlc[k],mrk);
								ret.push_back(jlc[k]);
							}
						}
					}
				}
			}
Kirill Terekhov's avatar
Kirill Terekhov committed
399
400
401
		}
		else
		{
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
430
431
432
433
434
435
436
437
438
439
440
441
442
			if( !m->HideMarker() )
			{
				Element::adj_type & lc = m->LowConn(hc);
				for(Element::adj_type::size_type i = 0; i < lc.size(); i++) //iterate over faces
				{
					Element::adj_type & ilc = m->LowConn(lc[i]);
					for(Element::adj_type::size_type j = 0; j < ilc.size(); j++) //iterate over face edges
					{
						Element::adj_type & jlc = m->LowConn(ilc[j]);
						for(Element::adj_type::size_type k = 0; k < jlc.size(); k++) //iterator over edge nodes
						{
							if( (invert ^ m->GetMarker(jlc[k],mask)) && !m->GetPrivateMarker(jlc[k],mrk) )
							{
								m->SetPrivateMarker(jlc[k],mrk);
								ret.push_back(jlc[k]);
							}
						}
					}
				}
			}
			else
			{
				MarkerType hm = m->HideMarker();
				Element::adj_type & lc = m->LowConn(hc);
				for(Element::adj_type::size_type i = 0; i < lc.size(); i++) if( !m->GetMarker(lc[i],hm) )  //iterate over faces
				{
					Element::adj_type & ilc = m->LowConn(lc[i]);
					for(Element::adj_type::size_type j = 0; j < ilc.size(); j++) if( !m->GetMarker(ilc[j],hm) ) //iterate over face edges
					{
						Element::adj_type & jlc = m->LowConn(ilc[j]);
						for(Element::adj_type::size_type k = 0; k < jlc.size(); k++) if( !m->GetMarker(jlc[k],hm) ) //iterator over edge nodes
						{
							if( (invert ^ m->GetMarker(jlc[k],mask)) && !m->GetPrivateMarker(jlc[k], mrk) )
							{
								m->SetPrivateMarker(jlc[k],mrk);
								ret.push_back(jlc[k]);
							}
						}
					}
				}
			}
Kirill Terekhov's avatar
Kirill Terekhov committed
443
		}
444
445
446
		ret.RemPrivateMarker(mrk);
		m->ReleasePrivateMarker(mrk);
		return ret;
Kirill Terekhov's avatar
Kirill Terekhov committed
447
448
	}

Kirill Terekhov's avatar
Kirill Terekhov committed
449
	ElementArray<Edge> Cell::getEdges() const
Kirill Terekhov's avatar
Kirill Terekhov committed
450
	{
Kirill Terekhov's avatar
Kirill Terekhov committed
451
452
453
454
		assert(GetHandleElementType(GetHandle())==CELL);
		Mesh * m = GetMeshLink();
		ElementArray<Edge> aret(m);
		if( !m->HideMarker() )
Kirill Terekhov's avatar
Kirill Terekhov committed
455
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
456
			if( Element::GetGeometricDimension(m->GetGeometricType(GetHandle())) == 2 ) // This cell is 2d face
Kirill Terekhov's avatar
Kirill Terekhov committed
457
			{
Kirill Terekhov's avatar
Kirill Terekhov committed
458
				adj_type const & lc = m->LowConn(GetHandle());
Kirill Terekhov's avatar
Kirill Terekhov committed
459
				aret.reserve(lc.size());
Kirill Terekhov's avatar
Kirill Terekhov committed
460
				if( lc.size() < 1 ) return aret;
Kirill Terekhov's avatar
Kirill Terekhov committed
461
462
				HandleType q = lc[0]; //edge 0
				adj_type const & qlc = m->LowConn(q);
Kirill Terekhov's avatar
Kirill Terekhov committed
463
464
465
				if( qlc.size() > 0 ) aret.push_back(qlc[0]); //node 0
				if( qlc.size() > 1 ) aret.push_back(qlc[1]); //node 1
				if( lc.size() < 2 ) return aret;
Kirill Terekhov's avatar
Kirill Terekhov committed
466
467
				HandleType r = lc[1]; //edge 1
				adj_type const & rlc = m->LowConn(r);
Kirill Terekhov's avatar
Kirill Terekhov committed
468
				if( aret.size() == 2 && rlc.size() == 2 )
Kirill Terekhov's avatar
Kirill Terekhov committed
469
				{
Kirill Terekhov's avatar
Kirill Terekhov committed
470
471
472
473
474
475
					if( aret.data()[0] == rlc[0] || aret.data()[0] == rlc[1] )
					{
						HandleType temp = aret.data()[0];
						aret.data()[0] = aret.data()[1];
						aret.data()[1] = temp;
					}
Kirill Terekhov's avatar
Kirill Terekhov committed
476
				}
Kirill Terekhov's avatar
Kirill Terekhov committed
477
				adj_type::size_type it = 1, iend = lc.size()-1;
Kirill Terekhov's avatar
Kirill Terekhov committed
478
479
				while(it < iend) //loop over edges
				{
Kirill Terekhov's avatar
Kirill Terekhov committed
480
481
482
483
484
					adj_type const & ilc = m->LowConn(lc[it]);
					if( aret.atback() == ilc[0] ) 
						aret.push_back(ilc[1]);
					else 
						aret.push_back(ilc[0]);
Kirill Terekhov's avatar
Kirill Terekhov committed
485
486
					++it;
				}
Kirill Terekhov's avatar
Kirill Terekhov committed
487
488
489
			}
			else
			{
Kirill Terekhov's avatar
Kirill Terekhov committed
490
				MarkerType mrk = m->CreatePrivateMarker();
Kirill Terekhov's avatar
Kirill Terekhov committed
491
492
				adj_type const & lc = m->LowConn(GetHandle());
				for(adj_type::size_type it = 0; it < lc.size(); it++) //faces
Kirill Terekhov's avatar
Kirill Terekhov committed
493
				{
Kirill Terekhov's avatar
Kirill Terekhov committed
494
495
					adj_type const & ilc = m->LowConn(lc[it]);
					for(adj_type::size_type jt = 0; jt < ilc.size(); jt++) //edges
Kirill Terekhov's avatar
Kirill Terekhov committed
496
						if( !m->GetPrivateMarker(ilc[jt],mrk))
Kirill Terekhov's avatar
Kirill Terekhov committed
497
						{
Kirill Terekhov's avatar
Kirill Terekhov committed
498
							aret.push_back(ilc[jt]);
Kirill Terekhov's avatar
Kirill Terekhov committed
499
							m->SetPrivateMarker(ilc[jt],mrk);
Kirill Terekhov's avatar
Kirill Terekhov committed
500
						}
Kirill Terekhov's avatar
Kirill Terekhov committed
501
				}
Kirill Terekhov's avatar
Kirill Terekhov committed
502
				for(ElementArray<Edge>::size_type it = 0; it < aret.size(); it++)
Kirill Terekhov's avatar
Kirill Terekhov committed
503
504
					m->RemPrivateMarker(aret.at(it),mrk);
				m->ReleasePrivateMarker(mrk);
Kirill Terekhov's avatar
Kirill Terekhov committed
505
506
507
508
			}
		}
		else
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
509
510
			MarkerType hm = m->HideMarker();
			if( Element::GetGeometricDimension(m->GetGeometricType(GetHandle())) == 2 ) // This cell is 2d face
Kirill Terekhov's avatar
Kirill Terekhov committed
511
			{
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
512
				enumerator i = ENUMUNDEF, k = ENUMUNDEF, k1 = ENUMUNDEF, k2;
Kirill Terekhov's avatar
Kirill Terekhov committed
513
				adj_type const & lc = m->LowConn(GetHandle());
Kirill Terekhov's avatar
Kirill Terekhov committed
514
				aret.reserve(lc.size());
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
515
				i = m->getNext(lc.data(),static_cast<enumerator>(lc.size()),i,hm);
Kirill Terekhov's avatar
Kirill Terekhov committed
516
				if( i == lc.size() ) return aret;
Kirill Terekhov's avatar
Kirill Terekhov committed
517
518
				HandleType q = lc[i]; //edge 0
				adj_type const & qlc = m->LowConn(q);
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
519
				k = m->getNext(qlc.data(),static_cast<enumerator>(qlc.size()),k,hm);
Kirill Terekhov's avatar
Kirill Terekhov committed
520
				if( k != qlc.size() ) aret.push_back(qlc[k]); //node 0
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
521
				k = m->getNext(qlc.data(),static_cast<enumerator>(qlc.size()),k,hm);
Kirill Terekhov's avatar
Kirill Terekhov committed
522
				if( k != qlc.size() ) aret.push_back(qlc[k]); //node 1
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
523
				i = m->getNext(lc.data(),static_cast<enumerator>(lc.size()),i,hm);
Kirill Terekhov's avatar
Kirill Terekhov committed
524
				if( i == lc.size() ) return aret;
Kirill Terekhov's avatar
Kirill Terekhov committed
525
526
				HandleType r = lc[i]; //edge 1
				adj_type const & rlc = m->LowConn(r);
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
527
528
				k1 = m->getNext(rlc.data(),static_cast<enumerator>(rlc.size()),k1,hm);
				k2 = m->getNext(rlc.data(),static_cast<enumerator>(rlc.size()),k1,hm);
Kirill Terekhov's avatar
Kirill Terekhov committed
529
				if( k1 != rlc.size() && k2 != rlc.size() && aret.size() == 2 )
Kirill Terekhov's avatar
Kirill Terekhov committed
530
				{
Kirill Terekhov's avatar
Kirill Terekhov committed
531
532
533
534
535
536
					if( aret.data()[0] == rlc[k1] || aret.data()[0] == rlc[k2] )
					{
						HandleType temp = aret.data()[0];
						aret.data()[0] = aret.data()[1];
						aret.data()[1] = temp;
					}
Kirill Terekhov's avatar
Kirill Terekhov committed
537
				}
Kirill Terekhov's avatar
Kirill Terekhov committed
538
				adj_type::size_type it = 1, iend = lc.size()-1;
539
				while(it < iend)
Kirill Terekhov's avatar
Kirill Terekhov committed
540
				{
541
542
543
544
545
546
547
548
549
550
551
					if( !m->GetMarker(lc[it],hm) ) //loop over edges
					{
						adj_type const & ilc = m->LowConn(lc[it]);
						k1 = ENUMUNDEF; 
						k1 = m->getNext(ilc.data(),static_cast<enumerator>(ilc.size()),k1,hm);
						k2 = m->getNext(ilc.data(),static_cast<enumerator>(ilc.size()),k1,hm);
						if( aret.atback() == ilc[k1] ) 
							aret.push_back(ilc[k2]);
						else 
							aret.push_back(ilc[k1]);
					}
Kirill Terekhov's avatar
Kirill Terekhov committed
552
553
554
555
556
					++it;
				}
			}
			else
			{
Kirill Terekhov's avatar
Kirill Terekhov committed
557
				MarkerType mrk = m->CreatePrivateMarker();
Kirill Terekhov's avatar
Kirill Terekhov committed
558
559
				adj_type const & lc = m->LowConn(GetHandle());
				for(adj_type::size_type it = 0; it < lc.size(); it++) if( !m->GetMarker(lc[it],hm) ) //faces
Kirill Terekhov's avatar
Kirill Terekhov committed
560
				{
Kirill Terekhov's avatar
Kirill Terekhov committed
561
562
					adj_type const & ilc = m->LowConn(lc[it]);
					for(adj_type::size_type jt = 0; jt < ilc.size(); jt++) if( !m->GetMarker(ilc[jt],hm) )//edges
Kirill Terekhov's avatar
Kirill Terekhov committed
563
						if( !m->GetPrivateMarker(ilc[jt],mrk))
Kirill Terekhov's avatar
Kirill Terekhov committed
564
						{
Kirill Terekhov's avatar
Kirill Terekhov committed
565
							aret.push_back(ilc[jt]);
Kirill Terekhov's avatar
Kirill Terekhov committed
566
							m->SetPrivateMarker(ilc[jt],mrk);
Kirill Terekhov's avatar
Kirill Terekhov committed
567
						}
Kirill Terekhov's avatar
Kirill Terekhov committed
568
				}
Kirill Terekhov's avatar
Kirill Terekhov committed
569
				for(ElementArray<Edge>::size_type it = 0; it < aret.size(); it++)
Kirill Terekhov's avatar
Kirill Terekhov committed
570
571
					m->RemPrivateMarker(aret.at(it),mrk);
				m->ReleasePrivateMarker(mrk);
Kirill Terekhov's avatar
Kirill Terekhov committed
572
573
574
575
			}
		}
		return aret;
	}
Kirill Terekhov's avatar
Kirill Terekhov committed
576
577


Kirill Terekhov's avatar
Kirill Terekhov committed
578
	ElementArray<Edge> Cell::getEdges(MarkerType mask, bool invert) const
Kirill Terekhov's avatar
Kirill Terekhov committed
579
	{
Kirill Terekhov's avatar
Kirill Terekhov committed
580
581
582
		assert(GetHandleElementType(GetHandle())==CELL);
		Mesh * m = GetMeshLink();
		ElementArray<Edge> aret(m);
Kirill Terekhov's avatar
Kirill Terekhov committed
583
		if( isPrivate(mask) )
Kirill Terekhov's avatar
Kirill Terekhov committed
584
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
585
			if( !m->HideMarker() )
Kirill Terekhov's avatar
Kirill Terekhov committed
586
			{
Kirill Terekhov's avatar
Kirill Terekhov committed
587
				if( Element::GetGeometricDimension(m->GetGeometricType(GetHandle())) == 2 ) // This cell is 2d face
Kirill Terekhov's avatar
Kirill Terekhov committed
588
				{
Kirill Terekhov's avatar
Kirill Terekhov committed
589
590
591
592
593
594
595
596
597
598
599
600
					adj_type const & lc = m->LowConn(GetHandle());
					aret.reserve(lc.size());
					HandleType last, first;
					HandleType q = lc[0]; //edge 0
					adj_type const & qlc = m->LowConn(q);
					if( invert ^ m->GetPrivateMarker(qlc[0],mask) ) aret.push_back(qlc[0]); //node 0
					if( invert ^ m->GetPrivateMarker(qlc[1],mask) ) aret.push_back(qlc[1]); //node 1
					first = qlc[0];
					last  = qlc[1];
					HandleType r = lc[1]; //edge 1
					adj_type const & rlc = m->LowConn(r);
					if( first == rlc[0] || first == rlc[1] )
Kirill Terekhov's avatar
Kirill Terekhov committed
601
					{
Kirill Terekhov's avatar
Kirill Terekhov committed
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
						last = first;
						if( aret.size() > 1 )
						{
							HandleType temp = aret.data()[0];
							aret.data()[0] = aret.data()[1];
							aret.data()[1] = temp;
						}
					}
					adj_type::size_type it = 1, iend = lc.size()-1;
					while(it < iend) //loop over edges
					{
						adj_type const & ilc = m->LowConn(lc[it]);
						if( last == ilc[0] ) last = ilc[1];
						else last = ilc[0];
						if( invert ^ m->GetPrivateMarker(last,mask) ) 
							aret.push_back(last);
						++it;
Kirill Terekhov's avatar
Kirill Terekhov committed
619
620
					}
				}
Kirill Terekhov's avatar
Kirill Terekhov committed
621
				else
Kirill Terekhov's avatar
Kirill Terekhov committed
622
				{
Kirill Terekhov's avatar
Kirill Terekhov committed
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
					MarkerType mrk = m->CreatePrivateMarker();
					adj_type const & lc = m->LowConn(GetHandle());
					for(adj_type::size_type it = 0; it < lc.size(); it++) //faces
					{
						adj_type const & ilc = m->LowConn(lc[it]);
						for(adj_type::size_type jt = 0; jt != ilc.size(); jt++) //edges
							if( (invert ^ m->GetPrivateMarker(ilc[jt],mask)) && !m->GetPrivateMarker(ilc[jt],mrk))
							{
								aret.push_back(ilc[jt]);
								m->SetPrivateMarker(ilc[jt],mrk);
							}
					}
					for(ElementArray<Edge>::size_type it = 0; it != aret.size(); it++)
						m->RemPrivateMarker(aret.at(it),mrk);
					m->ReleasePrivateMarker(mrk);
Kirill Terekhov's avatar
Kirill Terekhov committed
638
				}
Kirill Terekhov's avatar
Kirill Terekhov committed
639
640
641
			}
			else
			{
Kirill Terekhov's avatar
Kirill Terekhov committed
642
643
				MarkerType hm = GetMeshLink()->HideMarker();
				if( Element::GetGeometricDimension(m->GetGeometricType(GetHandle())) == 2 ) // This cell is 2d face
Kirill Terekhov's avatar
Kirill Terekhov committed
644
				{
Kirill Terekhov's avatar
Kirill Terekhov committed
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
					enumerator i = ENUMUNDEF, k = ENUMUNDEF, k1 = ENUMUNDEF, k2;
					HandleType last, first;
					adj_type const & lc = m->LowConn(GetHandle());
					aret.reserve(lc.size());
					i = m->getNext(lc.data(),static_cast<enumerator>(lc.size()),i,hm);
					HandleType q = lc[i]; //edge 0
					adj_type const & qlc = m->LowConn(q);
					k = m->getNext(qlc.data(),static_cast<enumerator>(qlc.size()),k,hm);
					if( invert ^ m->GetPrivateMarker(qlc[k],mask) ) aret.push_back(qlc[k]); //node 0
					first = qlc[k];
					k = m->getNext(qlc.data(),static_cast<enumerator>(qlc.size()),k,hm);
					if( invert ^ m->GetPrivateMarker(qlc[k],mask) ) aret.push_back(qlc[k]); //node 1
					last = qlc[k];
					i = m->getNext(lc.data(),static_cast<enumerator>(lc.size()),i,hm);
					HandleType r = lc[i]; //edge 1
					adj_type const & rlc = m->LowConn(r);
					k1 = m->getNext(rlc.data(),static_cast<enumerator>(rlc.size()),k1,hm);
					k2 = m->getNext(rlc.data(),static_cast<enumerator>(rlc.size()),k1,hm);
					if( first == rlc[k1] || first == rlc[k2] )
					{
						last = first;
						if( aret.size() > 1 )
Kirill Terekhov's avatar
Kirill Terekhov committed
667
						{
Kirill Terekhov's avatar
Kirill Terekhov committed
668
669
670
							HandleType temp = aret.data()[0];
							aret.data()[0] = aret.data()[1];
							aret.data()[1] = temp;
Kirill Terekhov's avatar
Kirill Terekhov committed
671
						}
Kirill Terekhov's avatar
Kirill Terekhov committed
672
673
					}
					adj_type::size_type it = 1, iend = lc.size()-1;
674
					while(it != iend)
Kirill Terekhov's avatar
Kirill Terekhov committed
675
					{
676
677
678
679
680
681
682
683
684
685
686
						if( !m->GetMarker(lc[it],hm) ) //loop over edges
						{
							adj_type const & ilc = m->LowConn(lc[it]);
							k1 = ENUMUNDEF; 
							k1 = m->getNext(ilc.data(),static_cast<enumerator>(ilc.size()),k1,hm);
							k2 = m->getNext(ilc.data(),static_cast<enumerator>(ilc.size()),k1,hm);
							if( last == ilc[k1] ) 
								last = ilc[k2];
							else last = ilc[k1];
							if( invert ^ m->GetPrivateMarker(last,mask) ) aret.push_back(last);
						}
Kirill Terekhov's avatar
Kirill Terekhov committed
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
						++it;
					}
				}
				else
				{
					MarkerType mrk = m->CreatePrivateMarker();
					adj_type const & lc = m->LowConn(GetHandle());
					for(adj_type::size_type it = 0; it < lc.size(); it++) if( !m->GetMarker(lc[it],hm) ) //faces
					{
						adj_type const & ilc = m->LowConn(lc[it]);
						for(adj_type::size_type jt = 0; jt < ilc.size(); jt++) if( !m->GetMarker(ilc[jt],hm) )//edges
							if( (invert ^ m->GetPrivateMarker(ilc[jt],mask)) && !m->GetPrivateMarker(ilc[jt],mrk))
							{
								aret.push_back(ilc[jt]);
								m->SetPrivateMarker(ilc[jt],mrk);
							}
					}
					for(ElementArray<Edge>::size_type it = 0; it < aret.size(); it++) 
						m->RemPrivateMarker(aret.at(it),mrk);
					m->ReleasePrivateMarker(mrk);
Kirill Terekhov's avatar
Kirill Terekhov committed
707
				}
Kirill Terekhov's avatar
Kirill Terekhov committed
708
709
710
711
			}
		}
		else
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
712
			if( !m->HideMarker() )
Kirill Terekhov's avatar
Kirill Terekhov committed
713
			{
Kirill Terekhov's avatar
Kirill Terekhov committed
714
				if( Element::GetGeometricDimension(m->GetGeometricType(GetHandle())) == 2 ) // This cell is 2d face
Kirill Terekhov's avatar
Kirill Terekhov committed
715
				{
Kirill Terekhov's avatar
Kirill Terekhov committed
716
717
718
719
720
721
722
723
724
725
726
727
					adj_type const & lc = m->LowConn(GetHandle());
					aret.reserve(lc.size());
					HandleType last, first;
					HandleType q = lc[0]; //edge 0
					adj_type const & qlc = m->LowConn(q);
					if( invert ^ m->GetMarker(qlc[0],mask) ) aret.push_back(qlc[0]); //node 0
					if( invert ^ m->GetMarker(qlc[1],mask) ) aret.push_back(qlc[1]); //node 1
					first = qlc[0];
					last  = qlc[1];
					HandleType r = lc[1]; //edge 1
					adj_type const & rlc = m->LowConn(r);
					if( first == rlc[0] || first == rlc[1] )
Kirill Terekhov's avatar
Kirill Terekhov committed
728
					{
Kirill Terekhov's avatar
Kirill Terekhov committed
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
						last = first;
						if( aret.size() > 1 )
						{
							HandleType temp = aret.data()[0];
							aret.data()[0] = aret.data()[1];
							aret.data()[1] = temp;
						}
					}
					adj_type::size_type it = 1, iend = lc.size()-1;
					while(it < iend) //loop over edges
					{
						adj_type const & ilc = m->LowConn(lc[it]);
						if( last == ilc[0] ) last = ilc[1];
						else last = ilc[0];
						if( invert ^ m->GetMarker(last,mask) ) 
							aret.push_back(last);
						++it;
Kirill Terekhov's avatar
Kirill Terekhov committed
746
747
					}
				}
Kirill Terekhov's avatar
Kirill Terekhov committed
748
				else
Kirill Terekhov's avatar
Kirill Terekhov committed
749
				{
Kirill Terekhov's avatar
Kirill Terekhov committed
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
					MarkerType mrk = m->CreatePrivateMarker();
					adj_type const & lc = m->LowConn(GetHandle());
					for(adj_type::size_type it = 0; it < lc.size(); it++) //faces
					{
						adj_type const & ilc = m->LowConn(lc[it]);
						for(adj_type::size_type jt = 0; jt != ilc.size(); jt++) //edges
							if( (invert ^ m->GetMarker(ilc[jt],mask)) && !m->GetPrivateMarker(ilc[jt],mrk))
							{
								aret.push_back(ilc[jt]);
								m->SetPrivateMarker(ilc[jt],mrk);
							}
					}
					for(ElementArray<Edge>::size_type it = 0; it != aret.size(); it++)
						m->RemPrivateMarker(aret.at(it),mrk);
					m->ReleasePrivateMarker(mrk);
Kirill Terekhov's avatar
Kirill Terekhov committed
765
766
767
768
				}
			}
			else
			{
Kirill Terekhov's avatar
Kirill Terekhov committed
769
770
				MarkerType hm = GetMeshLink()->HideMarker();
				if( Element::GetGeometricDimension(m->GetGeometricType(GetHandle())) == 2 ) // This cell is 2d face
Kirill Terekhov's avatar
Kirill Terekhov committed
771
				{
Kirill Terekhov's avatar
Kirill Terekhov committed
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
					enumerator i = ENUMUNDEF, k = ENUMUNDEF, k1 = ENUMUNDEF, k2;
					HandleType last, first;
					adj_type const & lc = m->LowConn(GetHandle());
					aret.reserve(lc.size());
					i = m->getNext(lc.data(),static_cast<enumerator>(lc.size()),i,hm);
					HandleType q = lc[i]; //edge 0
					adj_type const & qlc = m->LowConn(q);
					k = m->getNext(qlc.data(),static_cast<enumerator>(qlc.size()),k,hm);
					if( invert ^ m->GetMarker(qlc[k],mask) ) aret.push_back(qlc[k]); //node 0
					first = qlc[k];
					k = m->getNext(qlc.data(),static_cast<enumerator>(qlc.size()),k,hm);
					if( invert ^ m->GetMarker(qlc[k],mask) ) aret.push_back(qlc[k]); //node 1
					last = qlc[k];
					i = m->getNext(lc.data(),static_cast<enumerator>(lc.size()),i,hm);
					HandleType r = lc[i]; //edge 1
					adj_type const & rlc = m->LowConn(r);
					k1 = m->getNext(rlc.data(),static_cast<enumerator>(rlc.size()),k1,hm);
					k2 = m->getNext(rlc.data(),static_cast<enumerator>(rlc.size()),k1,hm);
					if( first == rlc[k1] || first == rlc[k2] )
					{
						last = first;
						if( aret.size() > 1 )
Kirill Terekhov's avatar
Kirill Terekhov committed
794
						{
Kirill Terekhov's avatar
Kirill Terekhov committed
795
796
797
							HandleType temp = aret.data()[0];
							aret.data()[0] = aret.data()[1];
							aret.data()[1] = temp;
Kirill Terekhov's avatar
Kirill Terekhov committed
798
						}
Kirill Terekhov's avatar
Kirill Terekhov committed
799
800
					}
					adj_type::size_type it = 1, iend = lc.size()-1;
801
					while(it != iend) 
Kirill Terekhov's avatar
Kirill Terekhov committed
802
					{
803
804
805
806
807
808
809
810
811
812
813
						if( !m->GetMarker(lc[it],hm) ) //loop over edges
						{
							adj_type const & ilc = m->LowConn(lc[it]);
							k1 = ENUMUNDEF; 
							k1 = m->getNext(ilc.data(),static_cast<enumerator>(ilc.size()),k1,hm);
							k2 = m->getNext(ilc.data(),static_cast<enumerator>(ilc.size()),k1,hm);
							if( last == ilc[k1] ) 
								last = ilc[k2];
							else last = ilc[k1];
							if( invert ^ m->GetMarker(last,mask) ) aret.push_back(last);
						}
Kirill Terekhov's avatar
Kirill Terekhov committed
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
						++it;
					}
				}
				else
				{
					MarkerType mrk = m->CreatePrivateMarker();
					adj_type const & lc = m->LowConn(GetHandle());
					for(adj_type::size_type it = 0; it < lc.size(); it++) if( !m->GetMarker(lc[it],hm) ) //faces
					{
						adj_type const & ilc = m->LowConn(lc[it]);
						for(adj_type::size_type jt = 0; jt < ilc.size(); jt++) if( !m->GetMarker(ilc[jt],hm) )//edges
							if( (invert ^ m->GetMarker(ilc[jt],mask)) && !m->GetPrivateMarker(ilc[jt],mrk))
							{
								aret.push_back(ilc[jt]);
								m->SetPrivateMarker(ilc[jt],mrk);
							}
					}
					for(ElementArray<Edge>::size_type it = 0; it < aret.size(); it++) 
						m->RemPrivateMarker(aret.at(it),mrk);
					m->ReleasePrivateMarker(mrk);
Kirill Terekhov's avatar
Kirill Terekhov committed
834
				}
Kirill Terekhov's avatar
Kirill Terekhov committed
835
836
837
838
839
			}
		}
		return aret;
	}

Kirill Terekhov's avatar
Kirill Terekhov committed
840
	ElementArray<Face> Cell::getFaces() const
Kirill Terekhov's avatar
Kirill Terekhov committed
841
	{
Kirill Terekhov's avatar
Kirill Terekhov committed
842
843
844
		assert(GetHandleElementType(GetHandle())==CELL);
		Mesh * m = GetMeshLink();
		if( !m->HideMarker() )
Kirill Terekhov's avatar
Kirill Terekhov committed
845
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
846
847
			adj_type const & lc = m->LowConn(GetHandle());
			return ElementArray<Face>(m,lc.data(),lc.data()+lc.size());
Kirill Terekhov's avatar
Kirill Terekhov committed
848
		}
Kirill Terekhov's avatar
Kirill Terekhov committed
849
850
		else
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
851
852
853
854
855
			MarkerType hm = m->HideMarker();
			ElementArray<Face> aret(m);
			adj_type & lc = m->LowConn(GetHandle());
			for(adj_type::size_type it = 0; it < lc.size(); ++it)
				if( !m->GetMarker(lc[it],hm) ) aret.push_back(lc[it]);
Kirill Terekhov's avatar
Kirill Terekhov committed
856
857
858
			return aret;
		}
	}
Kirill Terekhov's avatar
Kirill Terekhov committed
859
860


Kirill Terekhov's avatar
Kirill Terekhov committed
861
	ElementArray<Face> Cell::getFaces(MarkerType mask, bool invert) const
Kirill Terekhov's avatar
Kirill Terekhov committed
862
	{
Kirill Terekhov's avatar
Kirill Terekhov committed
863
864
865
866
		assert(GetHandleElementType(GetHandle())==CELL);
		Mesh * m = GetMeshLink();
		ElementArray<Face> aret(m);
		if( !m->HideMarker() )
Kirill Terekhov's avatar
Kirill Terekhov committed
867
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
868
			adj_type const & lc = m->LowConn(GetHandle());
Kirill Terekhov's avatar
Kirill Terekhov committed
869
870
871
872
873
874
875
876
877
878
			if( isPrivate(mask) )
			{
				for(adj_type::size_type it = 0; it < lc.size(); ++it)
					if( invert ^ m->GetPrivateMarker(lc[it],mask) ) aret.push_back(lc[it]);
			}
			else
			{
				for(adj_type::size_type it = 0; it < lc.size(); ++it)
					if( invert ^ m->GetMarker(lc[it],mask) ) aret.push_back(lc[it]);
			}
Kirill Terekhov's avatar
Kirill Terekhov committed
879
880
881
		}
		else
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
882
883
			MarkerType hm = m->HideMarker();
			adj_type const & lc = m->LowConn(GetHandle());
Kirill Terekhov's avatar
Kirill Terekhov committed
884
885
886
887
888
889
890
891
892
893
894
895
			if( isPrivate(mask) )
			{
				for(adj_type::size_type it = 0; it < lc.size(); ++it)
					if( (invert ^ m->GetPrivateMarker(lc[it],mask)) && !m->GetMarker(lc[it],hm) ) 
						aret.push_back(lc[it]);
			}
			else
			{
				for(adj_type::size_type it = 0; it < lc.size(); ++it)
					if( (invert ^ m->GetMarker(lc[it],mask)) && !m->GetMarker(lc[it],hm) ) 
						aret.push_back(lc[it]);
			}
Kirill Terekhov's avatar
Kirill Terekhov committed
896
897
898
		}
		return aret;
	}
Kirill Terekhov's avatar
Kirill Terekhov committed
899
900
}
#endif