BOARD::GetBoardPolygonOutlines(): do not generate a separate SHAPE_POLY_SET for holes.

They are already managed by SHAPE_POLY_SET board outline.
This commit is contained in:
jean-pierre charras 2017-03-22 10:58:14 +01:00
parent d99fbddc22
commit 05220a86f1
6 changed files with 57 additions and 73 deletions

View File

@ -475,20 +475,15 @@ void CINFO3D_VISU::createBoardPolygon()
{
m_board_poly.RemoveAllContours();
// Create board outlines and board holes
SHAPE_POLY_SET allLayerHoles;
wxString errmsg;
if( !m_board->GetBoardPolygonOutlines( m_board_poly, allLayerHoles, &errmsg ) )
if( !m_board->GetBoardPolygonOutlines( m_board_poly, /*allLayerHoles,*/ &errmsg ) )
{
errmsg.append( wxT( "\n\n" ) );
errmsg.append( _( "Cannot determine the board outline." ) );
wxLogMessage( errmsg );
}
m_board_poly.BooleanSubtract( allLayerHoles, SHAPE_POLY_SET::PM_FAST );
Polygon_Calc_BBox_3DU( m_board_poly, m_board2dBBox3DU, m_biuTo3Dunits );
}

View File

@ -2876,12 +2876,10 @@ BOARD_ITEM* BOARD::Duplicate( const BOARD_ITEM* aItem,
*/
extern bool BuildBoardPolygonOutlines( BOARD* aBoard,
SHAPE_POLY_SET& aOutlines,
SHAPE_POLY_SET& aHoles,
wxString* aErrorText );
bool BOARD::GetBoardPolygonOutlines( SHAPE_POLY_SET& aOutlines,
SHAPE_POLY_SET& aHoles,
wxString* aErrorText )
{
return BuildBoardPolygonOutlines( this, aOutlines, aHoles, aErrorText );
return BuildBoardPolygonOutlines( this, aOutlines, aErrorText );
}

View File

@ -575,14 +575,13 @@ public:
* from lines, arcs and circle items on edge cut layer
* Any closed outline inside the main outline is a hole
* All contours should be closed, i.e. have valid vertices to build a closed polygon
* @param aPoly The SHAPE_POLY_SET to fill in with outlines/holes.
* @param aOutlines The SHAPE_POLY_SET to fill in with outlines/holes.
* @param aErrorText = a wxString reference to display an error message
* with the coordinate of the point which creates the error
* (default = NULL , no message returned on error)
* @return true if success, false if a contour is not valid
*/
bool GetBoardPolygonOutlines( SHAPE_POLY_SET& aOutlines,
SHAPE_POLY_SET& aHoles,
wxString* aErrorText = NULL );
/**

View File

@ -190,7 +190,7 @@ bool ConvertOutlineToPolygon( std::vector< DRAWSEGMENT* >& aSegList,
std::vector< DRAWSEGMENT* > segList = aSegList;
unsigned prox; // a proximity BIU metric, not an accurate distance
const int STEPS = 16; // for a segmentation of an arc of 360 degrees
const int STEPS = 36; // for a segmentation of an arc of 360 degrees
DRAWSEGMENT* graphic;
wxPoint prevPt;
@ -584,7 +584,6 @@ bool ConvertOutlineToPolygon( std::vector< DRAWSEGMENT* >& aSegList,
*/
bool BuildBoardPolygonOutlines( BOARD* aBoard,
SHAPE_POLY_SET& aOutlines,
SHAPE_POLY_SET& aHoles,
wxString* aErrorText )
{
PCB_TYPE_COLLECTOR items;
@ -609,7 +608,7 @@ bool BuildBoardPolygonOutlines( BOARD* aBoard,
// only one main outline is expected
if( success && aOutlines.OutlineCount() )
{
int outlineId = 0;
/* int outlineId = 0;
int holecount = aOutlines.HoleCount( outlineId );
@ -623,7 +622,7 @@ bool BuildBoardPolygonOutlines( BOARD* aBoard,
// Remove holes from aOutlines:
SHAPE_POLY_SET::POLYGON& polygon = aOutlines.Polygon( outlineId );
polygon.erase( polygon.begin()+1, polygon.end() );
}
}*/
}
else
{

View File

@ -798,12 +798,10 @@ static void export_vrml_drawings( MODEL_VRML& aModel, BOARD* pcb )
// board edges and cutouts
static void export_vrml_board( MODEL_VRML& aModel, BOARD* aPcb )
{
SHAPE_POLY_SET bufferPcbOutlines; // stores the board main outlines
SHAPE_POLY_SET allLayerHoles; // Contains through holes, calculated only once
// Build a polygon from edge cut items
SHAPE_POLY_SET pcbOutlines; // stores the board main outlines
wxString msg;
if( !aPcb->GetBoardPolygonOutlines( bufferPcbOutlines, allLayerHoles, &msg ) )
if( !aPcb->GetBoardPolygonOutlines( pcbOutlines, &msg ) )
{
msg << "\n\n" <<
_( "Unable to calculate the board outlines; fall back to using the board boundary box." );
@ -812,9 +810,9 @@ static void export_vrml_board( MODEL_VRML& aModel, BOARD* aPcb )
int seg;
for( int i = 0; i < bufferPcbOutlines.OutlineCount(); i++ )
for( int cnt = 0; cnt < pcbOutlines.OutlineCount(); cnt++ )
{
const SHAPE_LINE_CHAIN& outline = bufferPcbOutlines.COutline( i );
const SHAPE_LINE_CHAIN& outline = pcbOutlines.COutline( cnt );
seg = aModel.m_board.NewContour();
@ -826,11 +824,11 @@ static void export_vrml_board( MODEL_VRML& aModel, BOARD* aPcb )
}
aModel.m_board.EnsureWinding( seg, false );
}
for( int i = 0; i < allLayerHoles.OutlineCount(); i++ )
// Generate holes:
for( int ii = 0; ii < pcbOutlines.HoleCount( cnt ); ii++ )
{
const SHAPE_LINE_CHAIN& outline = allLayerHoles.COutline( i );
const SHAPE_LINE_CHAIN& hole = pcbOutlines.Hole( cnt, ii );
seg = aModel.m_holes.NewContour();
@ -843,15 +841,16 @@ static void export_vrml_board( MODEL_VRML& aModel, BOARD* aPcb )
return;
}
for( int j = 0; j < outline.PointCount(); j++ )
for( int j = 0; j < hole.PointCount(); j++ )
{
aModel.m_holes.AddVertex( seg, (double)outline.CPoint(j).x * BOARD_SCALE,
-((double)outline.CPoint(j).y * BOARD_SCALE ) );
aModel.m_holes.AddVertex( seg, (double)hole.CPoint(j).x * BOARD_SCALE,
-((double)hole.CPoint(j).y * BOARD_SCALE ) );
}
aModel.m_holes.EnsureWinding( seg, true );
}
}
}

View File

@ -733,19 +733,16 @@ void SPECCTRA_DB::fillBOUNDARY( BOARD* aBoard, BOUNDARY* boundary )
{
wxString errMessage;
SHAPE_POLY_SET outlines;
SHAPE_POLY_SET holes;
aBoard->GetBoardPolygonOutlines( outlines, holes, &errMessage );
aBoard->GetBoardPolygonOutlines( outlines, &errMessage );
//const int STEPS = 36; // for a segmentation of an arc of 360 degrees
if( outlines.OutlineCount() ) // Should be always true
for( int cnt = 0; cnt < outlines.OutlineCount(); cnt++ ) // Should be one outline
{
PATH* path = new PATH( boundary );
boundary->paths.push_back( path );
path->layer_id = "pcb";
SHAPE_LINE_CHAIN& outline = outlines.Outline( 0 );
SHAPE_LINE_CHAIN& outline = outlines.Outline( cnt );
for( int ii = 0; ii < outline.PointCount(); ii++ )
{
@ -754,15 +751,11 @@ void SPECCTRA_DB::fillBOUNDARY( BOARD* aBoard, BOUNDARY* boundary )
}
// Close polygon:
wxPoint pos( outline.Point( 0 ).x, outline.Point( 0 ).y );
path->AppendPoint( mapPt( pos ) );
}
wxPoint pos0( outline.Point( 0 ).x, outline.Point( 0 ).y );
path->AppendPoint( mapPt( pos0 ) );
// Output the interior Edge.Cuts graphics as keepouts, using same nearness
// metric as the board edge as otherwise we have trouble completing complex
// polygons.
for( int ii = 0; ii < holes.OutlineCount(); ii++ )
// Generate holes as keepout:
for( int ii = 0; ii < outlines.HoleCount( cnt ); ii++ )
{
// emit a signal layers keepout for every interior polygon left...
KEEPOUT* keepout = new KEEPOUT( NULL, T_keepout );
@ -772,7 +765,7 @@ void SPECCTRA_DB::fillBOUNDARY( BOARD* aBoard, BOUNDARY* boundary )
poly_ko->SetLayerId( "signal" );
pcb->structure->keepouts.push_back( keepout );
SHAPE_LINE_CHAIN& hole = holes.Outline( ii );
SHAPE_LINE_CHAIN& hole = outlines.Hole( cnt, ii );
for( int jj = 0; jj < hole.PointCount(); jj++ )
{
@ -784,6 +777,7 @@ void SPECCTRA_DB::fillBOUNDARY( BOARD* aBoard, BOUNDARY* boundary )
wxPoint pos( hole.Point( 0 ).x, hole.Point( 0 ).y );
poly_ko->AppendPoint( mapPt( pos ) );
}
}
if( !errMessage.IsEmpty() )
wxLogMessage( errMessage );