#include "TriFace.h"

#include "Edge.h"

TriFace::TriFace(Edge* edge0, Edge* edge1, Edge* edge2, unsigned id)
    :  AbstractFace(id),
        mEdge0(edge0),
        mEdge1(edge1),
        mEdge2(edge2)
{

}

std::unique_ptr<TriFace> TriFace::Create(Edge* edge0, Edge* edge1, Edge* edge2, unsigned id)
{
    return std::make_unique<TriFace>(edge0, edge1, edge2, id);
}

TriFace::~TriFace()
{

}

std::vector<unsigned> TriFace::getNodeIds() const
{
    return {mEdge0->getNode0Id(), mEdge0->getNode1Id(), mEdge1->getNode1Id()};
}

unsigned TriFace::getNumNodes() const
{
    return 3;
}

void TriFace::replaceEdge(Edge* original, Edge* replacement)
{
    if (original == mEdge0)
    {
        mEdge0 = replacement;
    }
    else if (original == mEdge1)
    {
        mEdge1 = replacement;
    }
    else if (original == mEdge2)
    {
        mEdge2 = replacement;
    }
}

unsigned TriFace::getEdge0Id () const
{
    return mEdge0->getId();
}

unsigned TriFace::getEdge1Id () const
{
    return mEdge1->getId();
}

unsigned TriFace::getEdge2Id () const
{
    return mEdge2->getId();
}

std::vector<unsigned> TriFace::getEdgeIds() const
{
    return {mEdge0->getId(), mEdge1->getId(), mEdge2->getId()};
}

void TriFace::associateWidthEdges()
{
    mEdge0->associateFace(mId);
    mEdge1->associateFace(mId);
    mEdge2->associateFace(mId);
}
