mpri-graphics-project/Mesh.cpp

31 lines
661 B
C++
Raw Normal View History

2018-01-27 16:28:36 +01:00
#include "Mesh.hpp"
2018-01-27 16:28:36 +01:00
Mesh::Mesh()
{
}
2018-01-27 16:28:36 +01:00
size_t Mesh::add_vertice(const Point& pt) {
// Does the vertice already exists?
if (rev_vertices.find(pt) != rev_vertices.end())
return rev_vertices.find(pt)->second;
vertices.push_back(pt);
rev_vertices.insert(std::make_pair(pt, vertices.size() - 1));
return vertices.size() - 1;
}
void Mesh::add_face(const Face& face) {
faces.push_back(face);
}
void Mesh::add_face(size_t f1, size_t f2, size_t f3) {
add_face(Face(f1, f2, f3));
}
const std::vector<Point>& Mesh::get_vertices() const {
return vertices;
}
const std::vector<Face>& Mesh::get_faces() const {
return faces;
}