-
Notifications
You must be signed in to change notification settings - Fork 0
/
mesh.h
85 lines (68 loc) · 2.19 KB
/
mesh.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#ifndef MESH_H
#define MESH_H
#include "QVector3D"
#include "QVector"
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/boost/graph/graph_traits_Surface_mesh.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Polyhedron_incremental_builder_3.h>
#include <QTextStream>
#include <QDebug>
typedef CGAL::Simple_cartesian<double> K;
typedef CGAL::Polyhedron_3<K> Polyhedron;
enum MeshType {Triangular, Quadrilateral};
/**
* @brief Mesh osztály, amely csúcsok és indexek formájában ábrázol egy háromszögelt mesht.
*/
class Mesh
{
public:
/**
* @brief Egy vertexhez tartozó adatokat összefogó struktúra.
*/
struct Vertex
{
QVector3D m_position;
QVector3D m_normal;
QVector3D m_color;
};
static K::Point_3 toKernelVector(QVector3D v);
static QVector3D toQVector(K::Point_3 v);
static Vertex toVertex(K::Point_3 v);
static Vertex toVertex(QVector3D v);
/**
* @brief Default üres konstruktor.
*/
Mesh(int p_numFaceVertices = 3);
/**
* @brief Implicit indexeket beállító konstruktor.
*/
Mesh(QVector<Vertex>const& p_vertices, int p_numFaceVertices = 3);
/**
* @brief Csúcsokat és indexeket beállító konstruktor.
*/
Mesh(QVector<Vertex>const& p_vertices, QVector<int>const& p_indices, int p_numFaceVertices = 3);
/**
* @brief CGAL-ról Mesh-re konvertáló konstruktor.
*/
Mesh(Polyhedron surface_mesh);
static Mesh makeTriangle();
static Mesh makeCube(bool quads);
static Mesh makeTetrahedron();
/**
* @brief Automatically generates indices for the vertices currently present in the mesh.
*/
void generateIndices(bool regenerate = false);
/**
* @brief Converts the mesh to a CGAL-compatible representation.
*/
Polyhedron convertToSurfaceMesh(bool triangulate = false);
void joinIdenticalVertices(float epsilon = 0.01f);
QVector<Vertex> m_vertices;
QVector<int> m_indicesOriginal;
QVector<int> m_indicesTriangulated;
QVector<int> m_indicesSilhouette;
int m_numFaceVertices;
};
#endif // MESH_H