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

Member Function Documentation

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

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++().

118  {
119  // Advance vertex index
120  m_currentVertex ++;
121 
122  // Check whether the user wants to iterate through the vertices of the holes
123  // and behave accordingly
124  if( m_iterateHoles )
125  {
126  // If the last vertex of the contour was reached, advance the contour index
128  {
129  m_currentVertex = 0;
131 
132  // If the last contour of the current polygon was reached, advance the
133  // outline index
134  int totalContours = m_poly->CPolygon( m_currentPolygon ).size();
135 
136  if( m_currentContour >= totalContours )
137  {
138  m_currentContour = 0;
140  }
141  }
142  }
143  else
144  {
145  // If the last vertex of the outline was reached, advance to the following polygon
146  if( m_currentVertex >= m_poly->CPolygon( m_currentPolygon )[0].PointCount() )
147  {
148  m_currentVertex = 0;
150  }
151  }
152  }
const POLYGON & CPolygon(int aIndex) const
template<class T >
VERTEX_INDEX SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::GetIndex ( )
inline

Function GetIndex.

Returns
VERTEX_INDEX - indices of the current polygon, contour and vertex.

Definition at line 183 of file shape_poly_set.h.

References SHAPE_POLY_SET::VERTEX_INDEX::m_contour, 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::VERTEX_INDEX::m_polygon, and SHAPE_POLY_SET::VERTEX_INDEX::m_vertex.

Referenced by SHAPE_POLY_SET::RemoveNullSegments().

184  {
185  VERTEX_INDEX index;
186 
187  index.m_polygon = m_currentPolygon;
188  index.m_contour = m_currentContour;
189  index.m_vertex = m_currentVertex;
190 
191  return index;
192  }
struct SHAPE_POLY_SET::VERTEX_INDEX VERTEX_INDEX
Struct VERTEX_INDEX.
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 102 of file shape_poly_set.h.

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

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

Definition at line 169 of file shape_poly_set.h.

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

170  {
171  return Get();
172  }
template<class T >
void SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::operator++ ( int  dummy)
inline

Definition at line 154 of file shape_poly_set.h.

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

155  {
156  Advance();
157  }
void Advance()
Function Advance advances the indices of the current vertex/outline/contour, checking whether the ver...
template<class T >
void SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::operator++ ( )
inline

Definition at line 159 of file shape_poly_set.h.

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

160  {
161  Advance();
162  }
void Advance()
Function Advance advances the indices of the current vertex/outline/contour, checking whether the ver...
template<class T >
T* SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::operator-> ( )
inline

Definition at line 174 of file shape_poly_set.h.

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

175  {
176  return &Get();
177  }

Friends And Related Function Documentation

template<class T >
friend class SHAPE_POLY_SET
friend

Definition at line 196 of file shape_poly_set.h.

Member Data Documentation

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

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