KiCad PCB EDA Suite
Loading...
Searching...
No Matches
SNAP_RESOLVER Class Reference

#include <snap_resolver.h>

Public Types

using CLOCK = std::chrono::steady_clock
 
using CLOCK_CALLBACK = std::function<CLOCK::time_point()>
 
using FEASIBILITY_CALLBACK
 
using TRACE_CALLBACK = std::function<void( const std::string& )>
 

Public Member Functions

void AddCandidate (SNAP_CANDIDATE aCandidate)
 
void Clear ()
 
void SetRetainedCandidate (std::optional< SNAP_STABLE_ID > aId)
 
void SetStickyCandidates (std::vector< SNAP_STABLE_ID > aIds)
 Bias the ranking toward candidates accepted on a previous resolve so the chosen snap stays put until a competitor is clearly closer.
 
void SetRankingHysteresis (double aNormalizedResidual)
 Set how strongly a candidate with hysteresis is favoured, as a fraction of the snap radius.
 
void SetFeasibilityCallback (FEASIBILITY_CALLBACK aCallback)
 
void SetTraceCallback (TRACE_CALLBACK aCallback)
 
void SetClock (CLOCK_CALLBACK aClock)
 
void SetDeadline (CLOCK::duration aDeadline)
 
SNAP_RESULT Resolve (const SNAP_SOURCE_CONTEXT &aContext) const
 

Private Member Functions

bool hasHysteresis (const SNAP_STABLE_ID &aId) const
 True when a candidate should earn the ranking hysteresis (retained or sticky).
 

Private Attributes

std::vector< SNAP_CANDIDATEm_candidates
 
std::optional< SNAP_STABLE_IDm_retainedCandidate
 
std::vector< SNAP_STABLE_IDm_stickyCandidates
 
double m_rankingHysteresis = SNAP_DEFAULT_RANKING_HYSTERESIS
 
FEASIBILITY_CALLBACK m_feasibilityCallback
 
TRACE_CALLBACK m_traceCallback
 
CLOCK_CALLBACK m_clock
 
CLOCK::duration m_deadline = std::chrono::milliseconds( 8 )
 

Detailed Description

Definition at line 254 of file snap_resolver.h.

Member Typedef Documentation

◆ CLOCK

using SNAP_RESOLVER::CLOCK = std::chrono::steady_clock

Definition at line 257 of file snap_resolver.h.

◆ CLOCK_CALLBACK

using SNAP_RESOLVER::CLOCK_CALLBACK = std::function<CLOCK::time_point()>

Definition at line 258 of file snap_resolver.h.

◆ FEASIBILITY_CALLBACK

Initial value:
std::function<SNAP_RESULT( const SNAP_SOURCE_CONTEXT&, const std::vector<SNAP_CANDIDATE>& )>

Definition at line 260 of file snap_resolver.h.

◆ TRACE_CALLBACK

using SNAP_RESOLVER::TRACE_CALLBACK = std::function<void( const std::string& )>

Definition at line 262 of file snap_resolver.h.

Member Function Documentation

◆ AddCandidate()

void SNAP_RESOLVER::AddCandidate ( SNAP_CANDIDATE aCandidate)

◆ Clear()

void SNAP_RESOLVER::Clear ( )

Definition at line 578 of file snap_resolver.cpp.

References m_candidates.

◆ hasHysteresis()

bool SNAP_RESOLVER::hasHysteresis ( const SNAP_STABLE_ID & aId) const
private

True when a candidate should earn the ranking hysteresis (retained or sticky).

Definition at line 602 of file snap_resolver.cpp.

References m_retainedCandidate, and m_stickyCandidates.

Referenced by Resolve().

◆ Resolve()

◆ SetClock()

void SNAP_RESOLVER::SetClock ( CLOCK_CALLBACK aClock)

Definition at line 623 of file snap_resolver.cpp.

References m_clock.

◆ SetDeadline()

void SNAP_RESOLVER::SetDeadline ( CLOCK::duration aDeadline)

Definition at line 629 of file snap_resolver.cpp.

References m_deadline.

◆ SetFeasibilityCallback()

void SNAP_RESOLVER::SetFeasibilityCallback ( FEASIBILITY_CALLBACK aCallback)

Definition at line 611 of file snap_resolver.cpp.

References m_feasibilityCallback.

◆ SetRankingHysteresis()

void SNAP_RESOLVER::SetRankingHysteresis ( double aNormalizedResidual)

Set how strongly a candidate with hysteresis is favoured, as a fraction of the snap radius.

Definition at line 596 of file snap_resolver.cpp.

References m_rankingHysteresis.

◆ SetRetainedCandidate()

void SNAP_RESOLVER::SetRetainedCandidate ( std::optional< SNAP_STABLE_ID > aId)

Definition at line 584 of file snap_resolver.cpp.

References m_retainedCandidate.

◆ SetStickyCandidates()

void SNAP_RESOLVER::SetStickyCandidates ( std::vector< SNAP_STABLE_ID > aIds)

Bias the ranking toward candidates accepted on a previous resolve so the chosen snap stays put until a competitor is clearly closer.

Unlike the retained candidate these are not forced into the result, they only earn the ranking hysteresis that prevents frame-to-frame jitter between near-equal solutions.

Definition at line 590 of file snap_resolver.cpp.

References m_stickyCandidates.

◆ SetTraceCallback()

void SNAP_RESOLVER::SetTraceCallback ( TRACE_CALLBACK aCallback)

Definition at line 617 of file snap_resolver.cpp.

References m_traceCallback.

Member Data Documentation

◆ m_candidates

std::vector<SNAP_CANDIDATE> SNAP_RESOLVER::m_candidates
private

Definition at line 292 of file snap_resolver.h.

Referenced by AddCandidate(), Clear(), and Resolve().

◆ m_clock

CLOCK_CALLBACK SNAP_RESOLVER::m_clock
private
Initial value:
= []
{
return CLOCK::now();
}

Definition at line 298 of file snap_resolver.h.

Referenced by Resolve(), and SetClock().

◆ m_deadline

CLOCK::duration SNAP_RESOLVER::m_deadline = std::chrono::milliseconds( 8 )
private

Definition at line 302 of file snap_resolver.h.

Referenced by Resolve(), and SetDeadline().

◆ m_feasibilityCallback

FEASIBILITY_CALLBACK SNAP_RESOLVER::m_feasibilityCallback
private

Definition at line 296 of file snap_resolver.h.

Referenced by Resolve(), and SetFeasibilityCallback().

◆ m_rankingHysteresis

double SNAP_RESOLVER::m_rankingHysteresis = SNAP_DEFAULT_RANKING_HYSTERESIS
private

Definition at line 295 of file snap_resolver.h.

Referenced by Resolve(), and SetRankingHysteresis().

◆ m_retainedCandidate

std::optional<SNAP_STABLE_ID> SNAP_RESOLVER::m_retainedCandidate
private

Definition at line 293 of file snap_resolver.h.

Referenced by hasHysteresis(), Resolve(), and SetRetainedCandidate().

◆ m_stickyCandidates

std::vector<SNAP_STABLE_ID> SNAP_RESOLVER::m_stickyCandidates
private

Definition at line 294 of file snap_resolver.h.

Referenced by hasHysteresis(), Resolve(), and SetStickyCandidates().

◆ m_traceCallback

TRACE_CALLBACK SNAP_RESOLVER::m_traceCallback
private

Definition at line 297 of file snap_resolver.h.

Referenced by Resolve(), and SetTraceCallback().


The documentation for this class was generated from the following files: