diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/cpolygon2d.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/cpolygon2d.cpp index 9170f68677..62b6d8f599 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/cpolygon2d.cpp +++ b/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/cpolygon2d.cpp @@ -627,15 +627,10 @@ void Convert_path_polygon_to_polygon_blocks_and_dummy_blocks( SHAPE_POLY_SET subBlockPoly; - SHAPE_LINE_CHAIN sb = SHAPE_LINE_CHAIN( - VECTOR2I( leftToRight, - topToBottom ), - VECTOR2I( leftToRight + leftToRight_inc, - topToBottom ), - VECTOR2I( leftToRight + leftToRight_inc, - topToBottom + topToBottom_inc ), - VECTOR2I( leftToRight, - topToBottom + topToBottom_inc ) ); + SHAPE_LINE_CHAIN sb = SHAPE_LINE_CHAIN( { VECTOR2I( leftToRight, topToBottom ), + VECTOR2I( leftToRight + leftToRight_inc, topToBottom ), + VECTOR2I( leftToRight + leftToRight_inc, topToBottom + topToBottom_inc ), + VECTOR2I( leftToRight, topToBottom + topToBottom_inc ) } ); //sb.Append( leftToRight, topToBottom ); sb.SetClosed( true ); diff --git a/common/gr_basic.cpp b/common/gr_basic.cpp index 0ae89bf3c0..fb8966a0cf 100644 --- a/common/gr_basic.cpp +++ b/common/gr_basic.cpp @@ -427,7 +427,7 @@ void GRFilledSegment( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEn } -static bool IsGRSPolyDrawable( EDA_RECT* ClipBox, int n, const wxPoint* Points, ) +static bool IsGRSPolyDrawable( EDA_RECT* ClipBox, int n, const wxPoint* Points ) { if( !ClipBox ) return true; @@ -957,7 +957,7 @@ void ClipAndDrawPoly( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint* Points, int { if( aClipBox == NULL ) { - aDC->DrawPolygon( n, aPoints ); + aDC->DrawPolygon( n, Points ); return; } @@ -970,7 +970,7 @@ void ClipAndDrawPoly( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint* Points, int clippedPolygon.clear(); for( int ii = 0; ii < n; ii++ ) - inputPolygon.push_back( PointF( (REAL) aPoints[ii].x, (REAL) aPoints[ii].y ) ); + inputPolygon.push_back( PointF( (REAL) Points[ii].x, (REAL) Points[ii].y ) ); RectF window( (REAL) aClipBox->GetX(), (REAL) aClipBox->GetY(), (REAL) aClipBox->GetWidth(), (REAL) aClipBox->GetHeight() ); diff --git a/common/preview_items/polygon_geom_manager.cpp b/common/preview_items/polygon_geom_manager.cpp index 32991611e8..879a433b03 100644 --- a/common/preview_items/polygon_geom_manager.cpp +++ b/common/preview_items/polygon_geom_manager.cpp @@ -21,10 +21,12 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ #include +#include #include #include +#include POLYGON_GEOM_MANAGER::POLYGON_GEOM_MANAGER( CLIENT& aClient ): @@ -181,13 +183,13 @@ void POLYGON_GEOM_MANAGER::updateLeaderPoints( const VECTOR2I& aEndPoint, LEADER } } - m_leaderPts = SHAPE_LINE_CHAIN( last_pt, new_end ); + m_leaderPts = SHAPE_LINE_CHAIN( { last_pt, new_end } ); if( pt ) { // This checks for backtracking from the point to intersection if( SEG( last_pt, new_end ).Collinear( SEG( new_end, *pt ) ) ) - m_leaderPts = SHAPE_LINE_CHAIN( last_pt, *pt ); + m_leaderPts = SHAPE_LINE_CHAIN( { last_pt, *pt } ); else m_leaderPts.Append( *pt ); } @@ -195,7 +197,7 @@ void POLYGON_GEOM_MANAGER::updateLeaderPoints( const VECTOR2I& aEndPoint, LEADER else { // direct segment - m_leaderPts = SHAPE_LINE_CHAIN( last_pt, aEndPoint ); + m_leaderPts = SHAPE_LINE_CHAIN( { last_pt, aEndPoint } ); } m_client.OnGeometryChange( *this ); diff --git a/include/geometry/shape_line_chain.h b/include/geometry/shape_line_chain.h index dfd070239d..d1c7d26442 100644 --- a/include/geometry/shape_line_chain.h +++ b/include/geometry/shape_line_chain.h @@ -26,8 +26,9 @@ #ifndef __SHAPE_LINE_CHAIN #define __SHAPE_LINE_CHAIN -#include #include +#include +#include #include @@ -70,6 +71,7 @@ public: typedef std::vector INTERSECTIONS; + /** * Constructor * Initializes an empty line chain. @@ -85,50 +87,8 @@ public: SHAPE( SH_LINE_CHAIN ), m_points( aShape.m_points ), m_closed( aShape.m_closed ) {} - /** - * Constructor - * Initializes a 2-point line chain (a single segment) - */ - SHAPE_LINE_CHAIN( const VECTOR2I& aA, const VECTOR2I& aB ) : - SHAPE( SH_LINE_CHAIN ), m_closed( false ) - { - m_points.resize( 2 ); - m_points[0] = aA; - m_points[1] = aB; - } - - SHAPE_LINE_CHAIN( const VECTOR2I& aA, const VECTOR2I& aB, const VECTOR2I& aC ) : - SHAPE( SH_LINE_CHAIN ), m_closed( false ) - { - m_points.resize( 3 ); - m_points[0] = aA; - m_points[1] = aB; - m_points[2] = aC; - } - - SHAPE_LINE_CHAIN( const VECTOR2I& aA, const VECTOR2I& aB, const VECTOR2I& aC, const VECTOR2I& aD ) : - SHAPE( SH_LINE_CHAIN ), m_closed( false ) - { - m_points.resize( 4 ); - m_points[0] = aA; - m_points[1] = aB; - m_points[2] = aC; - m_points[3] = aD; - } - - SHAPE_LINE_CHAIN( const VECTOR2I* aV, int aCount ) : - SHAPE( SH_LINE_CHAIN ), - m_closed( false ) - { - m_points.resize( aCount ); - - for( int i = 0; i < aCount; i++ ) - m_points[i] = *aV++; - } - - SHAPE_LINE_CHAIN( const std::vector& aV ) : - SHAPE( SH_LINE_CHAIN ), - m_closed( false ) + SHAPE_LINE_CHAIN( const std::vector& aV, bool aClosed = false ) + : SHAPE( SH_LINE_CHAIN ), m_closed( aClosed ) { m_points.reserve( aV.size() ); @@ -136,9 +96,8 @@ public: m_points.emplace_back( pt.x, pt.y ); } - SHAPE_LINE_CHAIN( const std::vector& aV ) : - SHAPE( SH_LINE_CHAIN ), - m_closed( false ) + SHAPE_LINE_CHAIN( const std::vector& aV, bool aClosed = false ) + : SHAPE( SH_LINE_CHAIN ), m_closed( aClosed ) { m_points = aV; } @@ -153,7 +112,7 @@ public: m_points.emplace_back( point.X, point.Y ); } - ~SHAPE_LINE_CHAIN() + virtual ~SHAPE_LINE_CHAIN() {} SHAPE* Clone() const override; diff --git a/pcbnew/class_drawsegment.cpp b/pcbnew/class_drawsegment.cpp index 6cb9401276..471ee2180e 100644 --- a/pcbnew/class_drawsegment.cpp +++ b/pcbnew/class_drawsegment.cpp @@ -429,9 +429,8 @@ void DRAWSEGMENT::Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& aOffse for( int jj = 0; jj < outline.OutlineCount(); ++jj ) { SHAPE_LINE_CHAIN& poly = outline.Outline( jj ); - GRClosedPoly( nullptr, DC, poly.PointCount(), - static_cast( &poly.CPoint( 0 ) ), - IsPolygonFilled(), GetWidth(), color, color ); + GRClosedPoly( nullptr, DC, poly.PointCount(), (const wxPoint*) &poly.CPoint( 0 ), + IsPolygonFilled(), GetWidth(), color, color ); } } break; diff --git a/pcbnew/pad_print_functions.cpp b/pcbnew/pad_print_functions.cpp index 6f22cd1687..ac5ab656bb 100644 --- a/pcbnew/pad_print_functions.cpp +++ b/pcbnew/pad_print_functions.cpp @@ -281,8 +281,8 @@ void D_PAD::PrintShape( wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) if( poly.PointCount() > 0 ) { GRClosedPoly( nullptr, aDC, poly.PointCount(), - static_cast( &poly.CPoint( 0 ) ), - false, 0, aDrawInfo.m_Color, aDrawInfo.m_Color ); + (const wxPoint*) &poly.CPoint( 0 ), false, 0, aDrawInfo.m_Color, + aDrawInfo.m_Color ); } } } @@ -308,9 +308,8 @@ void D_PAD::PrintShape( wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) SHAPE_LINE_CHAIN& poly = outline.Outline( 0 ); - GRClosedPoly( nullptr, aDC, poly.PointCount(), - static_cast( &poly.CPoint( 0 ) ), filled, 0, - aDrawInfo.m_Color, aDrawInfo.m_Color ); + GRClosedPoly( nullptr, aDC, poly.PointCount(), (const wxPoint*) &poly.CPoint( 0 ), filled, + 0, aDrawInfo.m_Color, aDrawInfo.m_Color ); if( aDrawInfo.m_PadClearance ) { @@ -329,8 +328,8 @@ void D_PAD::PrintShape( wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) SHAPE_LINE_CHAIN& clearance_poly = outline.Outline( 0 ); GRClosedPoly( nullptr, aDC, clearance_poly.PointCount(), - static_cast( &clearance_poly.CPoint( 0 ) ), false, 0, - aDrawInfo.m_Color, aDrawInfo.m_Color ); + (const wxPoint*) &clearance_poly.CPoint( 0 ), false, 0, aDrawInfo.m_Color, + aDrawInfo.m_Color ); } } break; @@ -390,8 +389,8 @@ void D_PAD::PrintShape( wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) { auto& poly = outline.Outline( jj ); - GRClosedPoly( nullptr, aDC, poly.PointCount(), static_cast( &poly.CPoint( 0 ) ), - aDrawInfo.m_ShowPadFilled, 0, aDrawInfo.m_Color, aDrawInfo.m_Color ); + GRClosedPoly( nullptr, aDC, poly.PointCount(), (const wxPoint*) &poly.CPoint( 0 ), + aDrawInfo.m_ShowPadFilled, 0, aDrawInfo.m_Color, aDrawInfo.m_Color ); } if( aDrawInfo.m_PadClearance ) @@ -410,8 +409,8 @@ void D_PAD::PrintShape( wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) if( poly.PointCount() > 0 ) { GRClosedPoly( nullptr, aDC, poly.PointCount(), - static_cast( &poly.CPoint( 0 ) ), - false, 0, aDrawInfo.m_Color, aDrawInfo.m_Color ); + (const wxPoint*) &poly.CPoint( 0 ), false, 0, aDrawInfo.m_Color, + aDrawInfo.m_Color ); } } } diff --git a/pcbnew/plot_brditems_plotter.cpp b/pcbnew/plot_brditems_plotter.cpp index eba15d715c..e09755134f 100644 --- a/pcbnew/plot_brditems_plotter.cpp +++ b/pcbnew/plot_brditems_plotter.cpp @@ -690,8 +690,7 @@ void BRDITEMS_PLOTTER::PlotFilledAreas( ZONE_CONTAINER* aZone, SHAPE_POLY_SET& p for( int ic = 0; ic < outline.PointCount(); ++ic ) { - VECTOR2I& point = outline.Point( ic ); - cornerList.emplace_back( wxPoint( point.x, point.y ) ); + cornerList.emplace_back( wxPoint( outline.CPoint( ic ) ) ); } if( cornerList.size() ) // Plot the current filled area outline diff --git a/pcbnew/router/pns_diff_pair.cpp b/pcbnew/router/pns_diff_pair.cpp index 4f43208715..31fa9b88f3 100644 --- a/pcbnew/router/pns_diff_pair.cpp +++ b/pcbnew/router/pns_diff_pair.cpp @@ -520,8 +520,8 @@ void DP_GATEWAYS::BuildFromPrimitivePair( const DP_PRIMITIVE_PAIR& aPair, bool a VECTOR2I gw_p( p0_p + sign * ( dir + dp ) + dv ); VECTOR2I gw_n( p0_n + sign * ( dir + dp ) - dv ); - SHAPE_LINE_CHAIN entryP( p0_p, p0_p + sign * dir, gw_p ); - SHAPE_LINE_CHAIN entryN( p0_n, p0_n + sign * dir, gw_n ); + SHAPE_LINE_CHAIN entryP( { p0_p, p0_p + sign * dir, gw_p } ); + SHAPE_LINE_CHAIN entryN( { p0_n, p0_n + sign * dir, gw_n } ); DP_GATEWAY gw( gw_p, gw_n, false ); diff --git a/pcbnew/router/pns_line_placer.cpp b/pcbnew/router/pns_line_placer.cpp index 79a10886c8..55f4fa19e7 100644 --- a/pcbnew/router/pns_line_placer.cpp +++ b/pcbnew/router/pns_line_placer.cpp @@ -548,8 +548,8 @@ bool LINE_PLACER::rhStopAtNearestObstacle( const VECTOR2I& aP, LINE& aNewHead ) SEG segL( s.B, leadL.LineProject( aP ) ); SEG segR( s.B, leadR.LineProject( aP ) ); - LINE finishL( l0, SHAPE_LINE_CHAIN( segL.A, segL.B ) ); - LINE finishR( l0, SHAPE_LINE_CHAIN( segR.A, segR.B ) ); + LINE finishL( l0, SHAPE_LINE_CHAIN( { segL.A, segL.B } ) ); + LINE finishR( l0, SHAPE_LINE_CHAIN( { segR.A, segR.B } ) ); LINE reducedL = reduceToNearestObstacle( finishL ); LINE reducedR = reduceToNearestObstacle( finishR ); @@ -1213,7 +1213,7 @@ bool LINE_PLACER::buildInitialLine( const VECTOR2I& aP, LINE& aHead, bool aInver { if( Settings().GetFreeAngleMode() && Settings().Mode() == RM_MarkObstacles ) { - l = SHAPE_LINE_CHAIN( m_p_start, aP ); + l = SHAPE_LINE_CHAIN( { m_p_start, aP } ); } else { diff --git a/pcbnew/router/pns_optimizer.cpp b/pcbnew/router/pns_optimizer.cpp index abe0929fa5..8d368f7dac 100644 --- a/pcbnew/router/pns_optimizer.cpp +++ b/pcbnew/router/pns_optimizer.cpp @@ -723,10 +723,10 @@ OPTIMIZER::BREAKOUT_LIST OPTIMIZER::rectBreakouts( int aWidth, VECTOR2I d_vert = VECTOR2I( 0, s.y / 2 + aWidth ); VECTOR2I d_horiz = VECTOR2I( s.x / 2 + aWidth, 0 ); - breakouts.push_back( SHAPE_LINE_CHAIN( c, c + d_horiz ) ); - breakouts.push_back( SHAPE_LINE_CHAIN( c, c - d_horiz ) ); - breakouts.push_back( SHAPE_LINE_CHAIN( c, c + d_vert ) ); - breakouts.push_back( SHAPE_LINE_CHAIN( c, c - d_vert ) ); + breakouts.push_back( SHAPE_LINE_CHAIN( { c, c + d_horiz } ) ); + breakouts.push_back( SHAPE_LINE_CHAIN( { c, c - d_horiz } ) ); + breakouts.push_back( SHAPE_LINE_CHAIN( { c, c + d_vert } ) ); + breakouts.push_back( SHAPE_LINE_CHAIN( { c, c - d_vert } ) ); if( aPermitDiagonal ) { @@ -735,26 +735,26 @@ OPTIMIZER::BREAKOUT_LIST OPTIMIZER::rectBreakouts( int aWidth, if( s.x >= s.y ) { - breakouts.push_back( SHAPE_LINE_CHAIN( c, c + d_offset, - c + d_offset + VECTOR2I( l, l ) ) ); - breakouts.push_back( SHAPE_LINE_CHAIN( c, c + d_offset, - c + d_offset - VECTOR2I( -l, l ) ) ); - breakouts.push_back( SHAPE_LINE_CHAIN( c, c - d_offset, - c - d_offset + VECTOR2I( -l, l ) ) ); - breakouts.push_back( SHAPE_LINE_CHAIN( c, c - d_offset, - c - d_offset - VECTOR2I( l, l ) ) ); + breakouts.push_back( + SHAPE_LINE_CHAIN( { c, c + d_offset, c + d_offset + VECTOR2I( l, l ) } ) ); + breakouts.push_back( + SHAPE_LINE_CHAIN( { c, c + d_offset, c + d_offset - VECTOR2I( -l, l ) } ) ); + breakouts.push_back( + SHAPE_LINE_CHAIN( { c, c - d_offset, c - d_offset + VECTOR2I( -l, l ) } ) ); + breakouts.push_back( + SHAPE_LINE_CHAIN( { c, c - d_offset, c - d_offset - VECTOR2I( l, l ) } ) ); } else { // fixme: this could be done more efficiently - breakouts.push_back( SHAPE_LINE_CHAIN( c, c + d_offset, - c + d_offset + VECTOR2I( l, l ) ) ); - breakouts.push_back( SHAPE_LINE_CHAIN( c, c - d_offset, - c - d_offset - VECTOR2I( -l, l ) ) ); - breakouts.push_back( SHAPE_LINE_CHAIN( c, c + d_offset, - c + d_offset + VECTOR2I( -l, l ) ) ); - breakouts.push_back( SHAPE_LINE_CHAIN( c, c - d_offset, - c - d_offset - VECTOR2I( l, l ) ) ); + breakouts.push_back( + SHAPE_LINE_CHAIN( { c, c + d_offset, c + d_offset + VECTOR2I( l, l ) } ) ); + breakouts.push_back( + SHAPE_LINE_CHAIN( { c, c - d_offset, c - d_offset - VECTOR2I( -l, l ) } ) ); + breakouts.push_back( + SHAPE_LINE_CHAIN( { c, c + d_offset, c + d_offset + VECTOR2I( -l, l ) } ) ); + breakouts.push_back( + SHAPE_LINE_CHAIN( { c, c - d_offset, c - d_offset - VECTOR2I( l, l ) } ) ); } } diff --git a/pcbnew/router/pns_segment.h b/pcbnew/router/pns_segment.h index d07229c8f5..36f92e0354 100644 --- a/pcbnew/router/pns_segment.h +++ b/pcbnew/router/pns_segment.h @@ -97,7 +97,7 @@ public: const SHAPE_LINE_CHAIN CLine() const { - return SHAPE_LINE_CHAIN( m_seg.GetSeg().A, m_seg.GetSeg().B ); + return SHAPE_LINE_CHAIN( { m_seg.GetSeg().A, m_seg.GetSeg().B } ); } void SetEnds( const VECTOR2I& a, const VECTOR2I& b ) diff --git a/qa/qa_utils/geometry/line_chain_construction.cpp b/qa/qa_utils/geometry/line_chain_construction.cpp index 56d1b906df..5cdf363a60 100644 --- a/qa/qa_utils/geometry/line_chain_construction.cpp +++ b/qa/qa_utils/geometry/line_chain_construction.cpp @@ -35,7 +35,7 @@ SHAPE_LINE_CHAIN BuildRectChain( const VECTOR2I& aSize, const VECTOR2I& aCentre { aCentre.x + aSize.x / 2, aCentre.y - aSize.y / 2 }, }; - SHAPE_LINE_CHAIN chain( pts.data(), pts.size() ); + SHAPE_LINE_CHAIN chain( pts ); chain.SetClosed( true ); return chain; @@ -46,4 +46,4 @@ SHAPE_LINE_CHAIN BuildSquareChain( int aSize, const VECTOR2I& aCentre ) return BuildRectChain( { aSize, aSize }, aCentre ); } -} // namespace KI_TEST \ No newline at end of file +} // namespace KI_TEST