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

Class SEGMENT_ITERATOR_TEMPLATE. More...

#include <shape_poly_set.h>

Public Member Functions

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++ ()
 
Get ()
 
operator * ()
 
VERTEX_INDEX GetIndex ()
 Function GetIndex. More...
 
bool IsAdjacent (SEGMENT_ITERATOR_TEMPLATE< T > aOther)
 Function IsAdjacent. More...
 

Private Attributes

SHAPE_POLY_SETm_poly
 
int m_currentPolygon
 
int m_currentContour
 
int m_currentSegment
 
int m_lastPolygon
 
bool m_iterateHoles
 

Friends

class SHAPE_POLY_SET
 

Detailed Description

template<class T>
class SHAPE_POLY_SET::SEGMENT_ITERATOR_TEMPLATE< T >

Class SEGMENT_ITERATOR_TEMPLATE.

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

Definition at line 275 of file shape_poly_set.h.

Member Function Documentation

◆ Advance()

template<class T>
void SHAPE_POLY_SET::SEGMENT_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 297 of file shape_poly_set.h.

298  {
299  // Advance vertex index
301  int last;
302 
303  // Check whether the user wants to iterate through the vertices of the holes
304  // and behave accordingly
305  if( m_iterateHoles )
306  {
307  last = m_poly->CPolygon( m_currentPolygon )[m_currentContour].SegmentCount();
308 
309  // If the last vertex of the contour was reached, advance the contour index
310  if( m_currentSegment >= last )
311  {
312  m_currentSegment = 0;
314 
315  // If the last contour of the current polygon was reached, advance the
316  // outline index
317  int totalContours = m_poly->CPolygon( m_currentPolygon ).size();
318 
319  if( m_currentContour >= totalContours )
320  {
321  m_currentContour = 0;
323  }
324  }
325  }
326  else
327  {
328  last = m_poly->CPolygon( m_currentPolygon )[0].SegmentCount();
329  // If the last vertex of the outline was reached, advance to the following
330  // polygon
331  if( m_currentSegment >= last )
332  {
333  m_currentSegment = 0;
335  }
336  }
337  }
const POLYGON & CPolygon(int aIndex) const

References SHAPE_POLY_SET::CPolygon(), SHAPE_POLY_SET::SEGMENT_ITERATOR_TEMPLATE< T >::m_currentContour, SHAPE_POLY_SET::SEGMENT_ITERATOR_TEMPLATE< T >::m_currentPolygon, SHAPE_POLY_SET::SEGMENT_ITERATOR_TEMPLATE< T >::m_currentSegment, SHAPE_POLY_SET::SEGMENT_ITERATOR_TEMPLATE< T >::m_iterateHoles, and SHAPE_POLY_SET::SEGMENT_ITERATOR_TEMPLATE< T >::m_poly.

Referenced by SHAPE_POLY_SET::SEGMENT_ITERATOR_TEMPLATE< T >::operator++().

◆ Get()

◆ GetIndex()

◆ IsAdjacent()

template<class T>
bool SHAPE_POLY_SET::SEGMENT_ITERATOR_TEMPLATE< T >::IsAdjacent ( SEGMENT_ITERATOR_TEMPLATE< T >  aOther)
inline

Function IsAdjacent.

Parameters
aOtheris an iterator pointing to another segment.
Returns
bool - true if both iterators point to the same segment of the same contour of the same polygon of the same polygon set; false otherwise.

Definition at line 381 of file shape_poly_set.h.

382  {
383  // Check that both iterators point to the same contour of the same polygon of the
384  // same polygon set
385  if( m_poly == aOther.m_poly && m_currentPolygon == aOther.m_currentPolygon &&
386  m_currentContour == aOther.m_currentContour )
387  {
388  // Compute the total number of segments
389  int numSeg;
390  numSeg = m_poly->CPolygon( m_currentPolygon )[m_currentContour].SegmentCount();
391 
392  // Compute the difference of the segment indices. If it is exactly one, they
393  // are adjacent. The only missing case where they also are adjacent is when
394  // the segments are the first and last one, in which case the difference
395  // always equals the total number of segments minus one.
396  int indexDiff = abs( m_currentSegment - aOther.m_currentSegment );
397 
398  return ( indexDiff == 1 ) || ( indexDiff == (numSeg - 1) );
399  }
400 
401  return false;
402  }
const POLYGON & CPolygon(int aIndex) const
#define abs(a)
Definition: auxiliary.h:84

References abs, SHAPE_POLY_SET::CPolygon(), SHAPE_POLY_SET::SEGMENT_ITERATOR_TEMPLATE< T >::m_currentContour, SHAPE_POLY_SET::SEGMENT_ITERATOR_TEMPLATE< T >::m_currentPolygon, SHAPE_POLY_SET::SEGMENT_ITERATOR_TEMPLATE< T >::m_currentSegment, and SHAPE_POLY_SET::SEGMENT_ITERATOR_TEMPLATE< T >::m_poly.

Referenced by SHAPE_POLY_SET::IsPolygonSelfIntersecting().

◆ IsLastPolygon()

template<class T>
bool SHAPE_POLY_SET::SEGMENT_ITERATOR_TEMPLATE< T >::IsLastPolygon ( ) const
inline

Function IsLastOutline.

Returns
bool - true if the current outline is the last one.

Definition at line 282 of file shape_poly_set.h.

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

◆ operator *()

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

Definition at line 354 of file shape_poly_set.h.

355  {
356  return Get();
357  }

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

◆ operator bool()

◆ operator++() [1/2]

template<class T>
void SHAPE_POLY_SET::SEGMENT_ITERATOR_TEMPLATE< T >::operator++ ( int  dummy)
inline

Definition at line 339 of file shape_poly_set.h.

340  {
341  Advance();
342  }
void Advance()
Function Advance advances the indices of the current vertex/outline/contour, checking whether the ver...

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

◆ operator++() [2/2]

template<class T>
void SHAPE_POLY_SET::SEGMENT_ITERATOR_TEMPLATE< T >::operator++ ( )
inline

Definition at line 344 of file shape_poly_set.h.

345  {
346  Advance();
347  }
void Advance()
Function Advance advances the indices of the current vertex/outline/contour, checking whether the ver...

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

Friends And Related Function Documentation

◆ SHAPE_POLY_SET

template<class T>
friend class SHAPE_POLY_SET
friend

Definition at line 405 of file shape_poly_set.h.

Member Data Documentation

◆ m_currentContour

◆ m_currentPolygon

◆ m_currentSegment

◆ m_iterateHoles

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

◆ m_lastPolygon

◆ m_poly


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