33#include <wx/filename.h>
61 const int maskClearance =
pcbIUScale.mmToIU( 1.0 );
62 const double radiusRatio = 0.125;
63 const int originalRadius =
KiROUND( std::min( padW, padH ) * radiusRatio );
64 const int maxError =
pcbIUScale.mmToIU( 0.005 );
67 auto footprint = std::make_unique<FOOTPRINT>( &board );
69 auto pad =
new PAD( footprint.get() );
77 footprint->Add(
pad );
103 const double tolerance = std::pow(
pcbIUScale.mmToIU( 0.001 ), 2.0 );
105 BOOST_CHECK_LE(
std::abs( reverseDiff.
Area() ), tolerance );
119 const int maskClearance =
pcbIUScale.mmToIU( 1.0 );
120 const double radiusRatio = 0.125;
121 const int originalRadius =
KiROUND( std::min( padW, padH ) * radiusRatio );
126 std::unique_ptr<FOOTPRINT> footprint = std::make_unique<FOOTPRINT>( &board );
136 pad->SetPosition( footprint->GetPosition() );
137 pad->SetLocalSolderMaskMargin( maskClearance );
138 footprint->Add(
pad );
139 board.
Add( footprint.release() );
150 wxString gbrPath = wxFileName::CreateTempFileName( wxT(
"kicad_gbr_24327" ) );
167 wxFFile file( gbrPath, wxT(
"rb" ) );
169 wxFileOffset len = file.Length();
170 BOOST_REQUIRE_GT( len, 0 );
173 buffer.resize(
static_cast<size_t>( len ) );
174 BOOST_REQUIRE_EQUAL( file.Read( buffer.data(), len ),
static_cast<size_t>( len ) );
180 std::regex coordRe( R
"(X(-?\d+)Y(-?\d+)D0[12]\*)" );
181 auto coordBegin = std::sregex_iterator( buffer.begin(), buffer.end(), coordRe );
182 auto coordEnd = std::sregex_iterator();
184 long long minX = std::numeric_limits<long long>::max();
185 long long maxX = std::numeric_limits<long long>::min();
186 long long minY = std::numeric_limits<long long>::max();
187 long long maxY = std::numeric_limits<long long>::min();
190 for(
auto it = coordBegin; it != coordEnd; ++it )
192 long long x = std::stoll( ( *it )[1] );
193 long long y = std::stoll( ( *it )[2] );
194 minX = std::min( minX, x );
195 maxX = std::max( maxX, x );
196 minY = std::min( minY, y );
197 maxY = std::max( maxY, y );
201 BOOST_REQUIRE_GT( coordCount, 0 );
204 const long long bboxExtent = maxX - minX;
205 BOOST_REQUIRE_GT( bboxExtent, 0 );
211 const double expectedRadiusRatio =
static_cast<double>( originalRadius + maskClearance )
212 /
static_cast<double>( padW + 2 * maskClearance );
213 const double buggyRadiusRatio = radiusRatio;
214 BOOST_TEST_MESSAGE(
"Expected r/bbox " << expectedRadiusRatio <<
" buggy " << buggyRadiusRatio );
216 std::regex arcRe( R
"(X(-?\d+)Y(-?\d+)I(-?\d+)J(-?\d+)D01\*)" );
217 auto arcBegin = std::sregex_iterator( buffer.begin(), buffer.end(), arcRe );
218 auto arcEnd = std::sregex_iterator();
222 for(
auto it = arcBegin; it != arcEnd; ++it )
224 double i = std::stoll( ( *it )[3] );
225 double j = std::stoll( ( *it )[4] );
226 double r = std::hypot( i, j );
227 double ratio = r /
static_cast<double>( bboxExtent );
229 BOOST_CHECK_MESSAGE(
std::abs( ratio - expectedRadiusRatio ) < 1e-3,
230 "Arc radius/bbox ratio " << ratio <<
" does not match expected " << expectedRadiusRatio
231 <<
" (buggy value would be " << buggyRadiusRatio <<
")" );
237 if( wxFileExists( gbrPath ) )
238 wxRemoveFile( gbrPath );
259 pad->SetPosition( padPos );
263 board.
Add( footprint );
278 BOOST_CHECK(
pad->FlashLayer(
F_Mask ) );
279 BOOST_CHECK(
pad->FlashLayer(
B_Mask ) );
constexpr EDA_IU_SCALE pcbIUScale
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
virtual void SetNet(NETINFO_ITEM *aNetInfo)
Set a NET_INFO object for the item.
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
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.
bool BuildConnectivity(PROGRESS_REPORTER *aReporter=nullptr)
Build or rebuild the board connectivity database for the board, especially the list of connected item...
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.
Handle the data for a net.
@ NORMAL
Shape is the same on all layers.
static constexpr PCB_LAYER_ID ALL_LAYERS
! The layer identifier to use for the single defintion on normal padstacks
static LSET PTHMask()
layer set for a through hole pad
Parameters and options when plotting/printing a board.
void SetUseGerberX2format(bool aUse)
void SetDisableGerberMacros(bool aDisable)
void SetFormat(PLOT_FORMAT aFormat)
void SetEnd(const VECTOR2I &aEnd)
void SetStart(const VECTOR2I &aStart)
virtual void SetWidth(int aWidth)
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)
@ PTH
Plated through hole pad.
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_AUTO_TEST_CASE(RoundRectMaskMatchesInflatedOutline)
BOOST_TEST_MESSAGE("Polyline has "<< chain.PointCount()<< " points")
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I