/*
 * node.cpp
 *
 *  Created on: May 10, 2017
 *      Author: vadims
 */

#include <vector>
#include <algorithm>
#include "Node.hpp"

Node::Node(int nodeId, double xCoord, double yCoord, double zCoord)
{
	id = nodeId;
	xCoordinate = xCoord;
	yCoordinate = yCoord;
	zCoordinate = zCoord;
	is_midside = false;
}

Node::Node(const Node& that)
{
	xCoordinate = that.xCoordinate;
	yCoordinate = that.yCoordinate;
	zCoordinate = that.zCoordinate;
	id = that.id;
	ownerElements = that.ownerElements;
	is_midside = that.is_midside;
}

bool Node::operator==(const Node& rhs) const 
{ 
	return this->id == rhs.id; 
}

bool Node::operator!=(const Node& rhs) const 
{ 
	return this->id != rhs.id; 
}

bool Node::operator < (const Node& rhs) const
{
	return (id < rhs.id);
}

int Node::getId()
{
	return id;
}

double Node::x()
{ 
	return xCoordinate; 
}

double Node::y()
{ 
	return yCoordinate; 
}

double Node::z()
{ 
	return zCoordinate; 
}

std::vector<double> Node::getCoordinates()
{
	return { xCoordinate , yCoordinate, zCoordinate };
}

void Node::addOwnerElement(std::shared_ptr<Element> el)
{
	ownerElements.push_back(el);
}

std::vector<std::shared_ptr<Element>> Node::getOwnerElements()
{
	return std::vector<std::shared_ptr<Element>>(ownerElements.begin(), ownerElements.end());
}

bool Node::isMidsideNode()
{
	return is_midside;
}

void Node::setMidside(bool b)
{
	is_midside = b;
}

