21#include <boost/test/unit_test.hpp>
46 (generator_version "9.99")
55 (gr_line (start -5 -5) (end 60 -5) (layer "Edge.Cuts") (width 0.05))
56 (gr_line (start 60 -5) (end 60 5) (layer "Edge.Cuts") (width 0.05))
57 (gr_line (start 60 5) (end -5 5) (layer "Edge.Cuts") (width 0.05))
58 (gr_line (start -5 5) (end -5 -5) (layer "Edge.Cuts") (width 0.05))
59 (footprint "Term1" (layer "F.Cu") (uuid "00000000-0000-0000-0000-000000000a01")
61 (pad "1" smd rect (at 0 0) (size 0.8 0.8) (layers "F.Cu") (net 1 "/NET_A") (uuid "00000000-0000-0000-0000-000000000a02"))
63 (footprint "Bridge" (layer "F.Cu") (uuid "00000000-0000-0000-0000-000000000b01")
65 (pad "1" smd rect (at -2.5 0) (size 0.8 0.8) (layers "F.Cu") (net 1 "/NET_A") (uuid "00000000-0000-0000-0000-000000000b02"))
66 (pad "2" smd rect (at 2.5 0) (size 0.8 0.8) (layers "F.Cu") (net 2 "/NET_B") (uuid "00000000-0000-0000-0000-000000000b03"))
68 (footprint "Term2" (layer "F.Cu") (uuid "00000000-0000-0000-0000-000000000c01")
70 (pad "1" smd rect (at 0 0) (size 0.8 0.8) (layers "F.Cu") (net 2 "/NET_B") (uuid "00000000-0000-0000-0000-000000000c02"))
72 (segment (start 0 0) (end 20 0) (width 0.2) (layer "F.Cu") (net 1))
73 (segment (start 25 0) (end 50 0) (width 0.2) (layer "F.Cu") (net 2))
86 (generator_version "9.99")
94 (gr_line (start -5 -25) (end 60 -25) (layer "Edge.Cuts") (width 0.05))
95 (gr_line (start 60 -25) (end 60 25) (layer "Edge.Cuts") (width 0.05))
96 (gr_line (start 60 25) (end -5 25) (layer "Edge.Cuts") (width 0.05))
97 (gr_line (start -5 25) (end -5 -25) (layer "Edge.Cuts") (width 0.05))
98 (footprint "Term1" (layer "F.Cu") (uuid "00000000-0000-0000-0000-000000000d01")
100 (pad "1" smd rect (at 0 0) (size 0.8 0.8) (layers "F.Cu") (net 1 "/NET_A") (uuid "00000000-0000-0000-0000-000000000d02"))
102 (footprint "Term2" (layer "F.Cu") (uuid "00000000-0000-0000-0000-000000000e01")
104 (pad "1" smd rect (at 0 0) (size 0.8 0.8) (layers "F.Cu") (net 1 "/NET_A") (uuid "00000000-0000-0000-0000-000000000e02"))
106 (segment (start 0 0) (end 50 0) (width 0.2) (layer "F.Cu") (net 1))
107 (segment (start 12.5 0) (end 12.5 15) (width 0.2) (layer "F.Cu") (net 1))
108 (segment (start 25 0) (end 25 -20) (width 0.2) (layer "F.Cu") (net 1))
109 (segment (start 37.5 0) (end 37.5 18) (width 0.2) (layer "F.Cu") (net 1))
116std::unique_ptr<BOARD> loadBoard(
const char* aText,
const std::string& aSubdir )
118 namespace fs = std::filesystem;
119 fs::path tmpDir = fs::temp_directory_path() / aSubdir;
120 fs::create_directories( tmpDir );
121 fs::path pcbPath = tmpDir /
"trunk.kicad_pcb";
124 std::ofstream out( pcbPath );
129 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
130 plugin.
LoadBoard( pcbPath.string(), board.get() );
131 board->BuildConnectivity();
132 fs::remove( pcbPath );
139void tagAndSetTerminals(
BOARD* aBoard,
const wxString& aChain,
140 double aTermAxMm,
double aTermBxMm )
144 if( n && n->GetNetname().StartsWith( wxS(
"/NET_" ) ) )
145 n->SetNetChain( aChain );
148 PAD* termA =
nullptr;
149 PAD* termB =
nullptr;
150 constexpr int EPS = 100;
151 const VECTOR2I targetA(
static_cast<int>( aTermAxMm * 1000000 ), 0 );
152 const VECTOR2I targetB(
static_cast<int>( aTermBxMm * 1000000 ), 0 );
156 if( fp->Pads().empty() )
162 termA = fp->Pads().front();
165 termB = fp->Pads().front();
170 if( n && n->GetNetChain() == aChain )
173 n->SetTerminalPad( 0, termA );
175 n->SetTerminalPad( 1, termB );
189 auto board = loadBoard(
DAISY_PCB,
"kicad_drc_trunk_daisy" );
190 tagAndSetTerminals( board.get(), wxS(
"DSY" ), 0.0, 50.0 );
192 std::set<BOARD_CONNECTED_ITEM*> items;
196 if( t->GetNet() && t->GetNet()->GetNetChain() == wxS(
"DSY" ) )
200 for(
FOOTPRINT* fp : board->Footprints() )
202 for(
PAD* p : fp->Pads() )
204 if( p->GetNet() && p->GetNet()->GetNetChain() == wxS(
"DSY" ) )
212 BOOST_CHECK_CLOSE( topo.
TrunkLength(), 50.0e6, 5.0 );
220 auto board = loadBoard(
BRANCHED_PCB,
"kicad_drc_trunk_branched" );
221 tagAndSetTerminals( board.get(), wxS(
"BR" ), 0.0, 50.0 );
223 std::set<BOARD_CONNECTED_ITEM*> items;
227 if( t->GetNet() && t->GetNet()->GetNetChain() == wxS(
"BR" ) )
231 for(
FOOTPRINT* fp : board->Footprints() )
233 for(
PAD* p : fp->Pads() )
235 if( p->GetNet() && p->GetNet()->GetNetChain() == wxS(
"BR" ) )
243 BOOST_CHECK_CLOSE( topo.
TrunkLength(), 50.0e6, 5.0 );
Information pertinent to a Pcbnew printed circuit board.
const NETINFO_LIST & GetNetInfo() const
const FOOTPRINTS & Footprints() const
Build a topological view of a single named net chain's routed copper.
const std::vector< STUB > & Stubs() const
double TrunkLength() const
Handle the data for a net.
A #PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const std::map< std::string, UTF8 > *aProperties=nullptr, PROJECT *aProject=nullptr) override
Load information from some input file format that this PCB_IO implementation knows about into either ...
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_CASE(DaisyChainTrunkEqualsSumExplicit)
static const char * BRANCHED_PCB
static const char * DAISY_PCB
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I