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 185 of file shape_poly_set.h.

186  {
187  // Advance vertex index
188  m_currentVertex ++;
189 
190  // Check whether the user wants to iterate through the vertices of the holes
191  // and behave accordingly
192  if( m_iterateHoles )
193  {
194  // If the last vertex of the contour was reached, advance the contour index
196  {
197  m_currentVertex = 0;
199 
200  // If the last contour of the current polygon was reached, advance the
201  // outline index
202  int totalContours = m_poly->CPolygon( m_currentPolygon ).size();
203 
204  if( m_currentContour >= totalContours )
205  {
206  m_currentContour = 0;
208  }
209  }
210  }
211  else
212  {
213  // If the last vertex of the outline was reached, advance to the following polygon
214  if( m_currentVertex >= m_poly->CPolygon( m_currentPolygon )[0].PointCount() )
215  {
216  m_currentVertex = 0;
218  }
219  }
220  }
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()

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

◆ 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 237 of file shape_poly_set.h.

238  {
239  return Get();
240  }

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  {
169  return true;
170 
171  if( m_currentPolygon != m_poly->OutlineCount() - 1 )
172  return false;
173 
174  auto currentPolygon = m_poly->CPolygon( m_currentPolygon );
175 
176  return m_currentContour < (int) currentPolygon.size() - 1
177  || m_currentVertex < currentPolygon[m_currentContour].PointCount();
178  }
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_currentVertex, 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 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++() [2/2]

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

Definition at line 227 of file shape_poly_set.h.

228  {
229  Advance();
230  }
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 242 of file shape_poly_set.h.

243  {
244  return &Get();
245  }

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 264 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: