node.cpp 4.99 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 32
		assert(GetHandleElementType(GetHandle())==NODE);
		Mesh * m = GetMeshLink();
		ElementArray<Edge> aret(m);
		if( !m->HideMarker() )
Kirill Terekhov's avatar
Kirill Terekhov committed
33
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
34 35 36
			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
37 38 39
		}
		else
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
40 41 42 43
			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
44 45 46
		}
		return aret;
	}
Kirill Terekhov's avatar
Kirill Terekhov committed
47
	
Kirill Terekhov's avatar
Kirill Terekhov committed
48
	ElementArray<Face> Node::getFaces() const
Kirill Terekhov's avatar
Kirill Terekhov committed
49
	{
Kirill Terekhov's avatar
Kirill Terekhov committed
50
		assert(GetHandleElementType(GetHandle())==NODE);
Kirill Terekhov's avatar
Kirill Terekhov committed
51
		Mesh * m = GetMeshLink();
Kirill Terekhov's avatar
Kirill Terekhov committed
52
		ElementArray<Face> aret(m);
Kirill Terekhov's avatar
Kirill Terekhov committed
53
		MarkerType mrk = m->CreateMarker();
Kirill Terekhov's avatar
Kirill Terekhov committed
54
		if( !m->HideMarker() )
Kirill Terekhov's avatar
Kirill Terekhov committed
55
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
56 57
			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
58
			{
Kirill Terekhov's avatar
Kirill Terekhov committed
59 60 61
				adj_type const & ihc = m->HighConn(hc[it]);
				for(adj_type::size_type jt = 0; jt < ihc.size(); jt++) //faces
					if( !m->GetMarker(ihc[jt],mrk))
Kirill Terekhov's avatar
Kirill Terekhov committed
62
					{
Kirill Terekhov's avatar
Kirill Terekhov committed
63
						aret.push_back(ihc[jt]);
Kirill Terekhov's avatar
Kirill Terekhov committed
64
						m->SetMarker(ihc[jt],mrk);
Kirill Terekhov's avatar
Kirill Terekhov committed
65
					}
Kirill Terekhov's avatar
Kirill Terekhov committed
66
			}
Kirill Terekhov's avatar
Kirill Terekhov committed
67 68 69
		}
		else
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
70 71 72
			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
73
			{
Kirill Terekhov's avatar
Kirill Terekhov committed
74 75 76
				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( !m->GetMarker(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->SetMarker(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
		}
Kirill Terekhov's avatar
Kirill Terekhov committed
83
		for(ElementArray<Face>::size_type it = 0; it < aret.size(); it++) m->RemMarker(aret.at(it),mrk);
Kirill Terekhov's avatar
Kirill Terekhov committed
84 85 86
		m->ReleaseMarker(mrk);
		return aret;
	}
Kirill Terekhov's avatar
Kirill Terekhov committed
87

Kirill Terekhov's avatar
Kirill Terekhov committed
88
	ElementArray<Face> Node::getFaces(MarkerType mask, bool invert) const
Kirill Terekhov's avatar
Kirill Terekhov committed
89
	{
Kirill Terekhov's avatar
Kirill Terekhov committed
90
		assert(GetHandleElementType(GetHandle())==NODE);
Kirill Terekhov's avatar
Kirill Terekhov committed
91
		Mesh * m = GetMeshLink();
Kirill Terekhov's avatar
Kirill Terekhov committed
92
		ElementArray<Face> aret(m);
Kirill Terekhov's avatar
Kirill Terekhov committed
93
		MarkerType mrk = m->CreateMarker();
Kirill Terekhov's avatar
Kirill Terekhov committed
94
		if( !m->HideMarker() )
Kirill Terekhov's avatar
Kirill Terekhov committed
95
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
96 97
			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
98
			{
Kirill Terekhov's avatar
Kirill Terekhov committed
99 100 101
				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->GetMarker(ihc[jt],mrk))
Kirill Terekhov's avatar
Kirill Terekhov committed
102
					{
Kirill Terekhov's avatar
Kirill Terekhov committed
103
						aret.push_back(ihc[jt]);
Kirill Terekhov's avatar
Kirill Terekhov committed
104
						m->SetMarker(ihc[jt],mrk);
Kirill Terekhov's avatar
Kirill Terekhov committed
105
					}
Kirill Terekhov's avatar
Kirill Terekhov committed
106
			}
Kirill Terekhov's avatar
Kirill Terekhov committed
107 108 109
		}
		else
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
110 111 112
			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
113
			{
Kirill Terekhov's avatar
Kirill Terekhov committed
114 115 116
				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->GetMarker(ihc[jt],mrk))
Kirill Terekhov's avatar
Kirill Terekhov committed
117
					{
Kirill Terekhov's avatar
Kirill Terekhov committed
118
						aret.push_back(ihc[jt]);
Kirill Terekhov's avatar
Kirill Terekhov committed
119
						m->SetMarker(ihc[jt],mrk);
Kirill Terekhov's avatar
Kirill Terekhov committed
120
					}
Kirill Terekhov's avatar
Kirill Terekhov committed
121
			}
Kirill Terekhov's avatar
Kirill Terekhov committed
122
		}
Kirill Terekhov's avatar
Kirill Terekhov committed
123
		for(ElementArray<Face>::size_type it = 0; it < aret.size(); it++) m->RemMarker(aret.at(it),mrk);
Kirill Terekhov's avatar
Kirill Terekhov committed
124 125 126
		m->ReleaseMarker(mrk);
		return aret;
	}
Kirill Terekhov's avatar
Kirill Terekhov committed
127
	
Kirill Terekhov's avatar
Kirill Terekhov committed
128
	ElementArray<Cell> Node::getCells() const
Kirill Terekhov's avatar
Kirill Terekhov committed
129
	{
Kirill Terekhov's avatar
Kirill Terekhov committed
130 131 132
		assert(GetHandleElementType(GetHandle())==NODE);
		Mesh * m = GetMeshLink();
		if( !m->HideMarker() )
Kirill Terekhov's avatar
Kirill Terekhov committed
133
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
134 135
			adj_type const & lc = m->LowConn(GetHandle());
			return ElementArray<Cell>(m,lc.data(),lc.data()+lc.size());
Kirill Terekhov's avatar
Kirill Terekhov committed
136
		}
Kirill Terekhov's avatar
Kirill Terekhov committed
137 138
		else
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
139 140 141 142 143
			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
144 145 146 147
			return aret;
		}
	}

Kirill Terekhov's avatar
Kirill Terekhov committed
148
	ElementArray<Cell> Node::getCells(MarkerType mask, bool invert) const
Kirill Terekhov's avatar
Kirill Terekhov committed
149
	{
Kirill Terekhov's avatar
Kirill Terekhov committed
150 151 152 153
		assert(GetHandleElementType(GetHandle())==NODE);
		Mesh * m = GetMeshLink();
		ElementArray<Cell> aret(m);
		if( !m->HideMarker() )
Kirill Terekhov's avatar
Kirill Terekhov committed
154
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
155 156 157
			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
158 159 160
		}
		else
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
161 162 163 164
			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
165 166 167 168
		}
		return aret;
	}

Kirill Terekhov's avatar
Kirill Terekhov committed
169
	Storage::real_array Node::Coords() const {return GetMeshLink()->RealArrayDF(GetHandle(),GetMeshLink()->CoordsTag());}
Kirill Terekhov's avatar
Kirill Terekhov committed
170 171 172
}

#endif