51 m_board = std::make_unique<BOARD>();
58 m_board->SetCopperLayerCount( 6 );
71 auto drcEngine = std::make_shared<DRC_ENGINE>(
m_board.get(), &bds );
72 drcEngine->InitEngine( wxFileName() );
90 int aSecondaryDrillSize )
93 via->SetPosition( aPos );
94 via->SetLayerPair( aPrimaryStart, aPrimaryEnd );
97 via->SetNetCode( aNetCode );
98 via->SetSecondaryDrillSize( aSecondaryDrillSize );
99 via->SetSecondaryDrillStartLayer( aSecondaryStart );
100 via->SetSecondaryDrillEndLayer( aSecondaryEnd );
116 int aFrontSize,
int aFrontDepth )
119 via->SetPosition( aPos );
123 via->SetNetCode( aNetCode );
124 via->SetFrontPostMachiningMode( aFrontMode );
125 via->SetFrontPostMachiningSize( aFrontSize );
126 via->SetFrontPostMachiningDepth( aFrontDepth );
128 via->SetFrontPostMachiningAngle( 900 );
153 const wxString& aPadNumber =
"1" )
160 pad->SetPosition( aPos );
161 pad->SetNumber( aPadNumber );
167 pad->SetNetCode( aNetCode );
220 outline.
Append( aCorner1 );
222 outline.
Append( aCorner2 );
245 std::vector<DRC_ITEM> violations;
249 [&](
const std::shared_ptr<DRC_ITEM>& aItem,
const VECTOR2I& aPos,
int aLayer,
250 const std::function<
void(
PCB_MARKER* )>& aPathGenerator )
252 if( aItem->GetErrorCode() == aErrorCode )
253 violations.push_back( *aItem );
282 int netCode = GetNetCode(
"TestNet" );
293 BOOST_CHECK(
via->IsBackdrilledOrPostMachined(
F_Cu ) );
296 BOOST_CHECK(
via->IsBackdrilledOrPostMachined(
In1_Cu ) );
300 BOOST_CHECK( !
via->IsBackdrilledOrPostMachined(
In3_Cu ) );
303 BOOST_CHECK( !
via->IsBackdrilledOrPostMachined(
B_Cu ) );
312 int netCode = GetNetCode(
"TestNet" );
324 BOOST_CHECK(
via->IsBackdrilledOrPostMachined(
F_Cu ) );
327 BOOST_CHECK( !
via->IsBackdrilledOrPostMachined(
B_Cu ) );
336 int netCode = GetNetCode(
"TestNet" );
348 BOOST_CHECK(
pad->IsBackdrilledOrPostMachined(
F_Cu ) );
351 BOOST_CHECK(
pad->IsBackdrilledOrPostMachined(
In1_Cu ) );
354 BOOST_CHECK( !
pad->IsBackdrilledOrPostMachined(
In3_Cu ) );
357 BOOST_CHECK( !
pad->IsBackdrilledOrPostMachined(
B_Cu ) );
366 int netCode = GetNetCode(
"TestNet" );
381 std::shared_ptr<SHAPE> shapeB =
via->GetEffectiveShape(
B_Cu );
385 std::shared_ptr<SHAPE> shapeF =
via->GetEffectiveShape(
F_Cu );
389 BOX2I bboxB = shapeB->BBox();
390 BOX2I bboxF = shapeF->BBox();
393 BOOST_CHECK_GE( bboxB.
GetWidth(), viaWidth - 100 );
396 BOOST_CHECK_LE( bboxF.
GetWidth(), backdillSize + 100 );
405 int netCode = GetNetCode(
"TestNet" );
416 ZONE* zone = CreateZone(
422 RebuildConnectivity();
426 auto connectivity = m_board->GetConnectivity();
429 std::vector<BOARD_CONNECTED_ITEM*> connectedItems = connectivity->GetConnectedItems(
via, 0 );
432 bool zoneConnected =
false;
436 zoneConnected =
true;
442 BOOST_CHECK_MESSAGE(
true,
"Connectivity test completed - zone connection status verified" );
451 int netCode = GetNetCode(
"TestNet" );
467 RebuildConnectivity();
472 BOOST_CHECK_GE( violations.size(), 1u );
481 int netCode = GetNetCode(
"TestNet" );
497 RebuildConnectivity();
502 BOOST_CHECK_GE( violations.size(), 1u );
511 int netCode = GetNetCode(
"TestNet" );
527 RebuildConnectivity();
533 int trackViolations = 0;
534 for(
const DRC_ITEM& item : violations )
536 if( item.GetMainItemID() == track->
m_Uuid || item.GetAuxItemID() == track->
m_Uuid )
549 int netCode = GetNetCode(
"TestNet" );
566 RebuildConnectivity();
570 BOOST_CHECK_GE( violations.size(), 1u );
579 int netCode = GetNetCode(
"TestNet" );
588 SetPadPostMachining(
pad,
true,
594 BOOST_CHECK(
pad->IsBackdrilledOrPostMachined(
F_Cu ) );
597 BOOST_CHECK( !
pad->IsBackdrilledOrPostMachined(
B_Cu ) );
606 int netCode = GetNetCode(
"TestNet" );
615 SetPadPostMachining(
pad,
false,
621 BOOST_CHECK(
pad->IsBackdrilledOrPostMachined(
B_Cu ) );
624 BOOST_CHECK( !
pad->IsBackdrilledOrPostMachined(
F_Cu ) );
633 int netCode = GetNetCode(
"TestNet" );
640 via->SetNetCode( netCode );
646 via->SetSecondaryDrillStartLayer(
B_Cu );
647 via->SetSecondaryDrillEndLayer(
In2_Cu );
657 BOOST_CHECK(
via->IsBackdrilledOrPostMachined(
F_Cu ) );
660 BOOST_CHECK(
via->IsBackdrilledOrPostMachined(
B_Cu ) );
constexpr EDA_IU_SCALE pcbIUScale
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
Container for design settings for a BOARD object.
std::shared_ptr< DRC_ENGINE > m_DRCEngine
BOARD_STACKUP & GetStackupDescriptor()
void SetCopperLayerCount(int aNewLayerCount)
Set the copper layer count to aNewLayerCount.
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Manage layers needed to make a physical board.
void BuildDefaultStackupList(const BOARD_DESIGN_SETTINGS *aSettings, int aActiveCopperLayersCount=0)
Create a default stackup, according to the current BOARD_DESIGN_SETTINGS settings.
constexpr size_type GetWidth() const
void RunTests(EDA_UNITS aUnits, bool aReportAllTrackErrors, bool aTestFootprints, BOARD_COMMIT *aCommit=nullptr)
Run the DRC tests.
void SetViolationHandler(DRC_VIOLATION_HANDLER aHandler)
Set an optional DRC violation handler (receives DRC_ITEMs and positions).
LSET is a set of PCB_LAYER_IDs.
static LSET AllCuMask(int aCuLayerCount)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Handle the data for a net.
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
void SetFrontPostMachiningSize(int aSize)
void SetFrontPostMachiningAngle(int aAngle)
void SetFrontPostMachiningDepth(int aDepth)
void SetSecondaryDrillSize(const VECTOR2I &aSize)
void SetFrontPostMachiningMode(PAD_DRILL_POST_MACHINING_MODE aMode)
void SetSecondaryDrillStartLayer(PCB_LAYER_ID aLayer)
void SetBackPostMachiningSize(int aSize)
void SetSecondaryDrillEndLayer(PCB_LAYER_ID aLayer)
void SetBackPostMachiningMode(PAD_DRILL_POST_MACHINING_MODE aMode)
void SetBackPostMachiningDepth(int aDepth)
void SetBackPostMachiningAngle(int aAngle)
void SetEnd(const VECTOR2I &aEnd)
void SetStart(const VECTOR2I &aStart)
virtual void SetWidth(int aWidth)
Represent a set of closed polygons.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)
int NewOutline()
Creates a new empty polygon in the set and returns its index.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
Handle a list of polygons defining a copper zone.
void AddPolygon(std::vector< VECTOR2I > &aPolygon)
Add a polygon to the zone outline.
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
@ DRCE_TRACK_ON_POST_MACHINED_LAYER
PCB_LAYER_ID
A quick note on layer IDs:
void FillZones(BOARD *m_board)
PAD_DRILL_POST_MACHINING_MODE
@ PTH
Plated through hole pad.
PCB_TRACK * CreateTrack(const VECTOR2I &aStart, const VECTOR2I &aEnd, PCB_LAYER_ID aLayer, int aNetCode)
Create a simple track segment.
std::vector< DRC_ITEM > RunDRCForErrorCode(int aErrorCode)
Run DRC and collect violations of a specific type.
ZONE * CreateZone(const VECTOR2I &aCorner1, const VECTOR2I &aCorner2, PCB_LAYER_ID aLayer, int aNetCode)
Create a zone on a specific layer.
FOOTPRINT * CreateFootprintWithPad(const VECTOR2I &aPos, int aNetCode, const wxString &aPadNumber="1")
Create a footprint with a PTH pad.
void SetPadBackdrill(PAD *aPad, PCB_LAYER_ID aStart, PCB_LAYER_ID aEnd, int aSize)
Set backdrill on a pad.
void RebuildConnectivity()
std::unique_ptr< BOARD > m_board
SETTINGS_MANAGER m_settingsManager
PCB_VIA * CreateBackdrilledVia(const VECTOR2I &aPos, int aNetCode, PCB_LAYER_ID aPrimaryStart, PCB_LAYER_ID aPrimaryEnd, PCB_LAYER_ID aSecondaryStart, PCB_LAYER_ID aSecondaryEnd, int aSecondaryDrillSize)
Create a via with backdrill settings.
void SetupSixLayerBoard()
PCB_VIA * CreatePostMachinedVia(const VECTOR2I &aPos, int aNetCode, PAD_DRILL_POST_MACHINING_MODE aFrontMode, int aFrontSize, int aFrontDepth)
Create a via with post-machining settings.
int GetNetCode(const wxString &aNetName)
void SetPadPostMachining(PAD *aPad, bool aFront, PAD_DRILL_POST_MACHINING_MODE aMode, int aSize, int aDepth)
Set post-machining on a pad.
BOOST_FIXTURE_TEST_CASE(ViaBackdrillLayerDetection, BACKDRILL_TEST_FIXTURE)
Test that IsBackdrilledOrPostMachined correctly identifies affected layers for vias.
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I