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

195  {
196  // Advance vertex index
197  m_currentVertex ++;
198 
199  // Check whether the user wants to iterate through the vertices of the holes
200  // and behave accordingly
201  if( m_iterateHoles )
202  {
203  // If the last vertex of the contour was reached, advance the contour index
205  {
206  m_currentVertex = 0;
208 
209  // If the last contour of the current polygon was reached, advance the
210  // outline index
211  int totalContours = m_poly->CPolygon( m_currentPolygon ).size();
212 
213  if( m_currentContour >= totalContours )
214  {
215  m_currentContour = 0;
217  }
218  }
219  }
220  else
221  {
222  // If the last vertex of the outline was reached, advance to the following polygon
223  if( m_currentVertex >= m_poly->CPolygon( m_currentPolygon )[0].PointCount() )
224  {
225  m_currentVertex = 0;
227  }
228  }
229  }
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 170 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 247 of file shape_poly_set.h.

248  {
249  return Get();
250  }

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

176  {
178  return true;
179 
180  if( m_currentPolygon != m_poly->OutlineCount() - 1 )
181  return false;
182 
183  const auto& currentPolygon = m_poly->CPolygon( m_currentPolygon );
184 
185  return m_currentContour < (int) currentPolygon.size() - 1
186  || m_currentVertex < currentPolygon[m_currentContour].PointCount();
187  }
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 231 of file shape_poly_set.h.

232  {
233  Advance();
234  }
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 236 of file shape_poly_set.h.

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

253  {
254  return &Get();
255  }

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