Correct handling of arcs and circles (when used in pcb edges) in zone filling.
This commit is contained in:
parent
a1c528223c
commit
92ab71c2c2
|
@ -51,6 +51,11 @@ void AddRoundedEndsSegmentPolygon( Bool_Engine* aBooleng,
|
||||||
void AddTextBoxWithClearancePolygon( Bool_Engine* aBooleng,
|
void AddTextBoxWithClearancePolygon( Bool_Engine* aBooleng,
|
||||||
TEXTE_PCB* aText, int aClearanceValue );
|
TEXTE_PCB* aText, int aClearanceValue );
|
||||||
|
|
||||||
|
static void AddRingPolygon( Bool_Engine* aBooleng,
|
||||||
|
wxPoint aCentre,
|
||||||
|
wxPoint aStart,
|
||||||
|
wxPoint aEnd,
|
||||||
|
int aWidth );
|
||||||
|
|
||||||
// Local Variables:
|
// Local Variables:
|
||||||
/* how many segments are used to create a polygon from a circle: */
|
/* how many segments are used to create a polygon from a circle: */
|
||||||
|
@ -222,10 +227,38 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
|
||||||
switch( item->Type() )
|
switch( item->Type() )
|
||||||
{
|
{
|
||||||
case TYPE_DRAWSEGMENT:
|
case TYPE_DRAWSEGMENT:
|
||||||
|
|
||||||
|
switch( ( (DRAWSEGMENT*) item )->m_Shape )
|
||||||
|
{
|
||||||
|
case S_CIRCLE:
|
||||||
|
AddRingPolygon( booleng, ( (DRAWSEGMENT*) item )->m_Start,
|
||||||
|
( (DRAWSEGMENT*) item )->m_End, ( (DRAWSEGMENT*) item )->m_End,
|
||||||
|
( (DRAWSEGMENT*) item )->m_Width + (2 * m_ZoneClearance) );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case S_ARC:
|
||||||
|
{
|
||||||
|
wxPoint arc_start, arc_end;
|
||||||
|
arc_start = ( (DRAWSEGMENT*) item )->m_End;
|
||||||
|
arc_end = ( (DRAWSEGMENT*) item )->m_End;
|
||||||
|
RotatePoint( &arc_end,
|
||||||
|
( (DRAWSEGMENT*) item )->m_Start,
|
||||||
|
-( (DRAWSEGMENT*) item )->m_Angle );
|
||||||
|
AddRingPolygon( booleng, ( (DRAWSEGMENT*) item )->m_Start, arc_start, arc_end,
|
||||||
|
( (DRAWSEGMENT*) item )->m_Width + (2 * m_ZoneClearance) );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
|
||||||
AddRoundedEndsSegmentPolygon( booleng,
|
AddRoundedEndsSegmentPolygon( booleng,
|
||||||
( (DRAWSEGMENT*) item )->m_Start,
|
( (DRAWSEGMENT*) item )->m_Start,
|
||||||
( (DRAWSEGMENT*) item )->m_End,
|
( (DRAWSEGMENT*) item )->m_End,
|
||||||
( (DRAWSEGMENT*) item )->m_Width + (2 * m_ZoneClearance) );
|
( (DRAWSEGMENT*) item )->m_Width +
|
||||||
|
(2 * m_ZoneClearance) );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_TEXTE:
|
case TYPE_TEXTE:
|
||||||
|
@ -1108,6 +1141,52 @@ void AddRoundedEndsSegmentPolygon( Bool_Engine* aBooleng,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** Function AddRingPolygon
|
||||||
|
* Add a polygon cutout for an Arc in a zone area
|
||||||
|
* Convert arcs to multiple straight segments
|
||||||
|
* For a cicle, aStart = aEnd
|
||||||
|
*/
|
||||||
|
void AddRingPolygon( Bool_Engine* aBooleng, wxPoint aCentre,
|
||||||
|
wxPoint aStart, wxPoint aEnd,
|
||||||
|
int aWidth )
|
||||||
|
{
|
||||||
|
wxPoint start, end;
|
||||||
|
int arc_angle;
|
||||||
|
int delta = 3600 / s_CircleToSegmentsCount; // rot angle in 0.1 degree
|
||||||
|
|
||||||
|
if( aEnd == aStart )
|
||||||
|
arc_angle = 3600;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
double angle = atan2( aEnd.y - aCentre.y, aEnd.x - aCentre.x ) -
|
||||||
|
atan2( aStart.y - aCentre.y, aStart.x - aCentre.x );
|
||||||
|
// delta_angle is in 0.1 degrees
|
||||||
|
arc_angle = (int) round ( 1800.0 / M_PI * angle );
|
||||||
|
NEGATE ( arc_angle ); // Due to reverse orientation of Y axis,
|
||||||
|
// angles are negated, comparing to the mathematical Y orient.
|
||||||
|
}
|
||||||
|
|
||||||
|
if( arc_angle < 0 )
|
||||||
|
{
|
||||||
|
EXCHG( aStart, aEnd );
|
||||||
|
NEGATE( arc_angle );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compute the ends of segments and creates poly
|
||||||
|
end = start = aStart;
|
||||||
|
for( int ii = delta; ii < arc_angle; ii += delta )
|
||||||
|
{
|
||||||
|
end = aStart;
|
||||||
|
RotatePoint( &end, aCentre, ii );
|
||||||
|
AddRoundedEndsSegmentPolygon( aBooleng, start, end, aWidth );
|
||||||
|
start = end;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( end != aEnd )
|
||||||
|
AddRoundedEndsSegmentPolygon( aBooleng, end, aEnd, aWidth );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** function AddTextBoxWithClearancePolygon
|
/** function AddTextBoxWithClearancePolygon
|
||||||
* creates a polygon containing the text and add it to bool engine
|
* creates a polygon containing the text and add it to bool engine
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue