KiCad PCB EDA Suite
APER_MACRO_FREEPOLY Class Reference

A class to define an aperture macros based on a free polygon, i.e. More...

#include <gbr_plotter_apertures.h>

Public Member Functions

 APER_MACRO_FREEPOLY (const std::vector< VECTOR2I > &aPolygon, int aId)
 
bool IsSamePoly (const std::vector< VECTOR2I > &aPolygon) const
 
void Format (FILE *aOutput, double aIu2GbrMacroUnit)
 print the aperture macro definition to aOutput More...
 
int CornersCount () const
 

Public Attributes

std::vector< VECTOR2Im_Corners
 
int m_Id
 

Detailed Description

A class to define an aperture macros based on a free polygon, i.e.

using a primitive 4 to describe a free polygon with a rotation. the aperture macro has only one parameter: rotation and is defined on the fly for aGerber file

Definition at line 150 of file gbr_plotter_apertures.h.

Constructor & Destructor Documentation

◆ APER_MACRO_FREEPOLY()

APER_MACRO_FREEPOLY::APER_MACRO_FREEPOLY ( const std::vector< VECTOR2I > &  aPolygon,
int  aId 
)
inline

Definition at line 153 of file gbr_plotter_apertures.h.

154 {
155 m_Corners = aPolygon;
156 m_Id = aId;
157 }
std::vector< VECTOR2I > m_Corners

References m_Corners, and m_Id.

Member Function Documentation

◆ CornersCount()

int APER_MACRO_FREEPOLY::CornersCount ( ) const
inline

Definition at line 174 of file gbr_plotter_apertures.h.

174{ return (int)m_Corners.size(); }

References m_Corners.

◆ Format()

void APER_MACRO_FREEPOLY::Format ( FILE *  aOutput,
double  aIu2GbrMacroUnit 
)

print the aperture macro definition to aOutput

Parameters
aOutputis the FILE to write
aIu2GbrMacroUnitis the scaling factor from coordinates value to the Gerber file macros units (always mm or inches)

Definition at line 2012 of file GERBER_plotter.cpp.

2013{
2014 // Write aperture header
2015 fprintf( aOutput, "%%AM%s%d*\n", AM_FREEPOLY_BASENAME, m_Id );
2016 fprintf( aOutput, "4,1,%d,", (int)m_Corners.size() );
2017
2018 // Insert a newline after curr_line_count_max coordinates.
2019 int curr_line_corner_count = 0;
2020 const int curr_line_count_max = 20; // <= 0 to disable newlines
2021
2022 for( size_t ii = 0; ii <= m_Corners.size(); ii++ )
2023 {
2024 int jj = ii;
2025
2026 if( ii >= m_Corners.size() )
2027 jj = 0;
2028
2029 // Note: parameter values are always mm or inches
2030 fprintf( aOutput, "%#f,%#f,",
2031 m_Corners[jj].x * aIu2GbrMacroUnit, -m_Corners[jj].y * aIu2GbrMacroUnit );
2032
2033 if( curr_line_count_max >= 0 && ++curr_line_corner_count >= curr_line_count_max )
2034 {
2035 fprintf( aOutput, "\n" );
2036 curr_line_corner_count = 0;
2037 }
2038 }
2039
2040 // output rotation parameter
2041 fputs( "$1*%\n", aOutput );
2042}
#define AM_FREEPOLY_BASENAME

References AM_FREEPOLY_BASENAME, m_Corners, and m_Id.

◆ IsSamePoly()

bool APER_MACRO_FREEPOLY::IsSamePoly ( const std::vector< VECTOR2I > &  aPolygon) const
Returns
true if aPolygon is the same as this, i.e. if the aPolygon is the same as m_Corners
Parameters
aOtheris the candidate to compare

Definition at line 2006 of file GERBER_plotter.cpp.

2007{
2008 return polyCompare( m_Corners, aPolygon );
2009}
static bool polyCompare(const std::vector< VECTOR2I > &aPolygon, const std::vector< VECTOR2I > &aTestPolygon)

References m_Corners, and polyCompare().

Member Data Documentation

◆ m_Corners

std::vector<VECTOR2I> APER_MACRO_FREEPOLY::m_Corners

Definition at line 176 of file gbr_plotter_apertures.h.

Referenced by APER_MACRO_FREEPOLY(), CornersCount(), Format(), and IsSamePoly().

◆ m_Id

int APER_MACRO_FREEPOLY::m_Id

Definition at line 177 of file gbr_plotter_apertures.h.

Referenced by APER_MACRO_FREEPOLY(), and Format().


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