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

Immutable owning spatial snapshot of straight segments. More...

#include <segment_index.h>

Public Member Functions

 SEGMENT_INDEX (std::vector< SEG > aSegments)
 
 SEGMENT_INDEX (SEGMENT_INDEX &&) noexcept=default
 
SEGMENT_INDEX & operator= (SEGMENT_INDEX &&) noexcept=default
 
 SEGMENT_INDEX (const SEGMENT_INDEX &)=delete
 
SEGMENT_INDEX & operator= (const SEGMENT_INDEX &)=delete
 
size_t size () const
 
const SEG & Segment (int aIndex) const
 
template<typename VISITOR>
void VisitCandidates (const SEG &aQuery, int aPadding, VISITOR &&aVisitor) const
 Visit candidates overlapping aQuery's endpoint bounds expanded by aPadding.
 

Private Types

using TREE = KIRTREE::PACKED_RTREE<int, int, 2>
 

Static Private Member Functions

static int clampCoordinate (int64_t aValue)
 

Private Attributes

std::vector< SEG > m_segments
 
TREE m_tree
 

Detailed Description

Immutable owning spatial snapshot of straight segments.

Candidate order is unspecified. Queries conservatively include every segment whose endpoint bounds overlap the padded query bounds. The owned snapshot is independent of its source and is safe for concurrent const queries. This is an internal geometry helper; its API is not stable.

Definition at line 40 of file segment_index.h.

Member Typedef Documentation

◆ TREE

using SEGMENT_INDEX::TREE = KIRTREE::PACKED_RTREE<int, int, 2>
private

Definition at line 90 of file segment_index.h.

Constructor & Destructor Documentation

◆ SEGMENT_INDEX() [1/3]

SEGMENT_INDEX::SEGMENT_INDEX ( std::vector< SEG > aSegments)
inlineexplicit

Definition at line 43 of file segment_index.h.

References m_segments, and move.

Referenced by operator=(), operator=(), SEGMENT_INDEX(), and SEGMENT_INDEX().

◆ SEGMENT_INDEX() [2/3]

SEGMENT_INDEX::SEGMENT_INDEX ( SEGMENT_INDEX && )
defaultnoexcept

References SEGMENT_INDEX().

◆ SEGMENT_INDEX() [3/3]

SEGMENT_INDEX::SEGMENT_INDEX ( const SEGMENT_INDEX & )
delete

References SEGMENT_INDEX().

Member Function Documentation

◆ clampCoordinate()

static int SEGMENT_INDEX::clampCoordinate ( int64_t aValue)
inlinestaticprivate

Definition at line 92 of file segment_index.h.

Referenced by VisitCandidates().

◆ operator=() [1/2]

SEGMENT_INDEX & SEGMENT_INDEX::operator= ( const SEGMENT_INDEX & )
delete

References SEGMENT_INDEX().

◆ operator=() [2/2]

SEGMENT_INDEX & SEGMENT_INDEX::operator= ( SEGMENT_INDEX && )
defaultnoexcept

References SEGMENT_INDEX().

◆ Segment()

const SEG & SEGMENT_INDEX::Segment ( int aIndex) const
inline

Definition at line 67 of file segment_index.h.

References m_segments.

◆ size()

size_t SEGMENT_INDEX::size ( ) const
inline

Definition at line 65 of file segment_index.h.

References m_segments, and size().

Referenced by size().

◆ VisitCandidates()

template<typename VISITOR>
void SEGMENT_INDEX::VisitCandidates ( const SEG & aQuery,
int aPadding,
VISITOR && aVisitor ) const
inline

Visit candidates overlapping aQuery's endpoint bounds expanded by aPadding.

Negative padding is treated as zero so the query never shrinks below the query bounds and stays conservative. The visitor receives the original segment index and returns true to continue or false to stop.

Definition at line 77 of file segment_index.h.

References SEG::A, SEG::B, clampCoordinate(), m_tree, VECTOR2< T >::x, and VECTOR2< T >::y.

Member Data Documentation

◆ m_segments

std::vector<SEG> SEGMENT_INDEX::m_segments
private

Definition at line 98 of file segment_index.h.

Referenced by Segment(), SEGMENT_INDEX(), and size().

◆ m_tree

TREE SEGMENT_INDEX::m_tree
private

Definition at line 99 of file segment_index.h.

Referenced by VisitCandidates().


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