#include <cstdio>
#include <cstring>
#include <cmath>
#include <ctime>

#include "AdjacentTriangle.h"
#include "Mesh.h"

namespace bamg {


	/*Constructors/Destructors*/
	//See header file

	/*Methods*/
	/*FUNCTION AdjacentTriangle::Locked {{{*/
	int  AdjacentTriangle::Locked() const {
		return t->AdjEdgeIndex[a] & 4;
	}
	/*}}}*/
	/*FUNCTION AdjacentTriangle::MarkUnSwap {{{*/
	int  AdjacentTriangle::MarkUnSwap() const {
		return t->AdjEdgeIndex[a] & 8;
	}
	/*}}}*/
	/*FUNCTION AdjacentTriangle::GetAllFlag_UnSwap {{{*/
	int  AdjacentTriangle::GetAllFlag_UnSwap() const {
		// take all flag except MarkUnSwap
		return t->AdjEdgeIndex[a] & 1012;
	}
	/*}}}*/
	/*FUNCTION AdjacentTriangle::SetLock {{{*/
	void AdjacentTriangle::SetLock(){
		t->SetLocked(a);
	}
	/*}}}*/
	/*FUNCTION AdjacentTriangle::Adj {{{*/
	AdjacentTriangle AdjacentTriangle::Adj() const {
		return  t->Adj(a);
	}
	/*}}}*/
	/*FUNCTION AdjacentTriangle::EdgeVertex {{{*/
	BamgVertex* AdjacentTriangle::EdgeVertex(const int & i) const {
		return t->vertices[VerticesOfTriangularEdge[a][i]];
	}
	/*}}}*/
	/*FUNCTION AdjacentTriangle::OppositeVertex {{{*/
	BamgVertex* AdjacentTriangle::OppositeVertex() const {
		return t->vertices[bamg::OppositeVertex[a]]; 
	}
	/*}}}*/
	/*FUNCTION AdjacentTriangle::det {{{*/
	Icoor2 & AdjacentTriangle::det() const {
		return t->det;
	}
	/*}}}*/
	/*FUNCTION AdjacentTriangle::swap {{{*/
	int AdjacentTriangle::swap(){
		return  t->swap(a);
	}
	/*}}}*/
	/*FUNCTION AdjacentTriangle::SetAdj2 {{{*/
	void AdjacentTriangle::SetAdj2(const AdjacentTriangle & ta, int l  ){
		//set Adjacent Triangle of a triangle
		if(t) {
			t->adj[a]=ta.t;
			t->AdjEdgeIndex[a]=ta.a|l;
		}
		if(ta.t) {
			ta.t->adj[ta.a] = t ;
			ta.t->AdjEdgeIndex[ta.a] = a| l ;
		}
	}
	/*}}}*/

} 
