node.cpp 9.98 KB
Newer Older
Kirill Terekhov's avatar
Kirill Terekhov committed
1
2
3
4
5
6
#include "inmost.h"
#if defined(USE_MESH)
namespace INMOST
{

	
Kirill Terekhov's avatar
Kirill Terekhov committed
7
	ElementArray<Edge> Node::getEdges() const
Kirill Terekhov's avatar
Kirill Terekhov committed
8
	{
Kirill Terekhov's avatar
Kirill Terekhov committed
9
10
11
		assert(GetHandleElementType(GetHandle())==NODE);
		Mesh * m = GetMeshLink();
		if( !m->HideMarker() )
Kirill Terekhov's avatar
Kirill Terekhov committed
12
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
13
14
			adj_type const & hc = m->HighConn(GetHandle());
			return ElementArray<Edge>(m,hc.data(),hc.data()+hc.size());
Kirill Terekhov's avatar
Kirill Terekhov committed
15
		}
Kirill Terekhov's avatar
Kirill Terekhov committed
16
17
		else
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
18
19
20
21
22
			MarkerType hm = m->HideMarker();
			ElementArray<Edge> 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
23
24
25
			return aret;
		}
	}
Kirill Terekhov's avatar
Kirill Terekhov committed
26

Kirill Terekhov's avatar
Kirill Terekhov committed
27
	ElementArray<Edge> Node::getEdges(MarkerType mask, bool invert) const
Kirill Terekhov's avatar
Kirill Terekhov committed
28
	{
Kirill Terekhov's avatar
Kirill Terekhov committed
29
30
31
		assert(GetHandleElementType(GetHandle())==NODE);
		Mesh * m = GetMeshLink();
		ElementArray<Edge> aret(m);
Kirill Terekhov's avatar
Kirill Terekhov committed
32
		adj_type const & hc = m->HighConn(GetHandle());
Kirill Terekhov's avatar
Kirill Terekhov committed
33
		if( !m->HideMarker() )
Kirill Terekhov's avatar
Kirill Terekhov committed
34
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
35
36
37
38
39
40
41
42
43
44
			if( isPrivate(mask) )
			{
				for(adj_type::size_type it = 0; it < hc.size(); ++it)
					if( invert ^ m->GetPrivateMarker(hc[it],mask) ) aret.push_back(hc[it]);
			}
			else
			{
				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
45
46
47
		}
		else
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
48
			MarkerType hm = m->HideMarker();
Kirill Terekhov's avatar
Kirill Terekhov committed
49
50
51
52
53
54
55
56
57
58
			if( isPrivate(mask) )
			{
				for(adj_type::size_type it = 0; it < hc.size(); ++it)
					if( (invert ^ m->GetPrivateMarker(hc[it],mask)) && !m->GetMarker(hc[it],hm) ) aret.push_back(hc[it]);
			}
			else
			{
				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
59
60
61
		}
		return aret;
	}
Kirill Terekhov's avatar
Kirill Terekhov committed
62
	
Kirill Terekhov's avatar
Kirill Terekhov committed
63
	ElementArray<Face> Node::getFaces() const
Kirill Terekhov's avatar
Kirill Terekhov committed
64
	{
Kirill Terekhov's avatar
Kirill Terekhov committed
65
		assert(GetHandleElementType(GetHandle())==NODE);
Kirill Terekhov's avatar
Kirill Terekhov committed
66
		Mesh * m = GetMeshLink();
Kirill Terekhov's avatar
Kirill Terekhov committed
67
		ElementArray<Face> aret(m);
Kirill Terekhov's avatar
Kirill Terekhov committed
68
		MarkerType mrk = m->CreatePrivateMarker();
Kirill Terekhov's avatar
Kirill Terekhov committed
69
		if( !m->HideMarker() )
Kirill Terekhov's avatar
Kirill Terekhov committed
70
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
71
72
			adj_type const & hc = m->HighConn(GetHandle());
			for(adj_type::size_type it = 0; it < hc.size(); it++) //edges
Kirill Terekhov's avatar
Kirill Terekhov committed
73
			{
Kirill Terekhov's avatar
Kirill Terekhov committed
74
75
				adj_type const & ihc = m->HighConn(hc[it]);
				for(adj_type::size_type jt = 0; jt < ihc.size(); jt++) //faces
Kirill Terekhov's avatar
Kirill Terekhov committed
76
					if( !m->GetPrivateMarker(ihc[jt],mrk))
Kirill Terekhov's avatar
Kirill Terekhov committed
77
					{
Kirill Terekhov's avatar
Kirill Terekhov committed
78
						aret.push_back(ihc[jt]);
Kirill Terekhov's avatar
Kirill Terekhov committed
79
						m->SetPrivateMarker(ihc[jt],mrk);
Kirill Terekhov's avatar
Kirill Terekhov committed
80
					}
Kirill Terekhov's avatar
Kirill Terekhov committed
81
			}
Kirill Terekhov's avatar
Kirill Terekhov committed
82
83
84
		}
		else
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
85
86
87
			MarkerType hm = m->HideMarker();
			adj_type const & hc = m->HighConn(GetHandle());
			for(adj_type::size_type it = 0; it < hc.size(); it++) if( !m->GetMarker(hc[it],hm) )//edges
Kirill Terekhov's avatar
Kirill Terekhov committed
88
			{
Kirill Terekhov's avatar
Kirill Terekhov committed
89
90
				adj_type const & ihc = m->HighConn(hc[it]);
				for(adj_type::size_type jt = 0; jt < ihc.size(); jt++) if( !m->GetMarker(ihc[jt],hm) ) //faces
Kirill Terekhov's avatar
Kirill Terekhov committed
91
					if( !m->GetPrivateMarker(ihc[jt],mrk))
Kirill Terekhov's avatar
Kirill Terekhov committed
92
					{
Kirill Terekhov's avatar
Kirill Terekhov committed
93
						aret.push_back(ihc[jt]);
Kirill Terekhov's avatar
Kirill Terekhov committed
94
						m->SetPrivateMarker(ihc[jt],mrk);
Kirill Terekhov's avatar
Kirill Terekhov committed
95
					}
Kirill Terekhov's avatar
Kirill Terekhov committed
96
			}
Kirill Terekhov's avatar
Kirill Terekhov committed
97
		}
98
		aret.RemPrivateMarker(mrk);
Kirill Terekhov's avatar
Kirill Terekhov committed
99
		m->ReleasePrivateMarker(mrk);
Kirill Terekhov's avatar
Kirill Terekhov committed
100
101
		return aret;
	}
Kirill Terekhov's avatar
Kirill Terekhov committed
102

Kirill Terekhov's avatar
Kirill Terekhov committed
103
	ElementArray<Face> Node::getFaces(MarkerType mask, bool invert) const
Kirill Terekhov's avatar
Kirill Terekhov committed
104
	{
Kirill Terekhov's avatar
Kirill Terekhov committed
105
		assert(GetHandleElementType(GetHandle())==NODE);
Kirill Terekhov's avatar
Kirill Terekhov committed
106
		Mesh * m = GetMeshLink();
Kirill Terekhov's avatar
Kirill Terekhov committed
107
		ElementArray<Face> aret(m);
Kirill Terekhov's avatar
Kirill Terekhov committed
108
		MarkerType mrk = m->CreatePrivateMarker();
Kirill Terekhov's avatar
Kirill Terekhov committed
109
		if( isPrivate(mask) )
Kirill Terekhov's avatar
Kirill Terekhov committed
110
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
111
			if( !m->HideMarker() )
Kirill Terekhov's avatar
Kirill Terekhov committed
112
			{
Kirill Terekhov's avatar
Kirill Terekhov committed
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
				adj_type const & hc = m->HighConn(GetHandle());
				for(adj_type::size_type it = 0; it < hc.size(); it++) //edges
				{
					adj_type const & ihc = m->HighConn(hc[it]);
					for(adj_type::size_type jt = 0; jt < ihc.size(); jt++) //faces
						if( (invert ^ m->GetPrivateMarker(ihc[jt],mask)) && !m->GetPrivateMarker(ihc[jt],mrk))
						{
							aret.push_back(ihc[jt]);
							m->SetPrivateMarker(ihc[jt],mrk);
						}
				}
			}
			else
			{
				MarkerType hm = m->HideMarker();
				adj_type const & hc = m->HighConn(GetHandle());
				for(adj_type::size_type it = 0; it < hc.size(); it++) if( !m->GetMarker(hc[it],hm) )//edges
				{
					adj_type const & ihc = m->HighConn(hc[it]);
					for(adj_type::size_type jt = 0; jt < ihc.size(); jt++) if( !m->GetMarker(ihc[jt],hm) ) //faces
						if( (invert ^ m->GetPrivateMarker(ihc[jt],mask)) && !m->GetPrivateMarker(ihc[jt],mrk))
						{
							aret.push_back(ihc[jt]);
							m->SetPrivateMarker(ihc[jt],mrk);
						}
				}
Kirill Terekhov's avatar
Kirill Terekhov committed
139
			}
Kirill Terekhov's avatar
Kirill Terekhov committed
140
141
142
		}
		else
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
143
			if( !m->HideMarker() )
Kirill Terekhov's avatar
Kirill Terekhov committed
144
			{
Kirill Terekhov's avatar
Kirill Terekhov committed
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
				adj_type const & hc = m->HighConn(GetHandle());
				for(adj_type::size_type it = 0; it < hc.size(); it++) //edges
				{
					adj_type const & ihc = m->HighConn(hc[it]);
					for(adj_type::size_type jt = 0; jt < ihc.size(); jt++) //faces
						if( (invert ^ m->GetMarker(ihc[jt],mask)) && !m->GetPrivateMarker(ihc[jt],mrk))
						{
							aret.push_back(ihc[jt]);
							m->SetPrivateMarker(ihc[jt],mrk);
						}
				}
			}
			else
			{
				MarkerType hm = m->HideMarker();
				adj_type const & hc = m->HighConn(GetHandle());
				for(adj_type::size_type it = 0; it < hc.size(); it++) if( !m->GetMarker(hc[it],hm) )//edges
				{
					adj_type const & ihc = m->HighConn(hc[it]);
					for(adj_type::size_type jt = 0; jt < ihc.size(); jt++) if( !m->GetMarker(ihc[jt],hm) ) //faces
						if( (invert ^ m->GetMarker(ihc[jt],mask)) && !m->GetPrivateMarker(ihc[jt],mrk))
						{
							aret.push_back(ihc[jt]);
							m->SetPrivateMarker(ihc[jt],mrk);
						}
				}
Kirill Terekhov's avatar
Kirill Terekhov committed
171
			}
Kirill Terekhov's avatar
Kirill Terekhov committed
172
		}
173
		aret.RemPrivateMarker(mrk);
Kirill Terekhov's avatar
Kirill Terekhov committed
174
		m->ReleasePrivateMarker(mrk);
Kirill Terekhov's avatar
Kirill Terekhov committed
175
176
		return aret;
	}
Kirill Terekhov's avatar
Kirill Terekhov committed
177
	
Kirill Terekhov's avatar
Kirill Terekhov committed
178
	ElementArray<Cell> Node::getCells() const
Kirill Terekhov's avatar
Kirill Terekhov committed
179
	{
Kirill Terekhov's avatar
Kirill Terekhov committed
180
181
		assert(GetHandleElementType(GetHandle())==NODE);
		Mesh * m = GetMeshLink();
182
183
		ElementArray<Cell> aret(m);
		MarkerType mrk = m->CreatePrivateMarker();
Kirill Terekhov's avatar
Kirill Terekhov committed
184
		if( !m->HideMarker() )
Kirill Terekhov's avatar
Kirill Terekhov committed
185
		{
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
			adj_type const & edges = m->HighConn(GetHandle()); // all edges
			for(adj_type::const_iterator eit = edges.begin(); eit != edges.end(); ++eit)
			{
				adj_type const & faces = m->HighConn(*eit); // all faces of the edge
				for(adj_type::const_iterator fit = faces.begin(); fit != faces.end(); ++fit)
				{
					adj_type const & cells = m->HighConn(*fit);
					for(adj_type::const_iterator cit = cells.begin(); cit != cells.end(); ++cit)
					{
						if( !m->GetPrivateMarker(*cit,mrk) )
						{
							aret.push_back(*cit);
							m->SetPrivateMarker(*cit,mrk);
						}
					}
				}
			}
Kirill Terekhov's avatar
Kirill Terekhov committed
203
		}
Kirill Terekhov's avatar
Kirill Terekhov committed
204
205
		else
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
206
			MarkerType hm = m->HideMarker();
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
			adj_type const & edges = m->HighConn(GetHandle()); // all edges
			for(adj_type::const_iterator eit = edges.begin(); eit != edges.end(); ++eit) if( !m->GetMarker(*eit,hm) )
			{
				adj_type const & faces = m->HighConn(*eit); // all faces of the edge
				for(adj_type::const_iterator fit = faces.begin(); fit != faces.end(); ++fit) if( !m->GetMarker(*fit,hm) )
				{
					adj_type const & cells = m->HighConn(*fit);
					for(adj_type::const_iterator cit = cells.begin(); cit != cells.end(); ++cit) if( !m->GetMarker(*cit,hm) )
					{
						if( !m->GetPrivateMarker(*cit,mrk) )
						{
							aret.push_back(*cit);
							m->SetPrivateMarker(*cit,mrk);
						}
					}
				}
			}
Kirill Terekhov's avatar
Kirill Terekhov committed
224
		}
225
226
227
		aret.RemPrivateMarker(mrk);
		m->ReleasePrivateMarker(mrk);
		return aret;
Kirill Terekhov's avatar
Kirill Terekhov committed
228
229
	}

Kirill Terekhov's avatar
Kirill Terekhov committed
230
	ElementArray<Cell> Node::getCells(MarkerType mask, bool invert) const
Kirill Terekhov's avatar
Kirill Terekhov committed
231
	{
Kirill Terekhov's avatar
Kirill Terekhov committed
232
233
234
		assert(GetHandleElementType(GetHandle())==NODE);
		Mesh * m = GetMeshLink();
		ElementArray<Cell> aret(m);
235
		MarkerType mrk = m->CreatePrivateMarker();
Kirill Terekhov's avatar
Kirill Terekhov committed
236
		if( !m->HideMarker() )
Kirill Terekhov's avatar
Kirill Terekhov committed
237
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
238
239
			if( isPrivate(mask) )
			{
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
				adj_type const & edges = m->HighConn(GetHandle()); // all edges
				for(adj_type::const_iterator eit = edges.begin(); eit != edges.end(); ++eit)
				{
					adj_type const & faces = m->HighConn(*eit); // all faces of the edge
					for(adj_type::const_iterator fit = faces.begin(); fit != faces.end(); ++fit)
					{
						adj_type const & cells = m->HighConn(*fit);
						for(adj_type::const_iterator cit = cells.begin(); cit != cells.end(); ++cit)
						{
							if( (invert ^ m->GetPrivateMarker(*cit,mask)) && !m->GetPrivateMarker(*cit,mrk) )
							{
								aret.push_back(*cit);
								m->SetPrivateMarker(*cit,mrk);
							}
						}
					}
				}
Kirill Terekhov's avatar
Kirill Terekhov committed
257
258
259
			}
			else
			{
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
				adj_type const & edges = m->HighConn(GetHandle()); // all edges
				for(adj_type::const_iterator eit = edges.begin(); eit != edges.end(); ++eit)
				{
					adj_type const & faces = m->HighConn(*eit); // all faces of the edge
					for(adj_type::const_iterator fit = faces.begin(); fit != faces.end(); ++fit)
					{
						adj_type const & cells = m->HighConn(*fit);
						for(adj_type::const_iterator cit = cells.begin(); cit != cells.end(); ++cit)
						{
							if( (invert ^ m->GetMarker(*cit,mask)) && !m->GetPrivateMarker(*cit,mrk) )
							{
								aret.push_back(*cit);
								m->SetPrivateMarker(*cit,mrk);
							}
						}
					}
				}
Kirill Terekhov's avatar
Kirill Terekhov committed
277
			}
Kirill Terekhov's avatar
Kirill Terekhov committed
278
279
280
		}
		else
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
281
			MarkerType hm = m->HideMarker();
Kirill Terekhov's avatar
Kirill Terekhov committed
282
283
			if( isPrivate(mask) )
			{
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
				adj_type const & edges = m->HighConn(GetHandle()); // all edges
				for(adj_type::const_iterator eit = edges.begin(); eit != edges.end(); ++eit) if( !m->GetMarker(*eit,hm) )
				{
					adj_type const & faces = m->HighConn(*eit); // all faces of the edge
					for(adj_type::const_iterator fit = faces.begin(); fit != faces.end(); ++fit) if( !m->GetMarker(*fit,hm) )
					{
						adj_type const & cells = m->HighConn(*fit);
						for(adj_type::const_iterator cit = cells.begin(); cit != cells.end(); ++cit) if( !m->GetMarker(*cit,hm) )
						{
							if( (invert ^ m->GetPrivateMarker(*cit,mask)) && !m->GetPrivateMarker(*cit,mrk) )
							{
								aret.push_back(*cit);
								m->SetPrivateMarker(*cit,mrk);
							}
						}
					}
				}
Kirill Terekhov's avatar
Kirill Terekhov committed
301
302
303
			}
			else
			{
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
				adj_type const & edges = m->HighConn(GetHandle()); // all edges
				for(adj_type::const_iterator eit = edges.begin(); eit != edges.end(); ++eit) if( !m->GetMarker(*eit,hm) )
				{
					adj_type const & faces = m->HighConn(*eit); // all faces of the edge
					for(adj_type::const_iterator fit = faces.begin(); fit != faces.end(); ++fit) if( !m->GetMarker(*fit,hm) )
					{
						adj_type const & cells = m->HighConn(*fit);
						for(adj_type::const_iterator cit = cells.begin(); cit != cells.end(); ++cit) if( !m->GetMarker(*cit,hm) )
						{
							if( (invert ^ m->GetMarker(*cit,mask)) && !m->GetPrivateMarker(*cit,mrk) )
							{
								aret.push_back(*cit);
								m->SetPrivateMarker(*cit,mrk);
							}
						}
					}
				}
Kirill Terekhov's avatar
Kirill Terekhov committed
321
			}
Kirill Terekhov's avatar
Kirill Terekhov committed
322
		}
323
324
		aret.RemPrivateMarker(mrk);
		m->ReleasePrivateMarker(mrk);
Kirill Terekhov's avatar
Kirill Terekhov committed
325
326
327
		return aret;
	}

Kirill Terekhov's avatar
Kirill Terekhov committed
328
	Storage::real_array Node::Coords() const {return GetMeshLink()->RealArrayDF(GetHandle(),GetMeshLink()->CoordsTag());}
Kirill Terekhov's avatar
Kirill Terekhov committed
329
330
331
}

#endif