#include "AbstractMesh.h"

void AbstractMesh::addConstantNodeVectorAttribute(const std::string& tag, const std::vector<double>& values)
{

}

std::vector<std::vector<double> > AbstractMesh::getNodeVectorAttributes(const std::string& tag)
{
    std::vector<std::vector<double> > attribs(mNodes.size());
    return attribs;
}

void AbstractMesh::addVectorAttribute(const std::string& tag, const std::vector<double>& values)
{
    mVectorAttributes[tag] = values;
}

bool AbstractMesh::hasVectorAttribute(const std::string& tag) const
{
    return mVectorAttributes.find(tag) != mVectorAttributes.end();
}

std::vector<double> AbstractMesh::getVectorAttribute(const std::string& tag) const
{
    auto iter = mVectorAttributes.find(tag);
    if (iter != mVectorAttributes.end())
    {
        return iter->second;
    }
    return {};
}

void AbstractMesh::scale(double scaleX, double scaleY)
{
    for (auto& node : mNodes)
    {
        node->scale(scaleX, scaleY);
    }
}

void AbstractMesh::transform(const Transform& transform)
{
    auto scaleX = transform.getScaleX();
    auto scaleY = transform.getScaleY();

    scale(scaleX, scaleY);

    translate(transform.getLocation());
}

void AbstractMesh::translate(double offsetX, double offsetY, double offsetZ)
{
    for (auto& node : mNodes)
    {
        node->translate(offsetX, offsetY, offsetZ);
    }
}

void AbstractMesh::translate(const Point& offset)
{
    translate(offset.getX(), offset.getY(), offset.getZ());
}
