Polygon code cleanup
This commit is contained in:
parent
3b56ea6732
commit
899d23d4fd
|
@ -24,7 +24,6 @@ CPolyLine::CPolyLine()
|
|||
m_hatchStyle = NO_HATCH;
|
||||
m_hatchPitch = 0;
|
||||
m_layer = 0;
|
||||
m_width = 0;
|
||||
m_utility = 0;
|
||||
m_Kbool_Poly_Engine = NULL;
|
||||
}
|
||||
|
@ -135,9 +134,7 @@ int CPolyLine::NormalizeWithKbool( std::vector<CPolyLine*>* aExtraPolyList )
|
|||
else if( aExtraPolyList ) // a new outside contour is found: create a new CPolyLine
|
||||
{
|
||||
polyline = new CPolyLine;
|
||||
polyline->SetLayer( GetLayer() );
|
||||
polyline->SetHatchStyle( GetHatchStyle() );
|
||||
polyline->SetHatchPitch( GetHatchPitch() );
|
||||
polyline->ImportSettings( this );
|
||||
aExtraPolyList->push_back( polyline ); // put it in array
|
||||
bool first = true;
|
||||
|
||||
|
@ -453,99 +450,20 @@ void armBoolEng( Bool_Engine* aBooleng, bool aConvertHoles )
|
|||
*/
|
||||
int CPolyLine::NormalizeAreaOutlines( std::vector<CPolyLine*>* aNewPolygonList )
|
||||
{
|
||||
#if 1
|
||||
return NormalizeWithKbool( aNewPolygonList );
|
||||
#else // Do NOT use this code: it does not yet work
|
||||
unsigned corners_count = m_CornersList.size();
|
||||
}
|
||||
|
||||
KI_POLYGON_SET polysholes;
|
||||
KI_POLYGON_WITH_HOLES mainpoly;
|
||||
std::vector<KI_POLY_POINT> cornerslist;
|
||||
KI_POLYGON_WITH_HOLES_SET outlines;
|
||||
KI_POLYGON poly_tmp;
|
||||
|
||||
unsigned ic = 0;
|
||||
// enter main outline
|
||||
while( ic < corners_count )
|
||||
/**
|
||||
* Function ImportSettings
|
||||
* Copy settings (layer, hatch styles) from aPoly
|
||||
*/
|
||||
void CPolyLine::ImportSettings( const CPolyLine * aPoly )
|
||||
{
|
||||
const CPolyPt& corner = m_CornersList[ic++];
|
||||
cornerslist.push_back( KI_POLY_POINT( corner.x, corner.y ) );
|
||||
|
||||
if( corner.end_contour )
|
||||
break;
|
||||
SetLayer( aPoly->GetLayer() );
|
||||
SetHatchStyle( aPoly->GetHatchStyle() );
|
||||
SetHatchPitch( aPoly->GetHatchPitch() );
|
||||
}
|
||||
|
||||
mainpoly.set( cornerslist.begin(), cornerslist.end() );
|
||||
outlines.push_back( mainpoly );
|
||||
outlines &= mainpoly;
|
||||
|
||||
// Enter holes
|
||||
while( ic < corners_count )
|
||||
{
|
||||
cornerslist.clear();
|
||||
{
|
||||
while( ic < corners_count )
|
||||
{
|
||||
const CPolyPt& corner = m_CornersList[ic++];
|
||||
cornerslist.push_back( KI_POLY_POINT( corner.x, corner.y ) );
|
||||
|
||||
if( corner.end_contour )
|
||||
break;
|
||||
}
|
||||
|
||||
bpl::set_points( poly_tmp, cornerslist.begin(), cornerslist.end() );
|
||||
polysholes.push_back( poly_tmp );
|
||||
}
|
||||
}
|
||||
|
||||
outlines -= polysholes;
|
||||
|
||||
// copy polygon with holes to destination
|
||||
RemoveAllContours();
|
||||
|
||||
for( unsigned ii = 0; ii < outlines.size(); ii++ )
|
||||
{
|
||||
CPolyLine* polyline = this;
|
||||
if( ii > 0 )
|
||||
{
|
||||
polyline = new CPolyLine;
|
||||
polyline->SetLayer( GetLayer() );
|
||||
polyline->SetHatchStyle( GetHatchStyle() );
|
||||
polyline->SetHatchPitch( GetHatchPitch() );
|
||||
aNewPolygonList->push_back( polyline );
|
||||
}
|
||||
|
||||
KI_POLYGON_WITH_HOLES& curr_poly = outlines[ii];
|
||||
KI_POLYGON_WITH_HOLES::iterator_type corner = curr_poly.begin();
|
||||
// enter main contour
|
||||
while( corner != curr_poly.end() )
|
||||
{
|
||||
polyline->AppendCorner( corner->x(), corner->y() );
|
||||
corner++;
|
||||
}
|
||||
polyline->CloseLastContour();
|
||||
|
||||
// add holes (set of polygons)
|
||||
KI_POLYGON_WITH_HOLES::iterator_holes_type hole = curr_poly.begin_holes();
|
||||
while( hole != curr_poly.end_holes() )
|
||||
{
|
||||
KI_POLYGON::iterator_type hole_corner = hole->begin();
|
||||
// create area with external contour: Recreate only area edges, NOT holes
|
||||
while( hole_corner != hole->end() )
|
||||
{
|
||||
polyline->AppendCorner( hole_corner->x(), hole_corner->y() );
|
||||
hole_corner++;
|
||||
}
|
||||
polyline->CloseLastContour();
|
||||
hole++;
|
||||
}
|
||||
}
|
||||
|
||||
return outlines.size();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* initialize a contour
|
||||
* set layer, hatch style, and starting point
|
||||
*/
|
||||
|
@ -931,11 +849,6 @@ int CPolyLine::GetEndContour( int ic )
|
|||
CRect CPolyLine::GetBounds()
|
||||
{
|
||||
CRect r = GetCornerBounds();
|
||||
|
||||
r.left -= m_width / 2;
|
||||
r.right += m_width / 2;
|
||||
r.bottom -= m_width / 2;
|
||||
r.top += m_width / 2;
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
|
@ -108,6 +108,13 @@ public:
|
|||
CPolyLine();
|
||||
~CPolyLine();
|
||||
|
||||
/**
|
||||
* Function ImportSettings
|
||||
* Copy settings (layer, hatch styles) from aPoly
|
||||
* @param aPoly is the CPolyLine to import settings
|
||||
*/
|
||||
void ImportSettings( const CPolyLine * aPoly );
|
||||
|
||||
// functions for modifying the CPolyLine contours
|
||||
|
||||
/* initialize a contour
|
||||
|
@ -176,7 +183,7 @@ public:
|
|||
|
||||
// access functions
|
||||
void SetLayer( int aLayer ) { m_layer = aLayer; }
|
||||
int GetLayer() { return m_layer; }
|
||||
int GetLayer() const { return m_layer; }
|
||||
int GetNumCorners();
|
||||
int GetNumSides();
|
||||
int GetClosed();
|
||||
|
@ -193,13 +200,13 @@ public:
|
|||
|
||||
int GetEndContour( int ic );
|
||||
|
||||
int GetUtility( int ic ) { return m_CornersList[ic].m_utility; };
|
||||
int GetUtility( int ic ) const { return m_CornersList[ic].m_utility; };
|
||||
void SetUtility( int ic, int utility ) { m_CornersList[ic].m_utility = utility; };
|
||||
|
||||
int GetHatchPitch() { return m_hatchPitch; }
|
||||
int GetHatchPitch() const { return m_hatchPitch; }
|
||||
static int GetDefaultHatchPitchMils() { return 20; } // default hatch pitch value in mils
|
||||
|
||||
enum HATCH_STYLE GetHatchStyle() { return m_hatchStyle; }
|
||||
enum HATCH_STYLE GetHatchStyle() const { return m_hatchStyle; }
|
||||
void SetHatch( int aHatchStyle, int aHatchPitch, bool aRebuildHatch )
|
||||
{
|
||||
SetHatchPitch( aHatchPitch );
|
||||
|
@ -286,7 +293,6 @@ public:
|
|||
|
||||
private:
|
||||
int m_layer; // layer to draw on
|
||||
int m_width; // lines width when drawing. Provided but not really used
|
||||
enum HATCH_STYLE m_hatchStyle; // hatch style, see enum above
|
||||
int m_hatchPitch; // for DIAGONAL_EDGE hatched outlines, basic distance between 2 hatch lines
|
||||
// and the len of eacvh segment
|
||||
|
|
|
@ -59,7 +59,6 @@ typedef bpl::polygon_with_holes_data<int> KI_POLYGON_WITH_HOLES;
|
|||
* is always stored in a KI_POLYGON_WITH_HOLES_SET, because these operations
|
||||
* can create many separate polygons with holespolygons
|
||||
*/
|
||||
|
||||
typedef std::vector<KI_POLYGON_WITH_HOLES> KI_POLYGON_WITH_HOLES_SET;
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue