mpri-graphics-project/Mesh.cpp

30 lines
661 B
C++

#include "Mesh.hpp"
Mesh::Mesh()
{
}
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;
}