MCPcopy Create free account
hub / github.com/LASzip/LASzip / get_level_index

Method get_level_index

src/lasquadtree.cpp:277–320  ·  view source on GitHub ↗

returns the (sub-)level index of the cell that x & y fall into at the specified level

Source from the content-addressed store, hash-verified

275
276// returns the (sub-)level index of the cell that x & y fall into at the specified level
277U32 LASquadtree::get_level_index(const F64 x, const F64 y, U32 level) const
278{
279 volatile float cell_mid_x;
280 volatile float cell_mid_y;
281 float cell_min_x, cell_max_x;
282 float cell_min_y, cell_max_y;
283
284 cell_min_x = min_x;
285 cell_max_x = max_x;
286 cell_min_y = min_y;
287 cell_max_y = max_y;
288
289 U32 level_index = 0;
290
291 while (level)
292 {
293 level_index <<= 2;
294
295 cell_mid_x = (cell_min_x + cell_max_x)/2;
296 cell_mid_y = (cell_min_y + cell_max_y)/2;
297
298 if (x < cell_mid_x)
299 {
300 cell_max_x = cell_mid_x;
301 }
302 else
303 {
304 cell_min_x = cell_mid_x;
305 level_index |= 1;
306 }
307 if (y < cell_mid_y)
308 {
309 cell_max_y = cell_mid_y;
310 }
311 else
312 {
313 cell_min_y = cell_mid_y;
314 level_index |= 2;
315 }
316 level--;
317 }
318
319 return level_index;
320}
321
322// returns the (sub-)level index of the cell that x & y fall into
323U32 LASquadtree::get_level_index(const F64 x, const F64 y) const

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected