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

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

#include <shape_poly_set.h>

Public Member Functions

bool IsEndContour () const
 
bool IsLastPolygon () const
 
 operator bool () const
 
void Advance ()
 Advance 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 ()
 

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 >

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

Definition at line 204 of file shape_poly_set.h.

Member Function Documentation

◆ Advance()

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

Advance the indices of the current vertex/outline/contour, checking whether the vertices in the holes have to be iterated through.

Definition at line 244 of file shape_poly_set.h.

245  {
246  // Advance vertex index
247  m_currentVertex ++;
248 
249  // Check whether the user wants to iterate through the vertices of the holes
250  // and behave accordingly
251  if( m_iterateHoles )
252  {
253  // If the last vertex of the contour was reached, advance the contour index
254  if( m_currentVertex >=
256  {
257  m_currentVertex = 0;
259 
260  // If the last contour of the current polygon was reached, advance the
261  // outline index
262  int totalContours = m_poly->CPolygon( m_currentPolygon ).size();
263 
264  if( m_currentContour >= totalContours )
265  {
266  m_currentContour = 0;
268  }
269  }
270  }
271  else
272  {
273  // If the last vertex of the outline was reached, advance to the following polygon
274  if( m_currentVertex >= m_poly->CPolygon( m_currentPolygon )[0].PointCount() )
275  {
276  m_currentVertex = 0;
278  }
279  }
280  }
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
Returns
the indices of the current polygon, contour and vertex.

Definition at line 310 of file shape_poly_set.h.

311  {
312  VERTEX_INDEX index;
313 
314  index.m_polygon = m_currentPolygon;
315  index.m_contour = m_currentContour;
316  index.m_vertex = m_currentVertex;
317 
318  return index;
319  }
struct SHAPE_POLY_SET::VERTEX_INDEX VERTEX_INDEX
Structure to hold the necessary information in order to index a vertex on a SHAPE_POLY_SET object: th...

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

◆ IsEndContour()

◆ IsLastPolygon()

template<class T >
bool SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::IsLastPolygon ( ) const
inline
Returns
true if the current outline is the last one; false otherwise.

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

298  {
299  return Get();
300  }

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

227  {
229  return true;
230 
231  if( m_currentPolygon != m_poly->OutlineCount() - 1 )
232  return false;
233 
234  const auto& currentPolygon = m_poly->CPolygon( m_currentPolygon );
235 
236  return m_currentContour < (int) currentPolygon.size() - 1
237  || m_currentVertex < currentPolygon[m_currentContour].PointCount();
238  }
const POLYGON & CPolygon(int aIndex) const
int OutlineCount() const
Return the number of vertices in a given outline/hole.

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

283  {
284  Advance();
285  }
void Advance()
Advance the indices of the current vertex/outline/contour, checking whether the vertices in the holes...

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

288  {
289  Advance();
290  }
void Advance()
Advance the indices of the current vertex/outline/contour, checking whether the vertices in the holes...

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

303  {
304  return &Get();
305  }

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