-
Notifications
You must be signed in to change notification settings - Fork 0
/
oneform.cpp
147 lines (136 loc) · 3.46 KB
/
oneform.cpp
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
#include "myholomor.h"
Eigen::MatrixXd V_uv;
igl::viewer::Viewer viewer;
PMyMesh mesh;
Mos mos(mesh, viewer);
Oneform oneform(mesh, mos);
bool key_down(igl::viewer::Viewer& viewer, unsigned char key, int modifier)
{
if (key == '1')
{
mos.pre_draw1();
oneform.set_uv(V_uv);
viewer.data.set_uv(V_uv);
viewer.core.show_texture = true;
}
return false;
}
bool predr(igl::viewer::Viewer &viewer)
{
mos.pre_draw1();
return false;
}
int main()
{
igl::readOFF("e:/off/eight.off", mos.V, mos.F);
OpenMesh::IO::Options opt;
if (!OpenMesh::IO::read_mesh(mesh, "e:/off/eight.off", opt))
{
for (int i = 0; i<30; i++)
{
printf_s("¶Áȡʧ°Ü\r\n");
}
return -1;
}
oneform.F = mos.F;
oneform.V = mos.V;
oneform.init_g2();
oneform.init_w();
oneform.init_weight();
//std::cout << oneform.L << std::endl;
//mos.init_A();
mos.set_f();
mos.setkey();
oneform.set_omiga();
//mos.findsaddle(mos.vh[2]);
//oneform.one_omiga(mos.vh[2],2);
int sum = 0,sum1=0;
for (PMyMesh::HalfedgeIter hter=mesh.halfedges_begin();hter!=mesh.halfedges_end();hter++)
{
if (mesh.data(hter).omiga[2]==1)
{
sum++;
}
if (mesh.data(hter).omiga[2]==-1)
{
sum1++;
}
}
printf_s("sum: %d sum1: %d\r\n",sum,sum1);
//for (PMyMesh::EdgeIter eter=mesh.edges_begin();eter!=mesh.edges_end();eter++)
//{
// printf_s("edge id is : %d\r\n",(*eter).idx());
//}
oneform.set_harmonic_oneform();
//oneform.harmonic_oneform(2);
//viewer.callback_post_draw = &predr;
printf_s("%d\r\n",mesh.n_faces());
oneform.set_cotangentbasis();
oneform.set_cotangentstar();
oneform.init_ww();
//oneform.one_omigastar(2);
for (PMyMesh::EdgeIter eter=mesh.edges_begin();eter!=mesh.edges_end();eter++)
{
//printf_s("he1:%f,he2:%f\r\n",mesh.data(mesh.s_halfedge_handle(*eter,0)).omiga[2], mesh.data(mesh.s_halfedge_handle(*eter, 1)).omiga[2]);
}
//oneform.set_omigastar();
oneform.one_tromigastar(2);
/*Eigen::Vector3f temp1, temp2;
temp1.setZero();
temp2.setZero();
temp1(0) = 1;
temp2(1) = 1;
printf_s("%f\r\n",temp2.cross(temp1).coeff(2));*/
//oneform.init_ww();
//oneform.one_cotangentstar(2);
//oneform.one_omigastar(2);
// oneform.set_cotangentbasis();
/*for (PMyMesh::HalfedgeIter hter=mesh.halfedges_begin();hter!=mesh.halfedges_end();hter++)
{
printf_s("halfedge id is %d\r\n",(*hter).idx());
}*/
/*Eigen::Vector3d vv;
vv.setOnes();
vv.normalize();
for (int i=0;i<3;i++)
{
printf_s("%f\r\n",vv.coeff(i));
}*/
// printf_s("g_2= %d\r\n",2 + mesh.n_edges() - mesh.n_vertices() - mesh.n_faces());
/*int sum = 0;
for (PMyMesh::EdgeIter eter=mesh.edges_begin();eter!=mesh.edges_end();eter++)
{
if (mesh.data(eter).sharp_)
{
sum++;
}
}
printf_s("sum= %d\r\n",sum);*/
//mos.integral(mesh.vertex_handle(0),2);
//mos.drawedge();
//mos.draw_scene();
//oneform.set_uv(V_uv);
//Eigen::VectorXd z(mesh.n_vertices()); Eigen::MatrixXd c;
//z = V_uv.col(0);
//igl::jet(z,true,c);
//viewer.data.set_colors(c);
//std::cout << V_uv << std::endl;
//viewer.data.set_uv(V_uv);
// viewer.core.show_texture = true;
//viewer.core.animation_max_fps = 5.;
//init_edge_length();
//VertexHandle v = mesh.vertex_handle(0), v1 = mesh.vertex_handle(80);
/*mos.init_edge_length();
mos.init_sharp();
mos.set_destination(v);
mos.find_shortestway(v1);
mos.drawedge();
mos.draw_scene();*/
mos.ini_list(mesh.vertex_handle(100));
viewer.callback_key_down = &key_down;
viewer.core.is_animating = true;
viewer.launch();
/*int n = 0;
scanf_s("d",&n);*/
return 0;
}