-
Notifications
You must be signed in to change notification settings - Fork 0
/
TCViewer.h
94 lines (76 loc) · 2.66 KB
/
TCViewer.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
86
87
88
89
90
91
92
93
94
//== INCLUDES =================================================================
#include <QWidget>
#include <QString>
#include <QMessageBox>
#include <QFileDialog>
#include <OpenMesh/Core/IO/MeshIO.hh>
#include <OpenMesh/Tools/Utils/getopt.h>
#include <OpenMesh/Tools/Utils/Timer.hh>
#include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh>
#include <OpenMesh/Core/Mesh/Traits.hh>
#include "TCViewerT.h"
#include "MainWindow.h"
//== CLASS DEFINITION =========================================================
using namespace OpenMesh;
using namespace OpenMesh::Attributes;
struct TCTraits : public OpenMesh::DefaultTraits
{
VertexTraits
{
typedef OpenMesh::Vec3f Color;
private:
float valence;
Color valence_color;
public:
void set_valence (const float _val) { valence=_val; }
float get_valence () { return valence; }
void set_valence_color (Color _val_color) { valence_color=_val_color; }
Color get_valence_color () { return valence_color; }
};
};
typedef OpenMesh::TriMesh_ArrayKernelT<TCTraits> TCMesh;
//== CLASS DEFINITION =========================================================
class TCViewer : public TCViewerT<TCMesh>
{
Q_OBJECT
public:
/// default constructor
TCViewer(QWidget* parent=0) : TCViewerT<TCMesh>(parent)
{
}
OpenMesh::IO::Options& options() { return _options; }
const OpenMesh::IO::Options& options() const { return _options; }
void setOptions(const OpenMesh::IO::Options& opts) { VertexAttributes( OpenMesh::Attributes::Normal |
OpenMesh::Attributes::Color );_options = opts; }
/// open mesh
virtual bool open_mesh(const char* _filename, OpenMesh::IO::Options _opt);
/// load texture
virtual bool open_texture( const char *_filename );
bool set_texture( QImage& _texsrc );
void open_mesh_gui(QString fname);
void open_texture_gui(QString fname);
/// interpolate [0,1] into RGB valus
Vec3f interp_color(float _val);
Vec3f interp_color(float _val, float range_min, float range_max);
qglviewer::Vec OMVec3f_to_QGLVec(OpenMesh::Vec3f OMVec3f)
{ return qglviewer::Vec(OMVec3f.values_[0], OMVec3f.values_[1], OMVec3f.values_[2]); }
public slots:
void query_open_mesh_file();
void query_open_texture_file();
protected:
virtual void draw();
virtual void init();
private:
OpenMesh::IO::Options _options;
private slots:
void Smooth();
void Flat();
void Wireframe();
void Points();
void HiddenLine();
void Valence();
void GaussianCurvature();
void MeanCurvature();
void about();
void aboutQt();
};