7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-11 09:40:09 +00:00

Handle edge cases in kissing zones

When zone kisses happen from different polygons, we need to be careful
not to use the different polygons for ear comparisons or prev/next
pointers

Fixes https://gitlab.com/kicad/code/kicad/-/issues/18654
This commit is contained in:
Seth Hillbrand 2024-10-24 17:14:50 -07:00
parent bb9a329ee4
commit 64ff47c594
5 changed files with 72 additions and 18 deletions
libs/kimath
include/geometry
src/geometry
pcbnew
qa

View File

@ -223,9 +223,13 @@ class VERTEX
* bounding box formed around the triangle, checking whether any points are located
* inside the given triangle.
*
* @param aMatchUserData if true, the user data of the vertices must match. This can be
* useful when the vertices come from different polygons.
*
*
* @return true if aEar is the apex point of a ear in the polygon.
*/
bool isEar() const;
bool isEar( bool aMatchUserData = false ) const;
const int i;
const double x;

View File

@ -238,12 +238,21 @@ void VERTEX::updateOrder()
}
bool VERTEX::isEar() const
bool VERTEX::isEar( bool aMatchUserData ) const
{
const VERTEX* a = prev;
const VERTEX* b = this;
const VERTEX* c = next;
if( aMatchUserData )
{
while( a->GetUserData() != m_userData )
a = a->prev;
while( c->GetUserData() != m_userData )
c = c->next;
}
// If the area >=0, then the three points for a concave sequence
// with b as the reflex point
if( parent->area( a, b, c ) >= 0 )
@ -264,7 +273,8 @@ bool VERTEX::isEar() const
while( p && p->z <= maxZ )
{
if( p != a && p != c
if( ( !aMatchUserData || p->GetUserData() == m_userData )
&& p != a && p != c
&& p->inTriangle( *a, *b, *c )
&& parent->area( p->prev, p, p->next ) >= 0 )
return false;
@ -277,7 +287,8 @@ bool VERTEX::isEar() const
while( p && p->z >= minZ )
{
if( p != a && p != c
if( ( !aMatchUserData || p->GetUserData() == m_userData )
&& p != a && p != c
&& p->inTriangle( *a, *b, *c )
&& parent->area( p->prev, p, p->next ) >= 0 )
return false;

View File

@ -109,8 +109,7 @@ public:
VECTOR2D diff( p->x - aPt->x, p->y - aPt->y );
SEG::ecoord dist2 = diff.SquaredEuclideanNorm();
if( dist2 < limit2 && dist2 < min_dist
&& p->isEar() )
if( dist2 > 0 && dist2 < limit2 && dist2 < min_dist && p->isEar( true ) )
{
min_dist = dist2;
retval = p;

View File

@ -3,14 +3,17 @@
"3dviewports": [],
"design_settings": {
"defaults": {
"board_outline_line_width": 0.09999999999999999,
"copper_line_width": 0.19999999999999998,
"apply_defaults_to_fp_fields": false,
"apply_defaults_to_fp_shapes": false,
"apply_defaults_to_fp_text": false,
"board_outline_line_width": 0.1,
"copper_line_width": 0.2,
"copper_text_italic": false,
"copper_text_size_h": 1.5,
"copper_text_size_v": 1.5,
"copper_text_thickness": 0.3,
"copper_text_upright": false,
"courtyard_line_width": 0.049999999999999996,
"courtyard_line_width": 0.05,
"dimension_precision": 4,
"dimension_units": 3,
"dimensions": {
@ -21,7 +24,7 @@
"text_position": 0,
"units_format": 1
},
"fab_line_width": 0.09999999999999999,
"fab_line_width": 0.1,
"fab_text_italic": false,
"fab_text_size_h": 1.0,
"fab_text_size_v": 1.0,
@ -45,7 +48,7 @@
"silk_text_thickness": 0.15,
"silk_text_upright": false,
"zones": {
"min_clearance": 0.19999999999999998
"min_clearance": 0.2
}
},
"diff_pair_dimensions": [
@ -66,15 +69,20 @@
"copper_edge_clearance": "error",
"copper_sliver": "warning",
"courtyards_overlap": "error",
"creepage": "error",
"diff_pair_gap_out_of_range": "error",
"diff_pair_uncoupled_length_too_long": "error",
"drill_out_of_range": "error",
"duplicate_footprints": "warning",
"extra_footprint": "warning",
"footprint": "error",
"footprint_filters_mismatch": "ignore",
"footprint_symbol_mismatch": "warning",
"footprint_type_mismatch": "ignore",
"hole_clearance": "error",
"hole_near_hole": "error",
"hole_to_hole": "warning",
"holes_co_located": "warning",
"invalid_outline": "error",
"isolated_copper": "warning",
"item_on_disabled_layer": "error",
@ -101,7 +109,9 @@
"text_thickness": "warning",
"through_hole_pad_without_hole": "error",
"too_many_vias": "error",
"track_angle": "error",
"track_dangling": "warning",
"track_segment_length": "error",
"track_width": "error",
"tracks_crossing": "error",
"unconnected_items": "error",
@ -112,12 +122,13 @@
"rules": {
"max_error": 0.005,
"min_clearance": 0.0,
"min_connection": 0.09999999999999999,
"min_connection": 0.1,
"min_copper_edge_clearance": 0.0,
"min_groove_width": 0.0,
"min_hole_clearance": 0.0,
"min_hole_to_hole": 0.0,
"min_microvia_diameter": 0.19999999999999998,
"min_microvia_drill": 0.09999999999999999,
"min_microvia_diameter": 0.2,
"min_microvia_drill": 0.1,
"min_resolved_spokes": 2,
"min_silk_clearance": 0.0,
"min_text_height": 0.0,
@ -133,10 +144,11 @@
},
"teardrop_options": [
{
"td_onpadsmd": true,
"td_onpthpad": true,
"td_onroundshapesonly": false,
"td_onsmdpad": true,
"td_ontrackend": false,
"td_onviapad": true
"td_onvia": true
}
],
"teardrop_parameters": [
@ -177,6 +189,32 @@
"track_widths": [
0.0
],
"tuning_pattern_settings": {
"diff_pair_defaults": {
"corner_radius_percentage": 80,
"corner_style": 1,
"max_amplitude": 1.0,
"min_amplitude": 0.2,
"single_sided": false,
"spacing": 1.0
},
"diff_pair_skew_defaults": {
"corner_radius_percentage": 80,
"corner_style": 1,
"max_amplitude": 1.0,
"min_amplitude": 0.2,
"single_sided": false,
"spacing": 0.6
},
"single_track_defaults": {
"corner_radius_percentage": 80,
"corner_style": 1,
"max_amplitude": 1.0,
"min_amplitude": 0.2,
"single_sided": false,
"spacing": 0.6
}
},
"via_dimensions": [
{
"diameter": 0.0,
@ -192,6 +230,7 @@
"mfg": "",
"mpn": ""
},
"layer_pairs": [],
"layer_presets": [],
"viewports": []
},
@ -431,6 +470,7 @@
"microvia_drill": 0.1,
"name": "Default",
"pcb_color": "rgba(0, 0, 0, 0.000)",
"priority": 2147483647,
"schematic_color": "rgba(0, 0, 0, 0.000)",
"track_width": 0.25,
"via_diameter": 0.8,
@ -439,7 +479,7 @@
}
],
"meta": {
"version": 3
"version": 4
},
"net_colors": null,
"netclass_assignments": null,

View File

@ -53,7 +53,7 @@ BOOST_FIXTURE_TEST_CASE( DRCCopperConn, DRC_REGRESSION_TEST_FIXTURE )
{ "issue9870", 12 },
{ "connection_width_rules", 3 },
{ "issue12831", 0 },
{ "issue14130", 1 }
{ "issue14130", 0 }
};
for( const std::pair<wxString, int>& test : tests )