Starting resize support.

This commit is contained in:
James Grogan 2022-11-14 14:57:50 +00:00
parent cea3d2c39f
commit 9ade0e2d4b
26 changed files with 197 additions and 44 deletions

View file

@ -25,3 +25,18 @@ std::vector<unsigned> TriFace::getNodeIds() const
{
return {mEdge0->getNode0Id(), mEdge0->getNode1Id(), mEdge1->getNode1Id()};
}
void TriFace::addVectorAttribute(const std::string& tag, const std::vector<double>& values)
{
mVectorAttributes[tag] = values;
}
std::vector<double> TriFace::getVectorAttribute(const std::string& tag) const
{
auto iter = mVectorAttributes.find(tag);
if (iter != mVectorAttributes.end())
{
return iter->second;
}
return {};
}

View file

@ -2,6 +2,8 @@
#include <memory>
#include <vector>
#include <unordered_map>
#include <string>
class Edge;
@ -14,8 +16,14 @@ public:
static std::unique_ptr<TriFace> Create(Edge* edge0, Edge* edge1, Edge* edge2, unsigned id=0);
std::vector<unsigned> getNodeIds() const;
void addVectorAttribute(const std::string& tag, const std::vector<double>& values);
std::vector<double> getVectorAttribute(const std::string& tag) const;
private:
unsigned mId{0};
std::unordered_map<std::string, std::vector<double> > mVectorAttributes;
Edge* mEdge0{nullptr};
Edge* mEdge1{nullptr};
Edge* mEdge2{nullptr};

View file

@ -27,3 +27,21 @@ std::vector<std::vector<Point> > TriMesh::getFaceVertices() const
}
return verts;
}
std::vector<std::vector<double> > TriMesh::getFaceVectorAttributes(const std::string& tag)
{
std::vector<std::vector<double> > attribs(mFaces.size());
for(std::size_t idx=0; idx<mFaces.size(); idx++)
{
attribs[idx] = {mFaces[idx]->getVectorAttribute(tag)};
}
return attribs;
}
void TriMesh::addConstantFaceVectorAttribute(const std::string& tag, const std::vector<double>& values)
{
for (const auto& face : mFaces)
{
face->addVectorAttribute(tag, values);
}
}

View file

@ -29,6 +29,10 @@ public:
std::vector<std::vector<Point> > getFaceVertices() const;
void addConstantFaceVectorAttribute(const std::string& tag, const std::vector<double>& values);
std::vector<std::vector<double> > getFaceVectorAttributes(const std::string& tag);
private:
VecNodes mNodes;
VecEdges mEdges;