KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_pns_basics.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
26#include <optional>
27
28#include <pcbnew/board.h>
29#include <pcbnew/pad.h>
30#include <pcbnew/pcb_track.h>
31
33#include <router/pns_item.h>
35#include <router/pns_node.h>
36#include <router/pns_router.h>
37#include <router/pns_segment.h>
38#include <router/pns_solid.h>
39#include <router/pns_via.h>
40
41static bool isCopper( const PNS::ITEM* aItem )
42{
43 if( !aItem )
44 return false;
45
46 BOARD_ITEM* parent = aItem->Parent();
47
48 if( parent && parent->Type() == PCB_PAD_T )
49 {
50 PAD* pad = static_cast<PAD*>( parent );
51
52 if( pad->IsAperturePad() || pad->IsNPTHWithNoCopper() )
53 return false;
54 }
55
56 return true;
57}
58
59
60static bool isHole( const PNS::ITEM* aItem )
61{
62 if( !aItem )
63 return false;
64
65 return aItem->OfKind( PNS::ITEM::HOLE_T );
66}
67
68
69static bool isEdge( const PNS::ITEM* aItem )
70{
71 if( !aItem )
72 return false;
73
74 const BOARD_ITEM *parent = aItem->BoardItem();
75
76 return parent && ( parent->IsOnLayer( Edge_Cuts ) || parent->IsOnLayer( Margin ) );
77}
78
79
81{
82public:
86
88
89 virtual int Clearance( const PNS::ITEM* aA, const PNS::ITEM* aB,
90 bool aUseClearanceEpsilon = true ) override
91 {
92 PNS::CONSTRAINT constraint;
93 int rv = 0;
94 PNS_LAYER_RANGE layers;
95
96 if( !aB )
97 layers = aA->Layers();
98 else if( isEdge( aA ) )
99 layers = aB->Layers();
100 else if( isEdge( aB ) )
101 layers = aA->Layers();
102 else
103 layers = aA->Layers().Intersection( aB->Layers() );
104
105 // Normalize layer range (no -1 magic numbers)
107
108 for( int layer = layers.Start(); layer <= layers.End(); ++layer )
109 {
110 if( isHole( aA ) && isHole( aB) )
111 {
112 if( QueryConstraint( PNS::CONSTRAINT_TYPE::CT_HOLE_TO_HOLE, aA, aB, layer, &constraint ) )
113 {
114 if( constraint.m_Value.Min() > rv )
115 rv = constraint.m_Value.Min();
116 }
117 }
118 else if( isHole( aA ) || isHole( aB ) )
119 {
120 if( QueryConstraint( PNS::CONSTRAINT_TYPE::CT_HOLE_CLEARANCE, aA, aB, layer, &constraint ) )
121 {
122 if( constraint.m_Value.Min() > rv )
123 rv = constraint.m_Value.Min();
124 }
125 }
126 else if( isCopper( aA ) && ( !aB || isCopper( aB ) ) )
127 {
128 if( QueryConstraint( PNS::CONSTRAINT_TYPE::CT_CLEARANCE, aA, aB, layer, &constraint ) )
129 {
130 if( constraint.m_Value.Min() > rv )
131 rv = constraint.m_Value.Min();
132 }
133 }
134 else if( isEdge( aA ) || ( aB && isEdge( aB ) ) )
135 {
136 if( QueryConstraint( PNS::CONSTRAINT_TYPE::CT_EDGE_CLEARANCE, aA, aB, layer, &constraint ) )
137 {
138 if( constraint.m_Value.Min() > rv )
139 rv = constraint.m_Value.Min();
140 }
141 }
142 }
143
144 return rv;
145 }
146
147 virtual PNS::NET_HANDLE DpCoupledNet( PNS::NET_HANDLE aNet ) override { return nullptr; }
148 virtual int DpNetPolarity( PNS::NET_HANDLE aNet ) override { return -1; }
149
150 virtual bool DpNetPair( const PNS::ITEM* aItem, PNS::NET_HANDLE& aNetP,
151 PNS::NET_HANDLE& aNetN ) override
152 {
153 return false;
154 }
155
156 virtual int NetCode( PNS::NET_HANDLE aNet ) override
157 {
158 return -1;
159 }
160
161 virtual wxString NetName( PNS::NET_HANDLE aNet ) override
162 {
163 return wxEmptyString;
164 }
165
166 virtual bool QueryConstraint( PNS::CONSTRAINT_TYPE aType, const PNS::ITEM* aItemA,
167 const PNS::ITEM* aItemB, int aLayer,
168 PNS::CONSTRAINT* aConstraint ) override
169 {
170 ITEM_KEY key;
171
172 key.a = aItemA;
173 key.b = aItemB;
174 key.type = aType;
175
176 auto it = m_ruleMap.find( key );
177
178 if( it == m_ruleMap.end() )
179 {
180 int cl;
181 switch( aType )
182 {
186 default: return false;
187 }
188
189 //printf("GetDef %s %s %d cl %d\n", aItemA->KindStr().c_str(), aItemB->KindStr().c_str(), aType, cl );
190
191 aConstraint->m_Type = aType;
192 aConstraint->m_Value.SetMin( cl );
193
194 return true;
195 }
196 else
197 {
198 *aConstraint = it->second;
199 }
200
201 return true;
202 }
203
204 int ClearanceEpsilon() const override { return m_clearanceEpsilon; }
205
206 struct ITEM_KEY
207 {
208 const PNS::ITEM* a = nullptr;
209 const PNS::ITEM* b = nullptr;
211
212 bool operator==( const ITEM_KEY& other ) const
213 {
214 return a == other.a && b == other.b && type == other.type;
215 }
216
217 bool operator<( const ITEM_KEY& other ) const
218 {
219 if( a < other.a )
220 {
221 return true;
222 }
223 else if ( a == other.a )
224 {
225 if( b < other.b )
226 return true;
227 else if ( b == other.b )
228 return type < other.type;
229 }
230
231 return false;
232 }
233 };
234
235 bool IsInNetTie( const PNS::ITEM* aA ) override { return false; }
236
237 bool IsNetTieExclusion( const PNS::ITEM* aItem, const VECTOR2I& aCollisionPos,
238 const PNS::ITEM* aCollidingItem ) override
239 {
240 return false;
241 }
242
243 bool IsDrilledHole( const PNS::ITEM* aItem ) override { return false; }
244
245 bool IsNonPlatedSlot( const PNS::ITEM* aItem ) override { return false; }
246
247 bool IsKeepout( const PNS::ITEM* aObstacle, const PNS::ITEM* aItem, bool* aEnforce ) override
248 {
249 return false;
250 }
251
252 void AddMockRule( PNS::CONSTRAINT_TYPE aType, const PNS::ITEM* aItemA, const PNS::ITEM* aItemB,
253 PNS::CONSTRAINT& aConstraint )
254 {
255 ITEM_KEY key;
256
257 key.a = aItemA;
258 key.b = aItemB;
259 key.type = aType;
260
261 m_ruleMap[key] = aConstraint;
262 }
263
264 int m_defaultClearance = 200000;
265 int m_defaultHole2Hole = 220000;
267
268private:
269 std::map<ITEM_KEY, PNS::CONSTRAINT> m_ruleMap;
271};
272
273struct PNS_TEST_FIXTURE;
274
276{
277public:
279 m_testFixture( aFixture )
280 {}
281
283
284 void HideItem( PNS::ITEM* aItem ) override {};
285 void DisplayItem( const PNS::ITEM* aItem, int aClearance, bool aEdit = false,
286 int aFlags = 0 ) override {};
288
289 bool TestInheritTrackWidth( PNS::ITEM* aItem, int* aInheritedWidth,
290 const VECTOR2I& aStartPosition = VECTOR2I() )
291 {
292 return inheritTrackWidth( aItem, aInheritedWidth, aStartPosition );
293 }
294
295private:
297};
298
299
315
316
321
322static void dumpObstacles( const PNS::NODE::OBSTACLES &obstacles )
323{
324 for( const PNS::OBSTACLE& obs : obstacles )
325 {
326 BOOST_TEST_MESSAGE( wxString::Format( "%p [%s] - %p [%s], clearance %d",
327 obs.m_head, obs.m_head->KindStr().c_str(),
328 obs.m_item, obs.m_item->KindStr().c_str(),
329 obs.m_clearance ) );
330 }
331}
332
334{
335 PNS::VIA* v1 = new PNS::VIA( VECTOR2I( 0, 1000000 ), PNS_LAYER_RANGE( F_Cu, B_Cu ), 50000, 10000 );
336 PNS::VIA* v2 = new PNS::VIA( VECTOR2I( 0, 2000000 ), PNS_LAYER_RANGE( F_Cu, B_Cu ), 50000, 10000 );
337
338 std::unique_ptr<PNS::NODE> world ( new PNS::NODE );
339
340 v1->SetNet( (PNS::NET_HANDLE) 1 );
341 v2->SetNet( (PNS::NET_HANDLE) 2 );
342
343 world->SetMaxClearance( 10000000 );
344 world->SetRuleResolver( &m_ruleResolver );
345
346 world->AddRaw( v1 );
347 world->AddRaw( v2 );
348
349 BOOST_TEST_MESSAGE( "via to via, no violations" );
350 {
351 PNS::NODE::OBSTACLES obstacles;
352 int count = world->QueryColliding( v1, obstacles );
353 dumpObstacles( obstacles );
354 BOOST_CHECK_EQUAL( obstacles.size(), 0 );
355 BOOST_CHECK_EQUAL( count, 0 );
356 }
357
358 BOOST_TEST_MESSAGE( "via to via, forced copper to copper violation" );
359 {
360 PNS::NODE::OBSTACLES obstacles;
361 m_ruleResolver.m_defaultClearance = 1000000;
362 world->QueryColliding( v1, obstacles );
363 dumpObstacles( obstacles );
364
365 BOOST_CHECK_EQUAL( obstacles.size(), 1 );
366 const auto& first = *obstacles.begin();
367
368 BOOST_CHECK_EQUAL( first.m_head, v1 );
369 BOOST_CHECK_EQUAL( first.m_item, v2 );
370 BOOST_CHECK_EQUAL( first.m_clearance, m_ruleResolver.m_defaultClearance );
371 }
372
373 BOOST_TEST_MESSAGE( "via to via, forced hole to hole violation" );
374 {
375 PNS::NODE::OBSTACLES obstacles;
376 m_ruleResolver.m_defaultClearance = 200000;
377 m_ruleResolver.m_defaultHole2Hole = 1000000;
378
379 world->QueryColliding( v1, obstacles );
380 dumpObstacles( obstacles );
381
382 BOOST_CHECK_EQUAL( obstacles.size(), 1 );
383 auto iter = obstacles.begin();
384 const auto& first = *iter++;
385
386 BOOST_CHECK_EQUAL( first.m_head, v1->Hole() );
387 BOOST_CHECK_EQUAL( first.m_item, v2->Hole() );
388 BOOST_CHECK_EQUAL( first.m_clearance, m_ruleResolver.m_defaultHole2Hole );
389 }
390
391 BOOST_TEST_MESSAGE( "via to via, forced copper to hole violation" );
392 {
393 PNS::NODE::OBSTACLES obstacles;
394 m_ruleResolver.m_defaultHole2Hole = 220000;
395 m_ruleResolver.m_defaultHole2Copper = 1000000;
396
397 world->QueryColliding( v1, obstacles );
398 dumpObstacles( obstacles );
399
400 BOOST_CHECK_EQUAL( obstacles.size(), 2 );
401 auto iter = obstacles.begin();
402 const auto& first = *iter++;
403
404 // There is no guarantee on what order the two collisions will be in...
405 BOOST_CHECK( ( first.m_head == v1 && first.m_item == v2->Hole() )
406 || ( first.m_head == v1->Hole() && first.m_item == v2 ) );
407
408 BOOST_CHECK_EQUAL( first.m_clearance, m_ruleResolver.m_defaultHole2Copper );
409 }
410}
411
412
413BOOST_FIXTURE_TEST_CASE( PNSViaBackdrillRetention, PNS_TEST_FIXTURE )
414{
415 PNS::VIA via( VECTOR2I( 1000, 2000 ), PNS_LAYER_RANGE( F_Cu, B_Cu ), 40000, 20000, nullptr,
417 via.SetHoleLayers( PNS_LAYER_RANGE( F_Cu, In2_Cu ) );
418 via.SetHolePostMachining( std::optional<PAD_DRILL_POST_MACHINING_MODE>( PAD_DRILL_POST_MACHINING_MODE::COUNTERSINK ) );
419 via.SetSecondaryDrill( std::optional<int>( 12000 ) );
420 via.SetSecondaryHoleLayers( std::optional<PNS_LAYER_RANGE>( PNS_LAYER_RANGE( F_Cu, In1_Cu ) ) );
421 via.SetSecondaryHolePostMachining( std::optional<PAD_DRILL_POST_MACHINING_MODE>( PAD_DRILL_POST_MACHINING_MODE::NOT_POST_MACHINED ) );
422
423 PNS::VIA viaCopy( via );
424 std::unique_ptr<PNS::VIA> viaClone( via.Clone() );
425
426 auto checkVia = [&]( const PNS::VIA& candidate )
427 {
428 BOOST_CHECK_EQUAL( candidate.HoleLayers().Start(), via.HoleLayers().Start() );
429 BOOST_CHECK_EQUAL( candidate.HoleLayers().End(), via.HoleLayers().End() );
430 BOOST_CHECK( candidate.HolePostMachining().has_value() );
431 BOOST_CHECK( candidate.HolePostMachining().value() == PAD_DRILL_POST_MACHINING_MODE::COUNTERSINK );
432 BOOST_CHECK( candidate.SecondaryDrill().has_value() );
433 BOOST_CHECK_EQUAL( candidate.SecondaryDrill().value(), via.SecondaryDrill().value() );
434 BOOST_CHECK( candidate.SecondaryHoleLayers().has_value() );
435 BOOST_CHECK_EQUAL( candidate.SecondaryHoleLayers()->Start(),
436 via.SecondaryHoleLayers()->Start() );
437 BOOST_CHECK_EQUAL( candidate.SecondaryHoleLayers()->End(),
438 via.SecondaryHoleLayers()->End() );
439 BOOST_CHECK( candidate.SecondaryHolePostMachining().has_value() );
440
441 // run this BOOST_CHECK only if possible to avoid crash
442 if( candidate.SecondaryHolePostMachining().has_value() )
443 BOOST_CHECK( candidate.SecondaryHolePostMachining().value() == via.SecondaryHolePostMachining().value() );
444 };
445
446 checkVia( viaCopy );
447 checkVia( *viaClone );
448}
449
450
451BOOST_AUTO_TEST_CASE( PCBViaBackdrillCloneRetainsData )
452{
453 BOARD board;
454 PCB_VIA via( &board );
455
456 via.SetPrimaryDrillStartLayer( F_Cu );
457 via.SetPrimaryDrillEndLayer( B_Cu );
458 via.SetFrontPostMachining( std::optional<PAD_DRILL_POST_MACHINING_MODE>( PAD_DRILL_POST_MACHINING_MODE::COUNTERSINK ) );
459 via.SetSecondaryDrillSize( std::optional<int>( 15000 ) );
460 via.SetSecondaryDrillStartLayer( F_Cu );
461 via.SetSecondaryDrillEndLayer( In2_Cu );
462
463 via.SetBackPostMachining( std::optional<PAD_DRILL_POST_MACHINING_MODE>( PAD_DRILL_POST_MACHINING_MODE::COUNTERBORE ) );
464 via.SetTertiaryDrillSize( std::optional<int>( 8000 ) );
465 via.SetTertiaryDrillStartLayer( B_Cu );
466 via.SetTertiaryDrillEndLayer( In4_Cu );
467
468 PCB_VIA viaCopy( via );
469 std::unique_ptr<PCB_VIA> viaClone( static_cast<PCB_VIA*>( via.Clone() ) );
470
471 auto checkVia = [&]( const PCB_VIA& candidate )
472 {
473 BOOST_CHECK_EQUAL( candidate.GetPrimaryDrillStartLayer(), via.GetPrimaryDrillStartLayer() );
474 BOOST_CHECK_EQUAL( candidate.GetPrimaryDrillEndLayer(), via.GetPrimaryDrillEndLayer() );
475 BOOST_CHECK( candidate.GetFrontPostMachining().has_value() );
476 BOOST_CHECK_EQUAL( static_cast<int>( candidate.GetFrontPostMachining().value() ),
477 static_cast<int>( via.GetFrontPostMachining().value() ) );
478 BOOST_CHECK( candidate.GetSecondaryDrillSize().has_value() );
479 BOOST_CHECK_EQUAL( candidate.GetSecondaryDrillSize().value(),
480 via.GetSecondaryDrillSize().value() );
481 BOOST_CHECK_EQUAL( candidate.GetSecondaryDrillStartLayer(),
482 via.GetSecondaryDrillStartLayer() );
483 BOOST_CHECK_EQUAL( candidate.GetSecondaryDrillEndLayer(),
484 via.GetSecondaryDrillEndLayer() );
485
486 BOOST_CHECK( candidate.GetBackPostMachining().has_value() );
487 BOOST_CHECK_EQUAL( static_cast<int>( candidate.GetBackPostMachining().value() ),
488 static_cast<int>( via.GetBackPostMachining().value() ) );
489 BOOST_CHECK( candidate.GetTertiaryDrillSize().has_value() );
490 BOOST_CHECK_EQUAL( candidate.GetTertiaryDrillSize().value(),
491 via.GetTertiaryDrillSize().value() );
492 BOOST_CHECK_EQUAL( candidate.GetTertiaryDrillStartLayer(),
493 via.GetTertiaryDrillStartLayer() );
494 BOOST_CHECK_EQUAL( candidate.GetTertiaryDrillEndLayer(),
495 via.GetTertiaryDrillEndLayer() );
496 };
497
498 checkVia( viaCopy );
499 checkVia( *viaClone );
500}
501
502
511BOOST_AUTO_TEST_CASE( PNSLayerRangeSwapBehavior )
512{
513 // On a 2-layer board with FRONT_INNER_BACK mode, BoardCopperLayerCount() returns 2.
514 // The code would calculate PNS_LAYER_RANGE(1, 2 - 2) = PNS_LAYER_RANGE(1, 0)
515 // Since start > end, the constructor swaps them to (0, 1), which would span
516 // both F_Cu and B_Cu incorrectly.
517
518 PNS_LAYER_RANGE innerLayersRange2Layer( 1, 0 ); // What would happen on 2-layer board
519
520 // Verify the swap behavior that causes the bug
521 BOOST_CHECK_EQUAL( innerLayersRange2Layer.Start(), 0 );
522 BOOST_CHECK_EQUAL( innerLayersRange2Layer.End(), 1 );
523 BOOST_CHECK( innerLayersRange2Layer.Overlaps( 0 ) ); // F_Cu
524 BOOST_CHECK( innerLayersRange2Layer.Overlaps( 1 ) ); // B_Cu
525
526 // On a 4-layer board, inner layers are 1 and 2, so PNS_LAYER_RANGE(1, 4-2) = (1, 2)
527 PNS_LAYER_RANGE innerLayersRange4Layer( 1, 2 ); // Correct for 4-layer board
528
529 BOOST_CHECK_EQUAL( innerLayersRange4Layer.Start(), 1 );
530 BOOST_CHECK_EQUAL( innerLayersRange4Layer.End(), 2 );
531 BOOST_CHECK( !innerLayersRange4Layer.Overlaps( 0 ) ); // F_Cu - should not overlap
532 BOOST_CHECK( innerLayersRange4Layer.Overlaps( 1 ) ); // In1_Cu
533 BOOST_CHECK( innerLayersRange4Layer.Overlaps( 2 ) ); // In2_Cu
534 BOOST_CHECK( !innerLayersRange4Layer.Overlaps( 3 ) ); // B_Cu - should not overlap
535}
536
537
545BOOST_FIXTURE_TEST_CASE( PNSInheritTrackWidthCursorProximity, PNS_TEST_FIXTURE )
546{
547 std::unique_ptr<PNS::NODE> world( new PNS::NODE );
548 world->SetMaxClearance( 10000000 );
549 world->SetRuleResolver( &m_ruleResolver );
550
551 VECTOR2I padPos( 0, 0 );
553
554 // Pad at origin with a small circular shape
556 pad->SetShape( new SHAPE_CIRCLE( padPos, 500000 ) );
557 pad->SetPos( padPos );
558 pad->SetLayers( PNS_LAYER_RANGE( F_Cu ) );
559 pad->SetNet( net );
560 world->AddRaw( pad );
561
562 // Narrow track going right (250um width)
563 int narrowWidth = 250000;
564 PNS::SEGMENT* narrowSeg = new PNS::SEGMENT(
565 SEG( padPos, VECTOR2I( 5000000, 0 ) ), net );
566 narrowSeg->SetWidth( narrowWidth );
567 narrowSeg->SetLayers( PNS_LAYER_RANGE( F_Cu ) );
568 world->AddRaw( narrowSeg );
569
570 // Wide track going up (500um width)
571 int wideWidth = 500000;
572 PNS::SEGMENT* wideSeg = new PNS::SEGMENT(
573 SEG( padPos, VECTOR2I( 0, -5000000 ) ), net );
574 wideSeg->SetWidth( wideWidth );
575 wideSeg->SetLayers( PNS_LAYER_RANGE( F_Cu ) );
576 world->AddRaw( wideSeg );
577
578 int inherited = 0;
579
580 // Without cursor position, should fall back to minimum width
581 BOOST_CHECK( m_iface->TestInheritTrackWidth( pad, &inherited ) );
582 BOOST_CHECK_EQUAL( inherited, narrowWidth );
583
584 // Cursor near the narrow track (to the right) should select narrow width
585 inherited = 0;
586 BOOST_CHECK( m_iface->TestInheritTrackWidth( pad, &inherited,
587 VECTOR2I( 2000000, 0 ) ) );
588 BOOST_CHECK_EQUAL( inherited, narrowWidth );
589
590 // Cursor near the wide track (upward) should select wide width
591 inherited = 0;
592 BOOST_CHECK( m_iface->TestInheritTrackWidth( pad, &inherited,
593 VECTOR2I( 0, -2000000 ) ) );
594 BOOST_CHECK_EQUAL( inherited, wideWidth );
595
596 // Cursor slightly offset toward narrow track should still select narrow
597 inherited = 0;
598 BOOST_CHECK( m_iface->TestInheritTrackWidth( pad, &inherited,
599 VECTOR2I( 100000, 50000 ) ) );
600 BOOST_CHECK_EQUAL( inherited, narrowWidth );
601
602 // Cursor slightly offset toward wide track should select wide
603 inherited = 0;
604 BOOST_CHECK( m_iface->TestInheritTrackWidth( pad, &inherited,
605 VECTOR2I( 50000, -100000 ) ) );
606 BOOST_CHECK_EQUAL( inherited, wideWidth );
607}
608
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:83
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Test to see if this object is on the given layer.
Definition board_item.h:318
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:322
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
T Min() const
Definition minoptmax.h:33
void SetMin(T v)
Definition minoptmax.h:41
PNS::RULE_RESOLVER * GetRuleResolver() override
void DisplayItem(const PNS::ITEM *aItem, int aClearance, bool aEdit=false, int aFlags=0) override
void HideItem(PNS::ITEM *aItem) override
MOCK_PNS_KICAD_IFACE(PNS_TEST_FIXTURE *aFixture)
PNS_TEST_FIXTURE * m_testFixture
bool TestInheritTrackWidth(PNS::ITEM *aItem, int *aInheritedWidth, const VECTOR2I &aStartPosition=VECTOR2I())
virtual int NetCode(PNS::NET_HANDLE aNet) override
bool IsNetTieExclusion(const PNS::ITEM *aItem, const VECTOR2I &aCollisionPos, const PNS::ITEM *aCollidingItem) override
bool IsKeepout(const PNS::ITEM *aObstacle, const PNS::ITEM *aItem, bool *aEnforce) override
virtual int Clearance(const PNS::ITEM *aA, const PNS::ITEM *aB, bool aUseClearanceEpsilon=true) override
virtual bool QueryConstraint(PNS::CONSTRAINT_TYPE aType, const PNS::ITEM *aItemA, const PNS::ITEM *aItemB, int aLayer, PNS::CONSTRAINT *aConstraint) override
bool IsInNetTie(const PNS::ITEM *aA) override
std::map< ITEM_KEY, PNS::CONSTRAINT > m_ruleMap
virtual PNS::NET_HANDLE DpCoupledNet(PNS::NET_HANDLE aNet) override
bool IsDrilledHole(const PNS::ITEM *aItem) override
void AddMockRule(PNS::CONSTRAINT_TYPE aType, const PNS::ITEM *aItemA, const PNS::ITEM *aItemB, PNS::CONSTRAINT &aConstraint)
bool IsNonPlatedSlot(const PNS::ITEM *aItem) override
virtual bool DpNetPair(const PNS::ITEM *aItem, PNS::NET_HANDLE &aNetP, PNS::NET_HANDLE &aNetN) override
virtual wxString NetName(PNS::NET_HANDLE aNet) override
int ClearanceEpsilon() const override
virtual int DpNetPolarity(PNS::NET_HANDLE aNet) override
Definition pad.h:55
Base class for PNS router board items.
Definition pns_item.h:98
BOARD_ITEM * Parent() const
Definition pns_item.h:199
void SetLayers(const PNS_LAYER_RANGE &aLayers)
Definition pns_item.h:213
const PNS_LAYER_RANGE & Layers() const
Definition pns_item.h:212
bool OfKind(int aKindMask) const
Definition pns_item.h:181
virtual BOARD_ITEM * BoardItem() const
Definition pns_item.h:207
Keep the router "world" - i.e.
Definition pns_node.h:240
std::set< OBSTACLE > OBSTACLES
Definition pns_node.h:252
void SetWidth(int aWidth) override
Definition pns_segment.h:83
bool inheritTrackWidth(PNS::ITEM *aItem, int *aInheritedWidth, const VECTOR2I &aStartPosition)
Represent a contiguous set of PCB layers.
int Start() const
bool Overlaps(const PNS_LAYER_RANGE &aOther) const
int End() const
PNS_LAYER_RANGE Intersection(const PNS_LAYER_RANGE &aOther) const
Shortcut for comparisons/overlap tests.
Definition seg.h:42
constexpr PCB_LAYER_ID PCBNEW_LAYER_ID_START
Definition layer_ids.h:174
@ Edge_Cuts
Definition layer_ids.h:112
@ B_Cu
Definition layer_ids.h:65
@ In2_Cu
Definition layer_ids.h:67
@ Margin
Definition layer_ids.h:113
@ In4_Cu
Definition layer_ids.h:69
@ In1_Cu
Definition layer_ids.h:66
@ PCB_LAYER_ID_COUNT
Definition layer_ids.h:171
@ F_Cu
Definition layer_ids.h:64
CONSTRAINT_TYPE
Definition pns_node.h:52
void * NET_HANDLE
Definition pns_item.h:55
@ THROUGH
Definition pcb_track.h:68
bool operator<(const ITEM_KEY &other) const
bool operator==(const ITEM_KEY &other) const
An abstract function object, returning a design rule (clearance, diff pair gap, etc) required between...
Definition pns_node.h:73
MINOPTMAX< int > m_Value
Definition pns_node.h:75
CONSTRAINT_TYPE m_Type
Definition pns_node.h:74
Hold an object colliding with another object, along with some useful data about the collision.
Definition pns_node.h:88
SETTINGS_MANAGER m_settingsManager
MOCK_RULE_RESOLVER m_ruleResolver
PNS::ROUTER * m_router
MOCK_PNS_KICAD_IFACE * m_iface
VECTOR3I v1(5, 5, 5)
static bool isEdge(const PNS::ITEM *aItem)
static bool isHole(const PNS::ITEM *aItem)
static void dumpObstacles(const PNS::NODE::OBSTACLES &obstacles)
BOOST_FIXTURE_TEST_CASE(PNSHoleCollisions, PNS_TEST_FIXTURE)
static bool isCopper(const PNS::ITEM *aItem)
BOOST_AUTO_TEST_CASE(PCBViaBackdrillCloneRetainsData)
BOOST_TEST_MESSAGE("Polyline has "<< chain.PointCount()<< " points")
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2I v2(1, 0)
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition typeinfo.h:87
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695