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

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++ ()
 
const T & Get ()
 
const T & operator * ()
 
const 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 >

ITERATOR_TEMPLATE.

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

Definition at line 158 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 200 of file shape_poly_set.h.

201  {
202  // Advance vertex index
203  m_currentVertex ++;
204 
205  // Check whether the user wants to iterate through the vertices of the holes
206  // and behave accordingly
207  if( m_iterateHoles )
208  {
209  // If the last vertex of the contour was reached, advance the contour index
211  {
212  m_currentVertex = 0;
214 
215  // If the last contour of the current polygon was reached, advance the
216  // outline index
217  int totalContours = m_poly->CPolygon( m_currentPolygon ).size();
218 
219  if( m_currentContour >= totalContours )
220  {
221  m_currentContour = 0;
223  }
224  }
225  }
226  else
227  {
228  // If the last vertex of the outline was reached, advance to the following polygon
229  if( m_currentVertex >= m_poly->CPolygon( m_currentPolygon )[0].PointCount() )
230  {
231  m_currentVertex = 0;
233  }
234  }
235  }
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 176 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 >
const T& SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::operator * ( )
inline

Definition at line 253 of file shape_poly_set.h.

254  {
255  return Get();
256  }

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

182  {
184  return true;
185 
186  if( m_currentPolygon != m_poly->OutlineCount() - 1 )
187  return false;
188 
189  const auto& currentPolygon = m_poly->CPolygon( m_currentPolygon );
190 
191  return m_currentContour < (int) currentPolygon.size() - 1
192  || m_currentVertex < currentPolygon[m_currentContour].PointCount();
193  }
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 237 of file shape_poly_set.h.

238  {
239  Advance();
240  }
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 242 of file shape_poly_set.h.

243  {
244  Advance();
245  }
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 >
const T* SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::operator-> ( )
inline

Definition at line 258 of file shape_poly_set.h.

259  {
260  return &Get();
261  }

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