node.cpp 4.67 KB
Newer Older
Kirill Terekhov's avatar
Kirill Terekhov committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
#include "inmost.h"
#if defined(USE_MESH)
namespace INMOST
{

	Node::Node(Mesh * m) :Element(m,NODE)
	{
	}
	
	Node::Node(Mesh * m, INMOST_DATA_ENUM_TYPE lid, const Node & other) :Element(m,lid,other){}

	Node::Node(const Node & other) :Element(other){}

	
	Node & Node::operator =(Node const & other)
	{
		Element::operator =(other);
		return *this;
	}
	
	Node::~Node()
	{
		
	}
	
	adjacent<Edge> Node::getEdges()
	{
		if( !GetMeshLink()->HideMarker() )
Kirill Terekhov's avatar
Kirill Terekhov committed
29 30 31 32
		{
			adj_type const & hc = HighConn();
			return adjacent<Edge>(hc.data(),hc.data()+hc.size());
		}
Kirill Terekhov's avatar
Kirill Terekhov committed
33 34
		else
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
35
			MarkerType hm = GetMeshLink()->HideMarker();
Kirill Terekhov's avatar
Kirill Terekhov committed
36
			adjacent<Edge> aret;
Kirill Terekhov's avatar
Kirill Terekhov committed
37 38 39
			adj_type const & hc = HighConn();
			for(adj_type::enumerator it = 0; it < hc.size(); ++it)
				if( !hc[it]->GetMarker(hm) ) aret.push_back(hc[it]);
Kirill Terekhov's avatar
Kirill Terekhov committed
40 41 42
			return aret;
		}
	}
Kirill Terekhov's avatar
Kirill Terekhov committed
43

Kirill Terekhov's avatar
Kirill Terekhov committed
44
	adjacent<Edge> Node::getEdges(MarkerType mask, bool invert)
Kirill Terekhov's avatar
Kirill Terekhov committed
45 46 47 48
	{
		adjacent<Edge> aret;
		if( !GetMeshLink()->HideMarker() )
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
49 50 51
			adj_type const & hc = HighConn();
			for(adj_type::enumerator it = 0; it < hc.size(); ++it)
				if( invert ^ hc[it]->GetMarker(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
			MarkerType hm = GetMeshLink()->HideMarker();
			adj_type const & hc = HighConn();
			for(adj_type::enumerator it = 0; it < hc.size(); ++it)
				if( (invert ^ hc[it]->GetMarker(mask)) && !hc[it]->GetMarker(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 63 64 65 66
	
	adjacent<Face> Node::getFaces()
	{
		adjacent<Face> aret;
		Mesh * m = GetMeshLink();
Kirill Terekhov's avatar
Kirill Terekhov committed
67
		MarkerType mrk = m->CreateMarker();
Kirill Terekhov's avatar
Kirill Terekhov committed
68 69
		if( !GetMeshLink()->HideMarker() )
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
70 71 72 73 74 75
			adj_type const & hc = HighConn();
			for(adj_type::enumerator it = 0; it < hc.size(); it++) //edges
			{
				adj_type const & ihc = hc[it]->HighConn();
				for(adj_type::enumerator jt = 0; jt < ihc.size(); jt++) //faces
					if( !ihc[jt]->GetMarker(mrk))
Kirill Terekhov's avatar
Kirill Terekhov committed
76
					{
Kirill Terekhov's avatar
Kirill Terekhov committed
77 78
						aret.push_back(ihc[jt]);
						ihc[jt]->SetMarker(mrk);
Kirill Terekhov's avatar
Kirill Terekhov committed
79
					}
Kirill Terekhov's avatar
Kirill Terekhov committed
80
			}
Kirill Terekhov's avatar
Kirill Terekhov committed
81 82 83
		}
		else
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
84 85 86 87 88 89 90
			MarkerType hm = GetMeshLink()->HideMarker();
			adj_type const & hc = HighConn();
			for(adj_type::enumerator it = 0; it < hc.size(); it++) if( !hc[it]->GetMarker(hm) )//edges
			{
				adj_type const & ihc = hc[it]->HighConn();
				for(adj_type::enumerator jt = 0; jt < ihc.size(); jt++) if( !ihc[jt]->GetMarker(hm) ) //faces
					if( !ihc[jt]->GetMarker(mrk))
Kirill Terekhov's avatar
Kirill Terekhov committed
91
					{
Kirill Terekhov's avatar
Kirill Terekhov committed
92 93
						aret.push_back(ihc[jt]);
						ihc[jt]->SetMarker(mrk);
Kirill Terekhov's avatar
Kirill Terekhov committed
94
					}
Kirill Terekhov's avatar
Kirill Terekhov committed
95
			}
Kirill Terekhov's avatar
Kirill Terekhov committed
96
		}
Kirill Terekhov's avatar
Kirill Terekhov committed
97
		for(adjacent<Face>::enumerator it = 0; it < aret.size(); it++) aret[it].RemMarker(mrk);
Kirill Terekhov's avatar
Kirill Terekhov committed
98 99 100
		m->ReleaseMarker(mrk);
		return aret;
	}
Kirill Terekhov's avatar
Kirill Terekhov committed
101

Kirill Terekhov's avatar
Kirill Terekhov committed
102
	adjacent<Face> Node::getFaces(MarkerType mask, bool invert)
Kirill Terekhov's avatar
Kirill Terekhov committed
103 104 105
	{
		adjacent<Face> aret;
		Mesh * m = GetMeshLink();
Kirill Terekhov's avatar
Kirill Terekhov committed
106
		MarkerType mrk = m->CreateMarker();
Kirill Terekhov's avatar
Kirill Terekhov committed
107 108
		if( !GetMeshLink()->HideMarker() )
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
109 110 111 112 113 114
			adj_type const & hc = HighConn();
			for(adj_type::enumerator it = 0; it < hc.size(); it++) //edges
			{
				adj_type const & ihc = hc[it]->HighConn();
				for(adj_type::enumerator jt = 0; jt < ihc.size(); jt++) //faces
					if( (invert ^ ihc[jt]->GetMarker(mask)) && !ihc[jt]->GetMarker(mrk))
Kirill Terekhov's avatar
Kirill Terekhov committed
115
					{
Kirill Terekhov's avatar
Kirill Terekhov committed
116 117
						aret.push_back(ihc[jt]);
						ihc[jt]->SetMarker(mrk);
Kirill Terekhov's avatar
Kirill Terekhov committed
118
					}
Kirill Terekhov's avatar
Kirill Terekhov committed
119
			}
Kirill Terekhov's avatar
Kirill Terekhov committed
120 121 122
		}
		else
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
123 124 125 126 127 128 129
			MarkerType hm = GetMeshLink()->HideMarker();
			adj_type const & hc = HighConn();
			for(adj_type::enumerator it = 0; it < hc.size(); it++) if( !hc[it]->GetMarker(hm) )//edges
			{
				adj_type const & ihc = hc[it]->HighConn();
				for(adj_type::enumerator jt = 0; jt < ihc.size(); jt++) if( !ihc[jt]->GetMarker(hm) ) //faces
					if( (invert ^ ihc[jt]->GetMarker(mask)) && !ihc[jt]->GetMarker(mrk))
Kirill Terekhov's avatar
Kirill Terekhov committed
130
					{
Kirill Terekhov's avatar
Kirill Terekhov committed
131 132
						aret.push_back(ihc[jt]);
						ihc[jt]->SetMarker(mrk);
Kirill Terekhov's avatar
Kirill Terekhov committed
133
					}
Kirill Terekhov's avatar
Kirill Terekhov committed
134
			}
Kirill Terekhov's avatar
Kirill Terekhov committed
135
		}
Kirill Terekhov's avatar
Kirill Terekhov committed
136
		for(adjacent<Face>::enumerator it = 0; it < aret.size(); it++) aret[it].RemMarker(mrk);
Kirill Terekhov's avatar
Kirill Terekhov committed
137 138 139
		m->ReleaseMarker(mrk);
		return aret;
	}
Kirill Terekhov's avatar
Kirill Terekhov committed
140 141 142 143
	
	adjacent<Cell> Node::getCells()
	{
		if( !GetMeshLink()->HideMarker() )
Kirill Terekhov's avatar
Kirill Terekhov committed
144 145 146 147
		{
			adj_type const & lc = LowConn();
			return adjacent<Cell>(lc.data(),lc.data()+lc.size());
		}
Kirill Terekhov's avatar
Kirill Terekhov committed
148 149
		else
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
150
			MarkerType hm = GetMeshLink()->HideMarker();
Kirill Terekhov's avatar
Kirill Terekhov committed
151
			adjacent<Cell> aret;
Kirill Terekhov's avatar
Kirill Terekhov committed
152 153 154
			adj_type const & lc = LowConn();
			for(adj_type::enumerator it = 0; it < lc.size(); ++it)
				if( !lc[it]->GetMarker(hm) ) aret.push_back(lc[it]);
Kirill Terekhov's avatar
Kirill Terekhov committed
155 156 157 158
			return aret;
		}
	}

Kirill Terekhov's avatar
Kirill Terekhov committed
159
	adjacent<Cell> Node::getCells(MarkerType mask, bool invert)
Kirill Terekhov's avatar
Kirill Terekhov committed
160 161 162 163
	{
		adjacent<Cell> aret;
		if( !GetMeshLink()->HideMarker() )
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
164 165 166
			adj_type const & lc = LowConn();
			for(adj_type::enumerator it = 0; it < lc.size(); ++it)
				if( invert ^ lc[it]->GetMarker(mask) ) aret.push_back(lc[it]);
Kirill Terekhov's avatar
Kirill Terekhov committed
167 168 169
		}
		else
		{
Kirill Terekhov's avatar
Kirill Terekhov committed
170 171 172 173
			MarkerType hm = GetMeshLink()->HideMarker();
			adj_type const & lc = LowConn();
			for(adj_type::enumerator it = 0; it < lc.size(); ++it)
				if( (invert ^ lc[it]->GetMarker(mask)) && !lc[it]->GetMarker(hm) ) aret.push_back(lc[it]);
Kirill Terekhov's avatar
Kirill Terekhov committed
174 175 176 177
		}
		return aret;
	}

Kirill Terekhov's avatar
Kirill Terekhov committed
178 179 180 181
	Storage::real_array Node::Coords() {return RealArrayDF(GetMeshLink()->CoordsTag());}
}

#endif