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

179  {
180  // Advance vertex index
181  m_currentVertex ++;
182 
183  // Check whether the user wants to iterate through the vertices of the holes
184  // and behave accordingly
185  if( m_iterateHoles )
186  {
187  // If the last vertex of the contour was reached, advance the contour index
189  {
190  m_currentVertex = 0;
192 
193  // If the last contour of the current polygon was reached, advance the
194  // outline index
195  int totalContours = m_poly->CPolygon( m_currentPolygon ).size();
196 
197  if( m_currentContour >= totalContours )
198  {
199  m_currentContour = 0;
201  }
202  }
203  }
204  else
205  {
206  // If the last vertex of the outline was reached, advance to the following polygon
207  if( m_currentVertex >= m_poly->CPolygon( m_currentPolygon )[0].PointCount() )
208  {
209  m_currentVertex = 0;
211  }
212  }
213  }
const POLYGON & CPolygon(int aIndex) const
template<class T >
T& SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::Get ( )
inline

Definition at line 225 of file shape_poly_set.h.

226  {
228  }
POLYGON & Polygon(int aIndex)
Returns the aIndex-th subpolygon in the set
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 244 of file shape_poly_set.h.

References SHAPE_POLY_SET::VERTEX_INDEX::m_contour, SHAPE_POLY_SET::VERTEX_INDEX::m_polygon, and SHAPE_POLY_SET::VERTEX_INDEX::m_vertex.

Referenced by SHAPE_POLY_SET::RemoveNullSegments().

245  {
246  VERTEX_INDEX index;
247 
248  index.m_polygon = m_currentPolygon;
249  index.m_contour = m_currentContour;
250  index.m_vertex = m_currentVertex;
251 
252  return index;
253  }
struct SHAPE_POLY_SET::VERTEX_INDEX VERTEX_INDEX
Struct VERTEX_INDEX.
template<class T >
bool SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::IsEndContour ( ) const
inline

Function IsEndContour.

Returns
bool - true if the current vertex is the last one of the current contour (outline or hole); false otherwise.

Definition at line 154 of file shape_poly_set.h.

Referenced by POINT_EDITOR::addCorner(), ZONE_CONTAINER::DrawWhileCreateOutline(), DSN::SPECCTRA_DB::FromBOARD(), and SHAPE_POLY_SET::RemoveNullSegments().

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

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

Definition at line 168 of file shape_poly_set.h.

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

Definition at line 230 of file shape_poly_set.h.

231  {
232  return Get();
233  }
template<class T >
void SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::operator++ ( int  dummy)
inline

Definition at line 215 of file shape_poly_set.h.

216  {
217  Advance();
218  }
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 220 of file shape_poly_set.h.

221  {
222  Advance();
223  }
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 235 of file shape_poly_set.h.

236  {
237  return &Get();
238  }

Friends And Related Function Documentation

template<class T >
friend class SHAPE_POLY_SET
friend

Definition at line 257 of file shape_poly_set.h.

Member Data Documentation

template<class T >
int SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::m_currentContour
private
template<class T >
int SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::m_currentPolygon
private
template<class T >
int SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::m_currentVertex
private
template<class T >
bool SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::m_iterateHoles
private

Definition at line 264 of file shape_poly_set.h.

Referenced by SHAPE_POLY_SET::CIterate(), and SHAPE_POLY_SET::Iterate().

template<class T >
int SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::m_lastPolygon
private

Definition at line 263 of file shape_poly_set.h.

Referenced by SHAPE_POLY_SET::CIterate(), and SHAPE_POLY_SET::Iterate().

template<class T >
SHAPE_POLY_SET* SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::m_poly
private

Definition at line 259 of file shape_poly_set.h.

Referenced by SHAPE_POLY_SET::CIterate(), and SHAPE_POLY_SET::Iterate().


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