21#include <boost/test/data/test_case.hpp>
45struct CONNECTIVITY_CLUSTER_FIXTURE
47 SETTINGS_MANAGER m_settingsManager;
48 std::unique_ptr<BOARD> m_board;
53const std::vector<wxString> c_boards = {
64BOOST_FIXTURE_TEST_SUITE( ConnectivityClusters, CONNECTIVITY_CLUSTER_FIXTURE )
74 std::shared_ptr<CN_CONNECTIVITY_ALGO> algo = aBoard->GetConnectivity()->GetConnectivityAlgo();
81 std::map<CN_ITEM*, size_t> clusterOf;
84 for(
size_t ii = 0; ii < clusters.size(); ++ii )
86 for(
CN_ITEM* item : *clusters[ii] )
89 "item appears in more than one cluster" );
98 for(
const auto& [item, cluster] : clusterOf )
102 auto it = clusterOf.find( neighbour );
104 if( it == clusterOf.end() )
107 if( neighbour->Net() != item->Net() )
111 "connected items landed in different clusters" );
117 for(
const std::shared_ptr<CN_CLUSTER>& cluster : clusters )
119 std::set<CN_ITEM*> members( cluster->begin(), cluster->end() );
120 std::set<CN_ITEM*> seen;
121 std::deque<CN_ITEM*> queue;
123 queue.push_back( *cluster->begin() );
124 seen.insert( *cluster->begin() );
126 while( !queue.empty() )
128 CN_ITEM* current = queue.front();
133 if( members.count( neighbour ) && !seen.count( neighbour ) )
135 seen.insert( neighbour );
136 queue.push_back( neighbour );
155 std::shared_ptr<CN_CONNECTIVITY_ALGO> algo = conn->GetConnectivityAlgo();
157 std::map<int, std::set<const CN_CLUSTER*>> clustersPerNet;
159 for(
const std::shared_ptr<CN_CLUSTER>& cluster :
163 if( cluster->IsOrphaned() && cluster->Size() == 1
169 if( cluster->OriginNet() > 0 )
170 clustersPerNet[cluster->OriginNet()].insert( cluster.get() );
173 size_t netsChecked = 0;
174 size_t edgesSeen = 0;
176 for(
const auto& [net, netClusters] : clustersPerNet )
178 RN_NET* rn = conn->GetRatsnestForNet( net );
183 const std::vector<CN_EDGE>& edges = rn->
GetEdges();
186 "net " << net <<
" has " << netClusters.size() <<
" clusters but "
187 << edges.size() <<
" ratsnest edges" );
189 for(
const CN_EDGE& edge : edges )
190 BOOST_REQUIRE( edge.GetSourceNode() && edge.GetTargetNode() );
193 edgesSeen += edges.size();
197 BOOST_TEST_MESSAGE(
"net count " << netsChecked <<
", ratsnest edges " << edgesSeen );
202BOOST_DATA_TEST_CASE( ClustersAndRatsnestMatchTheBoard, boost::unit_test::data::make( c_boards ), boardName )
206 m_board->BuildConnectivity();
Information pertinent to a Pcbnew printed circuit board.
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
std::vector< std::shared_ptr< CN_CLUSTER > > CLUSTERS
CN_EDGE represents a point-to-point connection, whether realized or unrealized (ie: tracks etc.
CN_ITEM represents a BOARD_CONNECTED_ITEM in the connectivity system (ie: a pad, track/arc/via,...
const std::vector< CN_ITEM * > & ConnectedItems() const
Represents a single outline of a zone fill on a particular layer.
Describe ratsnest for a single net.
unsigned int GetNodeCount() const
const std::vector< CN_EDGE > & GetEdges() const
void LoadBoard(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< BOARD > &aBoard)
void FillZones(BOARD *m_board)
Class that computes missing connections on a PCB.
BOOST_DATA_TEST_CASE(ConvertToKicadUnit, boost::unit_test::data::make(altium_to_kicad_unit), input_value, expected_result)
Test conversation from Altium internal units into KiCad internal units.
static void checkRatsnestSpansClusters(BOARD *aBoard)
A ratsnest is a spanning forest over the clusters of a net, so it must hold exactly one edge fewer th...
static void checkClustersAreConnectedComponents(BOARD *aBoard)
Every item must land in exactly one cluster, each cluster must be internally reachable over the adjac...
BOOST_REQUIRE_EQUAL(rows.size(), 1)
BOOST_CHECK_EQUAL(std::any_cast< std::string >(rows[0].at("val")), "12345678901234567.89")
BOOST_REQUIRE_MESSAGE(dc.CacheTableInfo(table, { "part_id", "val" }), dc.GetLastError())
BOOST_REQUIRE(res.columns()==1)
BOOST_AUTO_TEST_SUITE_END()
BOOST_TEST_MESSAGE("Polyline has "<< chain.PointCount()<< " points")