48 const wxString& aBoardName,
int aExpectedViolationCount )
54 for(
int code = 0; code <
DRCE_LAST; ++code )
60 std::vector<DRC_ITEM> violations;
63 [&](
const std::shared_ptr<DRC_ITEM>& aItem,
const VECTOR2I&,
int,
68 violations.push_back( *aItem );
75 if( (
int) violations.size() == aExpectedViolationCount )
84 std::map<KIID, EDA_ITEM*> itemMap;
85 aBoard->FillItemMap( itemMap );
87 for(
const DRC_ITEM& item : violations )
90 BOOST_ERROR( wxString::Format(
"DRC line ending matrix: %s\n"
91 "%d violations found (expected %d)\n"
93 aBoardName, (
int) violations.size(), aExpectedViolationCount, report ) );
99 wxString brd_name( wxT(
"test_copper_graphics" ) );
105 std::vector<DRC_ITEM> violations;
119 [&](
const std::shared_ptr<DRC_ITEM>& aItem,
const VECTOR2I& aPos,
int aLayer,
120 const std::function<
void(
PCB_MARKER* )>& aPathGenerator )
125 violations.push_back( *aItem );
130 const int expected_err_cnt = 4;
135 if( violations.size() == expected_err_cnt )
147 std::map<KIID, EDA_ITEM*> itemMap;
148 m_board->FillItemMap( itemMap );
150 for(
const DRC_ITEM& item : violations )
153 BOOST_ERROR( wxString::Format(
"DRC copper graphics: %s\n"
154 "%d violations found (expected %d)\n"
157 (
int) violations.size(),
169 int expectedViolations;
172 const MATRIX_CASE cases[] = {
173 { wxT(
"line_ending_drc/line_ending_drc_fail" ), 123 },
174 { wxT(
"line_ending_drc/line_ending_drc_pass" ), 0 },
177 for(
const MATRIX_CASE& testCase : cases )
186 m_board = std::make_unique<BOARD>();
187 m_board->SetCopperLayerCount( 2 );
191 m_board->Add( netA );
192 m_board->Add( netB );
206 pad->SetPosition( aPos );
222 m_board->Add( graphic );
223 PAD* graphicPad = addPad( graphic->
GetEnd(), netA );
231 m_board->Add( track );
239 bds.
m_DRCEngine = std::make_shared<DRC_ENGINE>( m_board.get(), &bds );
243 for(
int code = 0; code <
DRCE_LAST; ++code )
249 BOOST_REQUIRE_EQUAL( m_board->Drawings().size(), 1 );
250 BOOST_REQUIRE_EQUAL( m_board->Tracks().size(), 1 );
257 BOOST_REQUIRE_GT( directConstraint.
GetValue().
Min(), 0 );
261 BOOST_REQUIRE_GT( reverseConstraint.
GetValue().
Min(), 0 );
272 int violationCount = 0;
273 std::vector<int> violationCodes;
276 [&](
const std::shared_ptr<DRC_ITEM>& aItem,
const VECTOR2I& ,
int ,
279 violationCodes.push_back( aItem->GetErrorCode() );
291 BOOST_CHECK_GE( m_board->m_CopperItemRTreeCache->QueryColliding( track,
F_Cu,
F_Cu,
294 return other == graphic;
297 BOOST_CHECK_GE( m_board->m_CopperItemRTreeCache->QueryColliding(
301 return other == graphic;
303 nullptr, m_board->m_DRCMaxClearance ),
308 if( violationCount < 1 )
312 for(
int code : violationCodes )
313 codes += wxString::Format( wxT(
" %d" ), code );
315 BOOST_TEST_MESSAGE( wxString::Format( wxT(
"Reported violation codes:%s" ), codes ) );
318 BOOST_CHECK_GE( violationCount, 1 );
constexpr EDA_IU_SCALE pcbIUScale
virtual void SetNet(NETINFO_ITEM *aNetInfo)
Set a NET_INFO object for the item.
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< NET_SETTINGS > m_NetSettings
std::map< int, SEVERITY > m_DRCSeverities
std::shared_ptr< DRC_ENGINE > m_DRCEngine
std::set< DRC_EXCLUSION, DRC_EXCLUSION_COMPARE > m_DrcExclusions
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
SEVERITY GetSeverity() const
const MINOPTMAX< int > & GetValue() 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).
DRC_CONSTRAINT EvalRules(DRC_CONSTRAINT_T aConstraintType, const BOARD_ITEM *a, const BOARD_ITEM *b, PCB_LAYER_ID aLayer, REPORTER *aReporter=nullptr)
void ClearViolationHandler()
void InitEngine(const wxFileName &aRulePath)
Initialize the DRC engine.
static DRC_EXCLUSION FromMarker(const PCB_MARKER &aMarker)
void SetStartEndingStyle(LINE_ENDING_STYLE aStyle)
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
void SetStartEndingLength(int aLength)
void SetStartEndingWidth(int aWidth)
LSET is a set of PCB_LAYER_IDs.
void SetClearance(int aClearance)
Handle the data for a net.
std::shared_ptr< NETCLASS > GetDefaultNetclass() const
Gets the default netclass for the project.
@ 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 SetWidth(int aWidth) override
void SetEnd(const VECTOR2I &aEnd) override
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT, DRC_CONSTRAINT_T aUsage=NULL_CONSTRAINT) const override
Make a set of SHAPE objects representing the PCB_SHAPE.
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
void SetStart(const VECTOR2I &aStart) override
void SetEnd(const VECTOR2I &aEnd)
void SetStart(const VECTOR2I &aStart)
const VECTOR2I & GetStart() const
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT, DRC_CONSTRAINT_T aUsage=NULL_CONSTRAINT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
virtual void SetWidth(int aWidth)
@ DRCE_SILK_MASK_CLEARANCE
@ DRCE_MIRRORED_TEXT_ON_FRONT_LAYER
@ DRCE_LIB_FOOTPRINT_ISSUES
@ DRCE_LIB_FOOTPRINT_MISMATCH
@ DRCE_UNMIRRORED_TEXT_ON_BACK_LAYER
void LoadBoard(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< BOARD > &aBoard)
@ SMD
Smd pad, appears on the solder paste layer (default)
std::unique_ptr< BOARD > m_board
DRC_COPPER_GRAPHICS_TEST_FIXTURE()
SETTINGS_MANAGER m_settingsManager
BOOST_FIXTURE_TEST_CASE(DRCCopperGraphicsTest, DRC_COPPER_GRAPHICS_TEST_FIXTURE)
static void runLineEndingMatrixDrcTest(SETTINGS_MANAGER &aSettingsManager, std::unique_ptr< BOARD > &aBoard, const wxString &aBoardName, int aExpectedViolationCount)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_TEST_MESSAGE("Polyline has "<< chain.PointCount()<< " points")
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I