Loading pcbnew/zones_convert_brd_items_to_polygons.cpp +124 −45 Original line number Diff line number Diff line Loading @@ -51,6 +51,11 @@ void AddRoundedEndsSegmentPolygon( Bool_Engine* aBooleng, void AddTextBoxWithClearancePolygon( Bool_Engine* aBooleng, TEXTE_PCB* aText, int aClearanceValue ); static void AddRingPolygon( Bool_Engine* aBooleng, wxPoint aCentre, wxPoint aStart, wxPoint aEnd, int aWidth ); // Local Variables: /* how many segments are used to create a polygon from a circle: */ Loading Loading @@ -222,10 +227,38 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) switch( item->Type() ) { 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, ( (DRAWSEGMENT*) item )->m_Start, ( (DRAWSEGMENT*) item )->m_End, ( (DRAWSEGMENT*) item )->m_Width + (2 * m_ZoneClearance) ); ( (DRAWSEGMENT*) item )->m_Width + (2 * m_ZoneClearance) ); break; } break; case TYPE_TEXTE: Loading Loading @@ -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 * creates a polygon containing the text and add it to bool engine */ Loading Loading
pcbnew/zones_convert_brd_items_to_polygons.cpp +124 −45 Original line number Diff line number Diff line Loading @@ -51,6 +51,11 @@ void AddRoundedEndsSegmentPolygon( Bool_Engine* aBooleng, void AddTextBoxWithClearancePolygon( Bool_Engine* aBooleng, TEXTE_PCB* aText, int aClearanceValue ); static void AddRingPolygon( Bool_Engine* aBooleng, wxPoint aCentre, wxPoint aStart, wxPoint aEnd, int aWidth ); // Local Variables: /* how many segments are used to create a polygon from a circle: */ Loading Loading @@ -222,10 +227,38 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) switch( item->Type() ) { 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, ( (DRAWSEGMENT*) item )->m_Start, ( (DRAWSEGMENT*) item )->m_End, ( (DRAWSEGMENT*) item )->m_Width + (2 * m_ZoneClearance) ); ( (DRAWSEGMENT*) item )->m_Width + (2 * m_ZoneClearance) ); break; } break; case TYPE_TEXTE: Loading Loading @@ -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 * creates a polygon containing the text and add it to bool engine */ Loading