stuff-from-scratch/src/rendering/mesh/AbstractMesh.cpp
2023-01-23 11:55:58 +00:00

80 lines
1.6 KiB
C++

#include "AbstractMesh.h"
void AbstractMesh::addConstantNodeVectorAttribute(const std::string&, const std::vector<double>&)
{
}
AbstractMesh::~AbstractMesh()
{
}
std::vector<std::vector<double> > AbstractMesh::getNodeVectorAttributes(const std::string&)
{
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();
}
unsigned AbstractMesh::getNumNodes() const
{
return unsigned(mNodes.size());
}
const VecNodes& AbstractMesh::getNodes() const
{
return mNodes;
}
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)
{
Transform transform({ 0.0, 0.0 }, scaleX, scaleY);
for (auto& node : mNodes)
{
node->apply(transform);
}
}
void AbstractMesh::transform(const Transform& transform)
{
for (auto& node : mNodes)
{
node->apply(transform);
}
}
void AbstractMesh::translate(double offsetX, double offsetY, double offsetZ)
{
const Point loc {-offsetX, -offsetY, -offsetZ};
Transform transform(loc);
for (auto& node : mNodes)
{
node->apply(transform);
}
}
void AbstractMesh::translate(const Point& offset)
{
translate(offset.getX(), offset.getY(), offset.getZ());
}