-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEdgeColleps.cpp
More file actions
72 lines (57 loc) · 2.06 KB
/
Copy pathEdgeColleps.cpp
File metadata and controls
72 lines (57 loc) · 2.06 KB
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
#include "MyViewer.h"
float MyViewer::ErrorDistance(MyMesh::VertexHandle p1, MyMesh::VertexHandle p2, MyMesh::Point newp)
{
float result = Calculate_Min(p1, newp) + Calculate_Min(p2, newp);
return result;
}
float MyViewer::Calculate_spline(MyMesh::VertexHandle p1, MyMesh::Point newp)
{
float result = 0.0f;
for (MyMesh::VertexFaceIter vf_it = mesh.vf_iter(p1); vf_it.is_valid(); ++vf_it) {
MyMesh::Point p = roundPoint(mesh.point(p1));
}
return result;
}
float MyViewer::Calculate_Min(MyMesh::VertexHandle p1, MyMesh::Point newp)
{
std::vector<float> min;
for (MyMesh::VertexFaceIter vf_it = mesh.vf_iter(p1); vf_it.is_valid(); ++vf_it) {
MyMesh::FaceHandle face_handle = *vf_it;
MyMesh::Normal face_normal = mesh.normal(face_handle);
MyMesh::Point p = roundPoint(mesh.point(p1));
MyMesh::Point r = p - roundPoint(newp);
double min_value = abs(r | face_normal);
min.push_back(min_value);
}
auto result = std::min_element(min.begin(), min.end());
return *result;
}
void MyViewer::collapseEdge(MyMesh::HalfedgeHandle h, int i)
{
MyMesh::VertexHandle v = mesh.to_vertex_handle(h);
MyMesh::VertexHandle v2 = mesh.from_vertex_handle(h);
MyMesh::Point point1 = mesh.point(v);
MyMesh::Point point2 = mesh.point(v2);
MyMesh::Point newPoint;
newPoint = (point1 + point2) / 2.0f;
if (mesh.is_boundary(v2))
{
newPoint = point2;
}
Edgecolleps[i].v = v;
Edgecolleps[i].v2 = v2;
putVertexes(v2, v, i);
mesh.collapse(h);
mesh.set_point(v, newPoint);
}
void MyViewer::Calculate_collapses(MyMesh::HalfedgeHandle h)
{
MyMesh::VertexHandle v = mesh.to_vertex_handle(h);
MyMesh::VertexHandle v2 = mesh.from_vertex_handle(h);
MyMesh::Point point1 = mesh.point(v);
MyMesh::Point point2 = mesh.point(v2);
MyMesh::Point newPoint;
newPoint = (point1 + point2) / 2.0f;
float error_distance = ErrorDistance(v, v2, newPoint);
Edgecolleps.push_back(Ecolleps(h.idx(), error_distance, h, v, point1, point2, getVertex(v2, v)));
}