class mola::internal::ClosestMatches

Overview

The capacity closest candidates seen so far, sorted by ascending distance (ties keep the order they were added in), for the k-NN and the capped radius searches of the voxel maps.

The first STACK_CAPACITY matches live on the stack, so the usual small-k queries do not allocate; the heap only takes the matches beyond that, so a large capacity costs nothing unless that many candidates are found.

#include <closest_matches.h>

class ClosestMatches
{
public:
    // structs

    struct Match;

    // fields

    static constexpr static size_t STACK_CAPACITY = 32;

    // construction

    ClosestMatches(size_t capacity);
    ClosestMatches(const ClosestMatches&);

    // methods

    ClosestMatches& operator = (const ClosestMatches&);

    void add(
        float sqrDist,
        const mrpt::math::TPoint3Df& pt,
        uint64_t id
        );

    size_t size() const;

    void appendTo(
        std::vector<mrpt::math::TPoint3Df>& pts,
        std::vector<float>& sqrDists,
        std::vector<uint64_t>& ids
        ) const;
};

Methods

void appendTo(
    std::vector<mrpt::math::TPoint3Df>& pts,
    std::vector<float>& sqrDists,
    std::vector<uint64_t>& ids
    ) const

Appends the matches, closest first, to the output vectors.