From 76518712c441a30a81aa8f2d53b80eef069b7ae8 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 9 May 2013 21:08:12 +0200 Subject: [PATCH] More work on CPOLYGONS_LIST class. Pcbnew: fix minor bug about plot line width. --- 3d-viewer/3d_draw.cpp | 11 +-- 3d-viewer/3d_draw_basic_functions.cpp | 6 +- common/convert_basic_shapes_to_polygon.cpp | 24 +++--- ...board_items_to_polygon_shape_transform.cpp | 36 ++++----- pcbnew/class_zone.cpp | 31 +++---- pcbnew/class_zone.h | 2 +- pcbnew/kicad_plugin.cpp | 12 +-- pcbnew/legacy_plugin.cpp | 8 +- pcbnew/onrightclick.cpp | 2 +- pcbnew/pcb_parser.cpp | 6 +- pcbnew/pcb_plot_params.cpp | 80 ++++++++++++------- pcbnew/pcb_plot_params.h | 15 +++- pcbnew/plot_brditems_plotter.cpp | 2 +- pcbnew/specctra_export.cpp | 4 +- pcbnew/zone_filling_algorithm.cpp | 2 +- pcbnew/zones_by_polygon.cpp | 2 +- ...nvert_brd_items_to_polygons_with_Boost.cpp | 4 +- ...ones_convert_to_polygons_aux_functions.cpp | 10 +-- ...ones_polygons_insulated_copper_islands.cpp | 4 +- pcbnew/zones_polygons_test_connections.cpp | 7 +- pcbnew/zones_test_and_combine_areas.cpp | 8 +- polygon/PolyLine.cpp | 53 ++++++------ polygon/PolyLine.h | 8 +- 23 files changed, 182 insertions(+), 155 deletions(-) diff --git a/3d-viewer/3d_draw.cpp b/3d-viewer/3d_draw.cpp index bd66df0ccb..ef303e55df 100644 --- a/3d-viewer/3d_draw.cpp +++ b/3d-viewer/3d_draw.cpp @@ -88,7 +88,8 @@ static void BuildPadShapeThickOutlineAsPolygon( D_PAD* aPad, aCircleToSegmentsCount, aCorrectionFactor ); // Add outlines as thick segments in polygon buffer - for( unsigned ii = 0, jj = corners.size() - 1; ii < corners.size(); jj = ii, ii++ ) + for( unsigned ii = 0, jj = corners.GetCornersCount() - 1; + ii < corners.GetCornersCount(); jj = ii, ii++ ) { TransformRoundedEndsSegmentToPolygon( aCornerBuffer, corners.GetPos( jj ), @@ -282,7 +283,7 @@ void EDA_3D_CANVAS::BuildBoard3DView() } // bufferPolys contains polygons to merge. Many overlaps . Calculate merged polygons - if( bufferPolys.size() == 0 ) + if( bufferPolys.GetCornersCount() == 0 ) continue; KI_POLYGON_SET currLayerPolyset; @@ -294,7 +295,7 @@ void EDA_3D_CANVAS::BuildBoard3DView() // Add holes in polygon list currLayerHoles.Append( allLayerHoles ); - if( currLayerHoles.size() > 0 ) + if( currLayerHoles.GetCornersCount() > 0 ) currLayerHoles.ExportTo( polysetHoles ); // Merge polygons, remove holes @@ -313,7 +314,7 @@ void EDA_3D_CANVAS::BuildBoard3DView() thickness, g_Parm_3D_Visu.m_BiuTo3Dunits ); - if( bufferZonesPolys.size() ) + if( bufferZonesPolys.GetCornersCount() ) Draw3D_SolidHorizontalPolyPolygons( bufferZonesPolys, zpos, thickness, g_Parm_3D_Visu.m_BiuTo3Dunits ); @@ -404,7 +405,7 @@ void EDA_3D_CANVAS::BuildBoard3DView() // bufferPolys contains polygons to merge. Many overlaps . // Calculate merged polygons and remove pads and vias holes - if( bufferPolys.size() == 0 ) + if( bufferPolys.GetCornersCount() == 0 ) continue; KI_POLYGON_SET currLayerPolyset; diff --git a/3d-viewer/3d_draw_basic_functions.cpp b/3d-viewer/3d_draw_basic_functions.cpp index 1e622062e9..bb08b572b3 100644 --- a/3d-viewer/3d_draw_basic_functions.cpp +++ b/3d-viewer/3d_draw_basic_functions.cpp @@ -96,11 +96,11 @@ static void Draw3D_VerticalPolygonalCylinder( const CPOLYGONS_LIST& aPolysList, // Draw the vertical polygonal side int startContour = 0; - for( unsigned ii = 0; ii < aPolysList.size(); ii++ ) + for( unsigned ii = 0; ii < aPolysList.GetCornersCount(); ii++ ) { unsigned jj = ii + 1; - if( aPolysList.IsEndContour( ii ) || jj >= aPolysList.size() ) + if( aPolysList.IsEndContour( ii ) || jj >= aPolysList.GetCornersCount() ) { jj = startContour; startContour = ii + 1; @@ -170,7 +170,7 @@ void Draw3D_SolidHorizontalPolyPolygons( const CPOLYGONS_LIST& aPolysList, { int startContour = 1; - for( unsigned ii = 0; ii < polylist.size(); ii++ ) + for( unsigned ii = 0; ii < polylist.GetCornersCount(); ii++ ) { if( startContour == 1 ) { diff --git a/common/convert_basic_shapes_to_polygon.cpp b/common/convert_basic_shapes_to_polygon.cpp index 1805d84bff..aa923b7dec 100644 --- a/common/convert_basic_shapes_to_polygon.cpp +++ b/common/convert_basic_shapes_to_polygon.cpp @@ -59,10 +59,10 @@ void TransformCircleToPolygon( CPOLYGONS_LIST& aCornerBuffer, RotatePoint( &corner_position.x, &corner_position.y, angle ); corner_position += aCenter; CPolyPt polypoint( corner_position.x, corner_position.y ); - aCornerBuffer.push_back( polypoint ); + aCornerBuffer.Append( polypoint ); } - aCornerBuffer.back().end_contour = true; + aCornerBuffer.CloseLastContour(); } @@ -112,7 +112,7 @@ void TransformRoundedEndsSegmentToPolygon( CPOLYGONS_LIST& aCornerBuffer, corner += startp; polypoint.x = corner.x; polypoint.y = corner.y; - aCornerBuffer.push_back( polypoint ); + aCornerBuffer.Append( polypoint ); } // Finish arc: @@ -121,7 +121,7 @@ void TransformRoundedEndsSegmentToPolygon( CPOLYGONS_LIST& aCornerBuffer, corner += startp; polypoint.x = corner.x; polypoint.y = corner.y; - aCornerBuffer.push_back( polypoint ); + aCornerBuffer.Append( polypoint ); // add left rounded end: for( int ii = 0; ii < 1800; ii += delta ) @@ -132,7 +132,7 @@ void TransformRoundedEndsSegmentToPolygon( CPOLYGONS_LIST& aCornerBuffer, corner += startp; polypoint.x = corner.x; polypoint.y = corner.y; - aCornerBuffer.push_back( polypoint ); + aCornerBuffer.Append( polypoint ); } // Finish arc: @@ -141,9 +141,9 @@ void TransformRoundedEndsSegmentToPolygon( CPOLYGONS_LIST& aCornerBuffer, corner += startp; polypoint.x = corner.x; polypoint.y = corner.y; - aCornerBuffer.push_back( polypoint ); + aCornerBuffer.Append( polypoint ); - aCornerBuffer.back().end_contour = true; + aCornerBuffer.CloseLastContour(); } @@ -229,13 +229,13 @@ void TransformRingToPolygon( CPOLYGONS_LIST& aCornerBuffer, curr_point += aCentre; polycorner.x = curr_point.x; polycorner.y = curr_point.y; - aCornerBuffer.push_back( polycorner ); + aCornerBuffer.Append( polycorner ); } // Draw the last point of inner circle polycorner.x = aCentre.x + inner_radius; polycorner.y = aCentre.y; - aCornerBuffer.push_back( polycorner ); + aCornerBuffer.Append( polycorner ); // Draw the outer circle of the ring for( int ii = 0; ii < 3600; ii += delta ) @@ -246,16 +246,16 @@ void TransformRingToPolygon( CPOLYGONS_LIST& aCornerBuffer, curr_point += aCentre; polycorner.x = curr_point.x; polycorner.y = curr_point.y; - aCornerBuffer.push_back( polycorner ); + aCornerBuffer.Append( polycorner ); } // Draw the last point of outer circle polycorner.x = aCentre.x + outer_radius; polycorner.y = aCentre.y; - aCornerBuffer.push_back( polycorner ); + aCornerBuffer.Append( polycorner ); // Close the polygon polycorner.x = aCentre.x + inner_radius; polycorner.end_contour = true; - aCornerBuffer.push_back( polycorner ); + aCornerBuffer.Append( polycorner ); } diff --git a/pcbnew/board_items_to_polygon_shape_transform.cpp b/pcbnew/board_items_to_polygon_shape_transform.cpp index 0d154cc3b9..0b2b40c336 100644 --- a/pcbnew/board_items_to_polygon_shape_transform.cpp +++ b/pcbnew/board_items_to_polygon_shape_transform.cpp @@ -137,7 +137,7 @@ void MODULE::TransformGraphicShapesWithClearanceToPolygonSet( RotatePoint( &corner.x, &corner.y, GetOrientation() ); corner.x += GetPosition().x; corner.y += GetPosition().y; - aCornerBuffer.push_back( corner ); + aCornerBuffer.Append( corner ); } aCornerBuffer.back().end_contour = true; break; @@ -170,7 +170,7 @@ void ZONE_CONTAINER::TransformSolidAreasShapesToPolygonSet( int aCircleToSegmentsCount, double aCorrectionFactor ) { - unsigned cornerscount = GetFilledPolysList().size(); + unsigned cornerscount = GetFilledPolysList().GetCornersCount(); CPOLYGONS_LIST polygonslist; if( cornerscount == 0 ) @@ -239,7 +239,7 @@ void TEXTE_PCB::TransformBoundingBoxWithClearanceToPolygon( { // Rotate polygon RotatePoint( &corners[ii].x, &corners[ii].y, m_Pos.x, m_Pos.y, m_Orient ); - aCornerBuffer.push_back( corners[ii] ); + aCornerBuffer.Append( corners[ii] ); } aCornerBuffer.back().end_contour = true; @@ -492,7 +492,7 @@ void D_PAD:: TransformShapeWithClearanceToPolygon( CPOLYGONS_LIST& aCornerBuffer // Rotate according to module orientation corner_position += PadShapePos; // Shift origin to position CPolyPt polypoint( corner_position.x, corner_position.y ); - aCornerBuffer.push_back( polypoint ); + aCornerBuffer.Append( polypoint ); } for( int i = 0; i < aCircleToSegmentsCount / 4 + 1; i++ ) @@ -505,7 +505,7 @@ void D_PAD:: TransformShapeWithClearanceToPolygon( CPOLYGONS_LIST& aCornerBuffer RotatePoint( &corner_position, angle ); corner_position += PadShapePos; CPolyPt polypoint( corner_position.x, corner_position.y ); - aCornerBuffer.push_back( polypoint ); + aCornerBuffer.Append( polypoint ); } for( int i = 0; i < aCircleToSegmentsCount / 4 + 1; i++ ) @@ -518,7 +518,7 @@ void D_PAD:: TransformShapeWithClearanceToPolygon( CPOLYGONS_LIST& aCornerBuffer RotatePoint( &corner_position, angle ); corner_position += PadShapePos; CPolyPt polypoint( corner_position.x, corner_position.y ); - aCornerBuffer.push_back( polypoint ); + aCornerBuffer.Append( polypoint ); } for( int i = 0; i < aCircleToSegmentsCount / 4 + 1; i++ ) @@ -531,10 +531,10 @@ void D_PAD:: TransformShapeWithClearanceToPolygon( CPOLYGONS_LIST& aCornerBuffer RotatePoint( &corner_position, angle ); corner_position += PadShapePos; CPolyPt polypoint( corner_position.x, corner_position.y ); - aCornerBuffer.push_back( polypoint ); + aCornerBuffer.Append( polypoint ); } - aCornerBuffer.back().end_contour = true; + aCornerBuffer.CloseLastContour(); break; } } @@ -569,10 +569,10 @@ void D_PAD::BuildPadShapePolygon( CPOLYGONS_LIST& aCornerBuffer, { corners[ii] += PadShapePos; // Shift origin to position CPolyPt polypoint( corners[ii].x, corners[ii].y ); - aCornerBuffer.push_back( polypoint ); + aCornerBuffer.Append( polypoint ); } - aCornerBuffer.back().end_contour = true; + aCornerBuffer.CloseLastContour(); break; } } @@ -768,10 +768,10 @@ void CreateThermalReliefPadPolygon( CPOLYGONS_LIST& aCornerBuffer, corner = corners_buffer[ii]; RotatePoint( &corner, th_angle + angle_pad ); // Rotate by segment angle and pad orientation corner += PadShapePos; - aCornerBuffer.push_back( CPolyPt( corner.x, corner.y ) ); + aCornerBuffer.Append( CPolyPt( corner.x, corner.y ) ); } - aCornerBuffer.back().end_contour = true; + aCornerBuffer.CloseLastContour(); th_angle += 900; // Note: th_angle in in 0.1 deg. } } @@ -872,7 +872,7 @@ void CreateThermalReliefPadPolygon( CPOLYGONS_LIST& aCornerBuffer, wxPoint cpos = corners_buffer[ic]; RotatePoint( &cpos, angle ); cpos += PadShapePos; - aCornerBuffer.push_back( CPolyPt( cpos.x, cpos.y ) ); + aCornerBuffer.Append( CPolyPt( cpos.x, cpos.y ) ); } aCornerBuffer.back().end_contour = true; @@ -897,7 +897,7 @@ void CreateThermalReliefPadPolygon( CPOLYGONS_LIST& aCornerBuffer, wxPoint cpos = corners_buffer[ic]; RotatePoint( &cpos, angle ); cpos += PadShapePos; - aCornerBuffer.push_back( CPolyPt( cpos.x, cpos.y ) ); + aCornerBuffer.Append( CPolyPt( cpos.x, cpos.y ) ); } aCornerBuffer.back().end_contour = true; @@ -970,10 +970,10 @@ void CreateThermalReliefPadPolygon( CPOLYGONS_LIST& aCornerBuffer, wxPoint cpos = corners_buffer[ic]; RotatePoint( &cpos, angle ); // Rotate according to module orientation cpos += PadShapePos; // Shift origin to position - aCornerBuffer.push_back( CPolyPt( cpos.x, cpos.y ) ); + aCornerBuffer.Append( CPolyPt( cpos.x, cpos.y ) ); } - aCornerBuffer.back().end_contour = true; + aCornerBuffer.CloseLastContour(); angle = AddAngles( angle, 1800 ); // this is calculate hole 3 } @@ -993,10 +993,10 @@ void CreateThermalReliefPadPolygon( CPOLYGONS_LIST& aCornerBuffer, wxPoint cpos = corners_buffer[ic]; RotatePoint( &cpos, angle ); cpos += PadShapePos; - aCornerBuffer.push_back( CPolyPt( cpos.x, cpos.y ) ); + aCornerBuffer.Append( CPolyPt( cpos.x, cpos.y ) ); } - aCornerBuffer.back().end_contour = true; + aCornerBuffer.CloseLastContour(); angle = AddAngles( angle, 1800 ); } diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp index 0082296d65..65385ec9ee 100644 --- a/pcbnew/class_zone.cpp +++ b/pcbnew/class_zone.cpp @@ -120,7 +120,8 @@ EDA_ITEM* ZONE_CONTAINER::Clone() const bool ZONE_CONTAINER::UnFill() { - bool change = ( m_FilledPolysList.size() > 0 ) || ( m_FillSegmList.size() > 0 ); + bool change = ( m_FilledPolysList.GetCornersCount() > 0 ) || + ( m_FillSegmList.size() > 0 ); m_FilledPolysList.clear(); m_FillSegmList.clear(); @@ -250,7 +251,7 @@ void ZONE_CONTAINER::DrawFilledArea( EDA_DRAW_PANEL* panel, if( DisplayOpt.DisplayZonesMode == 1 ) // Do not show filled areas return; - if( m_FilledPolysList.size() == 0 ) // Nothing to draw + if( m_FilledPolysList.GetCornersCount() == 0 ) // Nothing to draw return; BOARD* brd = GetBoard(); @@ -279,7 +280,7 @@ void ZONE_CONTAINER::DrawFilledArea( EDA_DRAW_PANEL* panel, CornersBuffer.clear(); // Draw all filled areas - int imax = m_FilledPolysList.size() - 1; + int imax = m_FilledPolysList.GetCornersCount() - 1; for( int ic = 0; ic <= imax; ic++ ) { @@ -490,7 +491,7 @@ bool ZONE_CONTAINER::HitTestForCorner( const wxPoint& refPos ) int min_dist = MIN_DIST_IN_MILS*IU_PER_MILS; wxPoint delta; - unsigned lim = m_Poly->m_CornersList.size(); + unsigned lim = m_Poly->m_CornersList.GetCornersCount(); for( unsigned item_pos = 0; item_pos < lim; item_pos++ ) { @@ -513,7 +514,7 @@ bool ZONE_CONTAINER::HitTestForCorner( const wxPoint& refPos ) bool ZONE_CONTAINER::HitTestForEdge( const wxPoint& refPos ) { - unsigned lim = m_Poly->m_CornersList.size(); + unsigned lim = m_Poly->m_CornersList.GetCornersCount(); m_CornerSelection = -1; // Set to not found @@ -610,7 +611,7 @@ bool ZONE_CONTAINER::HitTestFilledArea( const wxPoint& aRefPos ) const unsigned indexstart = 0, indexend; bool inside = false; - for( indexend = 0; indexend < m_FilledPolysList.size(); indexend++ ) + for( indexend = 0; indexend < m_FilledPolysList.GetCornersCount(); indexend++ ) { if( m_FilledPolysList.IsEndContour( indexend ) ) // end of a filled sub-area found { @@ -701,7 +702,7 @@ void ZONE_CONTAINER::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), GetLayerName(), BROWN ) ); - msg.Printf( wxT( "%d" ), (int) m_Poly->m_CornersList.size() ); + msg.Printf( wxT( "%d" ), (int) m_Poly->m_CornersList.GetCornersCount() ); aList.push_back( MSG_PANEL_ITEM( _( "Corners" ), msg, BLUE ) ); if( m_FillMode ) @@ -715,9 +716,9 @@ void ZONE_CONTAINER::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) msg.Printf( wxT( "%d" ), (int) m_Poly->m_HatchLines.size() ); aList.push_back( MSG_PANEL_ITEM( _( "Hatch lines" ), msg, BLUE ) ); - if( m_FilledPolysList.size() ) + if( m_FilledPolysList.GetCornersCount() ) { - msg.Printf( wxT( "%d" ), (int) m_FilledPolysList.size() ); + msg.Printf( wxT( "%d" ), (int) m_FilledPolysList.GetCornersCount() ); aList.push_back( MSG_PANEL_ITEM( _( "Corners in DrawList" ), msg, BLUE ) ); } } @@ -728,7 +729,7 @@ void ZONE_CONTAINER::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) void ZONE_CONTAINER::Move( const wxPoint& offset ) { /* move outlines */ - for( unsigned ii = 0; ii < m_Poly->m_CornersList.size(); ii++ ) + for( unsigned ii = 0; ii < m_Poly->m_CornersList.GetCornersCount(); ii++ ) { SetCornerPosition( ii, GetCornerPosition( ii ) + offset ); } @@ -736,7 +737,7 @@ void ZONE_CONTAINER::Move( const wxPoint& offset ) m_Poly->Hatch(); /* move filled areas: */ - for( unsigned ic = 0; ic < m_FilledPolysList.size(); ic++ ) + for( unsigned ic = 0; ic < m_FilledPolysList.GetCornersCount(); ic++ ) { m_FilledPolysList.SetX( ic, m_FilledPolysList.GetX( ic ) + offset.x ); m_FilledPolysList.SetY( ic, m_FilledPolysList.GetX( ic ) + offset.y ); @@ -778,7 +779,7 @@ void ZONE_CONTAINER::Rotate( const wxPoint& centre, double angle ) { wxPoint pos; - for( unsigned ic = 0; ic < m_Poly->m_CornersList.size(); ic++ ) + for( unsigned ic = 0; ic < m_Poly->m_CornersList.GetCornersCount(); ic++ ) { pos = m_Poly->m_CornersList.GetPos( ic ); RotatePoint( &pos, centre, angle ); @@ -789,7 +790,7 @@ void ZONE_CONTAINER::Rotate( const wxPoint& centre, double angle ) m_Poly->Hatch(); /* rotate filled areas: */ - for( unsigned ic = 0; ic < m_FilledPolysList.size(); ic++ ) + for( unsigned ic = 0; ic < m_FilledPolysList.GetCornersCount(); ic++ ) { pos = m_FilledPolysList.GetPos( ic ); RotatePoint( &pos, centre, angle ); @@ -814,7 +815,7 @@ void ZONE_CONTAINER::Flip( const wxPoint& aCentre ) void ZONE_CONTAINER::Mirror( const wxPoint& mirror_ref ) { - for( unsigned ic = 0; ic < m_Poly->m_CornersList.size(); ic++ ) + for( unsigned ic = 0; ic < m_Poly->m_CornersList.GetCornersCount(); ic++ ) { int py = m_Poly->m_CornersList.GetY( ic ) - mirror_ref.y; NEGATE( py ); @@ -824,7 +825,7 @@ void ZONE_CONTAINER::Mirror( const wxPoint& mirror_ref ) m_Poly->Hatch(); /* mirror filled areas: */ - for( unsigned ic = 0; ic < m_FilledPolysList.size(); ic++ ) + for( unsigned ic = 0; ic < m_FilledPolysList.GetCornersCount(); ic++ ) { int py = m_FilledPolysList.GetY( ic ) - mirror_ref.y; NEGATE( py ); diff --git a/pcbnew/class_zone.h b/pcbnew/class_zone.h index 3a84b3ba5c..fcdefe5898 100644 --- a/pcbnew/class_zone.h +++ b/pcbnew/class_zone.h @@ -449,7 +449,7 @@ public: int GetNumCorners( void ) const { - return m_Poly->GetNumCorners(); + return m_Poly->GetCornersCount(); } void RemoveAllContours( void ) diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp index 20eb72a3a9..7e50e8f82a 100644 --- a/pcbnew/kicad_plugin.cpp +++ b/pcbnew/kicad_plugin.cpp @@ -1398,12 +1398,12 @@ void PCB_IO::format( ZONE_CONTAINER* aZone, int aNestLevel ) const const CPOLYGONS_LIST& cv = aZone->Outline()->m_CornersList; int newLine = 0; - if( cv.size() ) + if( cv.GetCornersCount() ) { m_out->Print( aNestLevel+1, "(polygon\n"); m_out->Print( aNestLevel+2, "(pts\n" ); - for( unsigned it = 0; it < cv.size(); ++it ) + for( unsigned it = 0; it < cv.GetCornersCount(); ++it ) { if( newLine == 0 ) m_out->Print( aNestLevel+3, "(xy %s %s)", @@ -1429,7 +1429,7 @@ void PCB_IO::format( ZONE_CONTAINER* aZone, int aNestLevel ) const m_out->Print( aNestLevel+2, ")\n" ); - if( it+1 != cv.size() ) + if( it+1 != cv.GetCornersCount() ) { newLine = 0; m_out->Print( aNestLevel+1, ")\n" ); @@ -1446,12 +1446,12 @@ void PCB_IO::format( ZONE_CONTAINER* aZone, int aNestLevel ) const const CPOLYGONS_LIST& fv = aZone->GetFilledPolysList(); newLine = 0; - if( fv.size() ) + if( fv.GetCornersCount() ) { m_out->Print( aNestLevel+1, "(filled_polygon\n" ); m_out->Print( aNestLevel+2, "(pts\n" ); - for( unsigned it = 0; it < fv.size(); ++it ) + for( unsigned it = 0; it < fv.GetCornersCount(); ++it ) { if( newLine == 0 ) m_out->Print( aNestLevel+3, "(xy %s %s)", @@ -1477,7 +1477,7 @@ void PCB_IO::format( ZONE_CONTAINER* aZone, int aNestLevel ) const m_out->Print( aNestLevel+2, ")\n" ); - if( it+1 != fv.size() ) + if( it+1 != fv.GetCornersCount() ) { newLine = 0; m_out->Print( aNestLevel+1, ")\n" ); diff --git a/pcbnew/legacy_plugin.cpp b/pcbnew/legacy_plugin.cpp index 091b9f7176..dc7c46bb9a 100644 --- a/pcbnew/legacy_plugin.cpp +++ b/pcbnew/legacy_plugin.cpp @@ -2360,7 +2360,7 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER() bool end_contour = intParse( data, &data ); // end_countour was a bool when file saved, so '0' or '1' here int cornerUtilityFlg = intParse( data ); - polysList.push_back( CPolyPt( x, y, end_contour, cornerUtilityFlg ) ); + polysList.Append( CPolyPt( x, y, end_contour, cornerUtilityFlg ) ); } zc->AddFilledPolysList( polysList ); } @@ -3693,7 +3693,7 @@ void LEGACY_PLUGIN::saveZONE_CONTAINER( const ZONE_CONTAINER* me ) const // Save the corner list const CPOLYGONS_LIST& cv = me->Outline()->m_CornersList; - for( unsigned it = 0; it < cv.size(); ++it ) + for( unsigned it = 0; it < cv.GetCornersCount(); ++it ) { fprintf( m_fp, "ZCorner %s %d\n", fmtBIUPair( cv.GetX( it ), cv.GetY( it ) ).c_str(), @@ -3702,11 +3702,11 @@ void LEGACY_PLUGIN::saveZONE_CONTAINER( const ZONE_CONTAINER* me ) const // Save the PolysList const CPOLYGONS_LIST& fv = me->GetFilledPolysList(); - if( fv.size() ) + if( fv.GetCornersCount() ) { fprintf( m_fp, "$POLYSCORNERS\n" ); - for( unsigned it = 0; it < fv.size(); ++it ) + for( unsigned it = 0; it < fv.GetCornersCount(); ++it ) { fprintf( m_fp, "%s %d %d\n", fmtBIUPair( fv.GetX( it ), fv.GetY( it ) ).c_str(), diff --git a/pcbnew/onrightclick.cpp b/pcbnew/onrightclick.cpp index 538368545d..183ffe5c0c 100644 --- a/pcbnew/onrightclick.cpp +++ b/pcbnew/onrightclick.cpp @@ -665,7 +665,7 @@ void PCB_EDIT_FRAME::createPopUpMenuForZones( ZONE_CONTAINER* edge_zone, wxMenu* AddMenuItem( zones_menu, ID_POPUP_PCB_FILL_ZONE, _( "Fill Zone" ), KiBitmap( fill_zone_xpm ) ); - if( edge_zone->GetFilledPolysList().size() > 0 ) + if( edge_zone->GetFilledPolysList().GetCornersCount() > 0 ) { AddMenuItem( zones_menu, ID_POPUP_PCB_REMOVE_FILLED_AREAS_IN_CURRENT_ZONE, _( "Remove Filled Areas in Zone" ), KiBitmap( zone_unfill_xpm ) ); diff --git a/pcbnew/pcb_parser.cpp b/pcbnew/pcb_parser.cpp index 353ca582af..efcb0f49ad 100644 --- a/pcbnew/pcb_parser.cpp +++ b/pcbnew/pcb_parser.cpp @@ -2614,11 +2614,11 @@ ZONE_CONTAINER* PCB_PARSER::parseZONE_CONTAINER() throw( IO_ERROR, PARSE_ERROR ) for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { - pts.push_back( CPolyPt( parseXY() ) ); + pts.Append( CPolyPt( parseXY() ) ); } NeedRIGHT(); - pts.back().end_contour = true; + pts.CloseLastContour(); } break; @@ -2665,7 +2665,7 @@ ZONE_CONTAINER* PCB_PARSER::parseZONE_CONTAINER() throw( IO_ERROR, PARSE_ERROR ) zone->Outline()->SetHatch( hatchStyle, hatchPitch, true ); } - if( pts.size() ) + if( pts.GetCornersCount() ) zone->AddFilledPolysList( pts ); // Ensure keepout does not have a net (which have no sense for a keepout zone) diff --git a/pcbnew/pcb_plot_params.cpp b/pcbnew/pcb_plot_params.cpp index 52a239938b..7c4bf15ed3 100644 --- a/pcbnew/pcb_plot_params.cpp +++ b/pcbnew/pcb_plot_params.cpp @@ -2,7 +2,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 1992-2011 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 1992-2013 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 @@ -33,6 +33,7 @@ #define PLOT_LINEWIDTH_MIN (0.02*IU_PER_MM) // min value for default line thickness #define PLOT_LINEWIDTH_MAX (2*IU_PER_MM) // max value for default line thickness +#define PLOT_LINEWIDTH_DEFAULT (0.15*IU_PER_MM) // def. value for default line thickness #define HPGL_PEN_DIAMETER_MIN 0 #define HPGL_PEN_DIAMETER_MAX 100 // Unit = mil #define HPGL_PEN_SPEED_MIN 1 // this param is always in cm/s @@ -47,7 +48,7 @@ * Default line thickness in internal units used to draw or plot items using a * default thickness line value (Frame references) */ -int g_DrawDefaultLineThickness = (0.15*IU_PER_MM); +int g_DrawDefaultLineThickness = PLOT_LINEWIDTH_DEFAULT; using namespace PCBPLOTPARAMS_T; @@ -132,8 +133,8 @@ void PCB_PLOT_PARAMS::Format( OUTPUTFORMATTER* aFormatter, m_useGerberExtensions ? trueStr : falseStr ); aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_excludeedgelayer ), m_excludeEdgeLayer ? trueStr : falseStr ); - aFormatter->Print( aNestLevel+1, "(%s %d)\n", getTokenName( T_linewidth ), - m_lineWidth ); + aFormatter->Print( aNestLevel+1, "(%s %f)\n", getTokenName( T_linewidth ), + m_lineWidth / IU_PER_MM ); aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_plotframeref ), m_plotFrameRef ? trueStr : falseStr ); aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_viasonmask ), @@ -332,83 +333,89 @@ void PCB_PLOT_PARAMS_PARSER::Parse( PCB_PLOT_PARAMS* aPcbPlotParams ) aPcbPlotParams->m_layerSelection = atol( CurText() ); break; case T_usegerberextensions: - aPcbPlotParams->m_useGerberExtensions = ParseBool(); + aPcbPlotParams->m_useGerberExtensions = parseBool(); break; case T_psa4output: - aPcbPlotParams->m_A4Output = ParseBool(); + aPcbPlotParams->m_A4Output = parseBool(); break; case T_excludeedgelayer: - aPcbPlotParams->m_excludeEdgeLayer = ParseBool(); + aPcbPlotParams->m_excludeEdgeLayer = parseBool(); break; case T_linewidth: - aPcbPlotParams->m_lineWidth = ParseInt( PLOT_LINEWIDTH_MIN, - PLOT_LINEWIDTH_MAX ); + { + // Due to a bug, this (minor) parameter was saved in biu + // and now is saved in mm + // If the read value is outside bounds, force a default value + double tmp = parseDouble(); + if( !aPcbPlotParams->SetLineWidth( KiROUND( tmp * IU_PER_MM ) ) ) + aPcbPlotParams->SetLineWidth( PLOT_LINEWIDTH_DEFAULT ); + } break; case T_plotframeref: - aPcbPlotParams->m_plotFrameRef = ParseBool(); + aPcbPlotParams->m_plotFrameRef = parseBool(); break; case T_viasonmask: - aPcbPlotParams->m_plotViaOnMaskLayer = ParseBool(); + aPcbPlotParams->m_plotViaOnMaskLayer = parseBool(); break; case T_mode: - aPcbPlotParams->m_mode = static_cast( ParseInt( 0, 2 ) ); + aPcbPlotParams->m_mode = static_cast( parseInt( 0, 2 ) ); break; case T_useauxorigin: - aPcbPlotParams->m_useAuxOrigin = ParseBool(); + aPcbPlotParams->m_useAuxOrigin = parseBool(); break; case T_hpglpennumber: - aPcbPlotParams->m_HPGLPenNum = ParseInt( HPGL_PEN_NUMBER_MIN, + aPcbPlotParams->m_HPGLPenNum = parseInt( HPGL_PEN_NUMBER_MIN, HPGL_PEN_NUMBER_MAX ); break; case T_hpglpenspeed: - aPcbPlotParams->m_HPGLPenSpeed = ParseInt( HPGL_PEN_SPEED_MIN, + aPcbPlotParams->m_HPGLPenSpeed = parseInt( HPGL_PEN_SPEED_MIN, HPGL_PEN_SPEED_MAX ); break; case T_hpglpendiameter: - aPcbPlotParams->m_HPGLPenDiam = ParseInt( HPGL_PEN_DIAMETER_MIN, + aPcbPlotParams->m_HPGLPenDiam = parseInt( HPGL_PEN_DIAMETER_MIN, HPGL_PEN_DIAMETER_MAX ); break; case T_hpglpenoverlay: - aPcbPlotParams->m_HPGLPenOvr = ParseInt( HPGL_PEN_OVERLAP_MIN, + aPcbPlotParams->m_HPGLPenOvr = parseInt( HPGL_PEN_OVERLAP_MIN, HPGL_PEN_OVERLAP_MAX ); break; case T_pscolor: NeedSYMBOL(); // This actually was never used... break; case T_psnegative: - aPcbPlotParams->m_negative = ParseBool(); + aPcbPlotParams->m_negative = parseBool(); break; case T_plotreference: - aPcbPlotParams->m_plotReference = ParseBool(); + aPcbPlotParams->m_plotReference = parseBool(); break; case T_plotvalue: - aPcbPlotParams->m_plotValue = ParseBool(); + aPcbPlotParams->m_plotValue = parseBool(); break; case T_plotothertext: - aPcbPlotParams->m_plotOtherText = ParseBool(); + aPcbPlotParams->m_plotOtherText = parseBool(); break; case T_plotinvisibletext: - aPcbPlotParams->m_plotInvisibleText = ParseBool(); + aPcbPlotParams->m_plotInvisibleText = parseBool(); break; case T_padsonsilk: - aPcbPlotParams->m_plotPadsOnSilkLayer= ParseBool(); + aPcbPlotParams->m_plotPadsOnSilkLayer= parseBool(); break; case T_subtractmaskfromsilk: - aPcbPlotParams->m_subtractMaskFromSilk = ParseBool(); + aPcbPlotParams->m_subtractMaskFromSilk = parseBool(); break; case T_outputformat: aPcbPlotParams->m_format = static_cast( - ParseInt( PLOT_FIRST_FORMAT, PLOT_LAST_FORMAT ) ); + parseInt( PLOT_FIRST_FORMAT, PLOT_LAST_FORMAT ) ); break; case T_mirror: - aPcbPlotParams->m_mirror = ParseBool(); + aPcbPlotParams->m_mirror = parseBool(); break; case T_drillshape: aPcbPlotParams->m_drillMarks = static_cast - ( ParseInt( 0, 2 ) ); + ( parseInt( 0, 2 ) ); break; case T_scaleselection: - aPcbPlotParams->m_scaleSelection = ParseInt( 0, 4 ); + aPcbPlotParams->m_scaleSelection = parseInt( 0, 4 ); break; case T_outputdirectory: NeedSYMBOL(); @@ -423,7 +430,7 @@ void PCB_PLOT_PARAMS_PARSER::Parse( PCB_PLOT_PARAMS* aPcbPlotParams ) } -bool PCB_PLOT_PARAMS_PARSER::ParseBool() +bool PCB_PLOT_PARAMS_PARSER::parseBool() { T token = NeedSYMBOL(); @@ -434,7 +441,7 @@ bool PCB_PLOT_PARAMS_PARSER::ParseBool() } -int PCB_PLOT_PARAMS_PARSER::ParseInt( int aMin, int aMax ) +int PCB_PLOT_PARAMS_PARSER::parseInt( int aMin, int aMax ) { T token = NextTok(); @@ -450,3 +457,16 @@ int PCB_PLOT_PARAMS_PARSER::ParseInt( int aMin, int aMax ) return val; } + + +double PCB_PLOT_PARAMS_PARSER::parseDouble() +{ + T token = NextTok(); + + if( token != T_NUMBER ) + Expecting( T_NUMBER ); + + double val = strtod( CurText(), NULL ); + + return val; +} diff --git a/pcbnew/pcb_plot_params.h b/pcbnew/pcb_plot_params.h index 737032bbbb..6e314352e0 100644 --- a/pcbnew/pcb_plot_params.h +++ b/pcbnew/pcb_plot_params.h @@ -46,16 +46,25 @@ public: LINE_READER* GetReader() { return reader; }; void Parse( PCB_PLOT_PARAMS* aPcbPlotParams ) throw( PARSE_ERROR, IO_ERROR ); - bool ParseBool(); + +private: + bool parseBool(); /** - * Function ParseInt + * Function parseInt * parses an integer and constrains it between two values. * @param aMin is the smallest return value. * @param aMax is the largest return value. * @return int - the parsed integer. */ - int ParseInt( int aMin, int aMax ); + int parseInt( int aMin, int aMax ); + + /** + * Function parseDouble + * parses a double + * @return double - the parsed double. + */ + double parseDouble(); }; diff --git a/pcbnew/plot_brditems_plotter.cpp b/pcbnew/plot_brditems_plotter.cpp index 02c8a5f771..1922a20091 100644 --- a/pcbnew/plot_brditems_plotter.cpp +++ b/pcbnew/plot_brditems_plotter.cpp @@ -509,7 +509,7 @@ void BRDITEMS_PLOTTER::PlotTextePcb( TEXTE_PCB* pt_texte ) void BRDITEMS_PLOTTER::PlotFilledAreas( ZONE_CONTAINER* aZone ) { const CPOLYGONS_LIST& polysList = aZone->GetFilledPolysList(); - unsigned imax = polysList.size(); + unsigned imax = polysList.GetCornersCount(); if( imax == 0 ) // Nothing to draw return; diff --git a/pcbnew/specctra_export.cpp b/pcbnew/specctra_export.cpp index 5e85cd9628..40393e5e5c 100644 --- a/pcbnew/specctra_export.cpp +++ b/pcbnew/specctra_export.cpp @@ -1502,7 +1502,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard ) throw( IO_ERROR ) mainPolygon->layer_id = layerIds[ kicadLayer2pcb[ item->GetLayer() ] ]; - int count = item->Outline()->m_CornersList.size(); + int count = item->Outline()->m_CornersList.GetCornersCount(); int ndx = 0; // used in 2 for() loops below for( ; ndxlayer_id = layerIds[ kicadLayer2pcb[ item->GetLayer() ] ]; - int count = item->Outline()->m_CornersList.size(); + int count = item->Outline()->m_CornersList.GetCornersCount(); int ndx = 0; // used in 2 for() loops below for( ; ndxOutline()->GetNumCorners() <= 3 ) + if( aZone->Outline()->GetCornersCount() <= 3 ) { m_canvas->RefreshDrawingRect( aZone->GetBoundingBox() ); diff --git a/pcbnew/zones_convert_brd_items_to_polygons_with_Boost.cpp b/pcbnew/zones_convert_brd_items_to_polygons_with_Boost.cpp index 5418c55220..ef67888701 100644 --- a/pcbnew/zones_convert_brd_items_to_polygons_with_Boost.cpp +++ b/pcbnew/zones_convert_brd_items_to_polygons_with_Boost.cpp @@ -414,7 +414,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) // cornerBufferPolysToSubstract contains polygons to substract. // polyset_zone_solid_areas contains the main filled area // Calculate now actual solid areas - if( cornerBufferPolysToSubstract.size() > 0 ) + if( cornerBufferPolysToSubstract.GetCornersCount() > 0 ) { KI_POLYGON_SET polyset_holes; cornerBufferPolysToSubstract.ExportTo( polyset_holes ); @@ -440,7 +440,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) s_Correction, s_thermalRot ); // remove copper areas corresponding to not connected stubs - if( cornerBufferPolysToSubstract.size() ) + if( cornerBufferPolysToSubstract.GetCornersCount() ) { KI_POLYGON_SET polyset_holes; cornerBufferPolysToSubstract.ExportTo( polyset_holes ); diff --git a/pcbnew/zones_convert_to_polygons_aux_functions.cpp b/pcbnew/zones_convert_to_polygons_aux_functions.cpp index 9498cffbec..f570ebdd4b 100644 --- a/pcbnew/zones_convert_to_polygons_aux_functions.cpp +++ b/pcbnew/zones_convert_to_polygons_aux_functions.cpp @@ -68,7 +68,7 @@ void ZONE_CONTAINER::TransformOutlinesShapeWithClearanceToPolygon( KI_POLYGON_SET polyset_zone_solid_areas; std::vector cornerslist; unsigned ic = 0; - unsigned corners_count = zoneOutines.size(); + unsigned corners_count = zoneOutines.GetCornersCount(); while( ic < corners_count ) { cornerslist.clear(); @@ -104,10 +104,10 @@ void ZONE_CONTAINER::TransformOutlinesShapeWithClearanceToPolygon( corner.x = point.x(); corner.y = point.y(); corner.end_contour = false; - aCornerBuffer.push_back( corner ); + aCornerBuffer.Append( corner ); } - aCornerBuffer.back().end_contour = true; + aCornerBuffer.CloseLastContour(); } } @@ -284,8 +284,8 @@ void BuildUnconnectedThermalStubsPolygonList( CPOLYGONS_LIST& aCornerBuffer, CPolyPt corner; corner.x = cpos.x; corner.y = cpos.y; - corner.end_contour = ( ic < (corners_buffer.size() - 1) ) ? 0 : 1; - aCornerBuffer.push_back( corner ); + corner.end_contour = ( ic < (corners_buffer.size() - 1) ) ? false : true; + aCornerBuffer.Append( corner ); } } } diff --git a/pcbnew/zones_polygons_insulated_copper_islands.cpp b/pcbnew/zones_polygons_insulated_copper_islands.cpp index 214508d9f9..c2154ae5dc 100644 --- a/pcbnew/zones_polygons_insulated_copper_islands.cpp +++ b/pcbnew/zones_polygons_insulated_copper_islands.cpp @@ -40,7 +40,7 @@ void ZONE_CONTAINER::TestForCopperIslandAndRemoveInsulatedIslands( BOARD* aPcb ) { - if( m_FilledPolysList.size() == 0 ) + if( m_FilledPolysList.GetCornersCount() == 0 ) return; // Build a list of points connected to the net: @@ -79,7 +79,7 @@ void ZONE_CONTAINER::TestForCopperIslandAndRemoveInsulatedIslands( BOARD* aPcb ) unsigned indexstart = 0, indexend; bool connected = false; - for( indexend = 0; indexend < m_FilledPolysList.size(); indexend++ ) + for( indexend = 0; indexend < m_FilledPolysList.GetCornersCount(); indexend++ ) { if( m_FilledPolysList[indexend].end_contour ) // end of a filled sub-area found { diff --git a/pcbnew/zones_polygons_test_connections.cpp b/pcbnew/zones_polygons_test_connections.cpp index 6b0bd80582..ccc91634e2 100644 --- a/pcbnew/zones_polygons_test_connections.cpp +++ b/pcbnew/zones_polygons_test_connections.cpp @@ -51,7 +51,8 @@ void Merge_SubNets_Connected_By_CopperAreas( BOARD* aPcb, int aNetcode ); bool sort_areas( const ZONE_CONTAINER* ref, const ZONE_CONTAINER* tst ) { if( ref->GetNet() == tst->GetNet() ) - return ref->GetFilledPolysList().size() < tst->GetFilledPolysList().size(); + return ref->GetFilledPolysList().GetCornersCount() < + tst->GetFilledPolysList().GetCornersCount(); else return ref->GetNet() < tst->GetNet(); } @@ -94,7 +95,7 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode ) continue; if( (aNetcode >= 0) && ( aNetcode != curr_zone->GetNet() ) ) continue; - if( curr_zone->GetFilledPolysList().size() == 0 ) + if( curr_zone->GetFilledPolysList().GetCornersCount() == 0 ) continue; zones_candidates.push_back(curr_zone); } @@ -144,7 +145,7 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode ) // test if a candidate is inside a filled area of this zone unsigned indexstart = 0, indexend; const CPOLYGONS_LIST& polysList = curr_zone->GetFilledPolysList(); - for( indexend = 0; indexend < polysList.size(); indexend++ ) + for( indexend = 0; indexend < polysList.GetCornersCount(); indexend++ ) { // end of a filled sub-area found if( polysList.IsEndContour( indexend ) ) diff --git a/pcbnew/zones_test_and_combine_areas.cpp b/pcbnew/zones_test_and_combine_areas.cpp index 6896d355a7..b967f5cead 100644 --- a/pcbnew/zones_test_and_combine_areas.cpp +++ b/pcbnew/zones_test_and_combine_areas.cpp @@ -257,7 +257,7 @@ bool BOARD::TestAreaIntersection( ZONE_CONTAINER* area_ref, ZONE_CONTAINER* area // If a contour is inside an other contour, no segments intersects, but the zones // can be combined if a corner is inside an outline (only one corner is enought) - for( int ic2 = 0; ic2 < poly2->GetNumCorners(); ic2++ ) + for( int ic2 = 0; ic2 < poly2->GetCornersCount(); ic2++ ) { int x = poly2->GetX( ic2 ); int y = poly2->GetY( ic2 ); @@ -268,7 +268,7 @@ bool BOARD::TestAreaIntersection( ZONE_CONTAINER* area_ref, ZONE_CONTAINER* area } } - for( int ic1 = 0; ic1 < poly1->GetNumCorners(); ic1++ ) + for( int ic1 = 0; ic1 < poly1->GetCornersCount(); ic1++ ) { int x = poly1->GetX( ic1 ); int y = poly1->GetY( ic1 ); @@ -414,7 +414,7 @@ int BOARD::Test_Drc_Areas_Outlines_To_Areas_Outlines( ZONE_CONTAINER* aArea_To_E zone2zoneClearance = 1; // test for some corners of Area_Ref inside area_to_test - for( int ic = 0; ic < refSmoothedPoly->GetNumCorners(); ic++ ) + for( int ic = 0; ic < refSmoothedPoly->GetCornersCount(); ic++ ) { int x = refSmoothedPoly->GetX( ic ); int y = refSmoothedPoly->GetY( ic ); @@ -438,7 +438,7 @@ int BOARD::Test_Drc_Areas_Outlines_To_Areas_Outlines( ZONE_CONTAINER* aArea_To_E } // test for some corners of area_to_test inside Area_Ref - for( int ic2 = 0; ic2 < testSmoothedPoly->GetNumCorners(); ic2++ ) + for( int ic2 = 0; ic2 < testSmoothedPoly->GetCornersCount(); ic2++ ) { int x = testSmoothedPoly->GetX( ic2 ); int y = testSmoothedPoly->GetY( ic2 ); diff --git a/polygon/PolyLine.cpp b/polygon/PolyLine.cpp index 652cedeb2e..a50685233d 100644 --- a/polygon/PolyLine.cpp +++ b/polygon/PolyLine.cpp @@ -42,7 +42,7 @@ CPolyLine::~CPolyLine() int removed = 0; unsigned startcountour = 0; - for( unsigned icnt = 1; icnt < m_CornersList.size(); icnt ++ ) + for( unsigned icnt = 1; icnt < m_CornersList.GetCornersCount(); icnt ++ ) { unsigned last = icnt-1; if( m_CornersList[icnt].end_contour ) @@ -84,7 +84,7 @@ int CPolyLine::NormalizeAreaOutlines( std::vector* aNewPolygonList ) ClipperLib::Polygon raw_polygon; ClipperLib::Polygons normalized_polygons; - unsigned corners_count = m_CornersList.size(); + unsigned corners_count = m_CornersList.GetCornersCount(); KI_POLYGON_SET polysholes; KI_POLYGON_WITH_HOLES mainpoly; @@ -216,7 +216,7 @@ void CPolyLine::Start( LAYER_NUM layer, int x, int y, int hatch ) CPolyPt poly_pt( x, y ); poly_pt.end_contour = false; - m_CornersList.push_back( poly_pt ); + m_CornersList.Append( poly_pt ); } @@ -229,7 +229,7 @@ void CPolyLine::AppendCorner( int x, int y ) poly_pt.end_contour = false; // add entries for new corner - m_CornersList.push_back( poly_pt ); + m_CornersList.Append( poly_pt ); } // move corner of polyline @@ -535,16 +535,16 @@ void CPolyLine::InsertCorner( int ic, int x, int y ) { UnHatch(); - if( (unsigned) (ic) >= m_CornersList.size() ) + if( (unsigned) (ic) >= m_CornersList.GetCornersCount() ) { - m_CornersList.push_back( CPolyPt( x, y ) ); + m_CornersList.Append( CPolyPt( x, y ) ); } else { m_CornersList.InsertCorner(ic, CPolyPt( x, y ) ); } - if( (unsigned) (ic + 1) < m_CornersList.size() ) + if( (unsigned) (ic + 1) < m_CornersList.GetCornersCount() ) { if( m_CornersList[ic].end_contour ) { @@ -585,7 +585,7 @@ CRect CPolyLine::GetCornerBounds() r.left = r.bottom = INT_MAX; r.right = r.top = INT_MIN; - for( unsigned i = 0; i cornerslist; - corners_count = aPolysListWithHoles.size(); + corners_count = aPolysListWithHoles.GetCornersCount(); unsigned ic = 0; // enter main outline diff --git a/polygon/PolyLine.h b/polygon/PolyLine.h index 0dff5e88b9..d186f1ec43 100644 --- a/polygon/PolyLine.h +++ b/polygon/PolyLine.h @@ -118,8 +118,6 @@ public: // vector <> methods void reserve( int aSize ) { m_cornersList.reserve( aSize ); } void clear() { m_cornersList.clear(); } - unsigned size() const { return m_cornersList.size(); } - void push_back( const CPolyPt& aItem ) { m_cornersList.push_back( aItem ); } CPolyPt& back() { return m_cornersList.back(); } unsigned GetCornersCount() const { return m_cornersList.size(); } @@ -311,7 +309,11 @@ public: // access functions void SetLayer( LAYER_NUM aLayer ) { m_layer = aLayer; } LAYER_NUM GetLayer() const { return m_layer; } - int GetNumCorners() const; + + int GetCornersCount() const + { + return m_CornersList.GetCornersCount(); + } int GetClosed(); int GetContoursCount(); int GetContour( int ic );