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

A spatial index over the triangles of a cached triangulation, used to prune collision tests. More...

#include <shape_poly_tri_index.h>

Public Types

using TRI = SHAPE_POLY_SET::TRIANGULATED_POLYGON::TRI
 

Public Member Functions

 TRIANGULATION_INDEX (const std::vector< std::unique_ptr< SHAPE_POLY_SET::TRIANGULATED_POLYGON > > &aPolys)
 Index every triangle of every polygon. Immutable once constructed.
 
template<typename VISITOR>
void Query (const BOX2I &aBox, VISITOR aVisitor) const
 Visit every triangle whose bounding box overlaps aBox.
 

Private Attributes

KIRTREE::PACKED_RTREE< uint32_t, int, 2 > m_tree
 
std::vector< const TRI * > m_tris
 Not owning: the triangulation outlives us.
 

Detailed Description

A spatial index over the triangles of a cached triangulation, used to prune collision tests.

Visitation order is unspecified.

The index does not own the triangles, so whoever owns them must drop it whenever they are rebuilt, discarded or moved.

Definition at line 40 of file shape_poly_tri_index.h.

Member Typedef Documentation

◆ TRI

Constructor & Destructor Documentation

◆ TRIANGULATION_INDEX()

Member Function Documentation

◆ Query()

template<typename VISITOR>
void TRIANGULATION_INDEX::Query ( const BOX2I & aBox,
VISITOR aVisitor ) const
inline

Visit every triangle whose bounding box overlaps aBox.

aVisitor is called as bool( const TRI* ); returning false stops the search.

Definition at line 82 of file shape_poly_tri_index.h.

References BOX2< Vec >::GetBottom(), BOX2< Vec >::GetRight(), BOX2< Vec >::GetX(), BOX2< Vec >::GetY(), m_tree, and m_tris.

Referenced by VisitTriangleCandidates().

Member Data Documentation

◆ m_tree

KIRTREE::PACKED_RTREE<uint32_t, int, 2> TRIANGULATION_INDEX::m_tree
private

Definition at line 100 of file shape_poly_tri_index.h.

Referenced by Query(), and TRIANGULATION_INDEX().

◆ m_tris

std::vector<const TRI*> TRIANGULATION_INDEX::m_tris
private

Not owning: the triangulation outlives us.

Definition at line 103 of file shape_poly_tri_index.h.

Referenced by Query(), and TRIANGULATION_INDEX().


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