20#ifndef SEGMENT_INDEX_H
21#define SEGMENT_INDEX_H
46 TREE::Builder builder;
49 for(
size_t i = 0; i <
m_segments.size(); ++i )
51 const SEG& segment = m_segments[i];
52 const int min[2] = { std::min( segment.A.x, segment.B.x ), std::min( segment.A.y, segment.B.y ) };
53 const int max[2] = { std::max( segment.A.x, segment.B.x ), std::max( segment.A.y, segment.B.y ) };
54 builder.Add( min, max,
static_cast<int>( i ) );
76 template <
typename VISITOR>
79 const int64_t padding = std::max( aPadding, 0 );
80 const int64_t minX =
static_cast<int64_t
>( std::min( aQuery.
A.
x, aQuery.
B.
x ) ) - padding;
81 const int64_t minY =
static_cast<int64_t
>( std::min( aQuery.
A.
y, aQuery.
B.
y ) ) - padding;
82 const int64_t maxX =
static_cast<int64_t
>( std::max( aQuery.
A.
x, aQuery.
B.
x ) ) + padding;
83 const int64_t maxY =
static_cast<int64_t
>( std::max( aQuery.
A.
y, aQuery.
B.
y ) ) + padding;
86 m_tree.Search( min, max, aVisitor );
94 return static_cast<int>( std::clamp( aValue,
static_cast<int64_t
>( std::numeric_limits<int>::min() ),
95 static_cast<int64_t
>( std::numeric_limits<int>::max() ) ) );
Static (immutable) packed R-tree built via Hilbert-curve bulk loading.
void VisitCandidates(const SEG &aQuery, int aPadding, VISITOR &&aVisitor) const
Visit candidates overlapping aQuery's endpoint bounds expanded by aPadding.
static int clampCoordinate(int64_t aValue)
std::vector< SEG > m_segments
const SEG & Segment(int aIndex) const
SEGMENT_INDEX(std::vector< SEG > aSegments)
SEGMENT_INDEX(SEGMENT_INDEX &&) noexcept=default
KIRTREE::PACKED_RTREE< int, int, 2 > TREE