-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathViewer.h
126 lines (98 loc) · 2.93 KB
/
Viewer.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// Copyright (c) 2011 CNRS and LIRIS' Establishments (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 3 of the License,
// or (at your option) any later version.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0+
//
// Author(s) : Guillaume Damiand <[email protected]>
// Kumar Snehasish <[email protected]>
//
#ifndef VIEWER_H
#define VIEWER_H
#include "typedefs.h"
#include <vector>
#include <QMap>
#include <CGAL/Qt/qglviewer.h>
#include <QKeyEvent>
#include <QOpenGLFunctions_2_1>
#include <QOpenGLVertexArrayObject>
#include <QGLBuffer>
#include <QOpenGLShaderProgram>
#define NB_VBO_BUFFERS 8
#define NB_VAO_BUFFERS 4
class Viewer : public CGAL::QGLViewer
{
Q_OBJECT
typedef LCC::Dart_handle Dart_handle;
typedef LCC::Dart_const_handle Dart_const_handle;
public:
Viewer(QWidget* parent);
~Viewer();
void setScene(Scene* scene_)
{
scene = scene_;
}
public:
void draw();
virtual void init();
virtual void postSelection(const QPoint &point);
void keyPressEvent(QKeyEvent *e);
virtual QString helpString() const;
void set_semantic_formatting(FaceFormatter*);
public Q_SLOTS:
void sceneChanged();
private:
void initialize_buffers();
void attrib_buffers(CGAL::QGLViewer*);
void compile_shaders();
void compute_elements();
void compute_face(Dart_handle dh, LCC::size_type markface);
void compute_edge(Dart_handle dh, LCC::size_type markedge);
void compute_vertex(Dart_handle dh, LCC::size_type markvertex, bool& empty);
float hit(Face_cache object, CGAL::qglviewer::Vec orig, CGAL::qglviewer::Vec dir);
private:
Scene* scene;
bool wireframe;
bool flatShading;
bool edges;
bool vertices;
bool inverse_normal;
double size_points;
double size_edges;
QVector4D ambient;
bool m_previous_scene_empty;
bool are_buffers_initialized;
FaceFormatter* m_face_formatter;
//Shaders elements
int vertexLocation[3];
int normalsLocation;
int mvpLocation[2];
int mvLocation;
int colorLocation;
int colorsLocation;
int lightLocation[5];
std::vector<float> pos_points;
std::vector<float> pos_lines;
std::vector<float> pos_facets;
std::vector<float> smooth_normals;
std::vector<float> flat_normals;
std::vector<float> colors;
QGLBuffer buffers[NB_VBO_BUFFERS];
QOpenGLVertexArrayObject vao[NB_VAO_BUFFERS];
QOpenGLShaderProgram rendering_program;
QOpenGLShaderProgram rendering_program_p_l;
CGAL::Bbox_3 bb;
};
#endif