KiCad PCB EDA Suite
CPOLYGONS_LIST Class Reference

CPOLYGONS_LIST handle a list of contours (polygons corners). More...

#include <PolyLine.h>

Public Member Functions

 CPOLYGONS_LIST ()
 
CPolyPtoperator[] (int aIdx)
 
const std::vector< CPolyPt > & GetList () const
 
int GetX (int ic) const
 
void SetX (int ic, int aValue)
 
int GetY (int ic) const
 
void SetY (int ic, int aValue)
 
bool IsEndContour (int ic) const
 
const wxPointGetPos (int ic) const
 
const CPolyPtGetCorner (int ic) const
 
void reserve (int aSize)
 
void RemoveAllContours (void)
 
CPolyPtGetLastCorner ()
 
unsigned GetCornersCount () const
 
void DeleteCorner (int aIdx)
 
void DeleteCorners (int aIdFirstCorner, int aIdLastCorner)
 
void Append (const CPOLYGONS_LIST &aList)
 
void Append (const CPolyPt &aItem)
 
void Append (const wxPoint &aItem)
 
void InsertCorner (int aPosition, const CPolyPt &aItem)
 
void AddCorner (const CPolyPt &aCorner)
 function AddCorner add a corner to the list More...
 
void CloseLastContour ()
 function CloseLastContour Set the .end_contour member of the last corner in list to true More...
 
int GetContoursCount () const
 Function GetContoursCount. More...
 

Private Attributes

std::vector< CPolyPtm_cornersList
 

Detailed Description

CPOLYGONS_LIST handle a list of contours (polygons corners).

Each corner is a CPolyPt item. The last cornet of each contour has its end_contour member = true

Definition at line 114 of file PolyLine.h.

Constructor & Destructor Documentation

CPOLYGONS_LIST::CPOLYGONS_LIST ( )
inline

Definition at line 119 of file PolyLine.h.

119 {};

Member Function Documentation

void CPOLYGONS_LIST::AddCorner ( const CPolyPt aCorner)
inline

function AddCorner add a corner to the list

Definition at line 188 of file PolyLine.h.

Referenced by ConvertPolySetToPolyList().

189  {
190  m_cornersList.push_back( aCorner );
191  }
std::vector< CPolyPt > m_cornersList
Definition: PolyLine.h:117
void CPOLYGONS_LIST::Append ( const CPOLYGONS_LIST aList)
inline

Definition at line 160 of file PolyLine.h.

References m_cornersList.

Referenced by CPolyLine::AppendCorner(), CPolyLine::Copy(), CPolyLine::InsertCorner(), and CPolyLine::Start().

161  {
162  m_cornersList.insert( m_cornersList.end(),
163  aList.m_cornersList.begin(),
164  aList.m_cornersList.end() );
165  }
std::vector< CPolyPt > m_cornersList
Definition: PolyLine.h:117
void CPOLYGONS_LIST::Append ( const CPolyPt aItem)
inline

Definition at line 167 of file PolyLine.h.

168  {
169  m_cornersList.push_back( aItem );
170  }
std::vector< CPolyPt > m_cornersList
Definition: PolyLine.h:117
void CPOLYGONS_LIST::Append ( const wxPoint aItem)
inline

Definition at line 172 of file PolyLine.h.

173  {
174  CPolyPt item( aItem );
175 
176  m_cornersList.push_back( aItem );
177  }
std::vector< CPolyPt > m_cornersList
Definition: PolyLine.h:117
void CPOLYGONS_LIST::CloseLastContour ( )
inline

function CloseLastContour Set the .end_contour member of the last corner in list to true

Definition at line 197 of file PolyLine.h.

Referenced by CPolyLine::CloseLastContour().

198  {
199  if( m_cornersList.size() > 0 )
200  m_cornersList.back().end_contour = true;
201  }
std::vector< CPolyPt > m_cornersList
Definition: PolyLine.h:117
void CPOLYGONS_LIST::DeleteCorner ( int  aIdx)
inline

Definition at line 148 of file PolyLine.h.

Referenced by CPolyLine::DeleteCorner(), and CPolyLine::RemoveContour().

149  {
150  m_cornersList.erase( m_cornersList.begin() + aIdx );
151  }
std::vector< CPolyPt > m_cornersList
Definition: PolyLine.h:117
void CPOLYGONS_LIST::DeleteCorners ( int  aIdFirstCorner,
int  aIdLastCorner 
)
inline

Definition at line 154 of file PolyLine.h.

155  {
156  m_cornersList.erase( m_cornersList.begin() + aIdFirstCorner,
157  m_cornersList.begin() + aIdLastCorner + 1 );
158  }
std::vector< CPolyPt > m_cornersList
Definition: PolyLine.h:117
int CPOLYGONS_LIST::GetContoursCount ( ) const

Function GetContoursCount.

Returns
the number of polygons stored in list (number of corners flagged "end_contour"

Definition at line 620 of file PolyLine.cpp.

References m_cornersList.

Referenced by CPolyLine::GetContoursCount().

621 {
622  if( !m_cornersList.size() )
623  return 0;
624 
625  // count the number of corners flagged end_contour
626  int ncont = 0;
627 
628  for( unsigned ic = 0; ic < m_cornersList.size(); ic++ )
629  if( m_cornersList[ic].end_contour )
630  ncont++;
631 
632  // The last corner can be not yet flagged end_contour.
633  // It was not counted, but the polygon exists, so count it
634  if( !m_cornersList[m_cornersList.size() - 1].end_contour )
635  ncont++;
636 
637  return ncont;
638 }
std::vector< CPolyPt > m_cornersList
Definition: PolyLine.h:117
const CPolyPt& CPOLYGONS_LIST::GetCorner ( int  ic) const
inline

Definition at line 137 of file PolyLine.h.

137 { return m_cornersList[ic]; }
std::vector< CPolyPt > m_cornersList
Definition: PolyLine.h:117
CPolyPt& CPOLYGONS_LIST::GetLastCorner ( )
inline

Definition at line 144 of file PolyLine.h.

144 { return m_cornersList.back(); }
std::vector< CPolyPt > m_cornersList
Definition: PolyLine.h:117
const std::vector<CPolyPt>& CPOLYGONS_LIST::GetList ( ) const
inline

Definition at line 124 of file PolyLine.h.

References m_cornersList.

124 {return m_cornersList;}
std::vector< CPolyPt > m_cornersList
Definition: PolyLine.h:117
const wxPoint& CPOLYGONS_LIST::GetPos ( int  ic) const
inline

Definition at line 136 of file PolyLine.h.

Referenced by CPolyLine::GetPos().

136 { return m_cornersList[ic]; }
std::vector< CPolyPt > m_cornersList
Definition: PolyLine.h:117
int CPOLYGONS_LIST::GetX ( int  ic) const
inline

Definition at line 126 of file PolyLine.h.

Referenced by ConvertPolyListToPolySet(), CPolyLine::GetX(), CPolyLine::HitTestForCorner(), CPolyLine::HitTestForEdge(), and TestPointInsidePolygon().

126 { return m_cornersList[ic].x; }
std::vector< CPolyPt > m_cornersList
Definition: PolyLine.h:117
int CPOLYGONS_LIST::GetY ( int  ic) const
inline

Definition at line 128 of file PolyLine.h.

Referenced by ConvertPolyListToPolySet(), CPolyLine::GetY(), CPolyLine::HitTestForCorner(), CPolyLine::HitTestForEdge(), and TestPointInsidePolygon().

128 { return m_cornersList[ic].y; }
std::vector< CPolyPt > m_cornersList
Definition: PolyLine.h:117
void CPOLYGONS_LIST::InsertCorner ( int  aPosition,
const CPolyPt aItem 
)
inline

Definition at line 179 of file PolyLine.h.

Referenced by CPolyLine::InsertCorner().

180  {
181  m_cornersList.insert( m_cornersList.begin() + aPosition + 1, aItem );
182  }
std::vector< CPolyPt > m_cornersList
Definition: PolyLine.h:117
bool CPOLYGONS_LIST::IsEndContour ( int  ic) const
inline

Definition at line 131 of file PolyLine.h.

Referenced by ConvertPolyListToPolySet(), CPolyLine::HitTestForEdge(), and CPolyLine::IsEndContour().

132  {
133  return m_cornersList[ic].end_contour;
134  }
std::vector< CPolyPt > m_cornersList
Definition: PolyLine.h:117
CPolyPt& CPOLYGONS_LIST::operator[] ( int  aIdx)
inline

Definition at line 121 of file PolyLine.h.

121 { return m_cornersList[aIdx]; }
std::vector< CPolyPt > m_cornersList
Definition: PolyLine.h:117
void CPOLYGONS_LIST::RemoveAllContours ( void  )
inline

Definition at line 143 of file PolyLine.h.

Referenced by ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList_NG(), CPolyLine::Copy(), and CPolyLine::RemoveAllContours().

143 { m_cornersList.clear(); }
std::vector< CPolyPt > m_cornersList
Definition: PolyLine.h:117
void CPOLYGONS_LIST::reserve ( int  aSize)
inline

Definition at line 140 of file PolyLine.h.

140 { m_cornersList.reserve( aSize ); }
std::vector< CPolyPt > m_cornersList
Definition: PolyLine.h:117
void CPOLYGONS_LIST::SetX ( int  ic,
int  aValue 
)
inline

Definition at line 127 of file PolyLine.h.

Referenced by CPolyLine::SetX().

127 { m_cornersList[ic].x = aValue; }
std::vector< CPolyPt > m_cornersList
Definition: PolyLine.h:117
void CPOLYGONS_LIST::SetY ( int  ic,
int  aValue 
)
inline

Definition at line 129 of file PolyLine.h.

Referenced by CPolyLine::SetY().

129 { m_cornersList[ic].y = aValue; }
std::vector< CPolyPt > m_cornersList
Definition: PolyLine.h:117

Member Data Documentation

std::vector<CPolyPt> CPOLYGONS_LIST::m_cornersList
private

Definition at line 117 of file PolyLine.h.

Referenced by Append(), GetContoursCount(), and GetList().


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