Commit 92b43c74 authored by jean-pierre charras's avatar jean-pierre charras

Fix 0 length segment in outline zone creation, that breaks zone chamfer option.

parent 37ee2394
......@@ -392,7 +392,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
aCallback( current_char_pos.x, current_char_pos.y, end.x, end.y );
}
else
GRLine( aPanel->GetClipBox(), aDC,
GRLine( clipBox, aDC,
current_char_pos.x, current_char_pos.y, end.x, end.y, aWidth, aColor );
return;
......
......@@ -671,7 +671,8 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC )
{
ii = zone->GetNumCorners() - 1;
// edge in progress : the current corner coordinate was set by Show_New_Edge_While_Move_Mouse
// edge in progress : the current corner coordinate was set
// by Show_New_Edge_While_Move_Mouse
if( zone->GetCornerPosition( ii - 1 ) != zone->GetCornerPosition( ii ) )
{
if( !Drc_On || !zone->IsOnCopperLayer() || ( m_drc->Drc( zone, ii - 1 ) == OK_DRC ) )
......@@ -705,6 +706,9 @@ bool PCB_EDIT_FRAME::End_Zone( wxDC* DC )
return true;
}
// Remove the last corner if is is at the same location as the prevoius corner
zone->m_Poly->RemoveNullSegments();
// Validate the current edge:
int icorner = zone->GetNumCorners() - 1;
if( zone->IsOnCopperLayer() )
......
......@@ -32,6 +32,42 @@ CPolyLine::~CPolyLine()
UnHatch();
}
/* 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.
*/
int CPolyLine::RemoveNullSegments()
{
int removed = 0;
unsigned startcountour = 0;
for( unsigned icnt = 1; icnt < m_CornersList.size(); icnt ++ )
{
unsigned last = icnt-1;
if( m_CornersList[icnt].end_contour )
{
last = startcountour;
startcountour = icnt+1;
}
if( ( m_CornersList[last].x == m_CornersList[icnt].x ) &&
( m_CornersList[last].y == m_CornersList[icnt].y ) )
{
DeleteCorner( icnt );
icnt--;
removed ++;
}
if( m_CornersList[icnt].end_contour )
{
startcountour = icnt+1;
icnt++;
}
}
return removed;
}
/**
* Function NormalizeAreaOutlines
......@@ -65,6 +101,7 @@ int CPolyLine::NormalizeAreaOutlines( std::vector<CPolyLine*>* aNewPolygonList )
if( corner.end_contour )
break;
}
ClipperLib::SimplifyPolygon( raw_polygon, normalized_polygons );
// enter main outline
......@@ -148,6 +185,8 @@ int CPolyLine::NormalizeAreaOutlines( std::vector<CPolyLine*>* aNewPolygonList )
polyline->CloseLastContour();
hole++;
}
polyline->RemoveNullSegments();
}
return outlines.size();
......
......@@ -103,7 +103,14 @@ public:
void AppendCorner( int x, int y );
void InsertCorner( int ic, int x, int y );
void 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
* @param ic = the index of the corner to delete
*/
void DeleteCorner ( int ic );
void MoveCorner( int ic, int x, int y );
void CloseLastContour();
void RemoveContour( int icont );
......@@ -137,6 +144,14 @@ public:
*/
CPolyLine* Fillet( unsigned int aRadius, unsigned int aSegments );
/**
* Function RemoveNullSegments
* Removes corners which create a null segment edge
* (i.e. when 2 successive corners are at the same location)
* @return the count of removed corners.
*/
int RemoveNullSegments();
void RemoveAllContours( void );
// Remove or create hatch
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment