MCPcopy Create free account
hub / github.com/LAStools/LAStools / get_cell

Method get_cell

LASlib/src/lascopc.cpp:283–306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

281}
282
283I32 EPToctree::get_cell(const LASpoint*p, const EPTkey& key) const
284{
285 F64 size = get_halfsize()*2;
286 F64 res = size / (static_cast<uint64_t>(1) << key.d);
287
288 // Bounding box of the octant
289 F64 minx = res * key.x + (get_center_x() - get_halfsize());
290 F64 miny = res * key.y + (get_center_y() - get_halfsize());
291 F64 minz = res * key.z + (get_center_z() - get_halfsize());
292 F64 maxx = minx + res;
293 //F64 maxy = miny + res;
294 //F64 maxz = minz + res;
295
296 // Get cell id in this octant
297 F64 grid_resolution = (maxx - minx) / grid_size;
298 I32 xi = (I32)std::floor((p->get_x() - minx) / grid_resolution);
299 I32 yi = (I32)std::floor((p->get_y() - miny) / grid_resolution);
300 I32 zi = (I32)std::floor((p->get_z() - minz) / grid_resolution);
301 xi = (std::min)((std::max)(0, xi), grid_size - 1);
302 yi = (std::min)((std::max)(0, yi), grid_size - 1);
303 zi = (std::min)((std::max)(0, zi), grid_size - 1);
304
305 return zi * grid_size * grid_size + yi * grid_size + xi;
306}
307
308COPCindex::COPCindex(const LASheader& header) : EPToctree(header)
309{

Callers 1

mainFunction · 0.45

Calls 4

get_halfsizeFunction · 0.85
get_center_xFunction · 0.85
get_center_yFunction · 0.85
get_center_zFunction · 0.85

Tested by

no test coverage detected