node.cpp 4.26 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 29 30 31 32 33 34 35 36 37 38
#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() )
			return adjacent<Edge>(high_conn.begin(),high_conn.end());
		else
		{
			MIDType hm = GetMeshLink()->HideMarker();
			adjacent<Edge> aret;
			for(adj_iterator it = high_conn.begin(); it != high_conn.end(); ++it)
				if( !(*it)->GetMarker(hm) ) aret.push_back((*it));
			return aret;
		}
	}
Kirill Terekhov's avatar
Kirill Terekhov committed
39

Kirill Terekhov's avatar
Kirill Terekhov committed
40
	adjacent<Edge> Node::getEdges(MIDType mask, bool invert)
Kirill Terekhov's avatar
Kirill Terekhov committed
41 42 43 44 45
	{
		adjacent<Edge> aret;
		if( !GetMeshLink()->HideMarker() )
		{
			for(adj_iterator it = high_conn.begin(); it != high_conn.end(); ++it)
Kirill Terekhov's avatar
Kirill Terekhov committed
46
				if( invert ^ (*it)->GetMarker(mask) ) aret.push_back((*it));
Kirill Terekhov's avatar
Kirill Terekhov committed
47 48 49 50 51
		}
		else
		{
			MIDType hm = GetMeshLink()->HideMarker();
			for(adj_iterator it = high_conn.begin(); it != high_conn.end(); ++it)
Kirill Terekhov's avatar
Kirill Terekhov committed
52
				if( (invert ^ (*it)->GetMarker(mask)) && !(*it)->GetMarker(hm) ) aret.push_back((*it));
Kirill Terekhov's avatar
Kirill Terekhov committed
53 54 55
		}
		return aret;
	}
Kirill Terekhov's avatar
Kirill Terekhov committed
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
	
	adjacent<Face> Node::getFaces()
	{
		adjacent<Face> aret;
		Mesh * m = GetMeshLink();
		MIDType mrk = m->CreateMarker();
		if( !GetMeshLink()->HideMarker() )
		{
			for(Element::adj_iterator it = high_conn.begin(); it != high_conn.end(); it++) //edges
				for(Element::adj_iterator jt = (*it)->high_conn.begin(); jt != (*it)->high_conn.end(); jt++) //faces
					if( !(*jt)->GetMarker(mrk))
					{
						aret.push_back(*jt);
						(*jt)->SetMarker(mrk);
					}
		}
		else
		{
			MIDType hm = GetMeshLink()->HideMarker();
			for(Element::adj_iterator it = high_conn.begin(); it != high_conn.end(); it++) if( !(*it)->GetMarker(hm) )//edges
				for(Element::adj_iterator jt = (*it)->high_conn.begin(); jt != (*it)->high_conn.end(); jt++) if( !(*jt)->GetMarker(hm) ) //faces
					if( !(*jt)->GetMarker(mrk))
					{
						aret.push_back(*jt);
						(*jt)->SetMarker(mrk);
					}
		}
		for(adjacent<Face>::iterator it = aret.begin(); it != aret.end(); it++)
			it->RemMarker(mrk);
		m->ReleaseMarker(mrk);
		return aret;
	}
Kirill Terekhov's avatar
Kirill Terekhov committed
88

Kirill Terekhov's avatar
Kirill Terekhov committed
89
	adjacent<Face> Node::getFaces(MIDType mask, bool invert)
Kirill Terekhov's avatar
Kirill Terekhov committed
90 91 92 93 94 95 96 97
	{
		adjacent<Face> aret;
		Mesh * m = GetMeshLink();
		MIDType mrk = m->CreateMarker();
		if( !GetMeshLink()->HideMarker() )
		{
			for(Element::adj_iterator it = high_conn.begin(); it != high_conn.end(); it++) //edges
				for(Element::adj_iterator jt = (*it)->high_conn.begin(); jt != (*it)->high_conn.end(); jt++) //faces
Kirill Terekhov's avatar
Kirill Terekhov committed
98
					if( (invert ^ (*jt)->GetMarker(mask)) && !(*jt)->GetMarker(mrk))
Kirill Terekhov's avatar
Kirill Terekhov committed
99 100 101 102 103 104 105 106 107 108
					{
						aret.push_back(*jt);
						(*jt)->SetMarker(mrk);
					}
		}
		else
		{
			MIDType hm = GetMeshLink()->HideMarker();
			for(Element::adj_iterator it = high_conn.begin(); it != high_conn.end(); it++) if( !(*it)->GetMarker(hm) )//edges
				for(Element::adj_iterator jt = (*it)->high_conn.begin(); jt != (*it)->high_conn.end(); jt++) if( !(*jt)->GetMarker(hm) ) //faces
Kirill Terekhov's avatar
Kirill Terekhov committed
109
					if( (invert ^ (*jt)->GetMarker(mask)) && !(*jt)->GetMarker(mrk))
Kirill Terekhov's avatar
Kirill Terekhov committed
110 111 112 113 114 115 116 117 118 119
					{
						aret.push_back(*jt);
						(*jt)->SetMarker(mrk);
					}
		}
		for(adjacent<Face>::iterator it = aret.begin(); it != aret.end(); it++)
			it->RemMarker(mrk);
		m->ReleaseMarker(mrk);
		return aret;
	}
Kirill Terekhov's avatar
Kirill Terekhov committed
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
	
	adjacent<Cell> Node::getCells()
	{
		if( !GetMeshLink()->HideMarker() )
			return adjacent<Cell>(low_conn.begin(),low_conn.end());
		else
		{
			MIDType hm = GetMeshLink()->HideMarker();
			adjacent<Cell> aret;
			for(adj_iterator it = low_conn.begin(); it != low_conn.end(); ++it)
				if( !(*it)->GetMarker(hm) ) aret.push_back((*it));
			return aret;
		}
	}

Kirill Terekhov's avatar
Kirill Terekhov committed
135
	adjacent<Cell> Node::getCells(MIDType mask, bool invert)
Kirill Terekhov's avatar
Kirill Terekhov committed
136 137 138 139 140
	{
		adjacent<Cell> aret;
		if( !GetMeshLink()->HideMarker() )
		{
			for(adj_iterator it = low_conn.begin(); it != low_conn.end(); ++it)
Kirill Terekhov's avatar
Kirill Terekhov committed
141
				if( invert ^ (*it)->GetMarker(mask) ) aret.push_back((*it));
Kirill Terekhov's avatar
Kirill Terekhov committed
142 143 144 145 146
		}
		else
		{
			MIDType hm = GetMeshLink()->HideMarker();
			for(adj_iterator it = low_conn.begin(); it != low_conn.end(); ++it)
Kirill Terekhov's avatar
Kirill Terekhov committed
147
				if( (invert ^ (*it)->GetMarker(mask)) && !(*it)->GetMarker(hm) ) aret.push_back((*it));
Kirill Terekhov's avatar
Kirill Terekhov committed
148 149 150 151
		}
		return aret;
	}

Kirill Terekhov's avatar
Kirill Terekhov committed
152 153 154 155
	Storage::real_array Node::Coords() {return RealArrayDF(GetMeshLink()->CoordsTag());}
}

#endif