KiCad PCB EDA Suite
Loading...
Searching...
No Matches
SHAPE_INDEX< T > Class Template Reference

#include <shape_index.h>

Classes

class  Iterator
 

Public Types

using TREE_TYPE = KIRTREE::COW_RTREE<T, int, 2>
 

Public Member Functions

 SHAPE_INDEX (int aLayer)
 
 ~SHAPE_INDEX ()=default
 
 SHAPE_INDEX (SHAPE_INDEX &&aOther) noexcept=default
 
SHAPE_INDEXoperator= (SHAPE_INDEX &&aOther) noexcept=default
 
 SHAPE_INDEX (const SHAPE_INDEX &)=delete
 
SHAPE_INDEXoperator= (const SHAPE_INDEX &)=delete
 
SHAPE_INDEX Clone () const
 Create a CoW clone that shares tree structure with this index.
 
void Add (T aShape)
 Add a SHAPE to the index.
 
void Add (T aShape, const BOX2I &aBbox)
 Add a shape with alternate BBox.
 
void Remove (T aShape)
 Remove a SHAPE from the index.
 
void RemoveAll ()
 Remove all the contents of the index.
 
template<class V>
void Accept (V aVisitor)
 Accept a visitor for every SHAPE object contained in this INDEX.
 
void BulkLoad (std::vector< std::pair< T, BOX2I > > &aItems)
 Build from a batch of items using Hilbert-curve bulk loading.
 
void Reindex ()
 Rebuild the index.
 
template<class V>
int Query (const SHAPE *aShape, int aMinDistance, V &aVisitor) const
 Run a callback on every SHAPE object contained in the bounding box of (shape).
 
Iterator Begin () const
 Create an iterator for the current index object.
 
TREE_TYPE::Iterator begin () const
 
TREE_TYPE::Iterator end () const
 
size_t Size () const
 

Private Attributes

TREE_TYPE m_tree
 
int m_shapeLayer
 

Detailed Description

template<class T = SHAPE*>
class SHAPE_INDEX< T >

Definition at line 113 of file shape_index.h.

Member Typedef Documentation

◆ TREE_TYPE

template<class T = SHAPE*>
using SHAPE_INDEX< T >::TREE_TYPE = KIRTREE::COW_RTREE<T, int, 2>

Definition at line 116 of file shape_index.h.

Constructor & Destructor Documentation

◆ SHAPE_INDEX() [1/3]

template<class T = SHAPE*>
SHAPE_INDEX< T >::SHAPE_INDEX ( int aLayer)
inlineexplicit

Definition at line 189 of file shape_index.h.

◆ ~SHAPE_INDEX()

template<class T = SHAPE*>
SHAPE_INDEX< T >::~SHAPE_INDEX ( )
default

◆ SHAPE_INDEX() [2/3]

template<class T = SHAPE*>
SHAPE_INDEX< T >::SHAPE_INDEX ( SHAPE_INDEX< T > && aOther)
defaultnoexcept

◆ SHAPE_INDEX() [3/3]

template<class T = SHAPE*>
SHAPE_INDEX< T >::SHAPE_INDEX ( const SHAPE_INDEX< T > & )
delete

Member Function Documentation

◆ Accept()

template<class T = SHAPE*>
template<class V>
void SHAPE_INDEX< T >::Accept ( V aVisitor)
inline

Accept a visitor for every SHAPE object contained in this INDEX.

Parameters
aVisitoris the visitor object to be run.

Definition at line 268 of file shape_index.h.

◆ Add() [1/2]

template<class T = SHAPE*>
void SHAPE_INDEX< T >::Add ( T aShape)
inline

Add a SHAPE to the index.

Parameters
aShapeis the new SHAPE.

Definition at line 217 of file shape_index.h.

Referenced by SHAPE_INDEX< ITEM * >::Reindex().

◆ Add() [2/2]

template<class T = SHAPE*>
void SHAPE_INDEX< T >::Add ( T aShape,
const BOX2I & aBbox )
inline

Add a shape with alternate BBox.

Parameters
aShapeShape (Item) to add.
aBboxalternate bounding box. This should be a subset of the item's bbox

Definition at line 232 of file shape_index.h.

◆ Begin()

template<class T = SHAPE*>
Iterator SHAPE_INDEX< T >::Begin ( ) const
inline

Create an iterator for the current index object.

Returns
iterator to the first object.

Definition at line 341 of file shape_index.h.

◆ begin()

template<class T = SHAPE*>
TREE_TYPE::Iterator SHAPE_INDEX< T >::begin ( ) const
inline

Definition at line 347 of file shape_index.h.

Referenced by SHAPE_INDEX< T >::Iterator::Iterator().

◆ BulkLoad()

template<class T = SHAPE*>
void SHAPE_INDEX< T >::BulkLoad ( std::vector< std::pair< T, BOX2I > > & aItems)
inline

Build from a batch of items using Hilbert-curve bulk loading.

Replaces all existing content. O(n log n).

Definition at line 278 of file shape_index.h.

◆ Clone()

template<class T = SHAPE*>
SHAPE_INDEX SHAPE_INDEX< T >::Clone ( ) const
inline

Create a CoW clone that shares tree structure with this index.

O(1) – only increments the root node's refcount.

Definition at line 205 of file shape_index.h.

◆ end()

template<class T = SHAPE*>
TREE_TYPE::Iterator SHAPE_INDEX< T >::end ( ) const
inline

Definition at line 348 of file shape_index.h.

Referenced by SHAPE_INDEX< T >::Iterator::Iterator().

◆ operator=() [1/2]

template<class T = SHAPE*>
SHAPE_INDEX & SHAPE_INDEX< T >::operator= ( const SHAPE_INDEX< T > & )
delete

◆ operator=() [2/2]

template<class T = SHAPE*>
SHAPE_INDEX & SHAPE_INDEX< T >::operator= ( SHAPE_INDEX< T > && aOther)
defaultnoexcept

◆ Query()

template<class T = SHAPE*>
template<class V>
int SHAPE_INDEX< T >::Query ( const SHAPE * aShape,
int aMinDistance,
V & aVisitor ) const
inline

Run a callback on every SHAPE object contained in the bounding box of (shape).

Parameters
aShapeis the shape to search against.
aMinDistanceis the distance threshold.
aVisitoris the object to be invoked on every object contained in the search area.

Definition at line 325 of file shape_index.h.

◆ Reindex()

template<class T = SHAPE*>
void SHAPE_INDEX< T >::Reindex ( )
inline

Rebuild the index.

This should be used if the geometry of the objects contained by the index has changed.

Definition at line 303 of file shape_index.h.

◆ Remove()

template<class T = SHAPE*>
void SHAPE_INDEX< T >::Remove ( T aShape)
inline

Remove a SHAPE from the index.

Parameters
aShapeis the SHAPE to remove.

Definition at line 245 of file shape_index.h.

◆ RemoveAll()

template<class T = SHAPE*>
void SHAPE_INDEX< T >::RemoveAll ( )
inline

Remove all the contents of the index.

Definition at line 257 of file shape_index.h.

◆ Size()

template<class T = SHAPE*>
size_t SHAPE_INDEX< T >::Size ( ) const
inline

Definition at line 350 of file shape_index.h.

Member Data Documentation

◆ m_shapeLayer

template<class T = SHAPE*>
int SHAPE_INDEX< T >::m_shapeLayer
private

Definition at line 354 of file shape_index.h.

◆ m_tree

template<class T = SHAPE*>
TREE_TYPE SHAPE_INDEX< T >::m_tree
private

Definition at line 353 of file shape_index.h.

Referenced by SHAPE_INDEX< ITEM * >::Clone().


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