55 m_board->GetDesignSettings().m_DRCEngine->ClearViolationHandler();
73 BOOST_REQUIRE_MESSAGE( m_board,
"Failed to load board creepage" );
75 std::vector<std::shared_ptr<DRC_ITEM>> violations;
78 BOOST_REQUIRE_MESSAGE( bds.
m_DRCEngine,
"DRC engine not initialized" );
86 [&](
const std::shared_ptr<DRC_ITEM>& aItem,
const VECTOR2I& aPos,
int aLayer,
87 const std::function<
void(
PCB_MARKER* )>& aPathGenerator )
90 violations.push_back( aItem );
97 BOOST_TEST_MESSAGE( wxString::Format(
"Found %d creepage violations", (
int) violations.size() ) );
99 for(
const auto& v : violations )
100 BOOST_TEST_MESSAGE( wxString::Format(
" Violation: %s", v->GetErrorMessage(
false ) ) );
104 BOOST_CHECK_GE( violations.size(), 1 );
119 BOOST_REQUIRE_MESSAGE( m_board,
"Failed to load board creepage_malformed_edge" );
121 std::vector<std::shared_ptr<DRC_ITEM>> violations;
124 BOOST_REQUIRE_MESSAGE( bds.
m_DRCEngine,
"DRC engine not initialized" );
132 [&](
const std::shared_ptr<DRC_ITEM>& aItem,
const VECTOR2I& aPos,
int aLayer,
133 const std::function<
void(
PCB_MARKER* )>& aPathGenerator )
136 violations.push_back( aItem );
143 BOOST_TEST_MESSAGE( wxString::Format(
"Found %d creepage violations (malformed edge)",
144 (
int) violations.size() ) );
146 for(
const auto& v : violations )
147 BOOST_TEST_MESSAGE( wxString::Format(
" Violation: %s", v->GetErrorMessage(
false ) ) );
151 BOOST_CHECK_GE( violations.size(), 1 );
166 const std::filesystem::path rulePath = tmpDir.
Path() /
"creepage_rule_area.kicad_dru";
169 std::ofstream ruleFile( rulePath );
170 ruleFile <<
"(version 1)\n"
171 <<
"(rule OVC_3_Reinforced (constraint creepage (min 5.5mm)))\n";
174 m_board = std::make_unique<BOARD>();
175 m_board->SetCopperLayerCount( 2 );
181 m_board->Add( edge );
185 ZONE* ruleArea =
new ZONE( m_board.get() );
197 m_board->Add( ruleArea );
200 m_board->Add( hvNet );
213 m_board->Add( track );
226 m_board->BuildConnectivity();
230 bds.
m_DRCEngine = std::make_shared<DRC_ENGINE>( m_board.get(), &bds );
238 std::vector<std::shared_ptr<DRC_ITEM>> violations;
241 [&](
const std::shared_ptr<DRC_ITEM>& aItem,
const VECTOR2I& aPos,
int aLayer,
242 const std::function<
void(
PCB_MARKER* )>& aPathGenerator )
245 violations.push_back( aItem );
252 int ruleAreaHits = 0;
254 for(
const std::shared_ptr<DRC_ITEM>& item : violations )
256 BOOST_TEST_MESSAGE( wxString::Format(
" Violation: %s", item->GetErrorMessage(
false ) ) );
258 for(
const KIID&
id : { item->GetMainItemID(), item->GetAuxItemID() } )
260 BOARD_ITEM* boardItem = m_board->ResolveItem(
id,
true );
269 BOOST_CHECK_MESSAGE( ruleAreaHits == 0,
270 wxString::Format(
"%d creepage violations name the rule area as a violating item. A "
271 "rule area is a boundary, not copper.",
274 BOOST_CHECK_MESSAGE( violations.empty(),
275 wxString::Format(
"Expected no creepage violations, got %d.", (
int) violations.size() ) );
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::map< int, SEVERITY > m_DRCSeverities
std::shared_ptr< DRC_ENGINE > m_DRCEngine
SEVERITY GetSeverity(int aDRCErrorCode)
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
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 ClearViolationHandler()
void InitEngine(const wxFileName &aRulePath)
Initialize the DRC engine.
KICAD_T Type() const
Returns the type of object.
const std::filesystem::path & Path() const
Get the path to the temporary directory as a std::filesystem::path.
LSET is a set of PCB_LAYER_IDs.
Handle the data for a net.
void SetEnd(const VECTOR2I &aEnd) override
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)
virtual void SetWidth(int aWidth)
Handle a list of polygons defining a copper zone.
void SetDoNotAllowPads(bool aEnable)
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
bool AppendCorner(const VECTOR2I &aPosition, int aHoleIdx, bool aAllowDuplication=false)
Add a new corner to the zone outline (to the main outline or a hole)
void SetIsRuleArea(bool aEnable)
void SetDoNotAllowTracks(bool aEnable)
void SetLayerSet(const LSET &aLayerSet) override
void SetDoNotAllowVias(bool aEnable)
void SetDoNotAllowFootprints(bool aEnable)
void SetDoNotAllowZoneFills(bool aEnable)
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
void LoadBoard(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< BOARD > &aBoard)
std::unique_ptr< BOARD > m_board
SETTINGS_MANAGER m_settingsManager
DRC_CREEPAGE_TEST_FIXTURE()=default
~DRC_CREEPAGE_TEST_FIXTURE()
BOOST_FIXTURE_TEST_CASE(CreepageHVvsGND, DRC_CREEPAGE_TEST_FIXTURE)
BOOST_TEST_MESSAGE("Polyline has "<< chain.PointCount()<< " points")
@ PCB_ZONE_T
class ZONE, a copper pour area
VECTOR2< int32_t > VECTOR2I