You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: raycloudtools/raydecimate/raydecimate.cpp
+13-7Lines changed: 13 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -23,8 +23,9 @@ void usage(int exit_code = 1)
23
23
std::cout << "raydecimate raycloud 3 cm - reduces to one end point every 3 cm. A spatially even subsampling" << std::endl;
24
24
std::cout << "raydecimate raycloud 4 rays - reduces to every fourth ray. A temporally even subsampling (if rays are chronological)" << std::endl;
25
25
std::cout << "advanced methods not supported in rayrestore:" << std::endl;
26
-
std::cout << "raydecimate raycloud 20 cm 64 rays - A maximum of 64 rays per cubic 20 cm. Retains small-scale details compared to spatial decimation" << std::endl;
27
-
std::cout << "raydecimate raycloud 3 cm/m - reduces to ray ends spaced 3 cm apart for each metre of their length" << std::endl;
26
+
std::cout << "raydecimate raycloud 20 cm 64 points - A maximum of 64 end points per cubic 20 cm. Retains small-scale details compared to spatial decimation" << std::endl;
27
+
std::cout << "raydecimate raycloud 20 cm/ray - If all cells overlapping a ray intersect a ray then this way is not added" << std::endl;
28
+
std::cout << "raydecimate raycloud 3 cm/m - reduces to ray ends spaced 3 cm apart for each metre of their length. Good for maintaining a range of point densities" << std::endl;
28
29
// clang-format off
29
30
exit(exit_code);
30
31
}
@@ -49,20 +50,25 @@ int rayDecimate(int argc, char *argv[])
// #define END_FIRST // by traversing from end to start we match the existence of the ray more to the free space near the end point. In building1 test start first found more ray locations
187
+
#if defined END_FIRST
188
+
Eigen::Vector3d dir = starts[i] - ends[i];
189
+
const Eigen::Vector3d source = ends[i] / width;
190
+
const Eigen::Vector3d target = starts[i] / width;
191
+
#else
192
+
Eigen::Vector3d dir = ends[i] - starts[i];
193
+
const Eigen::Vector3d source = starts[i] / width;
194
+
const Eigen::Vector3d target = ends[i] / width;
195
+
#endif
196
+
constdouble length = dir.norm();
197
+
for (int a = 0; a<3; a++)
198
+
{
199
+
if (dir[a] == 0.0)
200
+
{
201
+
dir[a] = 1e-10; // prevent division by 0
202
+
}
203
+
}
204
+
constdouble eps = 1e-9; // to stay away from edge cases
205
+
constdouble maxDist = (target - source).norm();
206
+
207
+
// cached values to speed up the loop below
208
+
Eigen::Vector3i adds;
209
+
Eigen::Vector3d offsets;
210
+
for (int k = 0; k < 3; ++k)
211
+
{
212
+
if (dir[k] > 0.0)
213
+
{
214
+
adds[k] = 1;
215
+
offsets[k] = 0.5;
216
+
}
217
+
else
218
+
{
219
+
adds[k] = -1;
220
+
offsets[k] = -0.5;
221
+
}
222
+
}
223
+
224
+
Eigen::Vector3d p = source; // our moving variable as we walk over the grid
0 commit comments