48 m_board = std::make_unique<BOARD>();
55 m_board->SetCopperLayerCount( 6 );
68 auto drcEngine = std::make_shared<DRC_ENGINE>(
m_board.get(), &bds );
69 drcEngine->InitEngine( wxFileName() );
87 int aSecondaryDrillSize )
91 via->SetPosition( aPos );
92 via->SetLayerPair( aPrimaryStart, aPrimaryEnd );
95 via->SetNetCode( aNetCode );
96 via->SetSecondaryDrillSize( aSecondaryDrillSize );
97 via->SetSecondaryDrillStartLayer( aSecondaryStart );
98 via->SetSecondaryDrillEndLayer( aSecondaryEnd );
113 int aFrontSize,
int aFrontDepth )
117 via->SetPosition( aPos );
121 via->SetNetCode( aNetCode );
122 via->SetFrontPostMachiningMode( aFrontMode );
123 via->SetFrontPostMachiningSize( aFrontSize );
124 via->SetFrontPostMachiningDepth( aFrontDepth );
126 via->SetFrontPostMachiningAngle( 900 );
157 pad->SetPosition( aPos );
158 pad->SetNumber( aPadNumber );
164 pad->SetNetCode( aNetCode );
215 outline.
Append( aCorner1 );
217 outline.
Append( aCorner2 );
240 std::vector<DRC_ITEM> violations;
244 [&](
const std::shared_ptr<DRC_ITEM>& aItem,
const VECTOR2I& aPos,
int aLayer,
245 const std::function<
void(
PCB_MARKER* )>& aPathGenerator )
247 if( aItem->GetErrorCode() == aErrorCode )
248 violations.push_back( *aItem );
278 int netCode = GetNetCode(
"TestNet" );
288 BOOST_CHECK(
via->IsBackdrilledOrPostMachined(
F_Cu ) );
291 BOOST_CHECK(
via->IsBackdrilledOrPostMachined(
In1_Cu ) );
295 BOOST_CHECK( !
via->IsBackdrilledOrPostMachined(
In3_Cu ) );
298 BOOST_CHECK( !
via->IsBackdrilledOrPostMachined(
B_Cu ) );
309 int netCode = GetNetCode(
"TestNet" );
320 BOOST_CHECK( !
via->IsBackdrilledOrPostMachined(
F_Cu ) );
321 BOOST_CHECK( !
via->IsBackdrilledOrPostMachined(
In1_Cu ) );
322 BOOST_CHECK( !
via->IsBackdrilledOrPostMachined(
In2_Cu ) );
325 BOOST_CHECK(
via->IsBackdrilledOrPostMachined(
In3_Cu ) );
326 BOOST_CHECK(
via->IsBackdrilledOrPostMachined(
In4_Cu ) );
327 BOOST_CHECK(
via->IsBackdrilledOrPostMachined(
B_Cu ) );
336 int netCode = GetNetCode(
"TestNet" );
348 BOOST_CHECK(
via->IsBackdrilledOrPostMachined(
F_Cu ) );
351 BOOST_CHECK( !
via->IsBackdrilledOrPostMachined(
B_Cu ) );
360 int netCode = GetNetCode(
"TestNet" );
371 BOOST_CHECK(
pad->IsBackdrilledOrPostMachined(
F_Cu ) );
374 BOOST_CHECK(
pad->IsBackdrilledOrPostMachined(
In1_Cu ) );
377 BOOST_CHECK( !
pad->IsBackdrilledOrPostMachined(
In3_Cu ) );
380 BOOST_CHECK( !
pad->IsBackdrilledOrPostMachined(
B_Cu ) );
390 int netCode = GetNetCode(
"TestNet" );
438 int netCode = GetNetCode(
"TestNet" );
453 RebuildConnectivity();
457 auto connectivity = m_board->GetConnectivity();
460 std::vector<BOARD_CONNECTED_ITEM*> connectedItems = connectivity->GetConnectedItems(
via, 0 );
463 bool zoneConnected =
false;
468 zoneConnected =
true;
474 BOOST_CHECK_MESSAGE(
true,
"Connectivity test completed - zone connection status verified" );
483 int netCode = GetNetCode(
"TestNet" );
497 RebuildConnectivity();
502 BOOST_CHECK_GE( violations.size(), 1u );
511 int netCode = GetNetCode(
"TestNet" );
525 RebuildConnectivity();
530 BOOST_CHECK_GE( violations.size(), 1u );
539 int netCode = GetNetCode(
"TestNet" );
553 RebuildConnectivity();
559 int trackViolations = 0;
561 for(
const DRC_ITEM& item : violations )
563 if( item.GetMainItemID() == track->
m_Uuid || item.GetAuxItemID() == track->
m_Uuid )
576 int netCode = GetNetCode(
"TestNet" );
591 RebuildConnectivity();
595 BOOST_CHECK_GE( violations.size(), 1u );
604 int netCode = GetNetCode(
"TestNet" );
612 SetPadPostMachining(
pad,
true,
618 BOOST_CHECK(
pad->IsBackdrilledOrPostMachined(
F_Cu ) );
621 BOOST_CHECK( !
pad->IsBackdrilledOrPostMachined(
B_Cu ) );
630 int netCode = GetNetCode(
"TestNet" );
638 SetPadPostMachining(
pad,
false,
644 BOOST_CHECK(
pad->IsBackdrilledOrPostMachined(
B_Cu ) );
647 BOOST_CHECK( !
pad->IsBackdrilledOrPostMachined(
F_Cu ) );
656 int netCode = GetNetCode(
"TestNet" );
663 via->SetNetCode( netCode );
669 via->SetSecondaryDrillStartLayer(
B_Cu );
670 via->SetSecondaryDrillEndLayer(
In2_Cu );
680 BOOST_CHECK(
via->IsBackdrilledOrPostMachined(
F_Cu ) );
683 BOOST_CHECK(
via->IsBackdrilledOrPostMachined(
B_Cu ) );
698 int netCode = GetNetCode(
"TestNet" );
706 via->SetNetCode( netCode );
712 via->SetFrontPostMachiningAngle( 450 );
716 via->SetFrontPostMachiningAngle( 820 );
720 via->SetFrontPostMachiningAngle( 900 );
725 via->SetBackPostMachiningAngle( 600 );
746 int netCode = GetNetCode(
"TestNet" );
762 std::shared_ptr<SHAPE> physIn1;
763 std::shared_ptr<SHAPE> silkIn1;
777 std::shared_ptr<SHAPE> physB;
800 int netCode = GetNetCode(
"TestNet" );
802 std::shared_ptr<NETCLASS> netclass = std::make_shared<NETCLASS>(
"TestClass" );
803 netclass->SetViaDrill( netclassDrill );
804 m_board->FindNet( netCode )->SetNetClass( netclass );
815 via->SetPosition( aPos );
818 via->SetDrillDefault();
819 via->SetNetCode( netCode );
824 PCB_VIA* first = addVia( firstPos );
825 PCB_VIA* second = addVia( secondPos );
827 BOOST_REQUIRE_EQUAL( first->
GetDrillValue(), netclassDrill );
834 RebuildConnectivity();
838 BOOST_REQUIRE_EQUAL( violations.size(), 1u );
839 BOOST_CHECK( violations[0].GetMainItemID() == first->
m_Uuid
840 || violations[0].GetMainItemID() == second->
m_Uuid );
constexpr EDA_IU_SCALE pcbIUScale
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
virtual bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
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.
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.
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).
void InitEngine(const wxFileName &aRulePath)
Initialize the DRC engine.
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.
@ NORMAL
Shape is the same on all layers.
static constexpr PCB_LAYER_ID ALL_LAYERS
! The layer identifier to use for the single defintion on normal padstacks
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)
std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, DRC_CONSTRAINT_T aUsage=NULL_CONSTRAINT) const override
int GetDrillValue() const
Calculate the drill value for vias (m_drill if > 0, or default drill value for the board).
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.
bool SetNetCode(int aNetCode, bool aNoAssert) override
Override that clamps the netcode to 0 when this zone is in copper-thieving fill mode.
@ DRCE_TRACK_ON_POST_MACHINED_LAYER
@ DRCE_DRILLED_HOLES_TOO_CLOSE
@ SILK_CLEARANCE_CONSTRAINT
@ PHYSICAL_CLEARANCE_CONSTRAINT
@ HOLE_TO_HOLE_CONSTRAINT
@ DEFAULT
Flashing follows connectivity.
@ ALWAYS_FLASHED
Always flashed for connectivity.
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
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