diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp index b26e07f5b8..6836d71f31 100644 --- a/pcbnew/class_track.cpp +++ b/pcbnew/class_track.cpp @@ -978,27 +978,20 @@ bool TRACK::cmp_tracks::operator() ( const TRACK* a, const TRACK* b ) const std::shared_ptr TRACK::GetEffectiveShape( PCB_LAYER_ID aLayer ) const { - std::shared_ptr shape( new SHAPE_SEGMENT( m_Start, m_End, m_Width ) ); - - return shape; + return std::make_shared( m_Start, m_End, m_Width ); } std::shared_ptr VIA::GetEffectiveShape( PCB_LAYER_ID aLayer ) const { // fixme: pad stack support (depending on aLayer ) - std::shared_ptr shape( new SHAPE_CIRCLE( m_Start, m_Width / 2 ) ); - - return shape; + return std::make_shared( m_Start, m_Width / 2 ); } std::shared_ptr ARC::GetEffectiveShape( PCB_LAYER_ID aLayer ) const { - std::shared_ptr shape( new SHAPE_ARC( GetStart(), GetMid(), GetEnd(), - GetWidth() ) ); - - return shape; + return std::make_shared( GetStart(), GetMid(), GetEnd(), GetWidth() ); } diff --git a/pcbnew/drc/drc_test_provider_copper_clearance.cpp b/pcbnew/drc/drc_test_provider_copper_clearance.cpp index c6e88028a3..1e82b2c4e3 100644 --- a/pcbnew/drc/drc_test_provider_copper_clearance.cpp +++ b/pcbnew/drc/drc_test_provider_copper_clearance.cpp @@ -27,7 +27,7 @@ #include #include -//#include +#include #include #include #include @@ -508,8 +508,6 @@ void DRC_TEST_PROVIDER_COPPER_CLEARANCE::doTrackDrc( TRACK* aRefSeg, PCB_LAYER_I || static_cast( aRefSeg )->FlashLayer( aLayer ) || static_cast( aRefSeg )->GetDrill() > 0 ) ) { - SEG testSeg( aRefSeg->GetStart(), aRefSeg->GetEnd() ); - for( ZONE_CONTAINER* zone : m_board->Zones() ) { if( m_drcEngine->IsErrorLimitExceeded( DRCE_CLEARANCE ) ) @@ -543,12 +541,41 @@ void DRC_TEST_PROVIDER_COPPER_CLEARANCE::doTrackDrc( TRACK* aRefSeg, PCB_LAYER_I int allowedDist = minClearance + halfWidth - bds.GetDRCEpsilon(); const SHAPE_POLY_SET& zonePoly = zone->GetFilledPolysList( aLayer ); - int actual; + int actual = INT_MAX; VECTOR2I location; accountCheck( constraint ); - if( zonePoly.Collide( testSeg, allowedDist, &actual, &location ) ) + if( aRefSeg->Type() == PCB_ARC_T ) + { + std::shared_ptr refShape = aRefSeg->GetEffectiveShape(); + SHAPE_ARC* refArc = dynamic_cast( refShape.get() ); + SHAPE_LINE_CHAIN refArcSegs = refArc->ConvertToPolyline( bds.m_MaxError ); + + for( int i = 0; i < refArcSegs.SegmentCount(); ++i ) + { + SEG refArcSeg = refArcSegs.Segment( i ); + int segActual; + VECTOR2I segLocation; + + if( zonePoly.Collide( refArcSeg, allowedDist, &segActual, &segLocation ) ) + { + if( segActual < actual ) + { + actual = segActual; + location = segLocation; + } + } + } + } + else + { + SEG testSeg( aRefSeg->GetStart(), aRefSeg->GetEnd() ); + + zonePoly.Collide( testSeg, allowedDist, &actual, &location ); + } + + if( actual != INT_MAX ) { actual = std::max( 0, actual - halfWidth ); std::shared_ptr drcItem = DRC_ITEM::Create( DRCE_CLEARANCE );