27{
29
30
31 for (std::size_t k(0); k < 3; ++k)
32 {
33 max_point[k] += std::abs(max_point[k]) * 1e-6;
34 if (std::abs(max_point[k]) < std::numeric_limits<double>::epsilon())
35 {
36 max_point[k] = (max_point[k] - min_point[k]) * (1.0 + 1e-6);
37 }
38 }
39
40 Eigen::Vector3d delta = max_point - min_point;
41
42 if (delta[0] < std::numeric_limits<double>::epsilon())
43 {
44 const double max_delta(std::max(delta[1], delta[2]));
45 min_point[0] -= max_delta * 0.5e-3;
46 max_point[0] += max_delta * 0.5e-3;
47 delta[0] = max_point[0] - min_point[0];
48 }
49
50 if (delta[1] < std::numeric_limits<double>::epsilon())
51 {
52 const double max_delta(std::max(delta[0], delta[2]));
53 min_point[1] -= max_delta * 0.5e-3;
54 max_point[1] += max_delta * 0.5e-3;
55 delta[1] = max_point[1] - min_point[1];
56 }
57
58 if (delta[2] < std::numeric_limits<double>::epsilon())
59 {
60 const double max_delta(std::max(delta[0], delta[1]));
61 min_point[2] -= max_delta * 0.5e-3;
62 max_point[2] += max_delta * 0.5e-3;
63 delta[2] = max_point[2] - min_point[2];
64 }
65
68
69 const std::size_t n_tris(sfc->getNumberOfTriangles());
70 const std::size_t n_tris_per_cell(5);
71
72 Eigen::Matrix<bool, 3, 1> dim =
73 delta.array() >= std::numeric_limits<double>::epsilon();
74
75
76
77
78
79
80
81
82 auto sc_ceil = [](double v)
83 { return static_cast<std::size_t>(std::ceil(v)); };
84 switch (dim.count())
85 {
86 case 3:
88 sc_ceil(std::cbrt(n_tris * delta[0] * delta[0] /
89 (n_tris_per_cell * delta[1] * delta[2])));
91 sc_ceil(
_n_steps[0] * std::min(delta[1] / delta[0], 100.0));
93 sc_ceil(
_n_steps[0] * std::min(delta[2] / delta[0], 100.0));
94 break;
95 case 2:
96 if (dim[0] && dim[2])
97 {
98 _n_steps[0] = sc_ceil(std::sqrt(n_tris * delta[0] /
99 (n_tris_per_cell * delta[2])));
101 }
102 else if (dim[0] && dim[1])
103 {
104 _n_steps[0] = sc_ceil(std::sqrt(n_tris * delta[0] /
105 (n_tris_per_cell * delta[1])));
107 }
108 else if (dim[1] && dim[2])
109 {
110 _n_steps[1] = sc_ceil(std::sqrt(n_tris * delta[1] /
111 (n_tris_per_cell * delta[2])));
113 sc_ceil(n_tris * delta[2] / (n_tris_per_cell * delta[1]));
114 }
115 break;
116 case 1:
117 for (std::size_t k(0); k < 3; ++k)
118 {
119 if (dim[k])
120 {
122 sc_ceil(static_cast<double>(n_tris) / n_tris_per_cell);
123 }
124 }
125 }
126
127
128 for (std::size_t k(0); k < 3; k++)
129 {
131 if (delta[k] > std::numeric_limits<double>::epsilon())
132 {
134 }
135 else
136 {
138 }
139 }
140
143}
AABB(std::vector< PNT_TYPE * > const &pnts, std::vector< std::size_t > const &ids)
MinMaxPoints getMinMaxPoints() const
bool update(PNT_TYPE const &p)
void sortTrianglesInGridCells(GeoLib::Surface const *const sfc)
std::vector< std::vector< GeoLib::Triangle const * > > _triangles_in_grid_box
std::array< std::size_t, 3 > _n_steps
std::array< double, 3 > _inverse_step_sizes
std::array< double, 3 > _step_sizes