#include "Face.h"
#include <algorithm>
#include <iostream>

Face::Face(std::vector<int> n , int o)
{
	node_ids = n;
	owner_id = o;
	neighbour_id = 0;
}

Face::~Face()
{

}

Face::Face(const Face& f1) 
{ 
	node_ids = f1.node_ids; 
	owner_id = f1.owner_id;
	neighbour_id = f1.neighbour_id;
	boundary_name = f1.boundary_name;
	hash = f1.hash;
}

Face& Face::operator=(const Face& f1) 
{
	node_ids = f1.node_ids;
	owner_id = f1.owner_id;
	neighbour_id = f1.neighbour_id;
	boundary_name = f1.boundary_name;
	hash = f1.hash;
	return *this;
}

std::vector<int> Face::getPoints()
{
	return node_ids;
}

void Face::setNeighbour(int n)
{
	neighbour_id = n;
}

int Face::getOwner() const
{
	return owner_id;
}

int Face::getNeighbour() const
{
	return neighbour_id;
}

bool Face::isBoundaryFace()
{
	return (neighbour_id == 0);
}

void Face::setBoundary(std::string n)
{
	boundary_name = n;
}

std::string Face::getBoundary()
{
	return boundary_name;
}

bool operator== (const Face& f1, const Face& f2)
{
	return std::is_permutation(f1.node_ids.begin(), f1.node_ids.end(), f2.node_ids.begin());
}

bool operator!= (const Face& f1, const Face& f2)
{
	if (f1.hash == f2.hash)
		return false;
	else
        return !std::is_permutation(f1.node_ids.begin(), f1.node_ids.end(), f2.node_ids.begin());
}