76 BOOST_REQUIRE_MESSAGE( m_board,
"Failed to load board creepage" );
81 std::vector<int> netcodes;
83 for(
const auto& [code, net] : m_board->GetNetInfo().NetsByNetcode() )
86 netcodes.push_back( code );
93 double bestDist = std::numeric_limits<double>::infinity();
95 for(
size_t i = 0; i < netcodes.size(); ++i )
97 for(
size_t j = i + 1; j < netcodes.size(); ++j )
99 std::optional<CREEPAGE_RESULT> r =
103 if( r && r->m_distance < bestDist )
105 bestDist = r->m_distance;
112 BOOST_REQUIRE_MESSAGE( bestA > 0 && bestB > 0,
113 "No finite creepage net pair found on F_Cu" );
114 BOOST_TEST_MESSAGE( wxString::Format(
"Tracking nets %d vs %d, base creepage %.0f nm", bestA,
117 std::set<const BOARD_ITEM*> movingItems;
118 std::vector<BOARD_ITEM*> movable;
120 for(
PCB_TRACK* track : m_board->Tracks() )
122 if( track && track->GetNetCode() == bestA && track->IsOnLayer( layer ) )
124 movingItems.insert( track );
125 movable.push_back( track );
129 BOOST_REQUIRE_MESSAGE( !movable.empty(),
"Dragged net has no movable items" );
136 const std::vector<VECTOR2I> deltas = { { 0, 0 },
139 { -300000, -200000 } };
143 for(
const VECTOR2I& step : deltas )
153 std::optional<CREEPAGE_RESULT> full =
156 double updateDist = std::numeric_limits<double>::infinity();
160 if( ( r.m_netA == bestA && r.m_netB == bestB )
161 || ( r.m_netA == bestB && r.m_netB == bestA ) )
163 updateDist = r.m_distance;
169 applied.
y, updateDist,
170 full ? wxString::Format(
"%.0f", full->m_distance )
171 : wxString(
"none" ) ) );
173 BOOST_REQUIRE_MESSAGE( full.has_value(),
"Reference solve found no path" );
174 BOOST_REQUIRE_MESSAGE( std::isfinite( updateDist ),
175 "Incremental Update found no path for the tracked pair" );
178 BOOST_CHECK_LE(
std::abs( updateDist - full->m_distance ), 2000.0 );
182 item->Move( -applied );
197 BOOST_REQUIRE_MESSAGE( m_board,
"Failed to load board creepage" );
201 std::vector<int> netcodes;
203 for(
const auto& [code, net] : m_board->GetNetInfo().NetsByNetcode() )
205 if( net && code > 0 )
206 netcodes.push_back( code );
215 double bestDist = std::numeric_limits<double>::infinity();
217 for(
size_t i = 0; i < netcodes.size(); ++i )
219 for(
size_t j = i + 1; j < netcodes.size(); ++j )
221 std::optional<CREEPAGE_RESULT> r =
224 if( r && r->m_distance < bestDist )
226 bestDist = r->m_distance;
233 BOOST_REQUIRE_MESSAGE( bestA > 0 && bestB > 0,
"No finite creepage net pair found on F_Cu" );
237 for(
PCB_TRACK* track : m_board->Tracks() )
239 if( track && track->GetNetCode() == bestA && track->IsOnLayer( layer ) )
240 track->Move(
VECTOR2I( 500000, 0 ) );
244 double lo = std::numeric_limits<double>::infinity();
247 for(
int trial = 0; trial < 1000; ++trial )
249 std::optional<CREEPAGE_RESULT> r =
252 BOOST_REQUIRE_MESSAGE( r.has_value(),
"Reference solve found no path" );
254 lo = std::min( lo, r->m_distance );
255 hi = std::max( hi, r->m_distance );
259 BOOST_REQUIRE_MESSAGE( hi - lo <= 1.0,
260 wxString::Format(
"Solve is non-deterministic: lo=%.0f hi=%.0f", lo, hi ) );
Reusable creepage solver shared by the batch DRC provider and the realtime drag overlay.
std::vector< CREEPAGE_RESULT > Update(int aNearMargin=0)
Recompute creepage for the dragged nets at the items' current board positions.
void BeginInteractive(PCB_LAYER_ID aLayer, const std::set< int > &aAffectedNets, const std::set< const BOARD_ITEM * > &aMovingItems, int aMargin, std::function< double(int, int)> aConstraintFn)
Begin an interactive drag session.
std::optional< CREEPAGE_RESULT > SolveNetPairWholeBoard(int aNetA, int aNetB, PCB_LAYER_ID aLayer, double aConstraint)
Solve a single net pair against the whole board on one layer, building a fresh graph.
SETTINGS_MANAGER m_settingsManager
CREEPAGE_INCREMENTAL_FIXTURE()=default
std::unique_ptr< BOARD > m_board
Result of a single creepage query between two nets on one layer.
static constexpr int LARGE_CONSTRAINT
BOOST_FIXTURE_TEST_CASE(CreepageIncrementalEqualsFull, CREEPAGE_INCREMENTAL_FIXTURE)