24#include <boost/test/unit_test.hpp>
28#include <wx/filename.h>
45static std::vector<SHAPE_LINE_CHAIN>
ReadPolygons(
const wxString& aBoard )
47 std::vector<SHAPE_LINE_CHAIN> polygons;
50 while( ( pos = aBoard.find( wxT(
"(gr_poly" ), pos ) ) != wxString::npos )
52 size_t end = aBoard.find( wxT(
"(stroke" ), pos );
53 wxString block = aBoard.Mid( pos,
end - pos );
57 while( ( xy = block.find( wxT(
"(xy " ), xy ) ) != wxString::npos )
59 wxString coords = block.Mid( xy + 4 );
63 coords.BeforeFirst(
' ' ).ToCDouble( &x );
64 coords.AfterFirst(
' ' ).BeforeFirst(
')' ).ToCDouble( &y );
70 polygons.push_back( polygon );
82 if( polygon.PointInside( aPoint ) )
103 std::fill( std::begin( layerLookUpTable ), std::end( layerLookUpTable ), (
int)
UNSELECTED_LAYER );
104 layerLookUpTable[0] =
F_Cu;
106 wxString boardFile = wxFileName::CreateTempFileName( wxT(
"clear_polarity" ) );
112 wxFFile file( boardFile );
116 wxRemoveFile( boardFile );
119 std::vector<SHAPE_LINE_CHAIN> polygons =
ReadPolygons( board );
123 "the copper plane still covers the cleared channel" );
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
A helper class to export a Gerber set of files to Pcbnew.
bool ExportPcb(const int *aLayerLookUpTable, int aCopperLayers)
Save a board from a set of Gerber images.
GERBER_FILE_IMAGE_LIST is a helper class to handle a list of GERBER_FILE_IMAGE files which are loaded...
int AddGbrImage(GERBER_FILE_IMAGE *aGbrImage, int aIdx)
Add a GERBER_FILE_IMAGE* at index aIdx or at the first free location if aIdx < 0.
static GERBER_FILE_IMAGE_LIST & GetImagesList()
void DeleteAllImages()
Remove all loaded data in list, and delete all images, freeing the memory.
Hold the image data and parameters for one gerber file and layer parameters.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
#define GERBER_DRAWLAYERS_COUNT
Number of draw layers in Gerbview.
std::string GetTestDataRootDir()
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
static bool InsideAnyPolygon(const std::vector< SHAPE_LINE_CHAIN > &aPolygons, const VECTOR2I &aPoint)
static VECTOR2I MillimetrePoint(double aX, double aY)
static std::vector< SHAPE_LINE_CHAIN > ReadPolygons(const wxString &aBoard)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
VECTOR2< int32_t > VECTOR2I