-
Notifications
You must be signed in to change notification settings - Fork 0
/
region_grower_testers.hpp
80 lines (69 loc) · 2.45 KB
/
region_grower_testers.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
#pragma once
#include <geoflow/common.hpp>
#include <region_grower_DS_CGAL.hpp>
#include <region_grower.hpp>
#include <glm/glm.hpp>
#include <glm/gtc/type_ptr.hpp>
using namespace std;
class MaData : public regiongrower::CGAL_RegionGrowerDS {
public:
geoflow::vec3f& ma_bisector;
geoflow::vec1f& ma_sepangle;
geoflow::vec1f& ma_radii;
MaData(geoflow::PointCollection& ma_points, geoflow::vec3f& ma_bisector, geoflow::vec1f& ma_sepangle, geoflow::vec1f& ma_radii, size_t N=15)
: CGAL_RegionGrowerDS(ma_points, N), ma_bisector(ma_bisector), ma_sepangle(ma_sepangle), ma_radii(ma_radii){}
};
class Region : public regiongrower::Region {
public:
using regiongrower::Region::Region;
size_t count=0;
};
class AngleOfVectorsTester {
public:
float threshold;
AngleOfVectorsTester(float threshold=5) :
threshold(glm::cos(threshold*(3.14159265359/180))) {};
bool is_valid(MaData& cds, size_t candidate, size_t neighbour, Region& shape) {
auto b1 = glm::make_vec3(cds.ma_bisector[candidate].data());
auto b2 = glm::make_vec3(cds.ma_bisector[neighbour].data());
return glm::dot(b1,b2) > threshold;
}
};
class DiffOfAnglesTester {
public:
float threshold;
DiffOfAnglesTester(float threshold=5) :
threshold(threshold*(3.14159265359/180)) {};
bool is_valid(MaData& cds, size_t candidate, size_t neighbour, Region& shape) {
auto a1 = cds.ma_sepangle[candidate];
auto a2 = cds.ma_sepangle[neighbour];
// auto b1 = glm::make_vec3(cds.ma_points[candidate].data());
// auto b2 = glm::make_vec3(cds.ma_points[neighbour].data());
// std::cout << "neighbour " << neighbour << " of candidate " << candidate << ", dist: " << glm::distance(b1,b2) << "\n";
return glm::abs(a1-a2) < threshold;
}
};
class BallOverlapTester {
public:
float threshold;
BallOverlapTester(float threshold=1.2) :
threshold(threshold) {};
bool is_valid(MaData& cds, size_t candidate, size_t neighbour, Region& shape) {
auto r1 = cds.ma_radii[candidate];
auto r2 = cds.ma_radii[neighbour];
auto c1 = glm::make_vec3(cds.points[candidate].data());
auto c2 = glm::make_vec3(cds.points[neighbour].data());
auto d = glm::distance(c1,c2);
return (r1+r2)/d > threshold;
}
};
class CountTester {
public:
size_t threshold;
CountTester(size_t threshold=50) :
threshold(threshold) {};
bool is_valid(MaData& cds, size_t candidate, size_t neighbour, Region& shape) {
++shape.count;
return shape.count < threshold;
}
};