36#include <wx/filename.h>
64 const int maskClearance =
pcbIUScale.mmToIU( 1.0 );
65 const double radiusRatio = 0.125;
66 const int originalRadius =
KiROUND( std::min( padW, padH ) * radiusRatio );
67 const int maxError =
pcbIUScale.mmToIU( 0.005 );
70 auto footprint = std::make_unique<FOOTPRINT>( &board );
72 auto pad =
new PAD( footprint.get() );
79 footprint->Add(
pad );
89 VECTOR2I( padW + 2 * maskClearance, padH + 2 * maskClearance ) );
106 const double tolerance = std::pow(
pcbIUScale.mmToIU( 0.001 ), 2.0 );
108 BOOST_CHECK_LE(
std::abs( reverseDiff.
Area() ), tolerance );
122 const int maskClearance =
pcbIUScale.mmToIU( 1.0 );
123 const double radiusRatio = 0.125;
124 const int originalRadius =
KiROUND( std::min( padW, padH ) * radiusRatio );
129 auto footprint = std::make_unique<FOOTPRINT>( &board );
133 auto pad =
new PAD( footprint.get() );
139 pad->SetPosition( footprint->GetPosition() );
140 pad->SetLocalSolderMaskMargin( maskClearance );
141 footprint->Add(
pad );
142 board.
Add( footprint.release() );
153 wxString gbrPath = wxFileName::CreateTempFileName( wxT(
"kicad_gbr_24327" ) );
170 wxFFile file( gbrPath, wxT(
"rb" ) );
172 wxFileOffset len = file.Length();
173 BOOST_REQUIRE_GT( len, 0 );
176 buffer.resize(
static_cast<size_t>( len ) );
177 BOOST_REQUIRE_EQUAL( file.Read( buffer.data(), len ),
static_cast<size_t>( len ) );
183 std::regex coordRe( R
"(X(-?\d+)Y(-?\d+)D0[12]\*)" );
184 auto coordBegin = std::sregex_iterator( buffer.begin(), buffer.end(), coordRe );
185 auto coordEnd = std::sregex_iterator();
187 long long minX = std::numeric_limits<long long>::max();
188 long long maxX = std::numeric_limits<long long>::min();
189 long long minY = std::numeric_limits<long long>::max();
190 long long maxY = std::numeric_limits<long long>::min();
193 for(
auto it = coordBegin; it != coordEnd; ++it )
195 long long x = std::stoll( ( *it )[1] );
196 long long y = std::stoll( ( *it )[2] );
197 minX = std::min( minX, x );
198 maxX = std::max( maxX, x );
199 minY = std::min( minY, y );
200 maxY = std::max( maxY, y );
204 BOOST_REQUIRE_GT( coordCount, 0 );
207 const long long bboxExtent = maxX - minX;
208 BOOST_REQUIRE_GT( bboxExtent, 0 );
214 const double expectedRadiusRatio =
static_cast<double>( originalRadius + maskClearance )
215 /
static_cast<double>( padW + 2 * maskClearance );
216 const double buggyRadiusRatio = radiusRatio;
218 <<
" buggy " << buggyRadiusRatio );
220 std::regex arcRe( R
"(X(-?\d+)Y(-?\d+)I(-?\d+)J(-?\d+)D01\*)" );
221 auto arcBegin = std::sregex_iterator( buffer.begin(), buffer.end(), arcRe );
222 auto arcEnd = std::sregex_iterator();
226 for(
auto it = arcBegin; it != arcEnd; ++it )
228 double i = std::stoll( ( *it )[3] );
229 double j = std::stoll( ( *it )[4] );
230 double r = std::hypot( i, j );
231 double ratio = r /
static_cast<double>( bboxExtent );
234 "Arc radius/bbox ratio " << ratio
235 <<
" does not match expected "
236 << expectedRadiusRatio
237 <<
" (buggy value would be "
238 << buggyRadiusRatio <<
")" );
244 if( wxFileExists( gbrPath ) )
245 wxRemoveFile( gbrPath );
constexpr EDA_IU_SCALE pcbIUScale
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
int m_SolderMaskExpansion
Information pertinent to a Pcbnew printed circuit board.
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
constexpr size_type GetWidth() const
constexpr size_type GetHeight() const
virtual void SetViewport(const VECTOR2I &aOffset, double aIusPerDecimil, double aScale, bool aMirror) override
Set the plot offset and scaling for the current plot.
virtual bool EndPlot() override
void UseX2format(bool aEnable)
virtual bool StartPlot(const wxString &pageNumber) override
Write GERBER header to file initialize global variable g_Plot_PlotOutputFile.
void DisableApertMacros(bool aDisable)
Disable Aperture Macro (AM) command, only for broken Gerber Readers.
LSET is a set of PCB_LAYER_IDs.
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
Parameters and options when plotting/printing a board.
void SetUseGerberX2format(bool aUse)
void SetDisableGerberMacros(bool aDisable)
void SetFormat(PLOT_FORMAT aFormat)
virtual bool OpenFile(const wxString &aFullFilename)
Open or create the plot file aFullFilename.
void SetRenderSettings(RENDER_SETTINGS *aSettings)
Represent a set of closed polygons.
double Area()
Return the area of this poly set.
void BooleanSubtract(const SHAPE_POLY_SET &b)
Perform boolean polyset difference.
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
Minimal concrete render settings suitable for plotters in tests.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
@ SMD
Smd pad, appears on the solder paste layer (default)
void PlotStandardLayer(BOARD *aBoard, PLOTTER *aPlotter, const LSET &aLayerMask, const PCB_PLOT_PARAMS &aPlotOpt)
Plot copper or technical layers.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
VECTOR3I expected(15, 30, 45)
BOOST_CHECK_MESSAGE(totalMismatches==0, std::to_string(totalMismatches)+" board(s) with strategy disagreements")
BOOST_TEST_MESSAGE("\n=== Real-World Polygon PIP Benchmark ===\n"<< formatTable(table))
BOOST_AUTO_TEST_CASE(RoundRectMaskMatchesInflatedOutline)
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I