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 37 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 57 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 58 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 208 of file shape_index_list.h.

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

Definition at line 277 of file shape_index_list.h.

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

Definition at line 262 of file shape_index_list.h.

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

Definition at line 282 of file shape_index_list.h.

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

Definition at line 267 of file shape_index_list.h.

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

Definition at line 272 of file shape_index_list.h.

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

238  {
239  SHAPE_VEC_ITER i;
240  int n = 0;
241  VECTOR2I::extended_type minDistSq = (VECTOR2I::extended_type) aMinDistance * aMinDistance;
242 
243  BOX2I refBBox = aShape->BBox();
244 
245  for( i = m_shapes.begin(); i != m_shapes.end(); ++i )
246  {
247  if( refBBox.SquaredDistance( i->bbox ) <= minDistSq )
248  {
249  if( !aExact || i->shape->Collide( aShape, aMinDistance ) )
250  {
251  n++;
252 
253  if( !aV( i->parent ) )
254  return n;
255  }
256  }
257  }
258 
259  return n;
260  }
VECTOR2_TRAITS< int >::extended_type extended_type
Definition: vector2d.h:81
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 215 of file shape_index_list.h.

216  {
217  SHAPE_VEC_ITER i;
218 
219  for( i = m_shapes.begin(); i != m_shapes.end(); ++i )
220  {
221  if( i->parent == aItem )
222  break;
223  }
224 
225  if( i == m_shapes.end() )
226  return;
227 
228  m_shapes.erase( i );
229  }
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 231 of file shape_index_list.h.

232  {
233  return m_shapes.size();
234  }

Member Data Documentation


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