Restore min seg limit for rounded-corner pads.

It suffered from a cacophony of errors, starting with an errant
comment that made it later look like a bug.  Sigh.
This commit is contained in:
Jeff Young 2020-09-11 14:41:45 +01:00
parent e2bc7557cc
commit 6b4a6f4d3e
9 changed files with 13 additions and 490 deletions

View File

@ -124,7 +124,6 @@ void TransformOvalToPolygon( SHAPE_POLY_SET& aCornerBuffer, wxPoint aStart, wxPo
double delta_angle = atan2( (double)endp.y, (double)endp.x );
int seg_len = KiROUND( EuclideanNorm( endp ) );
// Compute the outlines of the segment, and creates a polygon
// Note: the polygonal shape is built from the equivalent horizontal
// segment starting at {0,0}, and ending at {seg_len,0}
@ -236,6 +235,11 @@ void TransformRoundChamferedRectToPolygon( SHAPE_POLY_SET& aCornerBuffer, const
int numSegs = GetArcToSegmentCount( aCornerRadius, aError, 360.0 );
// Choppy corners on rounded-corner rectangles look awful so enforce a minimum of
// 4 segments per corner.
if( numSegs < 16 )
numSegs = 16;
// To build the polygonal shape outside the actual shape, we use a bigger
// radius to build rounded corners.

View File

@ -1,5 +1,5 @@
#include <drc_proto/drc_engine.h>
#include <drc_proto/drc_item.h>
#include <drc/drc_engine.h>
#include <drc/drc_item.h>
#include <drc_proto/drc_test_provider.h>
test::DRC_TEST_PROVIDER::DRC_TEST_PROVIDER() :

View File

@ -104,7 +104,7 @@ public:
virtual void ReportProgress( double aProgress );
virtual void ReportStage ( const wxString& aStageName, int index, int total );
virtual std::set<test::DRC_CONSTRAINT_TYPE_T> GetMatchingConstraintIds() const = 0;
virtual std::set<DRC_CONSTRAINT_TYPE_T> GetMatchingConstraintIds() const = 0;
virtual bool IsRuleDriven() const
{
@ -113,16 +113,17 @@ public:
protected:
int forEachGeometryItem( const std::vector<KICAD_T> aTypes, const LSET aLayers, std::function<bool(BOARD_ITEM*)> aFunc );
int forEachGeometryItem( const std::vector<KICAD_T> aTypes, const LSET aLayers,
std::function<bool(BOARD_ITEM*)> aFunc );
virtual void reportRuleStatistics();
virtual void accountCheck( const test::DRC_RULE* ruleToTest );
virtual void accountCheck( const test::DRC_CONSTRAINT& constraintToTest );
virtual void accountCheck( const DRC_RULE* ruleToTest );
virtual void accountCheck( const DRC_CONSTRAINT& constraintToTest );
virtual bool isErrorLimitExceeded( int error_code );
EDA_UNITS userUnits() const;
DRC_ENGINE *m_drcEngine;
std::unordered_map<const test::DRC_RULE*, int> m_stats;
std::unordered_map<const DRC_RULE*, int> m_stats;
bool m_enable;
bool m_isRuleDriven = true;
};

View File

@ -1,127 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2007 Dick Hollenbeck, dick@softplc.com
* Copyright (C) 2018-2020 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef DRC_ITEM_PROTO_H
#define DRC_ITEM_PROTO_H
#include <macros.h>
#include <base_struct.h>
#include <rc_item.h>
#include <marker_base.h>
#include <class_board.h>
#include <pcb_base_frame.h>
#include <drc_proto/drc_engine.h>
namespace test {
class DRC_RULE;
class DRC_TEST_PROVIDER;
class DRC_ITEM : public RC_ITEM
{
public:
/**
* Constructs a DRC_ITEM for the given error code
* @see DRCE_T
*/
static std::shared_ptr<DRC_ITEM> Create( int aErrorCode );
/**
* Constructs a DRC item from a given error settings key
* @param aErrorKey is a settings key for an error code (the untranslated string that is used
* to represent a given error code in settings files and for storing ignored DRC items)
* @return the created item
*/
static std::shared_ptr<DRC_ITEM> Create( const wxString& aErrorKey );
static std::vector<std::reference_wrapper<RC_ITEM>> GetItemsWithSeverities()
{
return allItemTypes;
}
/**
* Translates this object into a fragment of HTML suitable for the wxHtmlListBox class.
* @return wxString - the html text.
*/
::wxString FormatHtml( ) const { return ""; } // fixme
void SetViolatingRule ( test::DRC_RULE *aRule ) { m_violatingRule = aRule; }
test::DRC_RULE* GetViolatingRule() const { return m_violatingRule; }
void SetViolatingTest( test::DRC_TEST_PROVIDER *aProvider ) { m_violatingTest = aProvider; }
test::DRC_TEST_PROVIDER* GetViolatingTest() const { return m_violatingTest; }
private:
DRC_ITEM( int aErrorCode = 0, const wxString& aTitle = "", const wxString& aSettingsKey = "" )
{
m_errorCode = aErrorCode;
m_errorTitle = aTitle;
m_settingsKey = aSettingsKey;
}
/// A list of all DRC_ITEM types which are valid error codes
static std::vector<std::reference_wrapper<RC_ITEM>> allItemTypes;
static DRC_ITEM unconnectedItems;
static DRC_ITEM shortingItems;
static DRC_ITEM itemsNotAllowed;
static DRC_ITEM clearance;
static DRC_ITEM tracksCrossing;
static DRC_ITEM copperEdgeClearance;
static DRC_ITEM zonesIntersect;
static DRC_ITEM zoneHasEmptyNet;
static DRC_ITEM viaDangling;
static DRC_ITEM trackDangling;
static DRC_ITEM holeClearance;
static DRC_ITEM trackWidth;
static DRC_ITEM viaTooSmall;
static DRC_ITEM annulus;
static DRC_ITEM drillTooSmall;
static DRC_ITEM viaHoleLargerThanPad;
static DRC_ITEM padstack;
static DRC_ITEM microviaTooSmall;
static DRC_ITEM microviaDrillTooSmall;
static DRC_ITEM keepout;
static DRC_ITEM courtyardsOverlap;
static DRC_ITEM missingCourtyard;
static DRC_ITEM malformedCourtyard;
static DRC_ITEM pthInsideCourtyard;
static DRC_ITEM npthInsideCourtyard;
static DRC_ITEM itemOnDisabledLayer;
static DRC_ITEM invalidOutline;
static DRC_ITEM duplicateFootprints;
static DRC_ITEM missingFootprint;
static DRC_ITEM extraFootprint;
static DRC_ITEM unresolvedVariable;
DRC_RULE *m_violatingRule = nullptr;
DRC_TEST_PROVIDER *m_violatingTest = nullptr;
};
};
#endif // DRC_ITEM_H

View File

@ -1,107 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <fctsys.h>
#include <class_board.h>
#include <class_board_item.h>
#include <drc_proto/drc_rule.h>
#include <drc_proto/drc_engine.h>
#include <pcb_expr_evaluator.h>
test::DRC_RULE::DRC_RULE() :
m_Unary( false ),
m_Enabled( true ),
m_priority( 0 ),
m_Severity( DRC_RULE_SEVERITY_T::DRC_SEVERITY_ERROR ),
m_condition( nullptr )
{
}
test::DRC_RULE::~DRC_RULE()
{
}
void test::DRC_RULE::AddConstraint( DRC_CONSTRAINT& aConstraint )
{
aConstraint.SetParentRule( this );
m_constraints.push_back( aConstraint );
}
test::DRC_RULE_CONDITION::DRC_RULE_CONDITION( const wxString& aExpression,
const LSET aLayerCondition ) :
m_expression( aExpression ),
m_layerCondition ( aLayerCondition ),
m_ucode ( nullptr )
{
}
test::DRC_RULE_CONDITION::~DRC_RULE_CONDITION()
{
}
bool test::DRC_RULE_CONDITION::EvaluateFor( const BOARD_ITEM* aItemA, const BOARD_ITEM* aItemB,
PCB_LAYER_ID aLayer )
{
// An unconditional rule is always true
if( m_expression.IsEmpty() )
return true;
// A rule which failed to compile is always false
if( !m_ucode )
return false;
BOARD_ITEM* a = const_cast<BOARD_ITEM*>( aItemA );
BOARD_ITEM* b = aItemB ? const_cast<BOARD_ITEM*>( aItemB ) : DELETED_BOARD_ITEM::GetInstance();
PCB_EXPR_CONTEXT ctx( aLayer );
ctx.SetItems( a, b );
return m_ucode->Run( &ctx )->AsDouble() != 0.0;
}
bool test::DRC_RULE_CONDITION::Compile( REPORTER* aReporter, int aSourceLine, int aSourceOffset )
{
PCB_EXPR_COMPILER compiler;
m_ucode.reset( new PCB_EXPR_UCODE );
PCB_EXPR_CONTEXT preflightContext( F_Cu );
bool ok = compiler.Compile( m_expression, m_ucode.get(), &preflightContext );
if(!ok)
{
drc_dbg(1, "Error: %s", compiler.GetError().message );
}
return ok;
}

View File

@ -1,248 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef DRC_RULE_PROTO_H
#define DRC_RULE_PROTO_H
#include <core/typeinfo.h>
#include <layers_id_colors_and_visibility.h>
#include <netclass.h>
#include <libeval_compiler/libeval_compiler.h>
class BOARD_ITEM;
namespace LIBEVAL
{
class UCODE;
class ERROR_STATUS;
};
class PCB_EXPR_UCODE;
namespace test
{
class DRC_RULE;
class DRC_RULE_CONDITION;
enum DRC_CONSTRAINT_TYPE_T
{
DRC_CONSTRAINT_TYPE_UNKNOWN = -1,
DRC_CONSTRAINT_TYPE_CLEARANCE = 0,
DRC_CONSTRAINT_TYPE_HOLE_CLEARANCE,
DRC_CONSTRAINT_TYPE_EDGE_CLEARANCE,
DRC_CONSTRAINT_TYPE_HOLE_SIZE,
DRC_CONSTRAINT_TYPE_COURTYARD_CLEARANCE,
DRC_CONSTRAINT_TYPE_SILK_TO_PAD,
DRC_CONSTRAINT_TYPE_SILK_TO_SILK,
DRC_CONSTRAINT_TYPE_TRACK_WIDTH,
DRC_CONSTRAINT_TYPE_ANNULUS_WIDTH,
DRC_CONSTRAINT_TYPE_DISALLOW,
DRC_CONSTRAINT_TYPE_VIA_DIAMETER
};
enum DRC_DISALLOW_T
{
DRC_DISALLOW_VIAS = (1 << 0),
DRC_DISALLOW_MICRO_VIAS = (1 << 1),
DRC_DISALLOW_BB_VIAS = (1 << 2),
DRC_DISALLOW_TRACKS = (1 << 3),
DRC_DISALLOW_PADS = (1 << 4),
DRC_DISALLOW_ZONES = (1 << 5),
DRC_DISALLOW_TEXTS = (1 << 6),
DRC_DISALLOW_GRAPHICS = (1 << 7),
DRC_DISALLOW_HOLES = (1 << 8),
DRC_DISALLOW_FOOTPRINTS = (1 << 9)
};
enum DRC_RULE_SEVERITY_T
{
DRC_SEVERITY_IGNORE = 0,
DRC_SEVERITY_WARNING,
DRC_SEVERITY_ERROR
};
template<class T=int>
class MINOPTMAX
{
public:
T Min() const { assert( m_hasMin ); return m_min; };
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; }
private:
T m_min;
T m_opt;
T m_max;
bool m_hasMin = false;
bool m_hasOpt = false;
bool m_hasMax = false;
};
class DRC_CONSTRAINT
{
public:
DRC_CONSTRAINT( DRC_CONSTRAINT_TYPE_T aType = DRC_CONSTRAINT_TYPE_T::DRC_CONSTRAINT_TYPE_UNKNOWN
) :
m_Type( aType ),
m_DisallowFlags( 0 ),
m_LayerCondition( LSET::AllLayersMask() ),
m_parentRule( nullptr ) // fixme
{
}
const MINOPTMAX<int>& GetValue() const { return m_Value; }
MINOPTMAX<int>& Value() { return m_Value; }
// fixme: needed?
bool Allowed() const { return m_Allow; }
void SetParentRule( DRC_RULE *aParentRule ) { m_parentRule = aParentRule; }
DRC_RULE* GetParentRule() const { return m_parentRule; }
DRC_CONSTRAINT_TYPE_T GetType() const { return m_Type; }
const LSET& GetAllowedLayers() const { return m_LayerCondition; }
public:
DRC_CONSTRAINT_TYPE_T m_Type;
int m_DisallowFlags;
LSET m_LayerCondition;
private:
DRC_RULE *m_parentRule;
MINOPTMAX<int> m_Value;
bool m_Allow;
};
class DRC_RULE
{
public:
DRC_RULE();
virtual ~DRC_RULE();
virtual bool IsImplicit() const { return false; };
virtual bool AppliesTo( const BOARD_ITEM* a, const BOARD_ITEM* b = nullptr ) const { return true; };
virtual bool IsEnabled() const { return m_Enabled; }
virtual bool HasSpecificItemSet() const { return false; };
virtual void FillSpecificItemSet( std::set<BOARD_ITEM*> specificItems ) { };
void SetPriority( int aPriority ) { m_priority = aPriority; }
int GetPriority() const { return m_priority; }
DRC_RULE_SEVERITY_T GetSeverity() const { return m_Severity; }
void SetName( const wxString& aName ) { m_name = aName; }
const wxString GetName() const { return m_name; }
std::vector<DRC_CONSTRAINT>& Constraints()
{
return m_constraints;
}
void AddConstraint( DRC_CONSTRAINT& aConstraint );
bool IsConditional() const
{
return m_condition != nullptr;
}
void SetCondition( test::DRC_RULE_CONDITION* aCondition )
{
m_condition = aCondition;
}
test::DRC_RULE_CONDITION* Condition()
{
return m_condition;
}
void SetLayerCondition( LSET aLayerCondition )
{
m_layerCondition = aLayerCondition;
}
private:
wxString m_name;
int m_priority; // 0 indicates automatic priority generation fixme: use enum
public:
bool m_Unary;
LSET m_layerCondition;
DRC_RULE_CONDITION* m_condition; // fixme: consider unique_ptr
std::vector<DRC_CONSTRAINT> m_constraints;
DRC_RULE_SEVERITY_T m_Severity;
bool m_Enabled;
};
class DRC_RULE_CONDITION
{
public:
DRC_RULE_CONDITION( const wxString& aExpression = "",
const LSET aLayerCondition = LSET::AllLayersMask() );
~DRC_RULE_CONDITION();
bool EvaluateFor( const BOARD_ITEM* aItemA, const BOARD_ITEM* aItemB,
PCB_LAYER_ID aLayer );
bool Compile( REPORTER* aReporter, int aSourceLine = 0, int aSourceOffset = 0 );
void SetLayerCondition( LSET aLayerCondition )
{
m_layerCondition = aLayerCondition;
}
void SetExpression( const wxString& aExpression )
{
m_expression = aExpression;
}
const wxString& GetExpression() const
{
return m_expression;
}
private:
LSET m_layerCondition;
wxString m_expression;
std::unique_ptr<PCB_EXPR_UCODE> m_ucode;
};
//DRC_RULE* GetRule( const BOARD_ITEM* aItem, const BOARD_ITEM* bItem, int aConstraint );
}; // namespace test
#endif // DRC_RULE_H