-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdiagram_types.cpp
136 lines (110 loc) · 3.21 KB
/
diagram_types.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
#include "diagram_types.h"
#include <queue>
void face_t::correct_edge_orientations()
{
if (edges.empty()) return;
std::map<face_t*, unsigned int>::iterator location;
location = edges[0]->related_faces.find(this);
std::vector<edge_tt*> edges_o;
edges_o.push_back(edges[0]);
std::vector<edge_tt*> edges_cpy(edges.begin() + 1, edges.end());
//todo: mivan ha rendezve tárolnánk õket vhogy...
for (size_t i = 0; i < edges.size() -1 ; ++i)
{
Point* actual_last_point = location->second == 0 ? edges_o[i]->edge.second.second : edges_o[i]->edge.first.second;
unsigned int new_orientation;
auto next = std::find_if(edges_cpy.begin(), edges_cpy.end(), [&actual_last_point, &new_orientation](const edge_tt* e)->bool
{
if (e->edge.first.second == actual_last_point)
{
new_orientation = 0;
actual_last_point = e->edge.second.second;
return true;
}
else if (e->edge.second.second == actual_last_point)
{
new_orientation = 1;
actual_last_point = e->edge.first.second;
return true;
}
return false;
});
if (next == edges_cpy.end())
{
qDebug() << "FAIL not founded pair";
return;
}
location = (*next)->related_faces.find(this);
location->second = new_orientation;
edges_o.push_back(*next);
edges_cpy.erase(next);
}
std::vector<edge_tt*>(edges_o).swap(edges);
//-------------------- TEST
/*for (auto& it : edges)
{
if (it->related_faces[this] == 0)
qDebug() << it->edge.first.first << " -> " << it->edge.second.first;
else
qDebug() << it->edge.second.first << " -> " << it->edge.first.first;
}*/
}
void face_t::correct_boundary_orientation()
{
qDebug() << "Correct Boundary orientation";
std::queue<face_t*> face_list;
std::set<face_t*> progress_faces;
std::set<face_t*> done_faces;
progress_faces.insert(this);
done_faces.insert(this);
face_list.push(this);
while (!face_list.empty())
{
face_t* act_face = face_list.front();
face_list.pop();
auto act_face_edges = act_face->edges;
for (auto& face_edge : act_face_edges)
{
face_t* next_boundary_face = nullptr;
int orientation_on_actual_face = -1;
int next_face_orientation = -1;
for (auto& related_face : face_edge->related_faces)
{
if (!related_face.first->is_power_crust_face()) continue;
if (related_face.first == act_face)
{
orientation_on_actual_face = related_face.second;
continue;
}
if (next_boundary_face == nullptr)
{
next_boundary_face = related_face.first;
next_face_orientation = related_face.second;
}
else
qDebug() << "CORRECT ORIENTATION ON BOUND IS BAAD";
}
if (next_boundary_face != nullptr)
{
if (done_faces.find(next_boundary_face) != done_faces.end())
{
if (next_face_orientation == orientation_on_actual_face)
{
qDebug() << "ERR: Bad orientation!";
}
continue;
}
if (next_face_orientation < 0 || orientation_on_actual_face < 0)
{
qDebug() << "ERR: orientation didnt set properly";
continue;
}
if ( next_face_orientation == orientation_on_actual_face )
next_boundary_face->swap_edge_orientations();
face_list.push(next_boundary_face);
done_faces.insert(next_boundary_face);
}
}
}
qDebug() << "Correct Boundary orientation END";
}