PolyLine.h, Polyline.cpp: a bit of cleaning code: add comments in header, remove duplicate (and not used) method.

This commit is contained in:
jean-pierre charras 2015-06-03 12:35:21 +02:00
parent 8afeba3325
commit fc4352f082
2 changed files with 72 additions and 24 deletions

View File

@ -605,12 +605,6 @@ void CPolyLine::UnHatch()
}
int CPolyLine::GetEndContour( int ic )
{
return m_CornersList[ic].end_contour;
}
const EDA_RECT CPolyLine::GetBoundingBox()
{
int xmin = INT_MAX;
@ -659,18 +653,28 @@ const EDA_RECT CPolyLine::GetBoundingBox( int icont )
}
int CPolyLine::GetContoursCount()
int CPolyLine::GetContoursCount() const
{
int ncont = 0;
return m_CornersList.GetContoursCount();
}
if( !m_CornersList.GetCornersCount() )
int CPOLYGONS_LIST::GetContoursCount() const
{
if( !m_cornersList.size() )
return 0;
for( unsigned ic = 0; ic < m_CornersList.GetCornersCount(); ic++ )
if( m_CornersList[ic].end_contour )
// count the number of corners flagged end_contour
int ncont = 0;
for( unsigned ic = 0; ic < m_cornersList.size(); ic++ )
if( m_cornersList[ic].end_contour )
ncont++;
if( !m_CornersList[m_CornersList.GetCornersCount() - 1].end_contour )
// The last corner can be not yet flagged end_contour.
// It was not counted, but the polygon exists, so count it
if( !m_cornersList[m_cornersList.size() - 1].end_contour )
ncont++;
return ncont;
@ -746,10 +750,10 @@ int CPolyLine::GetContourSize( int icont )
}
int CPolyLine::GetClosed()
bool CPolyLine::GetClosed()
{
if( m_CornersList.GetCornersCount() == 0 )
return 0;
return false;
else
return m_CornersList[m_CornersList.GetCornersCount() - 1].end_contour;
}
@ -795,7 +799,7 @@ void CPolyLine::Hatch()
max_y = m_CornersList[ic].y;
}
// Calculate spacing betwwen 2 hatch lines
// Calculate spacing between 2 hatch lines
int spacing;
if( m_hatchStyle == DIAGONAL_EDGE )
@ -1639,7 +1643,7 @@ void ConvertPolysListWithHolesToOnePolygon( const CPOLYGONS_LIST& aPolysListWith
bool CPolyLine::IsPolygonSelfIntersecting()
{
// first, check for sides intersecting other sides
int n_cont = GetContoursCount();
int n_cont = GetContoursCount();
// make bounding rect for each contour
std::vector<EDA_RECT> cr;

View File

@ -4,10 +4,10 @@
* Few parts of this code come from FreePCB, released under the GNU General Public License V2.
* (see http://www.freepcb.com/ )
*
* Copyright (C) 2012-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2012-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008-2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2008-2013 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2012-2014 KiCad Developers, see CHANGELOG.TXT for contributors.
* Copyright (C) 2012-2015 KiCad Developers, see CHANGELOG.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
@ -206,6 +206,13 @@ public:
m_cornersList.back().end_contour = true;
}
/**
* Function GetContoursCount.
* @return the number of polygons stored in list
* (number of corners flagged "end_contour"
*/
int GetContoursCount() const;
/**
* Function ExportTo
* Copy all contours to a KI_POLYGON_SET, each contour is exported
@ -387,22 +394,59 @@ public:
{
return m_CornersList.GetCornersCount();
}
int GetClosed();
int GetContoursCount();
/**
* @return true if the last corner in corners list is flagged end_contour
*/
bool GetClosed();
/**
* Function GetContoursCount.
* @return the number of polygons stored in list
* (number of corners flagged "end_contour"
*/
int GetContoursCount() const;
/**
* Function GetContour.
* @return the contour number containing the corner ic
* @param ic = the index of the corner in the corner list
*/
int GetContour( int ic );
/**
* Function GetContourStart.
* @return the index of the first corner (in corners list) of a contour
* @param icont = the index of the contour
*/
int GetContourStart( int icont );
/**
* Function GetContourEnd.
* @return the index of the last corner (in corners list) of a contour
* @param icont = the index of the contour
*/
int GetContourEnd( int icont );
/**
* Function GetContourSize.
* @return the corners count of a contour
* @param icont = the index of the contour
*/
int GetContourSize( int icont );
int GetX( int ic ) const { return m_CornersList.GetX( ic ); }
int GetY( int ic ) const { return m_CornersList.GetY( ic ); }
bool IsEndContour( int ic ) const
{ return m_CornersList.IsEndContour( ic ); }
/**
* Function IsEndContour.
* @return true if a corner is flagged end_contour
* @param ic= the index (in corners list) of the corner
*/
bool IsEndContour( int ic ) const { return m_CornersList.IsEndContour( ic ); }
const wxPoint& GetPos( int ic ) const { return m_CornersList.GetPos( ic ); }
int GetEndContour( int ic );
int GetUtility( int ic ) const { return m_CornersList.GetUtility( ic ); };
void SetUtility( int ic, int aFlag ) { m_CornersList.SetFlag( ic, aFlag ); };