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

#include <shape_index.h>

Classes

class  Iterator
 

Public Member Functions

 SHAPE_INDEX ()
 
 ~SHAPE_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 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 ()
 Create an iterator for the current index object.
 

Private Attributes

RTree< T, int, 2, double > * m_tree
 

Detailed Description

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

Definition at line 112 of file shape_index.h.

Constructor & Destructor Documentation

◆ SHAPE_INDEX()

template<class T >
SHAPE_INDEX< T >::SHAPE_INDEX

Definition at line 291 of file shape_index.h.

◆ ~SHAPE_INDEX()

template<class T >
SHAPE_INDEX< T >::~SHAPE_INDEX

Definition at line 297 of file shape_index.h.

Member Function Documentation

◆ Accept()

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

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

Parameters
aVisitoris the visitor object to be run.

Definition at line 237 of file shape_index.h.

References acceptVisitor(), SHAPE_INDEX< T >::Begin(), and SHAPE_INDEX< T >::Iterator::IsNull().

◆ Add() [1/2]

template<class T >
void SHAPE_INDEX< T >::Add ( aShape)

Add a SHAPE to the index.

Parameters
aShapeis the new SHAPE.

Definition at line 312 of file shape_index.h.

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

◆ Add() [2/2]

template<class T >
void SHAPE_INDEX< T >::Add ( aShape,
const BOX2I aBbox 
)

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 303 of file shape_index.h.

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

◆ Begin()

template<class T >
SHAPE_INDEX< T >::Iterator SHAPE_INDEX< T >::Begin

Create an iterator for the current index object.

Returns
iterator to the first object.

Definition at line 360 of file shape_index.h.

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

◆ 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 264 of file shape_index.h.

References SHAPE::BBox(), BOX2< Vec >::GetBottom(), BOX2< Vec >::GetRight(), BOX2< Vec >::GetX(), BOX2< Vec >::GetY(), BOX2< Vec >::Inflate(), and SHAPE_INDEX< T >::m_tree.

◆ Reindex()

template<class T >
void SHAPE_INDEX< T >::Reindex

Rebuild the index.

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

Definition at line 338 of file shape_index.h.

References boundingBox(), BOX2< Vec >::GetBottom(), BOX2< Vec >::GetRight(), BOX2< Vec >::GetX(), BOX2< Vec >::GetY(), and SHAPE_INDEX< T >::Iterator::IsNull().

◆ Remove()

template<class T >
void SHAPE_INDEX< T >::Remove ( aShape)

Remove a SHAPE from the index.

Parameters
aShapeis the SHAPE to remove.

Definition at line 322 of file shape_index.h.

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

◆ RemoveAll()

template<class T >
void SHAPE_INDEX< T >::RemoveAll

Remove all the contents of the index.

Definition at line 332 of file shape_index.h.

Member Data Documentation

◆ m_tree

template<class T = SHAPE*>
RTree<T, int, 2, double>* SHAPE_INDEX< T >::m_tree
private

Definition at line 283 of file shape_index.h.

Referenced by SHAPE_INDEX< T >::Iterator::Iterator(), and SHAPE_INDEX< T >::Query().


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