node.cpp 6.84 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
		}
Kirill Terekhov's avatar
Kirill Terekhov committed
98 99
		for(ElementArray<Face>::size_type it = 0; it < aret.size(); it++) m->RemPrivateMarker(aret.at(it),mrk);
		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
		}
Kirill Terekhov's avatar
Kirill Terekhov committed
173
		for(ElementArray<Face>::size_type it = 0; it < aret.size(); it++) m->RemMarker(aret.at(it),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 182
		assert(GetHandleElementType(GetHandle())==NODE);
		Mesh * m = GetMeshLink();
		if( !m->HideMarker() )
Kirill Terekhov's avatar
Kirill Terekhov committed
183
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
184 185
			adj_type const & lc = m->LowConn(GetHandle());
			return ElementArray<Cell>(m,lc.data(),lc.data()+lc.size());
Kirill Terekhov's avatar
Kirill Terekhov committed
186
		}
Kirill Terekhov's avatar
Kirill Terekhov committed
187 188
		else
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
189 190 191 192 193
			MarkerType hm = m->HideMarker();
			ElementArray<Cell> aret(m);
			adj_type const & 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
194 195 196 197
			return aret;
		}
	}

Kirill Terekhov's avatar
Kirill Terekhov committed
198
	ElementArray<Cell> Node::getCells(MarkerType mask, bool invert) const
Kirill Terekhov's avatar
Kirill Terekhov committed
199
	{
Kirill Terekhov's avatar
Kirill Terekhov committed
200 201 202
		assert(GetHandleElementType(GetHandle())==NODE);
		Mesh * m = GetMeshLink();
		ElementArray<Cell> aret(m);
Kirill Terekhov's avatar
Kirill Terekhov committed
203
		adj_type const & lc = m->LowConn(GetHandle());
Kirill Terekhov's avatar
Kirill Terekhov committed
204
		if( !m->HideMarker() )
Kirill Terekhov's avatar
Kirill Terekhov committed
205
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
206 207 208 209 210 211 212 213 214 215
			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
216 217 218
		}
		else
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
219
			MarkerType hm = m->HideMarker();
Kirill Terekhov's avatar
Kirill Terekhov committed
220 221 222 223 224 225 226 227 228 229
			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
230 231 232 233
		}
		return aret;
	}

Kirill Terekhov's avatar
Kirill Terekhov committed
234
	Storage::real_array Node::Coords() const {return GetMeshLink()->RealArrayDF(GetHandle(),GetMeshLink()->CoordsTag());}
Kirill Terekhov's avatar
Kirill Terekhov committed
235 236 237
}

#endif