10#define SE_KEY_UTIL_HPP
15#include <se/supereight_config.hpp>
21#define KEY_SCALE_LIMIT 19
76inline bool is_valid(
const Eigen::Vector3i& coord);
319template<Sort = Sort::SmallToLarge>
348template<se::Safe SafeB>
357template<se::Safe SafeB>
368template<se::Safe SafeB>
382template<se::Safe SafeB>
417#include "impl/key_util_impl.hpp"
#define KEY_SCALE_LIMIT
Definition key_util.hpp:21
se::code_t block_code(const se::key_t key, const se::scale_t max_block_scale)
Removes the voxel position detail within a block from a code.
void sort_keys< Sort::LargeToSmall >(std::vector< se::key_t > &keys)
Sorts the keys from largest to smallest.
se::key_t compact(uint64_t value)
Compresses a value E.g.
void face_neighbours(const se::key_t key, std::array< se::key_t, 6 > face_neighbour_keys)
TODO: 6-connectivity + centre.
bool key_at_scale(const se::key_t key, const se::scale_t scale, se::key_t &key_at_scale)
For a given key, change the key scale and reduce detail from Morton code up to given the scale.
void unique_keys(const std::vector< se::key_t > &keys, std::vector< se::key_t > &unique_keys)
Filter keys based on the whole key (i.e.
Eigen::Vector3i key_to_coord(const se::key_t key)
Reduce a key to only its Morton code.
void unique_allocation(const std::vector< se::key_t > &keys, const scale_t max_block_scale, std::vector< se::key_t > &unique_keys)
Filter keys based on unique allocation.
void siblings(const se::key_t key, std::array< se::key_t, 8 > sibling_keys)
TODO: 4 siblings (includes key)
void parent_to_child_key(const se::key_t parent_key, const se::code_t code_at_scale, se::key_t &child_key)
Compute the child key for a given parent key and child index.
bool is_child(const se::key_t parent_key, const se::key_t child_key)
Verify if a key is a child of a different key.
se::key_t block_key(const se::key_t key, const se::scale_t max_block_scale)
Removes the voxel position detail within a block from a key while maintainig the scale information.
void sort_keys< Sort::SmallToLarge >(std::vector< se::key_t > &keys)
Sorts the keys from smallest to largest.
bool is_siblings(const se::key_t sibling_1_key, const se::key_t sibling_2_key)
Verify if two keys encode sibling nodes/voxels.
void unique_at_scale(const std::vector< se::key_t > &keys, const se::scale_t scale, std::vector< se::key_t > &unique_keys)
Filter keys at a given scale.
bool encode_key(const Eigen::Vector3i &coord, const se::scale_t scale, se::key_t &key)
Encodes given coordinates and scale in a key.
void sort_keys(std::vector< se::key_t > &keys)
Sorting template.
se::code_t expand(unsigned long long value)
Expands a value that can be expressed by <= 19 bits E.g.
idx_t code_to_child_idx(const se::code_t code, const scale_t scale)
Extracts the child index from a Morton code for a given scale.
scale_t key_to_scale(const se::key_t key)
Reduce a key to only its scale.
void neighbours(const se::key_t key, std::array< se::key_t, 26 > neighbour_keys)
TODO: 26-connectivity.
se::code_t key_to_code(const se::key_t key)
Reduce a key to only its Morton code.
void parent_key(const se::key_t key, se::key_t &parent_key)
Compute the direct parent key for a given key.
void unique_codes(const std::vector< se::key_t > &keys, std::vector< se::key_t > &unique_keys)
Filter keys based on their code and keep the key with the smallest scale.
bool code_at_scale(const se::key_t key, const se::scale_t scale, se::code_t &code_at_scale)
For a given key, reduce detail from Morton code up to given a scale.
void encode_code(const Eigen::Vector3i &coord, se::code_t &code)
Compute the Morton code for given x,y,z coordinates.
void decode_code(const se::code_t code, Eigen::Vector3i &coord)
Compute the x,y,z coordinates for a given Morton code.
void decode_key(const se::key_t key, Eigen::Vector3i &coord, scale_t &scale)
Extracts the 3D coordinates and scale from a given key.
bool is_valid(const se::key_t key, const se::scale_t limit=KEY_SCALE_LIMIT)
Verify if a key is valid.
Helper wrapper to allocate and de-allocate octants in the octree.
Definition bounded_vector.hpp:14
uint64_t code_t
The type of the Morton code.
Definition type_util.hpp:44
unsigned int idx_t
Child or voxel index type.
Definition type_util.hpp:47
constexpr uint64_t CODE_MASK[]
The code mask for a given scale.
Definition key_util.hpp:38
constexpr uint64_t SCALE_MASK
11 111
Definition key_util.hpp:58
uint64_t scale_t
The type of the scale in the morton code.
Definition type_util.hpp:45
uint64_t key_t
key = 1 bit buffer + 57 bits of morton code + 6 bits of scale information The maxium scale is limited...
Definition type_util.hpp:43