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 35 of file shape_index_list.h.

Member Typedef Documentation

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

Definition at line 55 of file shape_index_list.h.

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

Definition at line 56 of file shape_index_list.h.

Member Function Documentation

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

Definition at line 206 of file shape_index_list.h.

207  {
208  SHAPE_ENTRY s( aItem );
209 
210  m_shapes.push_back( s );
211  }
template<class T, const SHAPE * = defaultShapeFunctor<T>>
iterator SHAPE_INDEX_LIST< T, >::begin ( )
inline

Definition at line 275 of file shape_index_list.h.

276  {
277  return iterator( m_shapes.begin() );
278  }
template<class T, const SHAPE * = defaultShapeFunctor<T>>
void SHAPE_INDEX_LIST< T, >::Clear ( )
inline

Definition at line 260 of file shape_index_list.h.

261  {
262  m_shapes.clear();
263  }
template<class T, const SHAPE * = defaultShapeFunctor<T>>
iterator SHAPE_INDEX_LIST< T, >::end ( )
inline

Definition at line 280 of file shape_index_list.h.

281  {
282  return iterator( m_shapes.end() );
283  }
template<class T, const SHAPE * = defaultShapeFunctor<T>>
query_iterator SHAPE_INDEX_LIST< T, >::qbegin ( SHAPE aShape,
int  aMinDistance,
bool  aExact 
)
inline

Definition at line 265 of file shape_index_list.h.

266  {
267  return query_iterator( m_shapes.begin(), m_shapes.end(), aShape, aMinDistance, aExact );
268  }
template<class T, const SHAPE * = defaultShapeFunctor<T>>
const query_iterator SHAPE_INDEX_LIST< T, >::qend ( )
inline

Definition at line 270 of file shape_index_list.h.

271  {
272  return query_iterator( m_shapes.end(), m_shapes.end(), NULL, 0, false );
273  }
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 235 of file shape_index_list.h.

236  {
237  SHAPE_VEC_ITER i;
238  int n = 0;
239  VECTOR2I::extended_type minDistSq = (VECTOR2I::extended_type) aMinDistance * aMinDistance;
240 
241  BOX2I refBBox = aShape->BBox();
242 
243  for( i = m_shapes.begin(); i != m_shapes.end(); ++i )
244  {
245  if( refBBox.SquaredDistance( i->bbox ) <= minDistSq )
246  {
247  if( !aExact || i->shape->Collide( aShape, aMinDistance ) )
248  {
249  n++;
250 
251  if( !aV( i->parent ) )
252  return n;
253  }
254  }
255  }
256 
257  return n;
258  }
VECTOR2_TRAITS< int >::extended_type extended_type
Definition: vector2d.h:77
ecoord_type SquaredDistance(const Vec &aP) const
Definition: box2.h:406
std::vector< SHAPE_ENTRY >::iterator SHAPE_VEC_ITER
virtual const BOX2I BBox(int aClearance=0) const =0
Function BBox()
template<class T, const SHAPE * = defaultShapeFunctor<T>>
void SHAPE_INDEX_LIST< T, >::Remove ( const T  aItem)
inline

Definition at line 213 of file shape_index_list.h.

214  {
215  SHAPE_VEC_ITER i;
216 
217  for( i = m_shapes.begin(); i != m_shapes.end(); ++i )
218  {
219  if( i->parent == aItem )
220  break;
221  }
222 
223  if( i == m_shapes.end() )
224  return;
225 
226  m_shapes.erase( i );
227  }
std::vector< SHAPE_ENTRY >::iterator SHAPE_VEC_ITER
template<class T, const SHAPE * = defaultShapeFunctor<T>>
int SHAPE_INDEX_LIST< T, >::Size ( ) const
inline

Definition at line 229 of file shape_index_list.h.

230  {
231  return m_shapes.size();
232  }

Member Data Documentation


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