KiCad PCB EDA Suite
SHAPE_INDEX_LIST< T, > Class Template Reference

#include <shape_index_list.h>

Classes

class  iterator
 
class  query_iterator
 
struct  SHAPE_ENTRY
 

Public Member Functions

void Add (T aItem)
 
void Remove (const T aItem)
 
int Size () const
 
template<class Visitor >
int Query (const SHAPE *aShape, int aMinDistance, Visitor &aV, bool aExact=true)
 
void Clear ()
 
query_iterator qbegin (SHAPE *aShape, int aMinDistance, bool aExact)
 
const query_iterator qend ()
 
iterator begin ()
 
iterator end ()
 

Private Types

typedef std::vector< SHAPE_ENTRYSHAPE_VEC
 
typedef std::vector< SHAPE_ENTRY >::iterator SHAPE_VEC_ITER
 

Private Attributes

SHAPE_VEC m_shapes
 

Detailed Description

template<class T, const SHAPE * = defaultShapeFunctor<T>>
class SHAPE_INDEX_LIST< T, >

Definition at line 42 of file shape_index_list.h.

Member Typedef Documentation

◆ SHAPE_VEC

template<class T , const SHAPE * = defaultShapeFunctor<T>>
typedef std::vector<SHAPE_ENTRY> SHAPE_INDEX_LIST< T, >::SHAPE_VEC
private

Definition at line 62 of file shape_index_list.h.

◆ SHAPE_VEC_ITER

template<class T , const SHAPE * = defaultShapeFunctor<T>>
typedef std::vector<SHAPE_ENTRY>::iterator SHAPE_INDEX_LIST< T, >::SHAPE_VEC_ITER
private

Definition at line 63 of file shape_index_list.h.

Member Function Documentation

◆ Add()

template<class T , const SHAPE * = defaultShapeFunctor<T>>
void SHAPE_INDEX_LIST< T, >::Add ( aItem)
inline

Definition at line 213 of file shape_index_list.h.

214 {
215 SHAPE_ENTRY s( aItem );
216
217 m_shapes.push_back( s );
218 }

References SHAPE_INDEX_LIST< T, >::m_shapes.

◆ begin()

template<class T , const SHAPE * = defaultShapeFunctor<T>>
iterator SHAPE_INDEX_LIST< T, >::begin ( )
inline

Definition at line 282 of file shape_index_list.h.

283 {
284 return iterator( m_shapes.begin() );
285 }

References SHAPE_INDEX_LIST< T, >::m_shapes.

◆ Clear()

template<class T , const SHAPE * = defaultShapeFunctor<T>>
void SHAPE_INDEX_LIST< T, >::Clear ( )
inline

Definition at line 267 of file shape_index_list.h.

268 {
269 m_shapes.clear();
270 }

References SHAPE_INDEX_LIST< T, >::m_shapes.

◆ end()

template<class T , const SHAPE * = defaultShapeFunctor<T>>
iterator SHAPE_INDEX_LIST< T, >::end ( )
inline

Definition at line 287 of file shape_index_list.h.

288 {
289 return iterator( m_shapes.end() );
290 }

References SHAPE_INDEX_LIST< T, >::m_shapes.

◆ qbegin()

template<class T , const SHAPE * = defaultShapeFunctor<T>>
query_iterator SHAPE_INDEX_LIST< T, >::qbegin ( SHAPE aShape,
int  aMinDistance,
bool  aExact 
)
inline

Definition at line 272 of file shape_index_list.h.

273 {
274 return query_iterator( m_shapes.begin(), m_shapes.end(), aShape, aMinDistance, aExact );
275 }

References SHAPE_INDEX_LIST< T, >::m_shapes.

◆ qend()

template<class T , const SHAPE * = defaultShapeFunctor<T>>
const query_iterator SHAPE_INDEX_LIST< T, >::qend ( )
inline

Definition at line 277 of file shape_index_list.h.

278 {
279 return query_iterator( m_shapes.end(), m_shapes.end(), nullptr, 0, false );
280 }

References SHAPE_INDEX_LIST< T, >::m_shapes.

◆ Query()

template<class T , const SHAPE * = defaultShapeFunctor<T>>
template<class Visitor >
int SHAPE_INDEX_LIST< T, >::Query ( const SHAPE aShape,
int  aMinDistance,
Visitor &  aV,
bool  aExact = true 
)
inline

Definition at line 242 of file shape_index_list.h.

243 {
245 int n = 0;
246 VECTOR2I::extended_type minDistSq = (VECTOR2I::extended_type) aMinDistance * aMinDistance;
247
248 BOX2I refBBox = aShape->BBox();
249
250 for( i = m_shapes.begin(); i != m_shapes.end(); ++i )
251 {
252 if( refBBox.SquaredDistance( i->bbox ) <= minDistSq )
253 {
254 if( !aExact || i->shape->Collide( aShape, aMinDistance ) )
255 {
256 n++;
257
258 if( !aV( i->parent ) )
259 return n;
260 }
261 }
262 }
263
264 return n;
265 }
ecoord_type SquaredDistance(const Vec &aP) const
Definition: box2.h:420
std::vector< SHAPE_ENTRY >::iterator SHAPE_VEC_ITER
virtual const BOX2I BBox(int aClearance=0) const =0
Compute a bounding box of the shape, with a margin of aClearance a collision.
VECTOR2_TRAITS< int >::extended_type extended_type
Definition: vector2d.h:76

References SHAPE::BBox(), SHAPE_INDEX_LIST< T, >::m_shapes, and BOX2< Vec >::SquaredDistance().

◆ Remove()

template<class T , const SHAPE * = defaultShapeFunctor<T>>
void SHAPE_INDEX_LIST< T, >::Remove ( const T  aItem)
inline

Definition at line 220 of file shape_index_list.h.

221 {
223
224 for( i = m_shapes.begin(); i != m_shapes.end(); ++i )
225 {
226 if( i->parent == aItem )
227 break;
228 }
229
230 if( i == m_shapes.end() )
231 return;
232
233 m_shapes.erase( i );
234 }

References SHAPE_INDEX_LIST< T, >::m_shapes.

◆ Size()

template<class T , const SHAPE * = defaultShapeFunctor<T>>
int SHAPE_INDEX_LIST< T, >::Size ( ) const
inline

Definition at line 236 of file shape_index_list.h.

237 {
238 return m_shapes.size();
239 }

References SHAPE_INDEX_LIST< T, >::m_shapes.

Member Data Documentation

◆ m_shapes


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