Start building mesh primitives.
This commit is contained in:
parent
a20c0183df
commit
fcd90b5db4
30 changed files with 856 additions and 97 deletions
|
@ -1,6 +1,5 @@
|
|||
#include "TriMesh.h"
|
||||
|
||||
#include "Node.h"
|
||||
#include "Edge.h"
|
||||
#include "TriFace.h"
|
||||
|
||||
|
@ -9,43 +8,39 @@ TriMesh::~TriMesh()
|
|||
|
||||
}
|
||||
|
||||
void TriMesh::populate(VecNodes& nodes, VecEdges& edges, VecFaces& faces)
|
||||
AbstractMesh::MeshType TriMesh::getType() const
|
||||
{
|
||||
mNodes = std::move(nodes);
|
||||
mEdges = std::move(edges);
|
||||
mFaces = std::move(faces);
|
||||
return AbstractMesh::MeshType::TRI;
|
||||
}
|
||||
|
||||
std::vector<unsigned> TriMesh::getFaceNodeIds() const
|
||||
std::unique_ptr<AbstractMesh> TriMesh::copy() const
|
||||
{
|
||||
unsigned nodes_per_face = 3;
|
||||
std::vector<unsigned> ids(nodes_per_face*mFaces.size());
|
||||
|
||||
for(std::size_t idx=0; idx<mFaces.size(); idx++)
|
||||
VecNodes nodes(mNodes.size());
|
||||
unsigned count = 0;
|
||||
for (auto& node : mNodes)
|
||||
{
|
||||
const auto nodeIds = mFaces[idx]->getNodeIds();
|
||||
for(std::size_t jdx=0; jdx<nodes_per_face; jdx++)
|
||||
{
|
||||
ids[nodes_per_face*idx + jdx] = nodeIds[jdx];
|
||||
}
|
||||
nodes[count] = std::make_unique<Node>(node->getPoint());
|
||||
count++;
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
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++)
|
||||
VecEdges edges(mEdges.size());
|
||||
count = 0;
|
||||
for (auto& edge : mEdges)
|
||||
{
|
||||
attribs[idx] = {mFaces[idx]->getVectorAttribute(tag)};
|
||||
edges[count] = std::make_unique<Edge>(nodes[edge->getNode0Id()].get(), nodes[edge->getNode0Id()].get());
|
||||
count++;
|
||||
}
|
||||
return attribs;
|
||||
}
|
||||
|
||||
void TriMesh::addConstantFaceVectorAttribute(const std::string& tag, const std::vector<double>& values)
|
||||
{
|
||||
for (const auto& face : mFaces)
|
||||
VecFaces faces(mFaces.size());
|
||||
count = 0;
|
||||
for (auto& face : mFaces)
|
||||
{
|
||||
face->addVectorAttribute(tag, values);
|
||||
auto ids = face->getEdgeIds();
|
||||
faces[count] = std::make_unique<TriFace>(edges[ids[0]].get(), edges[ids[1]].get(), edges[ids[2]].get());
|
||||
count++;
|
||||
}
|
||||
|
||||
auto mesh = std::make_unique<TriMesh>();
|
||||
mesh->populate(nodes, edges, faces);
|
||||
return mesh;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue