Mesh_analyzer
Loading...
Searching...
No Matches
mesh.h
1#ifndef MESH_H
2#define MESH_H
3
4#include <vector>
5#include <array>
6#include <iostream>
7#include <cmath>
8#include <unordered_set>
9#include <unordered_map>
10#include <fstream>
11#include <sstream>
12#include <string>
13
14
15#include "geometry/point.h"
16#include "geometry/edge.h"
17#include "geometry/triangle.h"
18
19
20
25class Mesh {
26public:
27 // Datas
28 std::vector<Point> vertices;
29 std::vector<Triangle> triangles;
30 std::vector<float> ratios;
31
32
38 size_t countUniqueEdges() const;
39
40
41 // Geometry
42
49 float calculateAspectRatio(const Triangle& t) const;
50
51
57
58
63 void analyzeMesh();
64
65
73 bool loadObj(const std::string& path);
74
75
81 std::unordered_map<Edge, int, EdgeHash> getEdgeValences() const;
82
83
88 std::vector<Edge> getBoundaryEdges() const;
89
90
96 void smooth(int iterations, float lambda);
97
98
99
100};
101
102#endif
A class representing a 3D mesh.
Definition mesh.h:25
std::vector< float > ratios
aspect ratios of triangles (for quality analysis)
Definition mesh.h:30
std::vector< Point > vertices
List of vertices in the mesh.
Definition mesh.h:28
void smooth(int iterations, float lambda)
Smooth the mesh by iteratively moving each vertex towards the centroid of its neighbors.
Definition mesh.cpp:133
void calculateAspectRatios()
Calculate the aspect ratio for all triangles in the mesh and store them in the ratios vector.
Definition mesh.cpp:39
float calculateAspectRatio(const Triangle &t) const
Calculate the aspect ratio of a triangle defined by its vertex indices. An aspect ratio near to 1 ind...
Definition mesh.cpp:26
bool loadObj(const std::string &path)
Load a mesh from an OBJ file using tinyobjloader.
Definition mesh.cpp:63
std::unordered_map< Edge, int, EdgeHash > getEdgeValences() const
Get the Edge Valences object.
Definition mesh.cpp:104
void analyzeMesh()
Analyze the mesh by printing out the number of vertices, triangles, and unique edges....
Definition mesh.cpp:49
std::vector< Triangle > triangles
List of triangles defined by vertex indices.
Definition mesh.h:29
std::vector< Edge > getBoundaryEdges() const
Get the boundary edges of the mesh.
Definition mesh.cpp:121
size_t countUniqueEdges() const
Count the number of unique edges in the mesh by iterating through all triangles and adding their edge...
Definition mesh.cpp:9
A struct representing a triangle in the mesh.
Definition triangle.h:19