-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathtrimeshview.h
267 lines (213 loc) · 8.49 KB
/
trimeshview.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
/*************************************************************************
* Copyright (c) 2014 Zhang Dongdong
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**************************************************************************/
#ifndef TRIMESHVIEW_H
#define TRIMESHVIEW_H
#include <QGLWidget>
#include <QMouseEvent>
#include <QWheelEvent>
#include <QKeyEvent>
#include <QTimer>
#include <QFile>
#include <QTextStream>
#include "trianglemesh.h"
#include "meshalgo.h"
#include "XForm.h"
#include "GLCamera.h"
#include "featurelines.h"
using namespace std;
class TriMeshView : public QGLWidget
{
Q_OBJECT
public:
explicit TriMeshView(QWidget *parent = 0);
~TriMeshView();
bool readMesh(const char *filename, const char* xffilename = "");
bool readXf(const char *filename);
void closeAllDrawings();
signals:
public slots:
void autospin();
protected:
void cls();
void resizeGL(int width, int height);
void paintGL();
void mousePressEvent(QMouseEvent *e);
void mouseReleaseEvent(QMouseEvent *e);
void mouseMoveEvent(QMouseEvent *e);
void wheelEvent(QWheelEvent *e);
void keyPressEvent(QKeyEvent *e);
void keyReleaseEvent(QKeyEvent *);
private:
//draw_base
float feature_size;
void compute_perview(vector<float> &ndotv, vector<float> &kr);
void compute_perview(vector<float> &ndotv, vector<float> &kr,
vector<float> &sctest_num, vector<float> &sctest_den,
vector<float> &shtest_num, vector<float> &q1,
vector<vec2> &t1, vector<float> &Dt1q1,
bool extra_sin2theta = false);
void draw_mesh();
void draw_base_mesh();
void draw_strips();
void draw_edges();
void draw_normals();
void draw_preview();
vector<Color> normal_colors;
void compute_normal_colors();
void draw_normal_colors();
void draw_curv1();
void draw_curv2();
vector<Color> curv_colors;
void compute_curv_colors();
void draw_color_maps();
void draw_curv_colors();
void write_to_file(const vector<float> &v, const QString &fileName);
public:
void time_ridge_valley();
void smooth_curv();
void smooth_dcurv();
void laplace_smooth_curv();
void saveCurv1(const QString &fileName);
void saveCurv2(const QString &fileName);
public:
//draw_base
bool isDrawEdges;
bool isDrawNormals;
bool isDrawPreview;
bool isDrawCurv1;
bool isDrawCurv2;
bool isDrawCurvColors;
bool isDrawNormalColors;
private:
//draw_lines
void draw_boundaries(bool do_hidden);
inline vec gradkr(int i);
float find_zero_hermite(int v0, int v1, float val0, float val1,
const vec &grad0, const vec &grad1);
inline float find_zero_linear(float val0, float val1);
void draw_face_isoline2(int v0, int v1, int v2,
const vector<float> &val,
const vector<float> &test_num,
const vector<float> &test_den,
bool do_hermite, bool do_test, float fade);
void draw_face_isoline(int v0, int v1, int v2,
const vector<float> &val,
const vector<float> &test_num,
const vector<float> &test_den,
const vector<float> &ndotv,
bool do_bfcull, bool do_hermite,
bool do_test, float fade);
void draw_isolines(const vector<float> &val,
const vector<float> &test_num,
const vector<float> &test_den,
const vector<float> &ndotv,
bool do_bfcull, bool do_hermite,
bool do_test, float fade);
void draw_silhouette(const vector<float> &ndotv);
void draw_occluding_contours(const vector<float> &ndotv, const vector<float> &kr);
void draw_suggestive_contours(const vector<float> &ndotv,
const vector<float> &kr,
const vector<float> &sctest_num,
const vector<float> &sctest_den);
void draw_isophotes(const vector<float> &ndotv);
void draw_topolines(const vector<float> &ndotv);
//ridges and valleys
void draw_segment_ridge(int v0, int v1, int v2,
float emax0, float emax1, float emax2,
float kmax0, float kmax1, float kmax2,
float thresh, bool to_center);
void draw_face_ridges(int v0, int v1, int v2,
bool do_ridge,
const vector<float> &ndotv,
bool do_bfcull, bool do_test, float thresh);
void draw_mesh_ridges(bool do_ridge, const vector<float> &ndotv,
bool do_bfcull, bool do_test, float thresh);
void draw_ridges(const vector<float> &ndotv, float thresh);
void draw_valleys(const vector<float> &ndotv, float thresh);
//apparent ridges
void compute_viewdep_curv(const TriangleMesh *mesh, int i, float ndotv,
float u2, float uv, float v2,
float &q1, vec2 &t1);
void compute_Dt1q1(const TriangleMesh *mesh, int i, float ndotv,
const vector<float> &q1, const vector<vec2> &t1,
float &Dt1q1);
void draw_segment_app_ridge(int v0, int v1, int v2,
float emax0, float emax1, float emax2,
float kmax0, float kmax1, float kmax2,
const vec &tmax0, const vec &tmax1, const vec &tmax2,
float thresh, bool to_center, bool do_test);
void draw_face_app_ridges(int v0, int v1, int v2,
const vector<float> &ndotv, const vector<float> &q1,
const vector<vec2> &t1, const vector<float> &Dt1q1,
bool do_bfcull, bool do_test, float thresh);
void draw_mesh_app_ridges(const vector<float> &ndotv, const vector<float> &q1,
const vector<vec2> &t1, const vector<float> &Dt1q1,
bool do_bfcull, bool do_test, float thresh);
void draw_apparent_ridges(const vector<float> &ndotv, const vector<float> &q1,
const vector<vec2> &t1, const vector<float> &Dt1q1,
float thresh);
public:
float getSugThresh(){ return sug_thresh; }
float getRvThresh(){ return rv_thresh; }
float getArThresh(){ return ar_thresh; }
void setSugThresh(float thresh) { sug_thresh = thresh; }
void setRvThresh(float thresh) { rv_thresh = thresh; }
void setArThresh(float thresh) { ar_thresh = thresh; }
private:
float sug_thresh;
float rv_thresh;
float ar_thresh;
public:
//draw_lines
bool isDrawBoundaries;
bool isDrawSilhouette;//外部轮廓
bool isDrawOccludingContours;
bool isDrawSuggestiveContours;
bool isDrawIsophotes;
bool isDrawTopolines;
bool isDrawRidges;
bool isDrawValleys;
bool isDrawApparentRidges;
bool isSavedRV;
bool saveRidgesFile(const QString &fileName);
bool isSavedOc;
bool saveOccludingFile(const QString &fileName);
bool isDrawRVLines;
bool isDrawRVFaces;
bool isDrawOCLines;
bool isDrawOCFaces;
bool saveRVMeshFile(const QString &fileName);
bool saveOCMeshFile(const QString &fileName);
void readFeatureLines(const QString &fileName);
private:
FeatureLines fLines;//只读
FeatureLines rv_fLines;
void compute_perview2(std::vector<float> &ndotv, vector<float> &kr);
vector<float> c_ndotv, c_kr;
FeatureLines c_fLines;
private:
private:
TriangleMesh *triMesh;
xform xf;
GLCamera camera;
point viewpos;//当前视点位置
vec currcolor;// Current line color
float currsmooth;
bool isCtrlPressed;
QTimer *timer;
};
#endif // TRIMESHVIEW_H