20#include <boost/test/unit_test.hpp>
45 (generator_version "9.99")
54 (gr_line (start -5 -5) (end 60 -5) (layer "Edge.Cuts") (width 0.05))
55 (gr_line (start 60 -5) (end 60 5) (layer "Edge.Cuts") (width 0.05))
56 (gr_line (start 60 5) (end -5 5) (layer "Edge.Cuts") (width 0.05))
57 (gr_line (start -5 5) (end -5 -5) (layer "Edge.Cuts") (width 0.05))
58 (footprint "Term1" (layer "F.Cu") (uuid "00000000-0000-0000-0000-000000000a01")
60 (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"))
62 (footprint "Bridge" (layer "F.Cu") (uuid "00000000-0000-0000-0000-000000000b01")
64 (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"))
65 (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"))
67 (footprint "Term2" (layer "F.Cu") (uuid "00000000-0000-0000-0000-000000000c01")
69 (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"))
71 (segment (start 0 0) (end 20 0) (width 0.2) (layer "F.Cu") (net 1))
72 (segment (start 25 0) (end 50 0) (width 0.2) (layer "F.Cu") (net 2))
85 (generator_version "9.99")
93 (gr_line (start -5 -25) (end 60 -25) (layer "Edge.Cuts") (width 0.05))
94 (gr_line (start 60 -25) (end 60 25) (layer "Edge.Cuts") (width 0.05))
95 (gr_line (start 60 25) (end -5 25) (layer "Edge.Cuts") (width 0.05))
96 (gr_line (start -5 25) (end -5 -25) (layer "Edge.Cuts") (width 0.05))
97 (footprint "Term1" (layer "F.Cu") (uuid "00000000-0000-0000-0000-000000000d01")
99 (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"))
101 (footprint "Term2" (layer "F.Cu") (uuid "00000000-0000-0000-0000-000000000e01")
103 (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"))
105 (segment (start 0 0) (end 50 0) (width 0.2) (layer "F.Cu") (net 1))
106 (segment (start 12.5 0) (end 12.5 15) (width 0.2) (layer "F.Cu") (net 1))
107 (segment (start 25 0) (end 25 -20) (width 0.2) (layer "F.Cu") (net 1))
108 (segment (start 37.5 0) (end 37.5 18) (width 0.2) (layer "F.Cu") (net 1))
115std::unique_ptr<BOARD> loadBoard(
const char* aText,
const std::string& aSubdir )
117 namespace fs = std::filesystem;
118 fs::path tmpDir = fs::temp_directory_path() / aSubdir;
119 fs::create_directories( tmpDir );
120 fs::path pcbPath = tmpDir /
"trunk.kicad_pcb";
123 std::ofstream out( pcbPath );
128 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
129 plugin.
LoadBoard( pcbPath.string(), board.get() );
130 board->BuildConnectivity();
131 fs::remove( pcbPath );
138void tagAndSetTerminals(
BOARD* aBoard,
const wxString& aChain,
139 double aTermAxMm,
double aTermBxMm )
143 if( n && n->GetNetname().StartsWith( wxS(
"/NET_" ) ) )
144 n->SetNetChain( aChain );
147 PAD* termA =
nullptr;
148 PAD* termB =
nullptr;
149 constexpr int EPS = 100;
150 const VECTOR2I targetA(
static_cast<int>( aTermAxMm * 1000000 ), 0 );
151 const VECTOR2I targetB(
static_cast<int>( aTermBxMm * 1000000 ), 0 );
155 if( fp->Pads().empty() )
161 termA = fp->Pads().front();
164 termB = fp->Pads().front();
169 if( n && n->GetNetChain() == aChain )
172 n->SetTerminalPad( 0, termA );
174 n->SetTerminalPad( 1, termB );
188 auto board = loadBoard(
DAISY_PCB,
"kicad_drc_trunk_daisy" );
189 tagAndSetTerminals( board.get(), wxS(
"DSY" ), 0.0, 50.0 );
191 std::set<BOARD_CONNECTED_ITEM*> items;
195 if( t->GetNet() && t->GetNet()->GetNetChain() == wxS(
"DSY" ) )
199 for(
FOOTPRINT* fp : board->Footprints() )
201 for(
PAD* p : fp->Pads() )
203 if( p->GetNet() && p->GetNet()->GetNetChain() == wxS(
"DSY" ) )
211 BOOST_CHECK_CLOSE( topo.
TrunkLength(), 50.0e6, 5.0 );
219 auto board = loadBoard(
BRANCHED_PCB,
"kicad_drc_trunk_branched" );
220 tagAndSetTerminals( board.get(), wxS(
"BR" ), 0.0, 50.0 );
222 std::set<BOARD_CONNECTED_ITEM*> items;
226 if( t->GetNet() && t->GetNet()->GetNetChain() == wxS(
"BR" ) )
230 for(
FOOTPRINT* fp : board->Footprints() )
232 for(
PAD* p : fp->Pads() )
234 if( p->GetNet() && p->GetNet()->GetNetChain() == wxS(
"BR" ) )
242 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