cell.cpp 10.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
		return true;
	}
	
Kirill Terekhov's avatar
Kirill Terekhov committed
14
	bool Cell::FixEdgeOrder() const
Kirill Terekhov's avatar
Kirill Terekhov committed
15
	{
Kirill Terekhov's avatar
Kirill Terekhov committed
16
		assert(GetHandleElementType(GetHandle())==CELL);
Kirill Terekhov's avatar
Kirill Terekhov committed
17 18 19
		return false;
	}
	
Kirill Terekhov's avatar
Kirill Terekhov committed
20
	ElementArray<Node> Cell::getNodes() const
Kirill Terekhov's avatar
Kirill Terekhov committed
21
	{
Kirill Terekhov's avatar
Kirill Terekhov committed
22 23 24
		assert(GetHandleElementType(GetHandle())==CELL);
		Mesh * m = GetMeshLink();
		if( !m->HideMarker() )
Kirill Terekhov's avatar
Kirill Terekhov committed
25
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
26 27
			adj_type const & hc = m->HighConn(GetHandle());
			return ElementArray<Node>(m,hc.data(),hc.data()+hc.size());
Kirill Terekhov's avatar
Kirill Terekhov committed
28
		}
Kirill Terekhov's avatar
Kirill Terekhov committed
29 30
		else
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
31 32 33 34 35
			MarkerType hm = m->HideMarker();
			ElementArray<Node> aret(m);
			adj_type const & hc = m->HighConn(GetHandle());
			for(adj_type::size_type it = 0; it < hc.size(); ++it)
				if( !m->GetMarker(hc[it],hm) ) aret.push_back(hc[it]);
Kirill Terekhov's avatar
Kirill Terekhov committed
36 37 38
			return aret;
		}
	}
Kirill Terekhov's avatar
Kirill Terekhov committed
39 40


Kirill Terekhov's avatar
Kirill Terekhov committed
41
	ElementArray<Node> Cell::getNodes(MarkerType mask, bool invert) const
Kirill Terekhov's avatar
Kirill Terekhov committed
42
	{
Kirill Terekhov's avatar
Kirill Terekhov committed
43 44 45 46
		assert(GetHandleElementType(GetHandle())==CELL);
		Mesh * m = GetMeshLink();
		ElementArray<Node> aret(m);
		if( !m->HideMarker() )
Kirill Terekhov's avatar
Kirill Terekhov committed
47
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
48 49 50 51
			adj_type const & hc = m->HighConn(GetHandle());
			for(adj_type::size_type it = 0; it < hc.size(); ++it)
				if( invert ^ m->GetMarker(hc[it],mask) ) 
					aret.push_back(hc[it]);
Kirill Terekhov's avatar
Kirill Terekhov committed
52 53 54
		}
		else
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
55 56 57 58 59
			MarkerType hm = m->HideMarker();
			adj_type const & hc = m->HighConn(GetHandle());
			for(adj_type::size_type it = 0; it < hc.size(); ++it)
				if( (invert ^ m->GetMarker(hc[it],mask)) && !m->GetMarker(hc[it],hm) ) 
					aret.push_back(hc[it]);
Kirill Terekhov's avatar
Kirill Terekhov committed
60 61 62 63
		}
		return aret;
	}

Kirill Terekhov's avatar
Kirill Terekhov committed
64
	ElementArray<Edge> Cell::getEdges() const
Kirill Terekhov's avatar
Kirill Terekhov committed
65
	{
Kirill Terekhov's avatar
Kirill Terekhov committed
66 67 68 69
		assert(GetHandleElementType(GetHandle())==CELL);
		Mesh * m = GetMeshLink();
		ElementArray<Edge> aret(m);
		if( !m->HideMarker() )
Kirill Terekhov's avatar
Kirill Terekhov committed
70
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
71
			if( Element::GetGeometricDimension(m->GetGeometricType(GetHandle())) == 2 ) // This cell is 2d face
Kirill Terekhov's avatar
Kirill Terekhov committed
72
			{
Kirill Terekhov's avatar
Kirill Terekhov committed
73
				adj_type const & lc = m->LowConn(GetHandle());
Kirill Terekhov's avatar
Kirill Terekhov committed
74
				aret.reserve(lc.size());
Kirill Terekhov's avatar
Kirill Terekhov committed
75 76
				HandleType q = lc[0]; //edge 0
				adj_type const & qlc = m->LowConn(q);
Kirill Terekhov's avatar
Kirill Terekhov committed
77 78
				aret.push_back(qlc[0]); //node 0
				aret.push_back(qlc[1]); //node 1
Kirill Terekhov's avatar
Kirill Terekhov committed
79 80
				HandleType r = lc[1]; //edge 1
				adj_type const & rlc = m->LowConn(r);
Kirill Terekhov's avatar
Kirill Terekhov committed
81
				if( aret.data()[0] == rlc[0] || aret.data()[0] == rlc[1] )
Kirill Terekhov's avatar
Kirill Terekhov committed
82
				{
Kirill Terekhov's avatar
Kirill Terekhov committed
83
					HandleType temp = aret.data()[0];
Kirill Terekhov's avatar
Kirill Terekhov committed
84 85 86
					aret.data()[0] = aret.data()[1];
					aret.data()[1] = temp;
				}
Kirill Terekhov's avatar
Kirill Terekhov committed
87
				adj_type::size_type it = 1, iend = lc.size()-1;
Kirill Terekhov's avatar
Kirill Terekhov committed
88 89
				while(it < iend) //loop over edges
				{
Kirill Terekhov's avatar
Kirill Terekhov committed
90 91 92 93 94
					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
95 96
					++it;
				}
Kirill Terekhov's avatar
Kirill Terekhov committed
97 98 99
			}
			else
			{
Kirill Terekhov's avatar
Kirill Terekhov committed
100
				MarkerType mrk = m->CreateMarker();
Kirill Terekhov's avatar
Kirill Terekhov committed
101 102
				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
103
				{
Kirill Terekhov's avatar
Kirill Terekhov committed
104 105 106
					adj_type const & ilc = m->LowConn(lc[it]);
					for(adj_type::size_type jt = 0; jt < ilc.size(); jt++) //edges
						if( !m->GetMarker(ilc[jt],mrk))
Kirill Terekhov's avatar
Kirill Terekhov committed
107
						{
Kirill Terekhov's avatar
Kirill Terekhov committed
108
							aret.push_back(ilc[jt]);
Kirill Terekhov's avatar
Kirill Terekhov committed
109
							m->SetMarker(ilc[jt],mrk);
Kirill Terekhov's avatar
Kirill Terekhov committed
110
						}
Kirill Terekhov's avatar
Kirill Terekhov committed
111
				}
Kirill Terekhov's avatar
Kirill Terekhov committed
112 113
				for(ElementArray<Edge>::size_type it = 0; it < aret.size(); it++)
					m->RemMarker(aret.at(it),mrk);
Kirill Terekhov's avatar
Kirill Terekhov committed
114 115 116 117 118
				m->ReleaseMarker(mrk);
			}
		}
		else
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
119 120
			MarkerType hm = m->HideMarker();
			if( Element::GetGeometricDimension(m->GetGeometricType(GetHandle())) == 2 ) // This cell is 2d face
Kirill Terekhov's avatar
Kirill Terekhov committed
121
			{
Kirill Terekhov's avatar
Kirill Terekhov committed
122 123
				integer i = -1, k = -1, k1 = -1, k2;
				adj_type const & lc = m->LowConn(GetHandle());
Kirill Terekhov's avatar
Kirill Terekhov committed
124
				aret.reserve(lc.size());
Kirill Terekhov's avatar
Kirill Terekhov committed
125 126 127 128
				i = m->getNext(lc.data(),static_cast<integer>(lc.size()),i,hm);
				HandleType q = lc[i]; //edge 0
				adj_type const & qlc = m->LowConn(q);
				k = m->getNext(qlc.data(),static_cast<integer>(qlc.size()),k,hm);
Kirill Terekhov's avatar
Kirill Terekhov committed
129
				aret.push_back(qlc[k]); //node 0
Kirill Terekhov's avatar
Kirill Terekhov committed
130
				k = m->getNext(qlc.data(),static_cast<integer>(qlc.size()),k,hm);
Kirill Terekhov's avatar
Kirill Terekhov committed
131
				aret.push_back(qlc[k]); //node 1
Kirill Terekhov's avatar
Kirill Terekhov committed
132 133 134 135 136
				i = m->getNext(lc.data(),static_cast<integer>(lc.size()),i,hm);
				HandleType r = lc[i]; //edge 1
				adj_type const & rlc = m->LowConn(r);
				k1 = m->getNext(rlc.data(),static_cast<integer>(rlc.size()),k1,hm);
				k2 = m->getNext(rlc.data(),static_cast<integer>(rlc.size()),k1,hm);
Kirill Terekhov's avatar
Kirill Terekhov committed
137
				if( aret.data()[0] == rlc[k1] || aret.data()[0] == rlc[k2] )
Kirill Terekhov's avatar
Kirill Terekhov committed
138
				{
Kirill Terekhov's avatar
Kirill Terekhov committed
139
					HandleType temp = aret.data()[0];
Kirill Terekhov's avatar
Kirill Terekhov committed
140 141 142
					aret.data()[0] = aret.data()[1];
					aret.data()[1] = temp;
				}
Kirill Terekhov's avatar
Kirill Terekhov committed
143 144
				adj_type::size_type it = 1, iend = lc.size()-1;
				while(it < iend) if( !m->GetMarker(lc[it],hm) ) //loop over edges
Kirill Terekhov's avatar
Kirill Terekhov committed
145
				{
Kirill Terekhov's avatar
Kirill Terekhov committed
146 147 148 149 150 151 152 153
					adj_type const & ilc = m->LowConn(lc[it]);
					k1 = -1; 
					k1 = m->getNext(ilc.data(),static_cast<integer>(ilc.size()),k1,hm);
					k2 = m->getNext(ilc.data(),static_cast<integer>(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
154 155 156 157 158
					++it;
				}
			}
			else
			{
Kirill Terekhov's avatar
Kirill Terekhov committed
159
				MarkerType mrk = m->CreateMarker();
Kirill Terekhov's avatar
Kirill Terekhov committed
160 161
				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
162
				{
Kirill Terekhov's avatar
Kirill Terekhov committed
163 164 165
					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( !m->GetMarker(ilc[jt],mrk))
Kirill Terekhov's avatar
Kirill Terekhov committed
166
						{
Kirill Terekhov's avatar
Kirill Terekhov committed
167
							aret.push_back(ilc[jt]);
Kirill Terekhov's avatar
Kirill Terekhov committed
168
							m->SetMarker(ilc[jt],mrk);
Kirill Terekhov's avatar
Kirill Terekhov committed
169
						}
Kirill Terekhov's avatar
Kirill Terekhov committed
170
				}
Kirill Terekhov's avatar
Kirill Terekhov committed
171 172
				for(ElementArray<Edge>::size_type it = 0; it < aret.size(); it++)
					m->RemMarker(aret.at(it),mrk);
Kirill Terekhov's avatar
Kirill Terekhov committed
173 174 175 176 177
				m->ReleaseMarker(mrk);
			}
		}
		return aret;
	}
Kirill Terekhov's avatar
Kirill Terekhov committed
178 179


Kirill Terekhov's avatar
Kirill Terekhov committed
180
	ElementArray<Edge> Cell::getEdges(MarkerType mask, bool invert) const
Kirill Terekhov's avatar
Kirill Terekhov committed
181
	{
Kirill Terekhov's avatar
Kirill Terekhov committed
182 183 184 185
		assert(GetHandleElementType(GetHandle())==CELL);
		Mesh * m = GetMeshLink();
		ElementArray<Edge> aret(m);
		if( !m->HideMarker() )
Kirill Terekhov's avatar
Kirill Terekhov committed
186
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
187
			if( Element::GetGeometricDimension(m->GetGeometricType(GetHandle())) == 2 ) // This cell is 2d face
Kirill Terekhov's avatar
Kirill Terekhov committed
188
			{
Kirill Terekhov's avatar
Kirill Terekhov committed
189
				adj_type const & lc = m->LowConn(GetHandle());
Kirill Terekhov's avatar
Kirill Terekhov committed
190
				aret.reserve(lc.size());
Kirill Terekhov's avatar
Kirill Terekhov committed
191 192 193 194 195
				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
Kirill Terekhov's avatar
Kirill Terekhov committed
196 197
				first = qlc[0];
				last  = qlc[1];
Kirill Terekhov's avatar
Kirill Terekhov committed
198 199
				HandleType r = lc[1]; //edge 1
				adj_type const & rlc = m->LowConn(r);
Kirill Terekhov's avatar
Kirill Terekhov committed
200
				if( first == rlc[0] || first == rlc[1] )
Kirill Terekhov's avatar
Kirill Terekhov committed
201 202 203 204
				{
					last = first;
					if( aret.size() > 1 )
					{
Kirill Terekhov's avatar
Kirill Terekhov committed
205
						HandleType temp = aret.data()[0];
Kirill Terekhov's avatar
Kirill Terekhov committed
206 207 208 209
						aret.data()[0] = aret.data()[1];
						aret.data()[1] = temp;
					}
				}
Kirill Terekhov's avatar
Kirill Terekhov committed
210
				adj_type::size_type it = 1, iend = lc.size()-1;
Kirill Terekhov's avatar
Kirill Terekhov committed
211 212
				while(it < iend) //loop over edges
				{
Kirill Terekhov's avatar
Kirill Terekhov committed
213
					adj_type const & ilc = m->LowConn(lc[it]);
Kirill Terekhov's avatar
Kirill Terekhov committed
214 215
					if( last == ilc[0] ) last = ilc[1];
					else last = ilc[0];
Kirill Terekhov's avatar
Kirill Terekhov committed
216 217
					if( invert ^ m->GetMarker(last,mask) ) 
						aret.push_back(last);
Kirill Terekhov's avatar
Kirill Terekhov committed
218 219
					++it;
				}
Kirill Terekhov's avatar
Kirill Terekhov committed
220 221 222
			}
			else
			{
Kirill Terekhov's avatar
Kirill Terekhov committed
223
				MarkerType mrk = m->CreateMarker();
Kirill Terekhov's avatar
Kirill Terekhov committed
224 225
				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
226
				{
Kirill Terekhov's avatar
Kirill Terekhov committed
227 228 229
					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->GetMarker(ilc[jt],mrk))
Kirill Terekhov's avatar
Kirill Terekhov committed
230
						{
Kirill Terekhov's avatar
Kirill Terekhov committed
231
							aret.push_back(ilc[jt]);
Kirill Terekhov's avatar
Kirill Terekhov committed
232
							m->SetMarker(ilc[jt],mrk);
Kirill Terekhov's avatar
Kirill Terekhov committed
233
						}
Kirill Terekhov's avatar
Kirill Terekhov committed
234
				}
Kirill Terekhov's avatar
Kirill Terekhov committed
235 236
				for(ElementArray<Edge>::size_type it = 0; it != aret.size(); it++)
					m->RemMarker(aret.at(it),mrk);
Kirill Terekhov's avatar
Kirill Terekhov committed
237 238 239 240 241
				m->ReleaseMarker(mrk);
			}
		}
		else
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
242
			MarkerType hm = GetMeshLink()->HideMarker();
Kirill Terekhov's avatar
Kirill Terekhov committed
243
			if( Element::GetGeometricDimension(m->GetGeometricType(GetHandle())) == 2 ) // This cell is 2d face
Kirill Terekhov's avatar
Kirill Terekhov committed
244
			{
Kirill Terekhov's avatar
Kirill Terekhov committed
245 246 247
				integer i = -1, k = -1, k1 = -1, k2;
				HandleType last, first;
				adj_type const & lc = m->LowConn(GetHandle());
Kirill Terekhov's avatar
Kirill Terekhov committed
248
				aret.reserve(lc.size());
Kirill Terekhov's avatar
Kirill Terekhov committed
249 250 251 252 253
				i = m->getNext(lc.data(),static_cast<integer>(lc.size()),i,hm);
				HandleType q = lc[i]; //edge 0
				adj_type const & qlc = m->LowConn(q);
				k = m->getNext(qlc.data(),static_cast<integer>(qlc.size()),k,hm);
				if( invert ^ m->GetMarker(qlc[k],mask) ) aret.push_back(qlc[k]); //node 0
Kirill Terekhov's avatar
Kirill Terekhov committed
254
				first = qlc[k];
Kirill Terekhov's avatar
Kirill Terekhov committed
255 256
				k = m->getNext(qlc.data(),static_cast<integer>(qlc.size()),k,hm);
				if( invert ^ m->GetMarker(qlc[k],mask) ) aret.push_back(qlc[k]); //node 1
Kirill Terekhov's avatar
Kirill Terekhov committed
257
				last = qlc[k];
Kirill Terekhov's avatar
Kirill Terekhov committed
258 259 260 261 262
				i = m->getNext(lc.data(),static_cast<integer>(lc.size()),i,hm);
				HandleType r = lc[i]; //edge 1
				adj_type const & rlc = m->LowConn(r);
				k1 = m->getNext(rlc.data(),static_cast<integer>(rlc.size()),k1,hm);
				k2 = m->getNext(rlc.data(),static_cast<integer>(rlc.size()),k1,hm);
Kirill Terekhov's avatar
Kirill Terekhov committed
263
				if( first == rlc[k1] || first == rlc[k2] )
Kirill Terekhov's avatar
Kirill Terekhov committed
264 265 266 267
				{
					last = first;
					if( aret.size() > 1 )
					{
Kirill Terekhov's avatar
Kirill Terekhov committed
268
						HandleType temp = aret.data()[0];
Kirill Terekhov's avatar
Kirill Terekhov committed
269 270 271 272
						aret.data()[0] = aret.data()[1];
						aret.data()[1] = temp;
					}
				}
Kirill Terekhov's avatar
Kirill Terekhov committed
273 274
				adj_type::size_type it = 1, iend = lc.size()-1;
				while(it != iend) if( !m->GetMarker(lc[it],hm) ) //loop over edges
Kirill Terekhov's avatar
Kirill Terekhov committed
275
				{
Kirill Terekhov's avatar
Kirill Terekhov committed
276 277 278 279 280 281
					adj_type const & ilc = m->LowConn(lc[it]);
					k1 = -1; 
					k1 = m->getNext(ilc.data(),static_cast<integer>(ilc.size()),k1,hm);
					k2 = m->getNext(ilc.data(),static_cast<integer>(ilc.size()),k1,hm);
					if( last == ilc[k1] ) 
						last = ilc[k2];
Kirill Terekhov's avatar
Kirill Terekhov committed
282
					else last = ilc[k1];
Kirill Terekhov's avatar
Kirill Terekhov committed
283
					if( invert ^ m->GetMarker(last,mask) ) aret.push_back(last);
Kirill Terekhov's avatar
Kirill Terekhov committed
284 285 286 287 288
					++it;
				}
			}
			else
			{
Kirill Terekhov's avatar
Kirill Terekhov committed
289
				MarkerType mrk = m->CreateMarker();
Kirill Terekhov's avatar
Kirill Terekhov committed
290 291
				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
292
				{
Kirill Terekhov's avatar
Kirill Terekhov committed
293 294 295
					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->GetMarker(ilc[jt],mrk))
Kirill Terekhov's avatar
Kirill Terekhov committed
296
						{
Kirill Terekhov's avatar
Kirill Terekhov committed
297
							aret.push_back(ilc[jt]);
Kirill Terekhov's avatar
Kirill Terekhov committed
298
							m->SetMarker(ilc[jt],mrk);
Kirill Terekhov's avatar
Kirill Terekhov committed
299
						}
Kirill Terekhov's avatar
Kirill Terekhov committed
300
				}
Kirill Terekhov's avatar
Kirill Terekhov committed
301 302
				for(ElementArray<Edge>::size_type it = 0; it < aret.size(); it++) 
					m->RemMarker(aret.at(it),mrk);
Kirill Terekhov's avatar
Kirill Terekhov committed
303 304 305 306 307 308
				m->ReleaseMarker(mrk);
			}
		}
		return aret;
	}

Kirill Terekhov's avatar
Kirill Terekhov committed
309
	ElementArray<Face> Cell::getFaces() const
Kirill Terekhov's avatar
Kirill Terekhov committed
310
	{
Kirill Terekhov's avatar
Kirill Terekhov committed
311 312 313
		assert(GetHandleElementType(GetHandle())==CELL);
		Mesh * m = GetMeshLink();
		if( !m->HideMarker() )
Kirill Terekhov's avatar
Kirill Terekhov committed
314
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
315 316
			adj_type const & lc = m->LowConn(GetHandle());
			return ElementArray<Face>(m,lc.data(),lc.data()+lc.size());
Kirill Terekhov's avatar
Kirill Terekhov committed
317
		}
Kirill Terekhov's avatar
Kirill Terekhov committed
318 319
		else
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
320 321 322 323 324
			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
325 326 327
			return aret;
		}
	}
Kirill Terekhov's avatar
Kirill Terekhov committed
328 329


Kirill Terekhov's avatar
Kirill Terekhov committed
330
	ElementArray<Face> Cell::getFaces(MarkerType mask, bool invert) const
Kirill Terekhov's avatar
Kirill Terekhov committed
331
	{
Kirill Terekhov's avatar
Kirill Terekhov committed
332 333 334 335
		assert(GetHandleElementType(GetHandle())==CELL);
		Mesh * m = GetMeshLink();
		ElementArray<Face> aret(m);
		if( !m->HideMarker() )
Kirill Terekhov's avatar
Kirill Terekhov committed
336
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
337 338 339
			adj_type const & lc = m->LowConn(GetHandle());
			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
340 341 342
		}
		else
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
343 344 345 346 347
			MarkerType hm = m->HideMarker();
			adj_type const & lc = m->LowConn(GetHandle());
			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
348 349 350
		}
		return aret;
	}
Kirill Terekhov's avatar
Kirill Terekhov committed
351 352
}
#endif