#include"Mesh_Base.h"

int Mesh_2D::GetNbrVertex()
{
	return _mNbrVertex;
}
void Mesh_2D::GetVertex(int num, Eigen::Vector3d &vertex)
{
	vertex(0) = _mVertex(num, 0);
	vertex(1) = _mVertex(num, 1);
	vertex(2) = _mVertex(num, 2);
}

int Mesh_2D::GetNbrEdge()
{
	return _mNbrEdge;
}
int Mesh_2D::GetEdge(int numEdge, int numVertex)
{
	return _mEdge(numEdge, numVertex);
}

int Mesh_2D::GetNbrTri()
{
	return _mNbrTri;
}
int Mesh_2D::GetTri(int numTri, int numVertex)
{
	return _mTri(numTri, numVertex);
}
int Mesh_2D::GetEdgeOfTri(int numTri, int numEdge)
{
	return _mEdgeOfTri(numTri, numEdge);
}
int Mesh_2D::GetDomainOfTri(int numTri)
{
	return _mDomainOfTri(numTri);
}

int Mesh_2D::GetNbrEdges()
{
	return _mNbrEdges;
}
void Mesh_2D::GetCoonOfEdges(int numEdges, Eigen::Vector2i& coonOfEdges)
{
	coonOfEdges(0) = _mCoonOfEdges(numEdges, 0);
	coonOfEdges(1) = _mCoonOfEdges(numEdges, 1);
}
void Mesh_2D::GetNormOfEdges(int numEdgs, Eigen::Vector3d& normOfEdges)
{
	normOfEdges(0) = _mNormOfEdges(numEdgs, 0);
	normOfEdges(1) = _mNormOfEdges(numEdgs, 1);
	normOfEdges(2) = _mNormOfEdges(numEdgs, 2);
}
int Mesh_2D::GetDomainOfEdges(int numEdges)
{
	return _mDomainOfEdges(numEdges);
}

int Mesh_3D::GetNbrVertex()
{
	return _mNbrVertex;
}
void Mesh_3D::GetVertex(int num, Eigen::Vector3d& vertex)
{
	vertex(0) = _mVertex(num, 0);
	vertex(1) = _mVertex(num, 1);
	vertex(2) = _mVertex(num, 2);
}

int Mesh_3D::GetNbrEdge()
{
	return _mNbrEdge;
}
int Mesh_3D::GetEdge(int numEdge, int numVertex)
{
	return _mEdge(numEdge, numVertex);
}

int Mesh_3D::GetNbrFace()
{
	return _mNbrFace;
}

int Mesh_3D::GetFace(int numFace, int numVertex)
{
	return _mFace(numFace, numVertex);
}

int Mesh_3D::GetFaceOfTet(int numTet, int numFace)
{
	return _mFaceOfTet(numTet, numFace);
}

int Mesh_3D::GetNbrTet()
{
	return _mNbrTet;
}
int Mesh_3D::GetTet(int numTet, int numVertex)
{
	return _mTet(numTet, numVertex);
}
int Mesh_3D::GetEdgeOfTet(int numTet, int numEdge)
{
	return _mEdgeOfTet(numTet, numEdge);
}
int Mesh_3D::GetDomainOfTet(int numTet)
{
	return _mDomainOfTet(numTet);
}

int Mesh_3D::GetNbrPrism()
{
	return _mNbrPrim;
}

int Mesh_3D::GetPrism(int numPrism, int numVertex)
{
	return _mPrism(numPrism, numVertex);
}

int Mesh_3D::GetEdgeOfPrism(int numPrism, int numEdge)
{
	return _mEdgeOfPrism(numPrism, numEdge);
}

int Mesh_3D::GetDomainOfPrism(int numPrism)
{
	return _mDomainOfPrism(numPrism);
}

int Mesh_3D::GetNbrTri()
{
	return _mNbrTri;
}
int Mesh_3D::GetTri(int numTri, int numVertex)
{
	return _mTri(numTri, numVertex);
}
int Mesh_3D::GetDomainOfTri(int numTri)
{
	return _mDomainOfTri(numTri);
}
void Mesh_3D::GetCoonOfTri(int numTri, Eigen::Vector3i& connOfTri)
{
	connOfTri(0) = _mConnOfTri(numTri, 0);
	connOfTri(1) = _mConnOfTri(numTri, 1);
	connOfTri(2) = 0;
}

int Mesh_3D::GetNbrQuad()
{
	return _mNbrQuad;
}
int Mesh_3D::GetQuad(int numQuad, int numVertex)
{
	return _mQuad(numQuad, numVertex);
}
int Mesh_3D::GetDomainOfQuad(int numQuad)
{
	return _mDomainOfQuad(numQuad);
}
void Mesh_3D::GetCoonOfQuad(int numQuad, Eigen::Vector2i& coonOfQuad)
{
	coonOfQuad(0) = _mConnOfQuad(numQuad, 0);
	coonOfQuad(1) = _mConnOfQuad(numQuad, 1);
}

void Mesh_3D::GetNormOfFace(int domain, Eigen::Vector3d& norm)
{
	if (domain >= 0 && domain < _mNormOfFace.rows())
	{
		norm(0) = _mNormOfFace(domain, 0);
		norm(1) = _mNormOfFace(domain, 1);
		norm(2) = _mNormOfFace(domain, 2);
	}
	else
	{
		norm = Eigen::Vector3d::Zero();
	}
}

void Mesh_3D::GetTriIndicesOfDomain(int domain, Eigen::VectorXi& triIndices)
{
	int count = 0;
	for (int i = 0; i < _mNbrTri; i++)
	{
		if (_mDomainOfTri(i) == domain)
			count++;
	}
	triIndices = Eigen::VectorXi(count);
	int idx = 0;
	for (int i = 0; i < _mNbrTri; i++)
	{
		if (_mDomainOfTri(i) == domain)
			triIndices(idx++) = i;
	}
}