EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
EBGeometry::SFC::Hilbert Struct Reference

Implementation of the 3D Hilbert space-filling curve. More...

#include <EBGeometry_SFC.hpp>

Static Public Member Functions

static uint64_t encode (const Index &a_point) noexcept
 Encode the input point into the linear Hilbert distance.
 
static Index decode (const uint64_t &a_code) noexcept
 Decode the linear Hilbert distance back into an Index.
 

Detailed Description

Implementation of the 3D Hilbert space-filling curve.

Uses Skilling's algorithm (J. Skilling, "Programming the Hilbert curve", AIP Conf. Proc. 707, 381 (2004)): encode() maps the 3D grid index into the Hilbert "transpose" representation and bit-interleaves it into the linear Hilbert distance; decode() reverses both steps. Unlike Morton (Z-order), the Hilbert curve has no long-range jumps – consecutive codes always map to spatially adjacent cells (Manhattan distance 1) – so an ordering along it produces more compact, better localized runs of primitives, which is why it is often preferred for building spatially coherent leaves. Encodes/decodes the same [0, ValidSpan] per-axis range as Morton and Nested, using the full 3*ValidBits = 63 bits of the code.

Member Function Documentation

◆ decode()

static Index EBGeometry::SFC::Hilbert::decode ( const uint64_t a_code)
inlinestaticnoexcept

Decode the linear Hilbert distance back into an Index.

Parameters
[in]a_codeHilbert code to decode. Must be a code actually produced by encode(), i.e. no bits above position 3*ValidBits-1 may be set.
Returns
3D grid index corresponding to a_code.

◆ encode()

static uint64_t EBGeometry::SFC::Hilbert::encode ( const Index a_point)
inlinestaticnoexcept

Encode the input point into the linear Hilbert distance.

Parameters
[in]a_point3D grid index to encode. Each component must be <= ValidSpan.
Returns
64-bit Hilbert code (distance along the curve) for a_point.

The documentation for this struct was generated from the following file: