drc_proto: implement QueryWorstConstraint

This commit is contained in:
Tomasz Wlostowski 2020-06-30 10:44:12 +02:00
parent bc86ea7682
commit e9d37dd7ce
4 changed files with 43 additions and 3 deletions

View File

@ -32,13 +32,12 @@ if( BUILD_GITHUB_PLUGIN )
endif()
add_dependencies( pnsrouter pcbcommon pcad2kicadpcb ${GITHUB_PLUGIN_LIBRARIES} )
add_executable( drc_proto
drc_rules_proto_keywords.cpp
drc_proto_test.cpp
drc_rule.cpp
drc_rule_parser.cpp
drc_rules_proto_keywords.cpp
drc_test_provider.cpp
drc_test_provider_clearance_base.cpp
drc_test_provider_copper_clearance.cpp
@ -51,6 +50,8 @@ add_executable( drc_proto
../../3d-viewer/3d_viewer/3d_viewer_settings.cpp
)
add_dependencies( drc_proto pnsrouter pcbcommon pcad2kicadpcb ${GITHUB_PLUGIN_LIBRARIES} )
include_directories( BEFORE ${INC_BEFORE} )
include_directories(
${CMAKE_SOURCE_DIR}

View File

@ -111,7 +111,7 @@ void test::DRC_ENGINE::inferImplicitRules()
}
static const int drc_debug_level = 10;
static const int drc_debug_level = -10;
void test::drc_dbg( int level, const char* fmt, ... )
{
@ -282,4 +282,37 @@ void test::DRC_ENGINE::ReportStage ( const wxString& aStageName, int index, int
m_progressReporter->BeginPhase( index ); // fixme: coalesce all stages/test providers
}
#if 0
test::DRC_CONSTRAINT test::DRC_ENGINE::GetWorstGlobalConstraint( test::DRC_RULE_ID_T ruleID )
{
DRC_CONSTRAINT rv;
rv.m_Value.SetMin( std::numeric_limits<int>::max() );
rv.m_Value.SetMax( std::numeric_limits<int>::min() );
for( auto rule : QueryRulesById( ruleID ) )
{
auto mm = rule->GetConstraint().m_Value;
if( mm.HasMax() )
rv.m_Value.SetMax( std::max( mm.Max(), rv.m_Value.Max() ) );
if( mm.HasMin() )
rv.m_Value.SetMin( std::min( mm.Min(), rv.m_Value.Min() ) );
}
return rv;
}
#endif
std::vector<test::DRC_RULE*> test::DRC_ENGINE::QueryRulesById( test::DRC_RULE_ID_T ruleID )
{
std::vector<test::DRC_RULE*> rv;
rv.push_back( m_ruleMap[ruleID]->defaultRule );
for( auto rule : m_ruleMap[ruleID]->sortedRules )
{
rv.push_back(rule->rule);
}
return rv;
}

View File

@ -190,6 +190,8 @@ public:
DRC_RULE* EvalRulesForItems(
DRC_RULE_ID_T ruleID, BOARD_ITEM* a, BOARD_ITEM* b = nullptr );
std::vector<DRC_RULE*> QueryRulesById( test::DRC_RULE_ID_T ruleID );
EDA_UNITS UserUnits() const
{
return EDA_UNITS::MILLIMETRES;

View File

@ -62,6 +62,10 @@ public:
T Max() const { assert( m_hasMax ); return m_max; };
T Opt() const { assert( m_hasOpt ); return m_opt; };
bool HasMin() const { return m_hasMin; }
bool HasMax() const { return m_hasMax; }
bool HasOpt() const { return m_hasOpt; }
void SetMin( T v ) { m_min = v; m_hasMin = true; }
void SetMax( T v ) { m_max = v; m_hasMax = true; }
void SetOpt( T v ) { m_opt = v; m_hasOpt = true; }