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

Method raster_occupancy

src/lasquadtree.cpp:501–555  ·  view source on GitHub ↗

recursively does the actual rastering of the occupancy

Source from the content-addressed store, hash-verified

499
500// recursively does the actual rastering of the occupancy
501void LASquadtree::raster_occupancy(BOOL(*does_cell_exist)(I32), U32* data, U32 min_x, U32 min_y, U32 level_index, U32 level, U32 stop_level) const
502{
503 U32 cell_index = get_cell_index(level_index, level);
504 U32 adaptive_pos = cell_index/32;
505 U32 adaptive_bit = ((U32)1) << (cell_index%32);
506 // have we reached a leaf
507 if (adaptive[adaptive_pos] & adaptive_bit) // interior node
508 {
509 if (level < stop_level) // do we need to continue
510 {
511 level_index <<= 2;
512 level += 1;
513 U32 size = 1 << (stop_level-level);
514 // recurse into the four children
515 raster_occupancy(does_cell_exist, data, min_x, min_y, level_index, level, stop_level);
516 raster_occupancy(does_cell_exist, data, min_x+size, min_y, level_index + 1, level, stop_level);
517 raster_occupancy(does_cell_exist, data, min_x, min_y+size, level_index + 2, level, stop_level);
518 raster_occupancy(does_cell_exist, data, min_x+size, min_y+size, level_index + 3, level, stop_level);
519 return;
520 }
521 else // no ... raster remaining subtree
522 {
523 U32 full_size = (1 << stop_level);
524 U32 size = 1 << (stop_level-level);
525 U32 max_y = min_y + size;
526 U32 pos, pos_x, pos_y;
527 for (pos_y = min_y; pos_y < max_y; pos_y++)
528 {
529 pos = pos_y*full_size + min_x;
530 for (pos_x = 0; pos_x < size; pos_x++)
531 {
532 data[pos/32] |= (1<<(pos%32));
533 pos++;
534 }
535 }
536 }
537 }
538 else if (does_cell_exist(cell_index))
539 {
540 // raster actual cell
541 U32 full_size = (1 << stop_level);
542 U32 size = 1 << (stop_level-level);
543 U32 max_y = min_y + size;
544 U32 pos, pos_x, pos_y;
545 for (pos_y = min_y; pos_y < max_y; pos_y++)
546 {
547 pos = pos_y*full_size + min_x;
548 for (pos_x = 0; pos_x < size; pos_x++)
549 {
550 data[pos/32] |= (1<<(pos%32));
551 pos++;
552 }
553 }
554 }
555}
556
557// rasters the occupancy to a simple binary raster at depth level
558U32* LASquadtree::raster_occupancy(BOOL(*does_cell_exist)(I32), U32 level) const

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected