forked from seub/CirclePackings
-
Notifications
You must be signed in to change notification settings - Fork 0
/
positions.hpp
91 lines (66 loc) · 2.59 KB
/
positions.hpp
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
/*This file is part of Circle Packings.
Circle Packings is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Circle Packings is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Circle Packings. If not, see <http://www.gnu.org/licenses/>.*/
#ifndef POSITIONS_HPP
#define POSITIONS_HPP
#include <QThread>
#include "basic_types.hpp"
#include "graph.hpp"
class QComboBox;
class Canvas;
class Positions : public QThread
{
Q_OBJECT
friend class Top_Algo;
friend class Tests;
public:
Positions () {}
void reset(const positions_algo_type positions_algo, const Graph<Empty> &G,
const unsigned int &zero, const unsigned int &one,
const unsigned int &two, std::vector<double> *ptr_radii,
const complex_number &angle, const double &tol,
Graph<Circle> *canvas_circle_packing = NULL, Canvas* canvas = NULL,
bool show_live_cp = false, bool* stop = NULL);
const Graph<Circle> & get_output_circle_packing() const;
const double & get_error() const;
signals:
void show_live_cp();
public slots:
void run();
private:
void compute_positions();
void compute_positions_regular();
void compute_positions_downwards();
void compute_positions_upwards();
void synchronise_angles();
void compute_max_error();
double compute_single_error(const unsigned int &index) const;
bool* stop_;
positions_algo_type positions_algo_;
Graph<Empty> G_;
unsigned int zero_;
unsigned int one_;
unsigned int two_;
std::vector<double> * ptr_radii_;
std::vector<double> radii_;
std::vector<complex_number> positions_;
double error_;
double tol_;
complex_number angle_;
Graph<Circle> output_circle_packing_;
Graph<Circle> *canvas_circle_packing_;
Canvas* canvas_;
bool show_live_cp_;
};
complex_number compute_next_position(const complex_number &pivot_affix, const complex_number &neighbor_affix,
const double &pivot_radius, const double &neighbor_radius, const double &next_radius,
const int &orientation);
#endif // POSITIONS_HPP