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

Method manage_cell

src/lasquadtree.cpp:751–789  ·  view source on GitHub ↗

create or finalize the cell (in the spatial hierarchy)

Source from the content-addressed store, hash-verified

749
750// create or finalize the cell (in the spatial hierarchy)
751BOOL LASquadtree::manage_cell(const U32 cell_index, const BOOL finalize)
752{
753 U32 adaptive_pos = cell_index/32;
754 U32 adaptive_bit = ((U32)1) << (cell_index%32);
755 if (adaptive_pos >= adaptive_alloc)
756 {
757 if (adaptive)
758 {
759 size_t n_pos = (size_t)adaptive_pos * 2;
760 adaptive = (U32*)realloc_las(adaptive, n_pos * sizeof(U32));
761 for (size_t i = adaptive_alloc; i < n_pos; i++) adaptive[i] = 0;
762 adaptive_alloc = n_pos;
763 }
764 else
765 {
766#pragma warning(push)
767#pragma warning(disable : 6011)
768 adaptive = (U32*)malloc_las(((size_t)adaptive_pos + 1) * sizeof(U32));
769 for (size_t i = adaptive_alloc; i <= adaptive_pos; i++) adaptive[i] = 0;
770 adaptive_alloc = (size_t)adaptive_pos + 1;
771#pragma warning(pop)
772 }
773 }
774 adaptive[adaptive_pos] &= ~adaptive_bit;
775 U32 index;
776 U32 level = get_level(cell_index);
777 U32 level_index = get_level_index(cell_index, level);
778 while (level)
779 {
780 level--;
781 level_index = level_index >> 2;
782 index = get_cell_index(level_index, level);
783 adaptive_pos = index/32;
784 adaptive_bit = ((U32)1) << (index%32);
785 if (adaptive[adaptive_pos] & adaptive_bit) break;
786 adaptive[adaptive_pos] |= adaptive_bit;
787 }
788 return TRUE;
789}
790
791// check whether the x & y coordinates fall into the tiling
792BOOL LASquadtree::inside(const F64 x, const F64 y) const

Callers 2

completeMethod · 0.80
readMethod · 0.80

Calls 2

realloc_lasFunction · 0.85
malloc_lasFunction · 0.85

Tested by

no test coverage detected