KiCad PCB EDA Suite
CPolyLine Class Reference

#include <PolyLine.h>

Public Types

enum  HATCH_STYLE { NO_HATCH, DIAGONAL_FULL, DIAGONAL_EDGE }
 

Public Member Functions

 CPolyLine ()
 
 CPolyLine (const CPolyLine &aCPolyLine)
 
 ~CPolyLine ()
 
void ImportSettings (const CPolyLine *aPoly)
 Function ImportSettings Copy settings (layer, hatch styles) from aPoly. More...
 
void Start (LAYER_NUM layer, int x, int y, int hatch)
 
void AppendCorner (int x, int y)
 
void InsertCorner (int ic, int x, int y)
 Function InsertCorner insert a new corner between two existing corners. More...
 
void DeleteCorner (int ic)
 Function DeleteCorner remove the given corner. More...
 
void MoveCorner (int ic, int x, int y)
 
void CloseLastContour ()
 function CloseLastContour Set the .end_contour member of the last corner of the last contour to true More...
 
void RemoveContour (int icont)
 Function RemoveContour. More...
 
bool IsPolygonSelfIntersecting ()
 Function IsPolygonSelfIntersecting Test a CPolyLine for self-intersection of vertex (all contours). More...
 
CPolyLineChamfer (unsigned int aDistance)
 Function Chamfer returns a chamfered version of a polygon. More...
 
CPolyLineFillet (unsigned int aRadius, unsigned int aSegments)
 Function Fillet returns a filleted version of a polygon. More...
 
int RemoveNullSegments ()
 Function RemoveNullSegments Removes corners which create a null segment edge (i.e. More...
 
void RemoveAllContours (void)
 function RemoveAllContours removes all corners from the list. More...
 
void UnHatch ()
 
void Hatch ()
 
void MoveOrigin (int x_off, int y_off)
 
const EDA_RECT GetBoundingBox ()
 
const EDA_RECT GetBoundingBox (int icont)
 
void Copy (const CPolyLine *src)
 
bool TestPointInside (int x, int y)
 
bool IsCutoutContour (int aCornerIdx)
 
void AppendArc (int xi, int yi, int xf, int yf, int xc, int yc, int num)
 Function AppendArc. More...
 
void SetLayer (LAYER_NUM aLayer)
 
LAYER_NUM GetLayer () const
 
int GetCornersCount () const
 
bool GetClosed ()
 
int GetContoursCount () const
 Function GetContoursCount. More...
 
int GetContour (int ic)
 Function GetContour. More...
 
int GetContourStart (int icont)
 Function GetContourStart. More...
 
int GetContourEnd (int icont)
 Function GetContourEnd. More...
 
int GetContourSize (int icont)
 Function GetContourSize. More...
 
int GetX (int ic) const
 
int GetY (int ic) const
 
bool IsEndContour (int ic) const
 Function IsEndContour. More...
 
const wxPointGetPos (int ic) const
 
int GetHatchPitch () const
 
enum HATCH_STYLE GetHatchStyle () const
 
void SetHatch (int aHatchStyle, int aHatchPitch, bool aRebuildHatch)
 
void SetX (int ic, int x)
 
void SetY (int ic, int y)
 
void SetHatchStyle (enum HATCH_STYLE style)
 
void SetHatchPitch (int pitch)
 
int NormalizeAreaOutlines (std::vector< CPolyLine * > *aNewPolygonList)
 Function NormalizeAreaOutlines Convert a self-intersecting polygon to one (or more) non self-intersecting polygon(s) Removes null segments. More...
 
void AppendBezier (int x1, int y1, int x2, int y2, int x3, int y3)
 
void AppendBezier (int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
 
int Distance (const wxPoint &aPoint)
 Function Distance Calculates the distance between a point and the zone: More...
 
int Distance (wxPoint aStart, wxPoint aEnd, int aWidth)
 Function Distance Calculates the distance between a segment and the zone: More...
 
int HitTestForEdge (const wxPoint &aPos, int aDistMax) const
 Function HitTestForEdge test is the point aPos is near (< aDistMax ) a vertex. More...
 
int HitTestForCorner (const wxPoint &aPos, int aDistMax) const
 Function HitTestForCorner test is the point aPos is near (< aDistMax ) a corner. More...
 

Static Public Member Functions

static int GetDefaultHatchPitchMils ()
 

Public Attributes

CPOLYGONS_LIST m_CornersList
 
std::vector< CSegmentm_HatchLines
 

Private Attributes

LAYER_NUM m_layer
 
enum HATCH_STYLE m_hatchStyle
 
int m_hatchPitch
 
int m_flags
 

Detailed Description

Definition at line 213 of file PolyLine.h.

Member Enumeration Documentation

Enumerator
NO_HATCH 
DIAGONAL_FULL 
DIAGONAL_EDGE 

Definition at line 216 of file PolyLine.h.

Constructor & Destructor Documentation

CPolyLine::CPolyLine ( )

Definition at line 51 of file PolyLine.cpp.

References F_Cu, m_flags, m_hatchPitch, m_hatchStyle, m_layer, and NO_HATCH.

Referenced by Chamfer(), Fillet(), and NormalizeAreaOutlines().

52 {
54  m_hatchPitch = 0;
55  m_layer = F_Cu;
56  m_flags = 0;
57 }
LAYER_NUM m_layer
Definition: PolyLine.h:480
enum HATCH_STYLE m_hatchStyle
Definition: PolyLine.h:481
int m_flags
Definition: PolyLine.h:485
int m_hatchPitch
Definition: PolyLine.h:482
CPolyLine::CPolyLine ( const CPolyLine aCPolyLine)

Definition at line 59 of file PolyLine.cpp.

References Copy(), and m_HatchLines.

60 {
61  Copy( &aCPolyLine );
62  m_HatchLines = aCPolyLine.m_HatchLines; // vector <> copy
63 }
void Copy(const CPolyLine *src)
Definition: PolyLine.cpp:943
std::vector< CSegment > m_HatchLines
Definition: PolyLine.h:488
CPolyLine::~CPolyLine ( )

Definition at line 68 of file PolyLine.cpp.

References UnHatch().

69 {
70  UnHatch();
71 }
void UnHatch()
Definition: PolyLine.cpp:559

Member Function Documentation

void CPolyLine::AppendArc ( int  xi,
int  yi,
int  xf,
int  yf,
int  xc,
int  yc,
int  num 
)

Function AppendArc.

Adds segments to current contour to approximate the given arc

Definition at line 987 of file PolyLine.cpp.

References AppendCorner(), CloseLastContour(), Distance(), and KiROUND().

988 {
989  // get radius
990  double radius = ::Distance( xi, yi, xf, yf );
991 
992  // get angles of start pint and end point
993  double th_i = atan2( (double) (yi - yc), (double) (xi - xc) );
994  double th_f = atan2( (double) (yf - yc), (double) (xf - xc) );
995  double th_d = (th_f - th_i) / (num - 1);
996  double theta = th_i;
997 
998  // generate arc
999  for( int ic = 0; ic < num; ic++ )
1000  {
1001  int x = xc + KiROUND( radius * cos( theta ) );
1002  int y = yc + KiROUND( radius * sin( theta ) );
1003  AppendCorner( x, y );
1004  theta += th_d;
1005  }
1006 
1007  CloseLastContour();
1008 }
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
void AppendCorner(int x, int y)
Definition: PolyLine.cpp:199
int Distance(const wxPoint &aPoint)
Function Distance Calculates the distance between a point and the zone:
Definition: PolyLine.cpp:1104
void CloseLastContour()
function CloseLastContour Set the .end_contour member of the last corner of the last contour to true ...
Definition: PolyLine.h:254
void CPolyLine::AppendBezier ( int  x1,
int  y1,
int  x2,
int  y2,
int  x3,
int  y3 
)

Definition at line 1011 of file PolyLine.cpp.

References AppendCorner(), and BEZIER_POLY::GetPoly().

1012 {
1013  std::vector<wxPoint> polyPoints;
1014 
1015  BEZIER_POLY converter( x1, y1, x2, y2, x3, y3 );
1016  converter.GetPoly( polyPoints );
1017 
1018  for( const auto& pt : polyPoints )
1019  AppendCorner( pt.x, pt.y );
1020 }
void AppendCorner(int x, int y)
Definition: PolyLine.cpp:199
Bezier curves to polygon converter.
Definition: bezier_curves.h:34
void CPolyLine::AppendBezier ( int  x1,
int  y1,
int  x2,
int  y2,
int  x3,
int  y3,
int  x4,
int  y4 
)

Definition at line 1023 of file PolyLine.cpp.

References AppendCorner(), and BEZIER_POLY::GetPoly().

1024 {
1025  std::vector<wxPoint> polyPoints;
1026 
1027  BEZIER_POLY converter( x1, y1, x2, y2, x3, y3, x4, y4 );
1028  converter.GetPoly( polyPoints );
1029 
1030  for( const auto& pt : polyPoints )
1031  AppendCorner( pt.x, pt.y );
1032 }
void AppendCorner(int x, int y)
Definition: PolyLine.cpp:199
Bezier curves to polygon converter.
Definition: bezier_curves.h:34
void CPolyLine::AppendCorner ( int  x,
int  y 
)

Definition at line 199 of file PolyLine.cpp.

References CPOLYGONS_LIST::Append(), CPolyPt::end_contour, m_CornersList, and UnHatch().

Referenced by AppendArc(), AppendBezier(), Chamfer(), and Fillet().

200 {
201  UnHatch();
202  CPolyPt poly_pt( x, y );
203  poly_pt.end_contour = false;
204 
205  // add entries for new corner
206  m_CornersList.Append( poly_pt );
207 }
void UnHatch()
Definition: PolyLine.cpp:559
CPOLYGONS_LIST m_CornersList
Definition: PolyLine.h:487
void Append(const CPOLYGONS_LIST &aList)
Definition: PolyLine.h:160
CPolyLine * CPolyLine::Chamfer ( unsigned int  aDistance)

Function Chamfer returns a chamfered version of a polygon.

Parameters
aDistanceis the chamfering distance.
Returns
CPolyLine* - Pointer to new polygon.

Definition at line 285 of file PolyLine.cpp.

References AppendCorner(), CloseLastContour(), Copy(), CPolyLine(), GetContourEnd(), GetContoursCount(), GetContourStart(), GetHatchStyle(), GetLayer(), KiROUND(), m_CornersList, RemoveNullSegments(), and Start().

286 {
287  // Null segments create serious issues in calculations.
288  // remove them:
290 
291  CPolyLine* newPoly = new CPolyLine;
292 
293  if( !aDistance )
294  {
295  newPoly->Copy( this );
296  return newPoly;
297  }
298 
299  int polycount = GetContoursCount();
300 
301  for( int contour = 0; contour < polycount; contour++ )
302  {
303  unsigned int startIndex = GetContourStart( contour );
304  unsigned int endIndex = GetContourEnd( contour );
305 
306  for( unsigned int index = startIndex; index <= endIndex; index++ )
307  {
308  // Current vertex
309  int x1 = m_CornersList[index].x;
310  int y1 = m_CornersList[index].y;
311  double xa, ya; // Previous vertex
312  double xb, yb; // Next vertex
313 
314  if( index == startIndex )
315  {
316  xa = m_CornersList[endIndex].x - x1;
317  ya = m_CornersList[endIndex].y - y1;
318  }
319  else
320  {
321  xa = m_CornersList[index - 1].x - x1;
322  ya = m_CornersList[index - 1].y - y1;
323  }
324 
325  if( index == endIndex )
326  {
327  xb = m_CornersList[startIndex].x - x1;
328  yb = m_CornersList[startIndex].y - y1;
329  }
330  else
331  {
332  xb = m_CornersList[index + 1].x - x1;
333  yb = m_CornersList[index + 1].y - y1;
334  }
335 
336  double lena = hypot( xa, ya );
337  double lenb = hypot( xb, yb );
338  double distance = aDistance;
339 
340  // Chamfer one half of an edge at most
341  if( 0.5 * lena < distance )
342  distance = 0.5 * lena;
343 
344  if( 0.5 * lenb < distance )
345  distance = 0.5 * lenb;
346 
347  int nx1 = KiROUND( distance * xa / lena );
348  int ny1 = KiROUND( distance * ya / lena );
349 
350  if( index == startIndex )
351  newPoly->Start( GetLayer(), x1 + nx1, y1 + ny1, GetHatchStyle() );
352  else
353  newPoly->AppendCorner( x1 + nx1, y1 + ny1 );
354 
355  int nx2 = KiROUND( distance * xb / lenb );
356  int ny2 = KiROUND( distance * yb / lenb );
357 
358  // Due to rounding errors, repeated corners could be added; this check prevents it
359  if(nx1 != nx2 || ny1 != ny2)
360  newPoly->AppendCorner( x1 + nx2, y1 + ny2 );
361  }
362 
363  newPoly->CloseLastContour();
364  }
365 
366  return newPoly;
367 }
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
void Copy(const CPolyLine *src)
Definition: PolyLine.cpp:943
void Start(LAYER_NUM layer, int x, int y, int hatch)
Definition: PolyLine.cpp:186
enum HATCH_STYLE GetHatchStyle() const
Definition: PolyLine.h:399
void AppendCorner(int x, int y)
Definition: PolyLine.cpp:199
int GetContourEnd(int icont)
Function GetContourEnd.
Definition: PolyLine.cpp:678
CPOLYGONS_LIST m_CornersList
Definition: PolyLine.h:487
int RemoveNullSegments()
Function RemoveNullSegments Removes corners which create a null segment edge (i.e.
Definition: PolyLine.cpp:77
int GetContoursCount() const
Function GetContoursCount.
Definition: PolyLine.cpp:613
LAYER_NUM GetLayer() const
Definition: PolyLine.h:337
void CloseLastContour()
function CloseLastContour Set the .end_contour member of the last corner of the last contour to true ...
Definition: PolyLine.h:254
int GetContourStart(int icont)
Function GetContourStart.
Definition: PolyLine.cpp:655
void CPolyLine::CloseLastContour ( )
inline

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

Definition at line 254 of file PolyLine.h.

References CPOLYGONS_LIST::CloseLastContour(), and m_CornersList.

Referenced by AppendArc(), Chamfer(), and Fillet().

255  {
257  }
CPOLYGONS_LIST m_CornersList
Definition: PolyLine.h:487
void CloseLastContour()
function CloseLastContour Set the .end_contour member of the last corner in list to true ...
Definition: PolyLine.h:197
void CPolyLine::Copy ( const CPolyLine src)

Definition at line 943 of file PolyLine.cpp.

References CPOLYGONS_LIST::Append(), m_CornersList, m_flags, m_hatchPitch, m_hatchStyle, m_layer, CPOLYGONS_LIST::RemoveAllContours(), and UnHatch().

Referenced by Chamfer(), CPolyLine(), and Fillet().

944 {
945  UnHatch();
946  m_layer = src->m_layer;
947  m_hatchStyle = src->m_hatchStyle;
948  m_hatchPitch = src->m_hatchPitch;
949  m_flags = src->m_flags;
952 }
void UnHatch()
Definition: PolyLine.cpp:559
CPOLYGONS_LIST m_CornersList
Definition: PolyLine.h:487
LAYER_NUM m_layer
Definition: PolyLine.h:480
enum HATCH_STYLE m_hatchStyle
Definition: PolyLine.h:481
int m_flags
Definition: PolyLine.h:485
void RemoveAllContours(void)
Definition: PolyLine.h:143
void Append(const CPOLYGONS_LIST &aList)
Definition: PolyLine.h:160
int m_hatchPitch
Definition: PolyLine.h:482
void CPolyLine::DeleteCorner ( int  ic)

Function DeleteCorner remove the given corner.

if it is the last point of a contour keep the controur closed by modifying the previous corner

Parameters
ic= the index of the corner to delete

Definition at line 222 of file PolyLine.cpp.

References CPOLYGONS_LIST::DeleteCorner(), GetClosed(), GetContour(), GetContourEnd(), GetContoursCount(), GetContourSize(), m_CornersList, RemoveContour(), and UnHatch().

Referenced by RemoveNullSegments().

223 {
224  UnHatch();
225  int icont = GetContour( ic );
226  int iend = GetContourEnd( icont );
227  bool closed = icont < GetContoursCount() - 1 || GetClosed();
228 
229  if( !closed )
230  {
231  // open contour, must be last contour
233  }
234  else
235  {
236  // closed contour
238 
239  if( ic == iend )
240  m_CornersList[ic - 1].end_contour = true;
241  }
242 
243  if( closed && GetContourSize( icont ) < 3 )
244  {
245  // delete the entire contour
246  RemoveContour( icont );
247  }
248 }
void UnHatch()
Definition: PolyLine.cpp:559
int GetContourEnd(int icont)
Function GetContourEnd.
Definition: PolyLine.cpp:678
void RemoveContour(int icont)
Function RemoveContour.
Definition: PolyLine.cpp:252
CPOLYGONS_LIST m_CornersList
Definition: PolyLine.h:487
int GetContourSize(int icont)
Function GetContourSize.
Definition: PolyLine.cpp:704
int GetContoursCount() const
Function GetContoursCount.
Definition: PolyLine.cpp:613
void DeleteCorner(int aIdx)
Definition: PolyLine.h:148
bool GetClosed()
Definition: PolyLine.cpp:710
int GetContour(int ic)
Function GetContour.
Definition: PolyLine.cpp:641
int CPolyLine::Distance ( const wxPoint aPoint)

Function Distance Calculates the distance between a point and the zone:

Parameters
aPointthe coordinate of the point.
Returns
int = distance between the point and outline. 0 if the point is inside

Definition at line 1104 of file PolyLine.cpp.

References GetContourEnd(), GetContoursCount(), GetContourStart(), GetPointToLineSegmentDistance(), GetX(), GetY(), KiROUND(), TestPointInside(), wxPoint::x, and wxPoint::y.

Referenced by AppendArc().

1105 {
1106  // We calculate the dist between the point and each outline segment
1107  // If the point is inside the outline, the dist is 0.
1108  if( TestPointInside( aPoint.x, aPoint.y ) )
1109  return 0;
1110 
1111  int distance = INT_MAX;
1112  int polycount = GetContoursCount();
1113 
1114  for( int icont = 0; icont < polycount; icont++ )
1115  {
1116  int ic_start = GetContourStart( icont );
1117  int ic_end = GetContourEnd( icont );
1118 
1119  // now test spacing between area outline and segment
1120  for( int ic2 = ic_start; ic2 <= ic_end; ic2++ )
1121  {
1122  int bx1 = GetX( ic2 );
1123  int by1 = GetY( ic2 );
1124  int bx2, by2;
1125 
1126  if( ic2 == ic_end )
1127  {
1128  bx2 = GetX( ic_start );
1129  by2 = GetY( ic_start );
1130  }
1131  else
1132  {
1133  bx2 = GetX( ic2 + 1 );
1134  by2 = GetY( ic2 + 1 );
1135  }
1136 
1137  int d = KiROUND( GetPointToLineSegmentDistance( aPoint.x, aPoint.y,
1138  bx1, by1, bx2, by2 ) );
1139 
1140  if( distance > d )
1141  distance = d;
1142 
1143  if( distance <= 0 )
1144  return 0;
1145  }
1146  }
1147 
1148  return distance;
1149 }
double GetPointToLineSegmentDistance(int x, int y, int xi, int yi, int xf, int yf)
Function GetPointToLineSegmentDistance Get distance between line segment and point.
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
int GetY(int ic) const
Definition: PolyLine.h:385
int GetContourEnd(int icont)
Function GetContourEnd.
Definition: PolyLine.cpp:678
int GetX(int ic) const
Definition: PolyLine.h:384
int GetContoursCount() const
Function GetContoursCount.
Definition: PolyLine.cpp:613
int GetContourStart(int icont)
Function GetContourStart.
Definition: PolyLine.cpp:655
bool TestPointInside(int x, int y)
Definition: PolyLine.cpp:913
int CPolyLine::Distance ( wxPoint  aStart,
wxPoint  aEnd,
int  aWidth 
)

Function Distance Calculates the distance between a segment and the zone:

Parameters
aStartthe starting point of the segment.
aEndthe ending point of the segment.
aWidththe width of the segment.
Returns
int = distance between the segment and outline. 0 if segment intersects or is inside

Definition at line 1044 of file PolyLine.cpp.

References GetClearanceBetweenSegments(), GetContourEnd(), GetContoursCount(), GetContourStart(), GetX(), GetY(), TestPointInside(), wxPoint::x, and wxPoint::y.

1045 {
1046  // We calculate the min dist between the segment and each outline segment
1047  // However, if the segment to test is inside the outline, and does not cross
1048  // any edge, it can be seen outside the polygon.
1049  // Therefore test if a segment end is inside ( testing only one end is enough )
1050  if( TestPointInside( aStart.x, aStart.y ) )
1051  return 0;
1052 
1053  int distance = INT_MAX;
1054  int polycount = GetContoursCount();
1055 
1056  for( int icont = 0; icont < polycount; icont++ )
1057  {
1058  int ic_start = GetContourStart( icont );
1059  int ic_end = GetContourEnd( icont );
1060 
1061  // now test spacing between area outline and segment
1062  for( int ic2 = ic_start; ic2 <= ic_end; ic2++ )
1063  {
1064  int bx1 = GetX( ic2 );
1065  int by1 = GetY( ic2 );
1066  int bx2, by2;
1067 
1068  if( ic2 == ic_end )
1069  {
1070  bx2 = GetX( ic_start );
1071  by2 = GetY( ic_start );
1072  }
1073  else
1074  {
1075  bx2 = GetX( ic2 + 1 );
1076  by2 = GetY( ic2 + 1 );
1077  }
1078 
1079  int d = GetClearanceBetweenSegments( bx1, by1, bx2, by2, 0,
1080  aStart.x, aStart.y, aEnd.x, aEnd.y,
1081  aWidth,
1082  1, // min clearance, should be > 0
1083  NULL, NULL );
1084 
1085  if( distance > d )
1086  distance = d;
1087 
1088  if( distance <= 0 )
1089  return 0;
1090  }
1091  }
1092 
1093  return distance;
1094 }
int GetY(int ic) const
Definition: PolyLine.h:385
int GetContourEnd(int icont)
Function GetContourEnd.
Definition: PolyLine.cpp:678
int GetClearanceBetweenSegments(int x1i, int y1i, int x1f, int y1f, int w1, int x2i, int y2i, int x2f, int y2f, int w2, int max_cl, int *x, int *y)
int GetX(int ic) const
Definition: PolyLine.h:384
int GetContoursCount() const
Function GetContoursCount.
Definition: PolyLine.cpp:613
int GetContourStart(int icont)
Function GetContourStart.
Definition: PolyLine.cpp:655
bool TestPointInside(int x, int y)
Definition: PolyLine.cpp:913
CPolyLine * CPolyLine::Fillet ( unsigned int  aRadius,
unsigned int  aSegments 
)

Function Fillet returns a filleted version of a polygon.

Parameters
aRadiusis the fillet radius.
aSegmentsis the number of segments / fillet.
Returns
CPolyLine* - Pointer to new polygon.

Definition at line 370 of file PolyLine.cpp.

References AppendCorner(), CloseLastContour(), Copy(), CPolyLine(), GetContourEnd(), GetContoursCount(), GetContourStart(), GetHatchStyle(), GetLayer(), KiROUND(), m_CornersList, RemoveNullSegments(), and Start().

371 {
372  // Null segments create serious issues in calculations.
373  // remove them:
375 
376  CPolyLine* newPoly = new CPolyLine;
377 
378  if( !aRadius )
379  {
380  newPoly->Copy( this );
381  return newPoly;
382  }
383 
384  int polycount = GetContoursCount();
385 
386  for( int contour = 0; contour < polycount; contour++ )
387  {
388  unsigned int startIndex = GetContourStart( contour );
389  unsigned int endIndex = GetContourEnd( contour );
390 
391  for( unsigned int index = startIndex; index <= endIndex; index++ )
392  {
393  // Current vertex
394  int x1 = m_CornersList[index].x;
395  int y1 = m_CornersList[index].y;
396  double xa, ya; // Previous vertex
397  double xb, yb; // Next vertex
398 
399  if( index == startIndex )
400  {
401  xa = m_CornersList[endIndex].x - x1;
402  ya = m_CornersList[endIndex].y - y1;
403  }
404  else
405  {
406  xa = m_CornersList[index - 1].x - x1;
407  ya = m_CornersList[index - 1].y - y1;
408  }
409 
410  if( index == endIndex )
411  {
412  xb = m_CornersList[startIndex].x - x1;
413  yb = m_CornersList[startIndex].y - y1;
414  }
415  else
416  {
417  xb = m_CornersList[index + 1].x - x1;
418  yb = m_CornersList[index + 1].y - y1;
419  }
420 
421  double lena = hypot( xa, ya );
422  double lenb = hypot( xb, yb );
423  double cosine = ( xa * xb + ya * yb ) / ( lena * lenb );
424 
425  double radius = aRadius;
426  double denom = sqrt( 2.0 / ( 1 + cosine ) - 1 );
427 
428  // Do nothing in case of parallel edges
429  if( std::isinf( denom ) )
430  continue;
431 
432  // Limit rounding distance to one half of an edge
433  if( 0.5 * lena * denom < radius )
434  radius = 0.5 * lena * denom;
435 
436  if( 0.5 * lenb * denom < radius )
437  radius = 0.5 * lenb * denom;
438 
439  // Calculate fillet arc absolute center point (xc, yx)
440  double k = radius / sqrt( .5 * ( 1 - cosine ) );
441  double lenab = sqrt( ( xa / lena + xb / lenb ) * ( xa / lena + xb / lenb ) +
442  ( ya / lena + yb / lenb ) * ( ya / lena + yb / lenb ) );
443  double xc = x1 + k * ( xa / lena + xb / lenb ) / lenab;
444  double yc = y1 + k * ( ya / lena + yb / lenb ) / lenab;
445 
446  // Calculate arc start and end vectors
447  k = radius / sqrt( 2 / ( 1 + cosine ) - 1 );
448  double xs = x1 + k * xa / lena - xc;
449  double ys = y1 + k * ya / lena - yc;
450  double xe = x1 + k * xb / lenb - xc;
451  double ye = y1 + k * yb / lenb - yc;
452 
453  // Cosine of arc angle
454  double argument = ( xs * xe + ys * ye ) / ( radius * radius );
455 
456  if( argument < -1 ) // Just in case...
457  argument = -1;
458  else if( argument > 1 )
459  argument = 1;
460 
461  double arcAngle = acos( argument );
462 
463  // Calculate the number of segments
464  double tempSegments = (double) aSegments * ( arcAngle / ( 2 * M_PI ) );
465 
466  if( tempSegments - (int) tempSegments > 0 )
467  tempSegments++;
468 
469  unsigned int segments = (unsigned int) tempSegments;
470 
471  double deltaAngle = arcAngle / segments;
472  double startAngle = atan2( -ys, xs );
473 
474  // Flip arc for inner corners
475  if( xa * yb - ya * xb <= 0 )
476  deltaAngle *= -1;
477 
478  double nx = xc + xs;
479  double ny = yc + ys;
480 
481  if( index == startIndex )
482  newPoly->Start( GetLayer(), KiROUND( nx ), KiROUND( ny ), GetHatchStyle() );
483  else
484  newPoly->AppendCorner( KiROUND( nx ), KiROUND( ny ) );
485 
486  // Store the previous added corner to make a sanity check
487  int prevX = KiROUND(nx);
488  int prevY = KiROUND(ny);
489 
490  for( unsigned int j = 0; j < segments; j++ )
491  {
492  nx = xc + cos( startAngle + (j + 1) * deltaAngle ) * radius;
493  ny = yc - sin( startAngle + (j + 1) * deltaAngle ) * radius;
494 
495  // Due to rounding errors, repeated corners could be added; this check prevents it
496  if(KiROUND(nx) != prevX || KiROUND(ny) != prevY)
497  {
498  newPoly->AppendCorner( KiROUND( nx ), KiROUND( ny ) );
499  prevX = KiROUND(nx);
500  prevY = KiROUND(ny);
501  }
502  }
503  }
504 
505  newPoly->CloseLastContour();
506  }
507 
508  return newPoly;
509 }
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
void Copy(const CPolyLine *src)
Definition: PolyLine.cpp:943
void Start(LAYER_NUM layer, int x, int y, int hatch)
Definition: PolyLine.cpp:186
enum HATCH_STYLE GetHatchStyle() const
Definition: PolyLine.h:399
void AppendCorner(int x, int y)
Definition: PolyLine.cpp:199
int GetContourEnd(int icont)
Function GetContourEnd.
Definition: PolyLine.cpp:678
CPOLYGONS_LIST m_CornersList
Definition: PolyLine.h:487
int RemoveNullSegments()
Function RemoveNullSegments Removes corners which create a null segment edge (i.e.
Definition: PolyLine.cpp:77
int GetContoursCount() const
Function GetContoursCount.
Definition: PolyLine.cpp:613
LAYER_NUM GetLayer() const
Definition: PolyLine.h:337
void CloseLastContour()
function CloseLastContour Set the .end_contour member of the last corner of the last contour to true ...
Definition: PolyLine.h:254
int GetContourStart(int icont)
Function GetContourStart.
Definition: PolyLine.cpp:655
const EDA_RECT CPolyLine::GetBoundingBox ( )
Returns
the full bounding box of polygons

Definition at line 565 of file PolyLine.cpp.

References CPOLYGONS_LIST::GetCornersCount(), m_CornersList, max, min, EDA_RECT::SetEnd(), and EDA_RECT::SetOrigin().

Referenced by IsPolygonSelfIntersecting().

566 {
567  int xmin = INT_MAX;
568  int ymin = INT_MAX;
569  int xmax = INT_MIN;
570  int ymax = INT_MIN;
571 
572  for( unsigned i = 0; i< m_CornersList.GetCornersCount(); i++ )
573  {
574  xmin = std::min( xmin, m_CornersList[i].x );
575  xmax = std::max( xmax, m_CornersList[i].x );
576  ymin = std::min( ymin, m_CornersList[i].y );
577  ymax = std::max( ymax, m_CornersList[i].y );
578  }
579 
580  EDA_RECT r;
581  r.SetOrigin( wxPoint( xmin, ymin ) );
582  r.SetEnd( wxPoint( xmax, ymax ) );
583 
584  return r;
585 }
void SetOrigin(const wxPoint &pos)
CPOLYGONS_LIST m_CornersList
Definition: PolyLine.h:487
unsigned GetCornersCount() const
Definition: PolyLine.h:146
void SetEnd(int x, int y)
#define max(a, b)
Definition: auxiliary.h:86
Class EDA_RECT handles the component boundary box.
#define min(a, b)
Definition: auxiliary.h:85
const EDA_RECT CPolyLine::GetBoundingBox ( int  icont)
Returns
the bounding box of a given polygon
Parameters
icont= the index of the polygon contour (0 = main contour, 1 ... n = other contours, usually holes)

Definition at line 588 of file PolyLine.cpp.

References GetContourEnd(), GetContourStart(), m_CornersList, max, min, EDA_RECT::SetEnd(), and EDA_RECT::SetOrigin().

589 {
590  int xmin = INT_MAX;
591  int ymin = INT_MAX;
592  int xmax = INT_MIN;
593  int ymax = INT_MIN;
594  int istart = GetContourStart( icont );
595  int iend = GetContourEnd( icont );
596 
597  for( int i = istart; i<=iend; i++ )
598  {
599  xmin = std::min( xmin, m_CornersList[i].x );
600  xmax = std::max( xmax, m_CornersList[i].x );
601  ymin = std::min( ymin, m_CornersList[i].y );
602  ymax = std::max( ymax, m_CornersList[i].y );
603  }
604 
605  EDA_RECT r;
606  r.SetOrigin( wxPoint( xmin, ymin ) );
607  r.SetEnd( wxPoint( xmax, ymax ) );
608 
609  return r;
610 }
int GetContourEnd(int icont)
Function GetContourEnd.
Definition: PolyLine.cpp:678
void SetOrigin(const wxPoint &pos)
CPOLYGONS_LIST m_CornersList
Definition: PolyLine.h:487
void SetEnd(int x, int y)
#define max(a, b)
Definition: auxiliary.h:86
Class EDA_RECT handles the component boundary box.
int GetContourStart(int icont)
Function GetContourStart.
Definition: PolyLine.cpp:655
#define min(a, b)
Definition: auxiliary.h:85
bool CPolyLine::GetClosed ( )
Returns
true if the last corner in corners list is flagged end_contour

Definition at line 710 of file PolyLine.cpp.

References CPOLYGONS_LIST::GetCornersCount(), and m_CornersList.

Referenced by DeleteCorner(), Hatch(), and TestPointInside().

711 {
712  if( m_CornersList.GetCornersCount() == 0 )
713  return false;
714  else
715  return m_CornersList[m_CornersList.GetCornersCount() - 1].end_contour;
716 }
CPOLYGONS_LIST m_CornersList
Definition: PolyLine.h:487
unsigned GetCornersCount() const
Definition: PolyLine.h:146
int CPolyLine::GetContour ( int  ic)

Function GetContour.

Returns
the contour number containing the corner ic
Parameters
ic= the index of the corner in the corner list

Definition at line 641 of file PolyLine.cpp.

References m_CornersList.

Referenced by DeleteCorner(), and IsCutoutContour().

642 {
643  int ncont = 0;
644 
645  for( int i = 0; i<ic; i++ )
646  {
647  if( m_CornersList[i].end_contour )
648  ncont++;
649  }
650 
651  return ncont;
652 }
CPOLYGONS_LIST m_CornersList
Definition: PolyLine.h:487
int CPolyLine::GetContourEnd ( int  icont)

Function GetContourEnd.

Returns
the index of the last corner (in corners list) of a contour
Parameters
icont= the index of the contour

Definition at line 678 of file PolyLine.cpp.

References GetContoursCount(), CPOLYGONS_LIST::GetCornersCount(), and m_CornersList.

Referenced by Chamfer(), DeleteCorner(), Distance(), Fillet(), GetBoundingBox(), GetContourSize(), IsPolygonSelfIntersecting(), RemoveContour(), and TestPointInside().

679 {
680  if( icont < 0 )
681  return 0;
682 
683  if( icont == GetContoursCount() - 1 )
684  return m_CornersList.GetCornersCount() - 1;
685 
686  int ncont = 0;
687 
688  for( unsigned i = 0; i<m_CornersList.GetCornersCount(); i++ )
689  {
690  if( m_CornersList[i].end_contour )
691  {
692  if( ncont == icont )
693  return i;
694 
695  ncont++;
696  }
697  }
698 
699  wxASSERT( 0 );
700  return 0;
701 }
CPOLYGONS_LIST m_CornersList
Definition: PolyLine.h:487
unsigned GetCornersCount() const
Definition: PolyLine.h:146
int GetContoursCount() const
Function GetContoursCount.
Definition: PolyLine.cpp:613
int CPolyLine::GetContoursCount ( ) const

Function GetContoursCount.

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

Definition at line 613 of file PolyLine.cpp.

References CPOLYGONS_LIST::GetContoursCount(), and m_CornersList.

Referenced by Chamfer(), DeleteCorner(), Distance(), Fillet(), GetContourEnd(), IsPolygonSelfIntersecting(), RemoveContour(), and TestPointInside().

614 {
616 }
CPOLYGONS_LIST m_CornersList
Definition: PolyLine.h:487
int GetContoursCount() const
Function GetContoursCount.
Definition: PolyLine.cpp:620
int CPolyLine::GetContourSize ( int  icont)

Function GetContourSize.

Returns
the corners count of a contour
Parameters
icont= the index of the contour

Definition at line 704 of file PolyLine.cpp.

References GetContourEnd(), and GetContourStart().

Referenced by DeleteCorner().

705 {
706  return GetContourEnd( icont ) - GetContourStart( icont ) + 1;
707 }
int GetContourEnd(int icont)
Function GetContourEnd.
Definition: PolyLine.cpp:678
int GetContourStart(int icont)
Function GetContourStart.
Definition: PolyLine.cpp:655
int CPolyLine::GetContourStart ( int  icont)

Function GetContourStart.

Returns
the index of the first corner (in corners list) of a contour
Parameters
icont= the index of the contour

Definition at line 655 of file PolyLine.cpp.

References CPOLYGONS_LIST::GetCornersCount(), and m_CornersList.

Referenced by Chamfer(), Distance(), Fillet(), GetBoundingBox(), GetContourSize(), IsPolygonSelfIntersecting(), RemoveContour(), and TestPointInside().

656 {
657  if( icont == 0 )
658  return 0;
659 
660  int ncont = 0;
661 
662  for( unsigned i = 0; i<m_CornersList.GetCornersCount(); i++ )
663  {
664  if( m_CornersList[i].end_contour )
665  {
666  ncont++;
667 
668  if( ncont == icont )
669  return i + 1;
670  }
671  }
672 
673  wxASSERT( 0 );
674  return 0;
675 }
CPOLYGONS_LIST m_CornersList
Definition: PolyLine.h:487
unsigned GetCornersCount() const
Definition: PolyLine.h:146
int CPolyLine::GetCornersCount ( ) const
inline

Definition at line 339 of file PolyLine.h.

References CPOLYGONS_LIST::GetCornersCount(), and m_CornersList.

Referenced by MoveOrigin().

340  {
342  }
CPOLYGONS_LIST m_CornersList
Definition: PolyLine.h:487
unsigned GetCornersCount() const
Definition: PolyLine.h:146
static int CPolyLine::GetDefaultHatchPitchMils ( )
inlinestatic

Definition at line 397 of file PolyLine.h.

397 { return 20; } // default hatch pitch value in mils
int CPolyLine::GetHatchPitch ( ) const
inline

Definition at line 396 of file PolyLine.h.

References m_hatchPitch.

Referenced by ImportSettings().

396 { return m_hatchPitch; }
int m_hatchPitch
Definition: PolyLine.h:482
enum HATCH_STYLE CPolyLine::GetHatchStyle ( ) const
inline

Definition at line 399 of file PolyLine.h.

References m_hatchStyle.

Referenced by Chamfer(), Fillet(), and ImportSettings().

399 { return m_hatchStyle; }
enum HATCH_STYLE m_hatchStyle
Definition: PolyLine.h:481
LAYER_NUM CPolyLine::GetLayer ( ) const
inline

Definition at line 337 of file PolyLine.h.

References m_layer.

Referenced by Chamfer(), Fillet(), Hatch(), and ImportSettings().

337 { return m_layer; }
LAYER_NUM m_layer
Definition: PolyLine.h:480
const wxPoint& CPolyLine::GetPos ( int  ic) const
inline

Definition at line 394 of file PolyLine.h.

References CPOLYGONS_LIST::GetPos(), and m_CornersList.

394 { return m_CornersList.GetPos( ic ); }
CPOLYGONS_LIST m_CornersList
Definition: PolyLine.h:487
const wxPoint & GetPos(int ic) const
Definition: PolyLine.h:136
int CPolyLine::GetX ( int  ic) const
inline

Definition at line 384 of file PolyLine.h.

References CPOLYGONS_LIST::GetX(), and m_CornersList.

Referenced by Distance(), IsPolygonSelfIntersecting(), and MoveOrigin().

384 { return m_CornersList.GetX( ic ); }
CPOLYGONS_LIST m_CornersList
Definition: PolyLine.h:487
int GetX(int ic) const
Definition: PolyLine.h:126
int CPolyLine::GetY ( int  ic) const
inline

Definition at line 385 of file PolyLine.h.

References CPOLYGONS_LIST::GetY(), and m_CornersList.

Referenced by Distance(), IsPolygonSelfIntersecting(), and MoveOrigin().

385 { return m_CornersList.GetY( ic ); }
CPOLYGONS_LIST m_CornersList
Definition: PolyLine.h:487
int GetY(int ic) const
Definition: PolyLine.h:128
void CPolyLine::Hatch ( )

Definition at line 728 of file PolyLine.cpp.

References DIAGONAL_EDGE, DIAGONAL_FULL, FindLineSegmentIntersection(), GetClosed(), CPOLYGONS_LIST::GetCornersCount(), GetLayer(), KiROUND(), m_CornersList, m_HatchLines, m_hatchPitch, m_hatchStyle, MAXPTS, NO_HATCH, and sort_ends_by_descending_X().

Referenced by InsertCorner(), MoveCorner(), MoveOrigin(), RemoveContour(), and SetHatch().

729 {
730  m_HatchLines.clear();
731 
732  if( m_hatchStyle == NO_HATCH || m_hatchPitch == 0 )
733  return;
734 
735  if( !GetClosed() ) // If not closed, the poly is beeing created and not finalised. Not not hatch
736  return;
737 
738  // define range for hatch lines
739  int min_x = m_CornersList[0].x;
740  int max_x = m_CornersList[0].x;
741  int min_y = m_CornersList[0].y;
742  int max_y = m_CornersList[0].y;
743 
744  for( unsigned ic = 1; ic < m_CornersList.GetCornersCount(); ic++ )
745  {
746  if( m_CornersList[ic].x < min_x )
747  min_x = m_CornersList[ic].x;
748 
749  if( m_CornersList[ic].x > max_x )
750  max_x = m_CornersList[ic].x;
751 
752  if( m_CornersList[ic].y < min_y )
753  min_y = m_CornersList[ic].y;
754 
755  if( m_CornersList[ic].y > max_y )
756  max_y = m_CornersList[ic].y;
757  }
758 
759  // Calculate spacing between 2 hatch lines
760  int spacing;
761 
762  if( m_hatchStyle == DIAGONAL_EDGE )
763  spacing = m_hatchPitch;
764  else
765  spacing = m_hatchPitch * 2;
766 
767  // set the "length" of hatch lines (the length on horizontal axis)
768  double hatch_line_len = m_hatchPitch;
769 
770  // To have a better look, give a slope depending on the layer
771  LAYER_NUM layer = GetLayer();
772  int slope_flag = (layer & 1) ? 1 : -1; // 1 or -1
773  double slope = 0.707106 * slope_flag; // 45 degrees slope
774  int max_a, min_a;
775 
776  if( slope_flag == 1 )
777  {
778  max_a = KiROUND( max_y - slope * min_x );
779  min_a = KiROUND( min_y - slope * max_x );
780  }
781  else
782  {
783  max_a = KiROUND( max_y - slope * max_x );
784  min_a = KiROUND( min_y - slope * min_x );
785  }
786 
787  min_a = (min_a / spacing) * spacing;
788 
789  // calculate an offset depending on layer number,
790  // for a better look of hatches on a multilayer board
791  int offset = (layer * 7) / 8;
792  min_a += offset;
793 
794  // now calculate and draw hatch lines
795  int nc = m_CornersList.GetCornersCount();
796 
797  // loop through hatch lines
798  #define MAXPTS 200 // Usually we store only few values per one hatch line
799  // depending on the compexity of the zone outline
800 
801  static std::vector <wxPoint> pointbuffer;
802  pointbuffer.clear();
803  pointbuffer.reserve( MAXPTS + 2 );
804 
805  for( int a = min_a; a < max_a; a += spacing )
806  {
807  // get intersection points for this hatch line
808 
809  // Note: because we should have an even number of intersections with the
810  // current hatch line and the zone outline (a closed polygon,
811  // or a set of closed polygons), if an odd count is found
812  // we skip this line (should not occur)
813  pointbuffer.clear();
814  int i_start_contour = 0;
815 
816  for( int ic = 0; ic<nc; ic++ )
817  {
818  double x, y, x2, y2;
819  int ok;
820 
821  if( m_CornersList[ic].end_contour ||
822  ( ic == (int) (m_CornersList.GetCornersCount() - 1) ) )
823  {
824  ok = FindLineSegmentIntersection( a, slope,
825  m_CornersList[ic].x, m_CornersList[ic].y,
826  m_CornersList[i_start_contour].x,
827  m_CornersList[i_start_contour].y,
828  &x, &y, &x2, &y2 );
829  i_start_contour = ic + 1;
830  }
831  else
832  {
833  ok = FindLineSegmentIntersection( a, slope,
834  m_CornersList[ic].x, m_CornersList[ic].y,
835  m_CornersList[ic + 1].x, m_CornersList[ic + 1].y,
836  &x, &y, &x2, &y2 );
837  }
838 
839  if( ok )
840  {
841  wxPoint point( KiROUND( x ), KiROUND( y ) );
842  pointbuffer.push_back( point );
843  }
844 
845  if( ok == 2 )
846  {
847  wxPoint point( KiROUND( x2 ), KiROUND( y2 ) );
848  pointbuffer.push_back( point );
849  }
850 
851  if( pointbuffer.size() >= MAXPTS ) // overflow
852  {
853  wxASSERT( 0 );
854  break;
855  }
856  }
857 
858  // ensure we have found an even intersection points count
859  // because intersections are the ends of segments
860  // inside the polygon(s) and a segment has 2 ends.
861  // if not, this is a strange case (a bug ?) so skip this hatch
862  if( pointbuffer.size() % 2 != 0 )
863  continue;
864 
865  // sort points in order of descending x (if more than 2) to
866  // ensure the starting point and the ending point of the same segment
867  // are stored one just after the other.
868  if( pointbuffer.size() > 2 )
869  sort( pointbuffer.begin(), pointbuffer.end(), sort_ends_by_descending_X );
870 
871  // creates lines or short segments inside the complex polygon
872  for( unsigned ip = 0; ip < pointbuffer.size(); ip += 2 )
873  {
874  double dx = pointbuffer[ip + 1].x - pointbuffer[ip].x;
875 
876  // Push only one line for diagonal hatch,
877  // or for small lines < twice the line len
878  // else push 2 small lines
879  if( m_hatchStyle == DIAGONAL_FULL || fabs( dx ) < 2 * hatch_line_len )
880  {
881  m_HatchLines.push_back( CSegment( pointbuffer[ip], pointbuffer[ip + 1] ) );
882  }
883  else
884  {
885  double dy = pointbuffer[ip + 1].y - pointbuffer[ip].y;
886  slope = dy / dx;
887 
888  if( dx > 0 )
889  dx = hatch_line_len;
890  else
891  dx = -hatch_line_len;
892 
893  double x1 = pointbuffer[ip].x + dx;
894  double x2 = pointbuffer[ip + 1].x - dx;
895  double y1 = pointbuffer[ip].y + dx * slope;
896  double y2 = pointbuffer[ip + 1].y - dx * slope;
897 
898  m_HatchLines.push_back( CSegment( pointbuffer[ip].x,
899  pointbuffer[ip].y,
900  KiROUND( x1 ), KiROUND( y1 ) ) );
901 
902  m_HatchLines.push_back( CSegment( pointbuffer[ip + 1].x,
903  pointbuffer[ip + 1].y,
904  KiROUND( x2 ), KiROUND( y2 ) ) );
905  }
906  }
907  }
908 }
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
CPOLYGONS_LIST m_CornersList
Definition: PolyLine.h:487
unsigned GetCornersCount() const
Definition: PolyLine.h:146
std::vector< CSegment > m_HatchLines
Definition: PolyLine.h:488
enum HATCH_STYLE m_hatchStyle
Definition: PolyLine.h:481
bool sort_ends_by_descending_X(const wxPoint &ref, const wxPoint &tst)
Definition: PolyLine.cpp:722
bool FindLineSegmentIntersection(double a, double b, int xi, int yi, int xf, int yf, double *x1, double *y1, double *x2, double *y2, double *dist)
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
LAYER_NUM GetLayer() const
Definition: PolyLine.h:337
#define MAXPTS
bool GetClosed()
Definition: PolyLine.cpp:710
int m_hatchPitch
Definition: PolyLine.h:482
int CPolyLine::HitTestForCorner ( const wxPoint aPos,
int  aDistMax 
) const

Function HitTestForCorner test is the point aPos is near (< aDistMax ) a corner.

Parameters
aPos= the reference point
aDistMax= the max distance between a vertex and the corner
Returns
int = the index of corner of the, or -1 if not found.

Definition at line 1197 of file PolyLine.cpp.

References abs, delta, dist, CPOLYGONS_LIST::GetCornersCount(), CPOLYGONS_LIST::GetX(), CPOLYGONS_LIST::GetY(), m_CornersList, max, wxPoint::x, and wxPoint::y.

1198 {
1199  int corner = -1; // Set to not found
1200  wxPoint delta;
1201  unsigned lim = m_CornersList.GetCornersCount();
1202 
1203  for( unsigned item_pos = 0; item_pos < lim; item_pos++ )
1204  {
1205  delta.x = aPos.x - m_CornersList.GetX( item_pos );
1206  delta.y = aPos.y - m_CornersList.GetY( item_pos );
1207 
1208  // Calculate a distance:
1209  int dist = std::max( abs( delta.x ), abs( delta.y ) );
1210 
1211  if( dist < aDistMax ) // this corner is a candidate:
1212  {
1213  corner = item_pos;
1214  aDistMax = dist;
1215  }
1216  }
1217 
1218  return corner;
1219 }
static const int dist[10][10]
Definition: dist.cpp:57
CPOLYGONS_LIST m_CornersList
Definition: PolyLine.h:487
unsigned GetCornersCount() const
Definition: PolyLine.h:146
#define abs(a)
Definition: auxiliary.h:84
static const int delta[8][2]
Definition: solve.cpp:112
#define max(a, b)
Definition: auxiliary.h:86
int GetY(int ic) const
Definition: PolyLine.h:128
int GetX(int ic) const
Definition: PolyLine.h:126
int CPolyLine::HitTestForEdge ( const wxPoint aPos,
int  aDistMax 
) const

Function HitTestForEdge test is the point aPos is near (< aDistMax ) a vertex.

Parameters
aPos= the reference point
aDistMax= the max distance between a vertex and the reference point
Returns
int = the index of the first corner of the vertex, or -1 if not found.

Definition at line 1155 of file PolyLine.cpp.

References dist, CPOLYGONS_LIST::GetCornersCount(), GetPointToLineSegmentDistance(), CPOLYGONS_LIST::GetX(), CPOLYGONS_LIST::GetY(), CPOLYGONS_LIST::IsEndContour(), KiROUND(), m_CornersList, wxPoint::x, and wxPoint::y.

1156 {
1157  unsigned lim = m_CornersList.GetCornersCount();
1158  int corner = -1; // Set to not found
1159  unsigned first_corner_pos = 0;
1160 
1161  for( unsigned item_pos = 0; item_pos < lim; item_pos++ )
1162  {
1163  unsigned end_segm = item_pos + 1;
1164 
1165  /* the last corner of the current outline is tested
1166  * the last segment of the current outline starts at current corner, and ends
1167  * at the first corner of the outline
1168  */
1169  if( m_CornersList.IsEndContour ( item_pos ) || end_segm >= lim )
1170  {
1171  unsigned tmp = first_corner_pos;
1172  first_corner_pos = end_segm; // first_corner_pos is the beginning of next outline
1173  end_segm = tmp; // end_segm is the beginning of the current outline
1174  }
1175 
1176  // test the dist between segment and ref point
1178  aPos.x, aPos.y,
1179  m_CornersList.GetX( item_pos ),
1180  m_CornersList.GetY( item_pos ),
1181  m_CornersList.GetX( end_segm ),
1182  m_CornersList.GetY( end_segm ) ) );
1183 
1184  if( dist < aDistMax )
1185  {
1186  corner = item_pos;
1187  aDistMax = dist;
1188  }
1189  }
1190 
1191  return corner;
1192 }
double GetPointToLineSegmentDistance(int x, int y, int xi, int yi, int xf, int yf)
Function GetPointToLineSegmentDistance Get distance between line segment and point.
bool IsEndContour(int ic) const
Definition: PolyLine.h:131
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
static const int dist[10][10]
Definition: dist.cpp:57
CPOLYGONS_LIST m_CornersList
Definition: PolyLine.h:487
unsigned GetCornersCount() const
Definition: PolyLine.h:146
int GetY(int ic) const
Definition: PolyLine.h:128
int GetX(int ic) const
Definition: PolyLine.h:126
void CPolyLine::ImportSettings ( const CPolyLine aPoly)

Function ImportSettings Copy settings (layer, hatch styles) from aPoly.

Parameters
aPolyis the CPolyLine to import settings

Definition at line 176 of file PolyLine.cpp.

References GetHatchPitch(), GetHatchStyle(), GetLayer(), SetHatchPitch(), SetHatchStyle(), and SetLayer().

Referenced by NormalizeAreaOutlines().

177 {
178  SetLayer( aPoly->GetLayer() );
179  SetHatchStyle( aPoly->GetHatchStyle() );
180  SetHatchPitch( aPoly->GetHatchPitch() );
181 }
void SetHatchPitch(int pitch)
Definition: PolyLine.h:424
enum HATCH_STYLE GetHatchStyle() const
Definition: PolyLine.h:399
int GetHatchPitch() const
Definition: PolyLine.h:396
LAYER_NUM GetLayer() const
Definition: PolyLine.h:337
void SetHatchStyle(enum HATCH_STYLE style)
Definition: PolyLine.h:419
void SetLayer(LAYER_NUM aLayer)
Definition: PolyLine.h:336
void CPolyLine::InsertCorner ( int  ic,
int  x,
int  y 
)

Function InsertCorner insert a new corner between two existing corners.

Parameters
ic= index for the insertion point: the corner is inserted AFTER ic
x,y= coordinates corner to insert

Definition at line 532 of file PolyLine.cpp.

References CPOLYGONS_LIST::Append(), CPOLYGONS_LIST::GetCornersCount(), Hatch(), CPOLYGONS_LIST::InsertCorner(), m_CornersList, and UnHatch().

533 {
534  UnHatch();
535 
536  if( (unsigned) (ic) >= m_CornersList.GetCornersCount() )
537  {
538  m_CornersList.Append( CPolyPt( x, y ) );
539  }
540  else
541  {
542  m_CornersList.InsertCorner(ic, CPolyPt( x, y ) );
543  }
544 
545  if( (unsigned) (ic + 1) < m_CornersList.GetCornersCount() )
546  {
547  if( m_CornersList[ic].end_contour )
548  {
549  m_CornersList[ic + 1].end_contour = true;
550  m_CornersList[ic].end_contour = false;
551  }
552  }
553 
554  Hatch();
555 }
void UnHatch()
Definition: PolyLine.cpp:559
void Hatch()
Definition: PolyLine.cpp:728
CPOLYGONS_LIST m_CornersList
Definition: PolyLine.h:487
unsigned GetCornersCount() const
Definition: PolyLine.h:146
void Append(const CPOLYGONS_LIST &aList)
Definition: PolyLine.h:160
void InsertCorner(int aPosition, const CPolyPt &aItem)
Definition: PolyLine.h:179
bool CPolyLine::IsCutoutContour ( int  aCornerIdx)
Returns
true if the corner aCornerIdx is on a hole inside the main outline and false if it is on the main outline

Definition at line 959 of file PolyLine.cpp.

References GetContour().

960 {
961  int ncont = GetContour( aCornerIdx );
962 
963  if( ncont == 0 ) // the first contour is the main outline, not an hole
964  return false;
965 
966  return true;
967 }
int GetContour(int ic)
Function GetContour.
Definition: PolyLine.cpp:641
bool CPolyLine::IsEndContour ( int  ic) const
inline

Function IsEndContour.

Returns
true if a corner is flagged end_contour
Parameters
ic=the index (in corners list) of the corner

Definition at line 392 of file PolyLine.h.

References CPOLYGONS_LIST::IsEndContour(), and m_CornersList.

392 { return m_CornersList.IsEndContour( ic ); }
bool IsEndContour(int ic) const
Definition: PolyLine.h:131
CPOLYGONS_LIST m_CornersList
Definition: PolyLine.h:487
bool CPolyLine::IsPolygonSelfIntersecting ( )

Function IsPolygonSelfIntersecting Test a CPolyLine for self-intersection of vertex (all contours).

Returns
: false if no intersecting sides true if intersecting sides When a CPolyLine is self intersectic, it need to be normalized. (converted to non intersecting polygons)

Definition at line 1232 of file PolyLine.cpp.

References FindSegmentIntersections(), GetBoundingBox(), GetContourEnd(), GetContoursCount(), GetContourStart(), GetX(), and GetY().

1233 {
1234  // first, check for sides intersecting other sides
1235  int n_cont = GetContoursCount();
1236 
1237  // make bounding rect for each contour
1238  std::vector<EDA_RECT> cr;
1239  cr.reserve( n_cont );
1240 
1241  for( int icont = 0; icont<n_cont; icont++ )
1242  cr.push_back( GetBoundingBox( icont ) );
1243 
1244  for( int icont = 0; icont<n_cont; icont++ )
1245  {
1246  int is_start = GetContourStart( icont );
1247  int is_end = GetContourEnd( icont );
1248 
1249  for( int is = is_start; is<=is_end; is++ )
1250  {
1251  int is_prev = is - 1;
1252 
1253  if( is_prev < is_start )
1254  is_prev = is_end;
1255 
1256  int is_next = is + 1;
1257 
1258  if( is_next > is_end )
1259  is_next = is_start;
1260 
1261  int x1i = GetX( is );
1262  int y1i = GetY( is );
1263  int x1f = GetX( is_next );
1264  int y1f = GetY( is_next );
1265 
1266  // check for intersection with any other sides
1267  for( int icont2 = icont; icont2 < n_cont; icont2++ )
1268  {
1269  if( !cr[icont].Intersects( cr[icont2] ) )
1270  {
1271  // rectangles don't overlap, do nothing
1272  }
1273  else
1274  {
1275  int is2_start = GetContourStart( icont2 );
1276  int is2_end = GetContourEnd( icont2 );
1277 
1278  for( int is2 = is2_start; is2<=is2_end; is2++ )
1279  {
1280  int is2_prev = is2 - 1;
1281 
1282  if( is2_prev < is2_start )
1283  is2_prev = is2_end;
1284 
1285  int is2_next = is2 + 1;
1286 
1287  if( is2_next > is2_end )
1288  is2_next = is2_start;
1289 
1290  if( icont != icont2
1291  || ( is2 != is && is2 != is_prev && is2 != is_next &&
1292  is != is2_prev && is != is2_next )
1293  )
1294  {
1295  int x2i = GetX( is2 );
1296  int y2i = GetY( is2 );
1297  int x2f = GetX( is2_next );
1298  int y2f = GetY( is2_next );
1299  int ret = FindSegmentIntersections( x1i, y1i, x1f, y1f,
1300  x2i, y2i, x2f, y2f );
1301  if( ret )
1302  {
1303  // intersection between non-adjacent sides
1304  return true;
1305  }
1306  }
1307  }
1308  }
1309  }
1310  }
1311  }
1312 
1313  return false;
1314 }
const EDA_RECT GetBoundingBox()
Definition: PolyLine.cpp:565
int GetY(int ic) const
Definition: PolyLine.h:385
int GetContourEnd(int icont)
Function GetContourEnd.
Definition: PolyLine.cpp:678
int GetX(int ic) const
Definition: PolyLine.h:384
int GetContoursCount() const
Function GetContoursCount.
Definition: PolyLine.cpp:613
int GetContourStart(int icont)
Function GetContourStart.
Definition: PolyLine.cpp:655
bool FindSegmentIntersections(int xi, int yi, int xf, int yf, int xi2, int yi2, int xf2, int yf2)
void CPolyLine::MoveCorner ( int  ic,
int  x,
int  y 
)

Definition at line 211 of file PolyLine.cpp.

References Hatch(), m_CornersList, and UnHatch().

212 {
213  UnHatch();
214  m_CornersList[ic].x = x;
215  m_CornersList[ic].y = y;
216  Hatch();
217 }
void UnHatch()
Definition: PolyLine.cpp:559
void Hatch()
Definition: PolyLine.cpp:728
CPOLYGONS_LIST m_CornersList
Definition: PolyLine.h:487
void CPolyLine::MoveOrigin ( int  x_off,
int  y_off 
)

Definition at line 970 of file PolyLine.cpp.

References GetCornersCount(), GetX(), GetY(), Hatch(), SetX(), SetY(), and UnHatch().

971 {
972  UnHatch();
973 
974  for( int ic = 0; ic < GetCornersCount(); ic++ )
975  {
976  SetX( ic, GetX( ic ) + x_off );
977  SetY( ic, GetY( ic ) + y_off );
978  }
979 
980  Hatch();
981 }
void UnHatch()
Definition: PolyLine.cpp:559
int GetY(int ic) const
Definition: PolyLine.h:385
void SetX(int ic, int x)
Definition: PolyLine.h:409
void Hatch()
Definition: PolyLine.cpp:728
void SetY(int ic, int y)
Definition: PolyLine.h:414
int GetX(int ic) const
Definition: PolyLine.h:384
int GetCornersCount() const
Definition: PolyLine.h:339
int CPolyLine::NormalizeAreaOutlines ( std::vector< CPolyLine * > *  aNewPolygonList)

Function NormalizeAreaOutlines Convert a self-intersecting polygon to one (or more) non self-intersecting polygon(s) Removes null segments.

Parameters
aNewPolygonList= a std::vector<CPolyLine*> reference where to store new CPolyLine needed by the normalization
Returns
the polygon count (always >= 1, because there is at least one polygon) There are new polygons only if the polygon count is > 1

Definition at line 117 of file PolyLine.cpp.

References SHAPE_POLY_SET::AddOutline(), SHAPE_POLY_SET::BooleanSubtract(), ConvertPolyListToPolySet(), ConvertPolySetToPolyList(), SHAPE_POLY_SET::CPolygon(), CPolyLine(), ImportSettings(), m_CornersList, SHAPE_POLY_SET::NewOutline(), SHAPE_POLY_SET::OutlineCount(), SHAPE_POLY_SET::PM_FAST, SHAPE_POLY_SET::PM_STRICTLY_SIMPLE, SHAPE_POLY_SET::Polygon(), RemoveAllContours(), RemoveNullSegments(), and SHAPE_POLY_SET::Simplify().

118 {
120 
121  // We are expecting only one main outline, but this main outline can have holes
122  // if holes: combine holes and remove them from the main outline.
123  // Note also we are using SHAPE_POLY_SET::PM_STRICTLY_SIMPLE in polygon
124  // calculations, but it is not mandatory. It is used mainly
125  // because there is usually only very few vertices in area outlines
126  SHAPE_POLY_SET::POLYGON& outline = polySet.Polygon( 0 );
127  SHAPE_POLY_SET holesBuffer;
128 
129  // Move holes stored in outline to holesBuffer:
130  // The first SHAPE_LINE_CHAIN is the main outline, others are holes
131  while( outline.size() > 1 )
132  {
133  holesBuffer.AddOutline( outline.back() );
134  outline.pop_back();
135  }
136 
138 
139  // If any hole, substract it to main outline
140  if( holesBuffer.OutlineCount() )
141  {
142  holesBuffer.Simplify( SHAPE_POLY_SET::PM_FAST);
143  polySet.BooleanSubtract( holesBuffer, SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
144  }
145 
147 
148  // Note: we can have more than outline, because a self intersecting outline will be
149  // broken to non intersecting polygons, and removing holes can also create a few polygons
150  for( int ii = 0; ii < polySet.OutlineCount(); ii++ )
151  {
152  CPolyLine* polyline = this;
153 
154  if( ii > 0 )
155  {
156  polyline = new CPolyLine;
157  polyline->ImportSettings( this );
158  aNewPolygonList->push_back( polyline );
159  }
160 
161  SHAPE_POLY_SET pnew;
162  pnew.NewOutline();
163  pnew.Polygon( 0 ) = polySet.CPolygon( ii );
164 
165  polyline->m_CornersList = ConvertPolySetToPolyList( pnew );
166  polyline->RemoveNullSegments();
167  }
168 
169  return polySet.OutlineCount();
170 }
std::vector< SHAPE_LINE_CHAIN > POLYGON
represents a single polygon outline with holes.
const CPOLYGONS_LIST ConvertPolySetToPolyList(const SHAPE_POLY_SET &aPolyset)
Definition: PolyLine.cpp:1362
void RemoveAllContours(void)
function RemoveAllContours removes all corners from the list.
Definition: PolyLine.cpp:513
const SHAPE_POLY_SET ConvertPolyListToPolySet(const CPOLYGONS_LIST &aList)
Definition: PolyLine.cpp:1316
CPOLYGONS_LIST m_CornersList
Definition: PolyLine.h:487
int OutlineCount() const
Returns the number of outlines in the set
int RemoveNullSegments()
Function RemoveNullSegments Removes corners which create a null segment edge (i.e.
Definition: PolyLine.cpp:77
Class SHAPE_POLY_SET.
void Simplify(POLYGON_MODE aFastMode)
Simplifies the polyset (merges overlapping polys, eliminates degeneracy/self-intersections) For aFast...
int NewOutline()
Creates a new empty polygon in the set and returns its index
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new outline to the set and returns its index
const POLYGON & CPolygon(int aIndex) const
void BooleanSubtract(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Performs boolean polyset difference For aFastMode meaning, see function booleanOp ...
POLYGON & Polygon(int aIndex)
Returns the aIndex-th subpolygon in the set
void ImportSettings(const CPolyLine *aPoly)
Function ImportSettings Copy settings (layer, hatch styles) from aPoly.
Definition: PolyLine.cpp:176
void CPolyLine::RemoveAllContours ( void  )

function RemoveAllContours removes all corners from the list.

Others params are not changed

Definition at line 513 of file PolyLine.cpp.

References m_CornersList, and CPOLYGONS_LIST::RemoveAllContours().

Referenced by NormalizeAreaOutlines().

521 {
523 }
CPOLYGONS_LIST m_CornersList
Definition: PolyLine.h:487
void RemoveAllContours(void)
Definition: PolyLine.h:143
void CPolyLine::RemoveContour ( int  icont)

Function RemoveContour.

Parameters
icont= contour number to remove remove a contour only if there is more than 1 contour

Definition at line 252 of file PolyLine.cpp.

References CPOLYGONS_LIST::DeleteCorner(), GetContourEnd(), GetContoursCount(), GetContourStart(), Hatch(), m_CornersList, and UnHatch().

Referenced by DeleteCorner().

260 {
261  UnHatch();
262  int istart = GetContourStart( icont );
263  int iend = GetContourEnd( icont );
264 
265  int polycount = GetContoursCount();
266 
267  if( icont == 0 && polycount == 1 )
268  {
269  // remove the only contour
270  wxASSERT( 0 );
271  }
272  else
273  {
274  // remove closed contour
275  for( int ic = iend; ic>=istart; ic-- )
276  {
278  }
279  }
280 
281  Hatch();
282 }
void UnHatch()
Definition: PolyLine.cpp:559
void Hatch()
Definition: PolyLine.cpp:728
int GetContourEnd(int icont)
Function GetContourEnd.
Definition: PolyLine.cpp:678
CPOLYGONS_LIST m_CornersList
Definition: PolyLine.h:487
int GetContoursCount() const
Function GetContoursCount.
Definition: PolyLine.cpp:613
void DeleteCorner(int aIdx)
Definition: PolyLine.h:148
int GetContourStart(int icont)
Function GetContourStart.
Definition: PolyLine.cpp:655
int CPolyLine::RemoveNullSegments ( )

Function RemoveNullSegments Removes corners which create a null segment edge (i.e.

when 2 successive corners are at the same location)

Returns
the count of removed corners.

Definition at line 77 of file PolyLine.cpp.

References DeleteCorner(), CPOLYGONS_LIST::GetCornersCount(), and m_CornersList.

Referenced by Chamfer(), Fillet(), and NormalizeAreaOutlines().

78 {
79  int removed = 0;
80  unsigned startcountour = 0;
81 
82  for( unsigned icnt = 1; icnt < m_CornersList.GetCornersCount(); icnt ++ )
83  {
84  unsigned last = icnt-1;
85  if( m_CornersList[icnt].end_contour )
86  {
87  last = startcountour;
88  startcountour = icnt+1;
89  }
90 
91  if( ( m_CornersList[last].x == m_CornersList[icnt].x ) &&
92  ( m_CornersList[last].y == m_CornersList[icnt].y ) )
93  {
94  DeleteCorner( icnt );
95  icnt--;
96  removed ++;
97  }
98 
99  if( m_CornersList[icnt].end_contour )
100  {
101  startcountour = icnt+1;
102  icnt++;
103  }
104  }
105 
106  return removed;
107 }
CPOLYGONS_LIST m_CornersList
Definition: PolyLine.h:487
unsigned GetCornersCount() const
Definition: PolyLine.h:146
void DeleteCorner(int ic)
Function DeleteCorner remove the given corner.
Definition: PolyLine.cpp:222
void CPolyLine::SetHatch ( int  aHatchStyle,
int  aHatchPitch,
bool  aRebuildHatch 
)
inline

Definition at line 400 of file PolyLine.h.

References Hatch(), m_hatchStyle, and SetHatchPitch().

401  {
402  SetHatchPitch( aHatchPitch );
403  m_hatchStyle = (enum HATCH_STYLE) aHatchStyle;
404 
405  if( aRebuildHatch )
406  Hatch();
407  }
void SetHatchPitch(int pitch)
Definition: PolyLine.h:424
void Hatch()
Definition: PolyLine.cpp:728
enum HATCH_STYLE m_hatchStyle
Definition: PolyLine.h:481
void CPolyLine::SetHatchPitch ( int  pitch)
inline

Definition at line 424 of file PolyLine.h.

References m_hatchPitch.

Referenced by ImportSettings(), and SetHatch().

424 { m_hatchPitch = pitch; }
int m_hatchPitch
Definition: PolyLine.h:482
void CPolyLine::SetHatchStyle ( enum HATCH_STYLE  style)
inline

Definition at line 419 of file PolyLine.h.

References m_hatchStyle.

Referenced by ImportSettings(), and Start().

420  {
421  m_hatchStyle = style;
422  }
enum HATCH_STYLE m_hatchStyle
Definition: PolyLine.h:481
void CPolyLine::SetLayer ( LAYER_NUM  aLayer)
inline

Definition at line 336 of file PolyLine.h.

References m_layer.

Referenced by ImportSettings().

336 { m_layer = aLayer; }
LAYER_NUM m_layer
Definition: PolyLine.h:480
void CPolyLine::SetX ( int  ic,
int  x 
)
inline

Definition at line 409 of file PolyLine.h.

References m_CornersList, and CPOLYGONS_LIST::SetX().

Referenced by MoveOrigin().

410  {
411  m_CornersList.SetX( ic, x );
412  }
CPOLYGONS_LIST m_CornersList
Definition: PolyLine.h:487
void SetX(int ic, int aValue)
Definition: PolyLine.h:127
void CPolyLine::SetY ( int  ic,
int  y 
)
inline

Definition at line 414 of file PolyLine.h.

References m_CornersList, and CPOLYGONS_LIST::SetY().

Referenced by MoveOrigin().

415  {
416  m_CornersList.SetY( ic, y );
417  }
CPOLYGONS_LIST m_CornersList
Definition: PolyLine.h:487
void SetY(int ic, int aValue)
Definition: PolyLine.h:129
void CPolyLine::Start ( LAYER_NUM  layer,
int  x,
int  y,
int  hatch 
)

Definition at line 186 of file PolyLine.cpp.

References CPOLYGONS_LIST::Append(), CPolyPt::end_contour, m_CornersList, m_layer, and SetHatchStyle().

Referenced by Chamfer(), and Fillet().

187 {
188  m_layer = layer;
189  SetHatchStyle( (enum HATCH_STYLE) hatch );
190  CPolyPt poly_pt( x, y );
191  poly_pt.end_contour = false;
192 
193  m_CornersList.Append( poly_pt );
194 }
CPOLYGONS_LIST m_CornersList
Definition: PolyLine.h:487
LAYER_NUM m_layer
Definition: PolyLine.h:480
void SetHatchStyle(enum HATCH_STYLE style)
Definition: PolyLine.h:419
void Append(const CPOLYGONS_LIST &aList)
Definition: PolyLine.h:160
bool CPolyLine::TestPointInside ( int  x,
int  y 
)

Definition at line 913 of file PolyLine.cpp.

References GetClosed(), GetContourEnd(), GetContoursCount(), GetContourStart(), m_CornersList, and TestPointInsidePolygon().

Referenced by Distance().

914 {
915  if( !GetClosed() )
916  {
917  wxASSERT( 0 );
918  }
919 
920  // Test all polygons.
921  // Since the first is the main outline, and other are holes,
922  // if the tested point is inside only one contour, it is inside the whole polygon
923  // (in fact inside the main outline, and outside all holes).
924  // if inside 2 contours (the main outline + an hole), it is outside the poly.
925  int polycount = GetContoursCount();
926  bool inside = false;
927 
928  for( int icont = 0; icont < polycount; icont++ )
929  {
930  int istart = GetContourStart( icont );
931  int iend = GetContourEnd( icont );
932 
933  // test point inside the current polygon
934  if( TestPointInsidePolygon( m_CornersList, istart, iend, px, py ) )
935  inside = not inside;
936  }
937 
938  return inside;
939 }
int GetContourEnd(int icont)
Function GetContourEnd.
Definition: PolyLine.cpp:678
CPOLYGONS_LIST m_CornersList
Definition: PolyLine.h:487
bool TestPointInsidePolygon(const CPOLYGONS_LIST &aPolysList, int aIdxstart, int aIdxend, int aRefx, int aRefy)
Function TestPointInsidePolygon test if a point is inside or outside a polygon.
int GetContoursCount() const
Function GetContoursCount.
Definition: PolyLine.cpp:613
bool GetClosed()
Definition: PolyLine.cpp:710
int GetContourStart(int icont)
Function GetContourStart.
Definition: PolyLine.cpp:655
void CPolyLine::UnHatch ( )

Definition at line 559 of file PolyLine.cpp.

References m_HatchLines.

Referenced by AppendCorner(), Copy(), DeleteCorner(), InsertCorner(), MoveCorner(), MoveOrigin(), RemoveContour(), and ~CPolyLine().

560 {
561  m_HatchLines.clear();
562 }
std::vector< CSegment > m_HatchLines
Definition: PolyLine.h:488

Member Data Documentation

int CPolyLine::m_flags
private

Definition at line 485 of file PolyLine.h.

Referenced by Copy(), and CPolyLine().

std::vector<CSegment> CPolyLine::m_HatchLines

Definition at line 488 of file PolyLine.h.

Referenced by CPolyLine(), Hatch(), and UnHatch().

int CPolyLine::m_hatchPitch
private

Definition at line 482 of file PolyLine.h.

Referenced by Copy(), CPolyLine(), GetHatchPitch(), Hatch(), and SetHatchPitch().

enum HATCH_STYLE CPolyLine::m_hatchStyle
private

Definition at line 481 of file PolyLine.h.

Referenced by Copy(), CPolyLine(), GetHatchStyle(), Hatch(), SetHatch(), and SetHatchStyle().

LAYER_NUM CPolyLine::m_layer
private

Definition at line 480 of file PolyLine.h.

Referenced by Copy(), CPolyLine(), GetLayer(), SetLayer(), and Start().


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