KiCad PCB EDA Suite
SHAPE_POLY_SET::ITERATOR_TEMPLATE< T > Class Template Reference

Class ITERATOR_TEMPLATE. More...

#include <shape_poly_set.h>

Public Member Functions

bool IsEndContour () const
 Function IsEndContour. More...
 
bool IsLastPolygon () const
 Function IsLastOutline. More...
 
 operator bool () const
 
void Advance ()
 Function Advance advances the indices of the current vertex/outline/contour, checking whether the vertices in the holes have to be iterated through. More...
 
void operator++ (int dummy)
 
void operator++ ()
 
T & Get ()
 
T & operator * ()
 
T * operator-> ()
 
VERTEX_INDEX GetIndex ()
 Function GetIndex. More...
 

Private Attributes

SHAPE_POLY_SETm_poly
 
int m_currentPolygon
 
int m_currentContour
 
int m_currentVertex
 
int m_lastPolygon
 
bool m_iterateHoles
 

Friends

class SHAPE_POLY_SET
 

Detailed Description

template<class T>
class SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >

Class ITERATOR_TEMPLATE.

Base class for iterating over all vertices in a given SHAPE_POLY_SET.

Definition at line 143 of file shape_poly_set.h.

Member Function Documentation

◆ Advance()

template<class T >
void SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::Advance ( )
inline

Function Advance advances the indices of the current vertex/outline/contour, checking whether the vertices in the holes have to be iterated through.

Definition at line 180 of file shape_poly_set.h.

181  {
182  // Advance vertex index
183  m_currentVertex ++;
184 
185  // Check whether the user wants to iterate through the vertices of the holes
186  // and behave accordingly
187  if( m_iterateHoles )
188  {
189  // If the last vertex of the contour was reached, advance the contour index
191  {
192  m_currentVertex = 0;
194 
195  // If the last contour of the current polygon was reached, advance the
196  // outline index
197  int totalContours = m_poly->CPolygon( m_currentPolygon ).size();
198 
199  if( m_currentContour >= totalContours )
200  {
201  m_currentContour = 0;
203  }
204  }
205  }
206  else
207  {
208  // If the last vertex of the outline was reached, advance to the following polygon
209  if( m_currentVertex >= m_poly->CPolygon( m_currentPolygon )[0].PointCount() )
210  {
211  m_currentVertex = 0;
213  }
214  }
215  }
const POLYGON & CPolygon(int aIndex) const

References SHAPE_POLY_SET::CPolygon(), SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::m_currentContour, SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::m_currentPolygon, SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::m_currentVertex, SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::m_iterateHoles, and SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::m_poly.

Referenced by SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::operator++().

◆ Get()

◆ GetIndex()

template<class T >
VERTEX_INDEX SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::GetIndex ( )
inline

◆ IsEndContour()

◆ IsLastPolygon()

template<class T >
bool SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::IsLastPolygon ( ) const
inline

Function IsLastOutline.

Returns
bool - true if the current outline is the last one; false otherwise.

Definition at line 161 of file shape_poly_set.h.

References SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::m_currentPolygon, and SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::m_lastPolygon.

◆ operator *()

template<class T >
T& SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::operator * ( )
inline

Definition at line 232 of file shape_poly_set.h.

233  {
234  return Get();
235  }

References SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::Get().

◆ operator bool()

template<class T >
SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::operator bool ( ) const
inline

Definition at line 166 of file shape_poly_set.h.

167  {
168  return ( ( m_currentPolygon < m_lastPolygon ) || ( m_currentPolygon == m_poly->OutlineCount() - 1 &&
169  ( m_currentContour < static_cast<int>( m_poly->CPolygon( m_currentPolygon ).size() ) - 1 ||
170  ( m_currentVertex < m_poly->CPolygon( m_currentPolygon )[m_currentContour].PointCount() )
171  )
172  ) );
173  }
const POLYGON & CPolygon(int aIndex) const
int OutlineCount() const
Returns the number of outlines in the set

References SHAPE_POLY_SET::CPolygon(), SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::m_currentContour, SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::m_currentPolygon, SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::m_lastPolygon, SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::m_poly, and SHAPE_POLY_SET::OutlineCount().

◆ operator++() [1/2]

template<class T >
void SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::operator++ ( int  dummy)
inline

Definition at line 217 of file shape_poly_set.h.

218  {
219  Advance();
220  }
void Advance()
Function Advance advances the indices of the current vertex/outline/contour, checking whether the ver...

References SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::Advance().

◆ operator++() [2/2]

template<class T >
void SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::operator++ ( )
inline

Definition at line 222 of file shape_poly_set.h.

223  {
224  Advance();
225  }
void Advance()
Function Advance advances the indices of the current vertex/outline/contour, checking whether the ver...

References SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::Advance().

◆ operator->()

template<class T >
T* SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::operator-> ( )
inline

Definition at line 237 of file shape_poly_set.h.

238  {
239  return &Get();
240  }

References SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::Get().

Friends And Related Function Documentation

◆ SHAPE_POLY_SET

template<class T >
friend class SHAPE_POLY_SET
friend

Definition at line 259 of file shape_poly_set.h.

Member Data Documentation

◆ m_currentContour

◆ m_currentPolygon

◆ m_currentVertex

◆ m_iterateHoles

template<class T >
bool SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::m_iterateHoles
private

◆ m_lastPolygon

◆ m_poly


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