merged divertion
This commit is contained in:
commit
1c9433fb31
|
@ -305,7 +305,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
|
||||||
{
|
{
|
||||||
CPolyPt* endcorner = &polysList[ic];
|
CPolyPt* endcorner = &polysList[ic];
|
||||||
|
|
||||||
if( begincorner->utility == 0 )
|
if( begincorner->m_utility == 0 )
|
||||||
{
|
{
|
||||||
// Draw only basic outlines, not extra segments
|
// Draw only basic outlines, not extra segments
|
||||||
dummysegment.m_Start.x = begincorner->x;
|
dummysegment.m_Start.x = begincorner->x;
|
||||||
|
@ -318,7 +318,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
|
||||||
if( (endcorner->end_contour) || (ic == imax) )
|
if( (endcorner->end_contour) || (ic == imax) )
|
||||||
{
|
{
|
||||||
// the last corner of a filled area is found: draw it
|
// the last corner of a filled area is found: draw it
|
||||||
if( endcorner->utility == 0 )
|
if( endcorner->m_utility == 0 )
|
||||||
{
|
{
|
||||||
// Draw only basic outlines, not extra segments
|
// Draw only basic outlines, not extra segments
|
||||||
dummysegment.m_Start.x = endcorner->x;
|
dummysegment.m_Start.x = endcorner->x;
|
||||||
|
|
|
@ -561,15 +561,15 @@ void LIB_ARC::BeginEdit( int aEditMode, const wxPoint aPosition )
|
||||||
// Drag either the start, end point or the outline
|
// Drag either the start, end point or the outline
|
||||||
if( HitTestPoints( m_ArcStart, aPosition, MINIMUM_SELECTION_DISTANCE ) )
|
if( HitTestPoints( m_ArcStart, aPosition, MINIMUM_SELECTION_DISTANCE ) )
|
||||||
{
|
{
|
||||||
m_editSelectPoint = START;
|
m_editSelectPoint = ARC_STATUS_START;
|
||||||
}
|
}
|
||||||
else if( HitTestPoints( m_ArcEnd, aPosition, MINIMUM_SELECTION_DISTANCE ) )
|
else if( HitTestPoints( m_ArcEnd, aPosition, MINIMUM_SELECTION_DISTANCE ) )
|
||||||
{
|
{
|
||||||
m_editSelectPoint = END;
|
m_editSelectPoint = ARC_STATUS_END;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_editSelectPoint = OUTLINE;
|
m_editSelectPoint = ARC_STATUS_OUTLINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_editState = 0;
|
m_editState = 0;
|
||||||
|
@ -619,12 +619,12 @@ void LIB_ARC::calcEdit( const wxPoint& aPosition )
|
||||||
wxPoint newCenterPoint, startPos, endPos;
|
wxPoint newCenterPoint, startPos, endPos;
|
||||||
|
|
||||||
// Choose the point of the arc to be adjusted
|
// Choose the point of the arc to be adjusted
|
||||||
if( m_editSelectPoint == START )
|
if( m_editSelectPoint == ARC_STATUS_START )
|
||||||
{
|
{
|
||||||
startPos = aPosition;
|
startPos = aPosition;
|
||||||
endPos = m_ArcEnd;
|
endPos = m_ArcEnd;
|
||||||
}
|
}
|
||||||
else if( m_editSelectPoint == END )
|
else if( m_editSelectPoint == ARC_STATUS_END )
|
||||||
{
|
{
|
||||||
endPos = aPosition;
|
endPos = aPosition;
|
||||||
startPos = m_ArcStart;
|
startPos = m_ArcStart;
|
||||||
|
@ -658,7 +658,7 @@ void LIB_ARC::calcEdit( const wxPoint& aPosition )
|
||||||
newCenterPoint = m_Pos;
|
newCenterPoint = m_Pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( m_editSelectPoint == START || m_editSelectPoint == END )
|
if( m_editSelectPoint == ARC_STATUS_START || m_editSelectPoint == ARC_STATUS_END )
|
||||||
{
|
{
|
||||||
// Compute the new center point when the start/end points are modified
|
// Compute the new center point when the start/end points are modified
|
||||||
wxPoint middlePoint = wxPoint( (startPos.x + endPos.x) / 2,
|
wxPoint middlePoint = wxPoint( (startPos.x + endPos.x) / 2,
|
||||||
|
|
|
@ -37,15 +37,15 @@ class TRANSFORM;
|
||||||
|
|
||||||
class LIB_ARC : public LIB_ITEM
|
class LIB_ARC : public LIB_ITEM
|
||||||
{
|
{
|
||||||
enum SELECT_T
|
enum SELECT_T // When creating an arc: status of arc
|
||||||
{
|
{
|
||||||
START,
|
ARC_STATUS_START,
|
||||||
END,
|
ARC_STATUS_END,
|
||||||
OUTLINE,
|
ARC_STATUS_OUTLINE,
|
||||||
};
|
};
|
||||||
|
|
||||||
int m_Radius;
|
int m_Radius;
|
||||||
int m_t1; /* First radius angle of the arc in 0.1 degrees. */
|
int m_t1; // First radius angle of the arc in 0.1 degrees.
|
||||||
int m_t2; /* Second radius angle of the arc in 0.1 degrees. */
|
int m_t2; /* Second radius angle of the arc in 0.1 degrees. */
|
||||||
wxPoint m_ArcStart;
|
wxPoint m_ArcStart;
|
||||||
wxPoint m_ArcEnd; /* Arc end position. */
|
wxPoint m_ArcEnd; /* Arc end position. */
|
||||||
|
|
Binary file not shown.
|
@ -1302,12 +1302,12 @@ static void AddNewTrace( PCB_EDIT_FRAME* pcbframe, wxDC* DC )
|
||||||
g_CurrentTrackList.PushBack( newTrack );
|
g_CurrentTrackList.PushBack( newTrack );
|
||||||
}
|
}
|
||||||
|
|
||||||
g_FirstTrackSegment->start = pcbframe->GetBoard()->GetPad( g_FirstTrackSegment, START );
|
g_FirstTrackSegment->start = pcbframe->GetBoard()->GetPad( g_FirstTrackSegment, FLG_START );
|
||||||
|
|
||||||
if( g_FirstTrackSegment->start )
|
if( g_FirstTrackSegment->start )
|
||||||
g_FirstTrackSegment->SetState( BEGIN_ONPAD, ON );
|
g_FirstTrackSegment->SetState( BEGIN_ONPAD, ON );
|
||||||
|
|
||||||
g_CurrentTrackSegment->end = pcbframe->GetBoard()->GetPad( g_CurrentTrackSegment, END );
|
g_CurrentTrackSegment->end = pcbframe->GetBoard()->GetPad( g_CurrentTrackSegment, FLG_END );
|
||||||
|
|
||||||
if( g_CurrentTrackSegment->end )
|
if( g_CurrentTrackSegment->end )
|
||||||
g_CurrentTrackSegment->SetState( END_ONPAD, ON );
|
g_CurrentTrackSegment->SetState( END_ONPAD, ON );
|
||||||
|
|
|
@ -167,19 +167,19 @@ void ZONE_CONTAINER::TransformShapeWithClearanceToPolygon( std::vector <CPolyPt>
|
||||||
|
|
||||||
// Calculate the polygon with clearance and holes
|
// Calculate the polygon with clearance and holes
|
||||||
// holes are linked to the main outline, so only one polygon should be created.
|
// holes are linked to the main outline, so only one polygon should be created.
|
||||||
KPolygonSet polyset_zone_solid_areas;
|
KI_POLYGON_SET polyset_zone_solid_areas;
|
||||||
std::vector<KPolyPoint> cornerslist;
|
std::vector<KI_POLY_POINT> cornerslist;
|
||||||
unsigned ic = 0;
|
unsigned ic = 0;
|
||||||
unsigned corners_count = zoneOutines.size();
|
unsigned corners_count = zoneOutines.size();
|
||||||
while( ic < corners_count )
|
while( ic < corners_count )
|
||||||
{
|
{
|
||||||
cornerslist.clear();
|
cornerslist.clear();
|
||||||
KPolygon poly;
|
KI_POLYGON poly;
|
||||||
{
|
{
|
||||||
for( ; ic < corners_count; ic++ )
|
for( ; ic < corners_count; ic++ )
|
||||||
{
|
{
|
||||||
CPolyPt* corner = &zoneOutines[ic];
|
CPolyPt* corner = &zoneOutines[ic];
|
||||||
cornerslist.push_back( KPolyPoint( corner->x, corner->y ) );
|
cornerslist.push_back( KI_POLY_POINT( corner->x, corner->y ) );
|
||||||
if( corner->end_contour )
|
if( corner->end_contour )
|
||||||
{
|
{
|
||||||
ic++;
|
ic++;
|
||||||
|
@ -197,12 +197,12 @@ void ZONE_CONTAINER::TransformShapeWithClearanceToPolygon( std::vector <CPolyPt>
|
||||||
// Put the resultng polygon in buffer
|
// Put the resultng polygon in buffer
|
||||||
for( unsigned ii = 0; ii < polyset_zone_solid_areas.size(); ii++ )
|
for( unsigned ii = 0; ii < polyset_zone_solid_areas.size(); ii++ )
|
||||||
{
|
{
|
||||||
KPolygon& poly = polyset_zone_solid_areas[ii];
|
KI_POLYGON& poly = polyset_zone_solid_areas[ii];
|
||||||
CPolyPt corner( 0, 0, false );
|
CPolyPt corner( 0, 0, false );
|
||||||
|
|
||||||
for( unsigned jj = 0; jj < poly.size(); jj++ )
|
for( unsigned jj = 0; jj < poly.size(); jj++ )
|
||||||
{
|
{
|
||||||
KPolyPoint point = *(poly.begin() + jj);
|
KI_POLY_POINT point = *(poly.begin() + jj);
|
||||||
corner.x = point.x();
|
corner.x = point.x();
|
||||||
corner.y = point.y();
|
corner.y = point.y();
|
||||||
corner.end_contour = false;
|
corner.end_contour = false;
|
||||||
|
|
|
@ -1681,7 +1681,7 @@ D_PAD* BOARD::GetPad( TRACK* aTrace, int aEndPoint )
|
||||||
|
|
||||||
int aLayerMask = GetLayerMask( aTrace->GetLayer() );
|
int aLayerMask = GetLayerMask( aTrace->GetLayer() );
|
||||||
|
|
||||||
if( aEndPoint == START )
|
if( aEndPoint == FLG_START )
|
||||||
{
|
{
|
||||||
aPosition = aTrace->m_Start;
|
aPosition = aTrace->m_Start;
|
||||||
}
|
}
|
||||||
|
@ -2271,7 +2271,7 @@ TRACK* BOARD::CreateLockPoint( wxPoint& aPosition, TRACK* aSegment, PICKED_ITEMS
|
||||||
aSegment->end = newTrack;
|
aSegment->end = newTrack;
|
||||||
aSegment->SetState( END_ONPAD, OFF );
|
aSegment->SetState( END_ONPAD, OFF );
|
||||||
|
|
||||||
D_PAD * pad = GetPad( newTrack, START );
|
D_PAD * pad = GetPad( newTrack, FLG_START );
|
||||||
|
|
||||||
if ( pad )
|
if ( pad )
|
||||||
{
|
{
|
||||||
|
|
|
@ -1282,7 +1282,7 @@ TRACK* TRACK::GetTrace( TRACK* aStartTrace, TRACK* aEndTrace, int aEndPoint )
|
||||||
int ii;
|
int ii;
|
||||||
int max_dist;
|
int max_dist;
|
||||||
|
|
||||||
if( aEndPoint == START )
|
if( aEndPoint == FLG_START )
|
||||||
position = m_Start;
|
position = m_Start;
|
||||||
else
|
else
|
||||||
position = m_End;
|
position = m_End;
|
||||||
|
|
|
@ -210,7 +210,7 @@ void ZONE_CONTAINER::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int aDrawMode, const
|
||||||
{
|
{
|
||||||
seg_start = GetCornerPosition( ic ) + offset;
|
seg_start = GetCornerPosition( ic ) + offset;
|
||||||
|
|
||||||
if( m_Poly->corner[ic].end_contour == false && ic < GetNumCorners() - 1 )
|
if( m_Poly->m_CornersList[ic].end_contour == false && ic < GetNumCorners() - 1 )
|
||||||
{
|
{
|
||||||
seg_end = GetCornerPosition( ic + 1 ) + offset;
|
seg_end = GetCornerPosition( ic + 1 ) + offset;
|
||||||
}
|
}
|
||||||
|
@ -306,7 +306,7 @@ void ZONE_CONTAINER::DrawFilledArea( EDA_DRAW_PANEL* panel,
|
||||||
|
|
||||||
CornersBuffer.push_back( coord );
|
CornersBuffer.push_back( coord );
|
||||||
|
|
||||||
CornersTypeBuffer.push_back( (char) corner->utility );
|
CornersTypeBuffer.push_back( (char) corner->m_utility );
|
||||||
|
|
||||||
if( (corner->end_contour) || (ic == imax) ) // the last corner of a filled area is found: draw it
|
if( (corner->end_contour) || (ic == imax) ) // the last corner of a filled area is found: draw it
|
||||||
{
|
{
|
||||||
|
@ -432,13 +432,13 @@ void ZONE_CONTAINER::DrawWhileCreateOutline( EDA_DRAW_PANEL* panel, wxDC* DC, in
|
||||||
int yi = GetCornerPosition( ic ).y;
|
int yi = GetCornerPosition( ic ).y;
|
||||||
int xf, yf;
|
int xf, yf;
|
||||||
|
|
||||||
if( m_Poly->corner[ic].end_contour == false && ic < icmax )
|
if( m_Poly->m_CornersList[ic].end_contour == false && ic < icmax )
|
||||||
{
|
{
|
||||||
is_close_segment = false;
|
is_close_segment = false;
|
||||||
xf = GetCornerPosition( ic + 1 ).x;
|
xf = GetCornerPosition( ic + 1 ).x;
|
||||||
yf = GetCornerPosition( ic + 1 ).y;
|
yf = GetCornerPosition( ic + 1 ).y;
|
||||||
|
|
||||||
if( (m_Poly->corner[ic + 1].end_contour) || (ic == icmax - 1) )
|
if( (m_Poly->m_CornersList[ic + 1].end_contour) || (ic == icmax - 1) )
|
||||||
current_gr_mode = GR_XOR;
|
current_gr_mode = GR_XOR;
|
||||||
else
|
else
|
||||||
current_gr_mode = draw_mode;
|
current_gr_mode = draw_mode;
|
||||||
|
@ -507,12 +507,12 @@ bool ZONE_CONTAINER::HitTestForCorner( const wxPoint& refPos )
|
||||||
int min_dist = MIN_DIST_IN_MILS*IU_PER_MILS;
|
int min_dist = MIN_DIST_IN_MILS*IU_PER_MILS;
|
||||||
|
|
||||||
wxPoint delta;
|
wxPoint delta;
|
||||||
unsigned lim = m_Poly->corner.size();
|
unsigned lim = m_Poly->m_CornersList.size();
|
||||||
|
|
||||||
for( unsigned item_pos = 0; item_pos < lim; item_pos++ )
|
for( unsigned item_pos = 0; item_pos < lim; item_pos++ )
|
||||||
{
|
{
|
||||||
delta.x = refPos.x - m_Poly->corner[item_pos].x;
|
delta.x = refPos.x - m_Poly->m_CornersList[item_pos].x;
|
||||||
delta.y = refPos.y - m_Poly->corner[item_pos].y;
|
delta.y = refPos.y - m_Poly->m_CornersList[item_pos].y;
|
||||||
|
|
||||||
// Calculate a distance:
|
// Calculate a distance:
|
||||||
int dist = MAX( abs( delta.x ), abs( delta.y ) );
|
int dist = MAX( abs( delta.x ), abs( delta.y ) );
|
||||||
|
@ -530,7 +530,7 @@ bool ZONE_CONTAINER::HitTestForCorner( const wxPoint& refPos )
|
||||||
|
|
||||||
bool ZONE_CONTAINER::HitTestForEdge( const wxPoint& refPos )
|
bool ZONE_CONTAINER::HitTestForEdge( const wxPoint& refPos )
|
||||||
{
|
{
|
||||||
unsigned lim = m_Poly->corner.size();
|
unsigned lim = m_Poly->m_CornersList.size();
|
||||||
|
|
||||||
m_CornerSelection = -1; // Set to not found
|
m_CornerSelection = -1; // Set to not found
|
||||||
|
|
||||||
|
@ -547,7 +547,7 @@ bool ZONE_CONTAINER::HitTestForEdge( const wxPoint& refPos )
|
||||||
* the last segment of the current outline starts at current corner, and ends
|
* the last segment of the current outline starts at current corner, and ends
|
||||||
* at the first corner of the outline
|
* at the first corner of the outline
|
||||||
*/
|
*/
|
||||||
if( m_Poly->corner[item_pos].end_contour || end_segm >= lim )
|
if( m_Poly->m_CornersList[item_pos].end_contour || end_segm >= lim )
|
||||||
{
|
{
|
||||||
unsigned tmp = first_corner_pos;
|
unsigned tmp = first_corner_pos;
|
||||||
first_corner_pos = end_segm; // first_corner_pos is now the beginning of the next outline
|
first_corner_pos = end_segm; // first_corner_pos is now the beginning of the next outline
|
||||||
|
@ -557,10 +557,10 @@ bool ZONE_CONTAINER::HitTestForEdge( const wxPoint& refPos )
|
||||||
/* test the dist between segment and ref point */
|
/* test the dist between segment and ref point */
|
||||||
int dist = (int) GetPointToLineSegmentDistance( refPos.x,
|
int dist = (int) GetPointToLineSegmentDistance( refPos.x,
|
||||||
refPos.y,
|
refPos.y,
|
||||||
m_Poly->corner[item_pos].x,
|
m_Poly->m_CornersList[item_pos].x,
|
||||||
m_Poly->corner[item_pos].y,
|
m_Poly->m_CornersList[item_pos].y,
|
||||||
m_Poly->corner[end_segm].x,
|
m_Poly->m_CornersList[end_segm].x,
|
||||||
m_Poly->corner[end_segm].y );
|
m_Poly->m_CornersList[end_segm].y );
|
||||||
|
|
||||||
if( dist < min_dist )
|
if( dist < min_dist )
|
||||||
{
|
{
|
||||||
|
@ -703,7 +703,7 @@ void ZONE_CONTAINER::DisplayInfo( EDA_DRAW_FRAME* frame )
|
||||||
msg = board->GetLayerName( m_Layer );
|
msg = board->GetLayerName( m_Layer );
|
||||||
frame->AppendMsgPanel( _( "Layer" ), msg, BROWN );
|
frame->AppendMsgPanel( _( "Layer" ), msg, BROWN );
|
||||||
|
|
||||||
msg.Printf( wxT( "%d" ), (int) m_Poly->corner.size() );
|
msg.Printf( wxT( "%d" ), (int) m_Poly->m_CornersList.size() );
|
||||||
frame->AppendMsgPanel( _( "Corners" ), msg, BLUE );
|
frame->AppendMsgPanel( _( "Corners" ), msg, BLUE );
|
||||||
|
|
||||||
if( m_FillMode )
|
if( m_FillMode )
|
||||||
|
@ -730,7 +730,7 @@ void ZONE_CONTAINER::DisplayInfo( EDA_DRAW_FRAME* frame )
|
||||||
void ZONE_CONTAINER::Move( const wxPoint& offset )
|
void ZONE_CONTAINER::Move( const wxPoint& offset )
|
||||||
{
|
{
|
||||||
/* move outlines */
|
/* move outlines */
|
||||||
for( unsigned ii = 0; ii < m_Poly->corner.size(); ii++ )
|
for( unsigned ii = 0; ii < m_Poly->m_CornersList.size(); ii++ )
|
||||||
{
|
{
|
||||||
SetCornerPosition( ii, GetCornerPosition( ii ) + offset );
|
SetCornerPosition( ii, GetCornerPosition( ii ) + offset );
|
||||||
}
|
}
|
||||||
|
@ -761,7 +761,7 @@ void ZONE_CONTAINER::MoveEdge( const wxPoint& offset )
|
||||||
SetCornerPosition( ii, GetCornerPosition( ii ) + offset );
|
SetCornerPosition( ii, GetCornerPosition( ii ) + offset );
|
||||||
|
|
||||||
// Move the end point of the selected edge:
|
// Move the end point of the selected edge:
|
||||||
if( m_Poly->corner[ii].end_contour || ii == GetNumCorners() - 1 )
|
if( m_Poly->m_CornersList[ii].end_contour || ii == GetNumCorners() - 1 )
|
||||||
{
|
{
|
||||||
int icont = m_Poly->GetContour( ii );
|
int icont = m_Poly->GetContour( ii );
|
||||||
ii = m_Poly->GetContourStart( icont );
|
ii = m_Poly->GetContourStart( icont );
|
||||||
|
@ -781,13 +781,13 @@ void ZONE_CONTAINER::Rotate( const wxPoint& centre, double angle )
|
||||||
{
|
{
|
||||||
wxPoint pos;
|
wxPoint pos;
|
||||||
|
|
||||||
for( unsigned ii = 0; ii < m_Poly->corner.size(); ii++ )
|
for( unsigned ii = 0; ii < m_Poly->m_CornersList.size(); ii++ )
|
||||||
{
|
{
|
||||||
pos.x = m_Poly->corner[ii].x;
|
pos.x = m_Poly->m_CornersList[ii].x;
|
||||||
pos.y = m_Poly->corner[ii].y;
|
pos.y = m_Poly->m_CornersList[ii].y;
|
||||||
RotatePoint( &pos, centre, angle );
|
RotatePoint( &pos, centre, angle );
|
||||||
m_Poly->corner[ii].x = pos.x;
|
m_Poly->m_CornersList[ii].x = pos.x;
|
||||||
m_Poly->corner[ii].y = pos.y;
|
m_Poly->m_CornersList[ii].y = pos.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Poly->Hatch();
|
m_Poly->Hatch();
|
||||||
|
@ -820,11 +820,11 @@ void ZONE_CONTAINER::Flip( const wxPoint& aCentre )
|
||||||
|
|
||||||
void ZONE_CONTAINER::Mirror( const wxPoint& mirror_ref )
|
void ZONE_CONTAINER::Mirror( const wxPoint& mirror_ref )
|
||||||
{
|
{
|
||||||
for( unsigned ii = 0; ii < m_Poly->corner.size(); ii++ )
|
for( unsigned ii = 0; ii < m_Poly->m_CornersList.size(); ii++ )
|
||||||
{
|
{
|
||||||
m_Poly->corner[ii].y -= mirror_ref.y;
|
m_Poly->m_CornersList[ii].y -= mirror_ref.y;
|
||||||
NEGATE( m_Poly->corner[ii].y );
|
NEGATE( m_Poly->m_CornersList[ii].y );
|
||||||
m_Poly->corner[ii].y += mirror_ref.y;
|
m_Poly->m_CornersList[ii].y += mirror_ref.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Poly->Hatch();
|
m_Poly->Hatch();
|
||||||
|
|
|
@ -613,7 +613,7 @@ private:
|
||||||
|
|
||||||
/* set of filled polygons used to draw a zone as a filled area.
|
/* set of filled polygons used to draw a zone as a filled area.
|
||||||
* from outlines (m_Poly) but unlike m_Poly these filled polygons have no hole
|
* from outlines (m_Poly) but unlike m_Poly these filled polygons have no hole
|
||||||
* (they are* all in one piece) In very simple cases m_FilledPolysList is same
|
* (they are all in one piece) In very simple cases m_FilledPolysList is same
|
||||||
* as m_Poly. In less simple cases (when m_Poly has holes) m_FilledPolysList is
|
* as m_Poly. In less simple cases (when m_Poly has holes) m_FilledPolysList is
|
||||||
* a polygon equivalent to m_Poly, without holes but with extra outline segment
|
* a polygon equivalent to m_Poly, without holes but with extra outline segment
|
||||||
* connecting "holes" with external main outline. In complex cases an outline
|
* connecting "holes" with external main outline. In complex cases an outline
|
||||||
|
|
|
@ -272,7 +272,7 @@ static void DeleteUnconnectedTracks( PCB_EDIT_FRAME* aFrame )
|
||||||
|
|
||||||
if( (type_end & START_ON_PAD ) == 0 )
|
if( (type_end & START_ON_PAD ) == 0 )
|
||||||
{
|
{
|
||||||
other = segment->GetTrace( aFrame->GetBoard()->m_Track, NULL, START );
|
other = segment->GetTrace( aFrame->GetBoard()->m_Track, NULL, FLG_START );
|
||||||
|
|
||||||
if( other == NULL ) // Test a connection to zones
|
if( other == NULL ) // Test a connection to zones
|
||||||
{
|
{
|
||||||
|
@ -306,7 +306,7 @@ static void DeleteUnconnectedTracks( PCB_EDIT_FRAME* aFrame )
|
||||||
segment->SetState( BUSY, ON );
|
segment->SetState( BUSY, ON );
|
||||||
|
|
||||||
SEGVIA* via = (SEGVIA*) other;
|
SEGVIA* via = (SEGVIA*) other;
|
||||||
other = via->GetTrace( aFrame->GetBoard()->m_Track, NULL, START );
|
other = via->GetTrace( aFrame->GetBoard()->m_Track, NULL, FLG_START );
|
||||||
|
|
||||||
if( other == NULL )
|
if( other == NULL )
|
||||||
{
|
{
|
||||||
|
@ -327,7 +327,7 @@ static void DeleteUnconnectedTracks( PCB_EDIT_FRAME* aFrame )
|
||||||
// if not connected to a pad, test if segment's END is connected to another track
|
// if not connected to a pad, test if segment's END is connected to another track
|
||||||
if( (type_end & END_ON_PAD ) == 0 )
|
if( (type_end & END_ON_PAD ) == 0 )
|
||||||
{
|
{
|
||||||
other = segment->GetTrace( aFrame->GetBoard()->m_Track, NULL, END );
|
other = segment->GetTrace( aFrame->GetBoard()->m_Track, NULL, FLG_END );
|
||||||
|
|
||||||
if( other == NULL ) // Test a connection to zones
|
if( other == NULL ) // Test a connection to zones
|
||||||
{
|
{
|
||||||
|
@ -362,7 +362,7 @@ static void DeleteUnconnectedTracks( PCB_EDIT_FRAME* aFrame )
|
||||||
segment->SetState( BUSY, ON );
|
segment->SetState( BUSY, ON );
|
||||||
|
|
||||||
SEGVIA* via = (SEGVIA*) other;
|
SEGVIA* via = (SEGVIA*) other;
|
||||||
other = via->GetTrace( aFrame->GetBoard()->m_Track, NULL, END );
|
other = via->GetTrace( aFrame->GetBoard()->m_Track, NULL, FLG_END );
|
||||||
|
|
||||||
if( other == NULL )
|
if( other == NULL )
|
||||||
{
|
{
|
||||||
|
@ -486,7 +486,7 @@ static void clean_segments( PCB_EDIT_FRAME* aFrame )
|
||||||
// search for a possible point that connects on the START point of the segment
|
// search for a possible point that connects on the START point of the segment
|
||||||
for( segStart = segment->Next(); ; )
|
for( segStart = segment->Next(); ; )
|
||||||
{
|
{
|
||||||
segStart = segment->GetTrace( segStart, NULL, START );
|
segStart = segment->GetTrace( segStart, NULL, FLG_START );
|
||||||
|
|
||||||
if( segStart )
|
if( segStart )
|
||||||
{
|
{
|
||||||
|
@ -500,7 +500,7 @@ static void clean_segments( PCB_EDIT_FRAME* aFrame )
|
||||||
|
|
||||||
// We must have only one segment connected
|
// We must have only one segment connected
|
||||||
segStart->SetState( BUSY, ON );
|
segStart->SetState( BUSY, ON );
|
||||||
other = segment->GetTrace( aFrame->GetBoard()->m_Track, NULL, START );
|
other = segment->GetTrace( aFrame->GetBoard()->m_Track, NULL, FLG_START );
|
||||||
segStart->SetState( BUSY, OFF );
|
segStart->SetState( BUSY, OFF );
|
||||||
|
|
||||||
if( other == NULL )
|
if( other == NULL )
|
||||||
|
@ -514,7 +514,7 @@ static void clean_segments( PCB_EDIT_FRAME* aFrame )
|
||||||
if( flag ) // We have the starting point of the segment is connected to an other segment
|
if( flag ) // We have the starting point of the segment is connected to an other segment
|
||||||
{
|
{
|
||||||
segDelete = MergeColinearSegmentIfPossible( aFrame->GetBoard(), segment, segStart,
|
segDelete = MergeColinearSegmentIfPossible( aFrame->GetBoard(), segment, segStart,
|
||||||
START );
|
FLG_START );
|
||||||
|
|
||||||
if( segDelete )
|
if( segDelete )
|
||||||
{
|
{
|
||||||
|
@ -526,7 +526,7 @@ static void clean_segments( PCB_EDIT_FRAME* aFrame )
|
||||||
// search for a possible point that connects on the END point of the segment:
|
// search for a possible point that connects on the END point of the segment:
|
||||||
for( segEnd = segment->Next(); ; )
|
for( segEnd = segment->Next(); ; )
|
||||||
{
|
{
|
||||||
segEnd = segment->GetTrace( segEnd, NULL, END );
|
segEnd = segment->GetTrace( segEnd, NULL, FLG_END );
|
||||||
|
|
||||||
if( segEnd )
|
if( segEnd )
|
||||||
{
|
{
|
||||||
|
@ -538,7 +538,7 @@ static void clean_segments( PCB_EDIT_FRAME* aFrame )
|
||||||
|
|
||||||
// We must have only one segment connected
|
// We must have only one segment connected
|
||||||
segEnd->SetState( BUSY, ON );
|
segEnd->SetState( BUSY, ON );
|
||||||
other = segment->GetTrace( aFrame->GetBoard()->m_Track, NULL, END );
|
other = segment->GetTrace( aFrame->GetBoard()->m_Track, NULL, FLG_END );
|
||||||
segEnd->SetState( BUSY, OFF );
|
segEnd->SetState( BUSY, OFF );
|
||||||
|
|
||||||
if( other == NULL )
|
if( other == NULL )
|
||||||
|
@ -554,7 +554,8 @@ static void clean_segments( PCB_EDIT_FRAME* aFrame )
|
||||||
|
|
||||||
if( flag & 2 ) // We have the ending point of the segment is connected to an other segment
|
if( flag & 2 ) // We have the ending point of the segment is connected to an other segment
|
||||||
{
|
{
|
||||||
segDelete = MergeColinearSegmentIfPossible( aFrame->GetBoard(), segment, segEnd, END );
|
segDelete = MergeColinearSegmentIfPossible( aFrame->GetBoard(),
|
||||||
|
segment, segEnd, FLG_END );
|
||||||
|
|
||||||
if( segDelete )
|
if( segDelete )
|
||||||
{
|
{
|
||||||
|
@ -643,7 +644,7 @@ TRACK* MergeColinearSegmentIfPossible( BOARD* aPcb, TRACK* aTrackRef, TRACK* aCa
|
||||||
* (this function) is called when there is only 2 connected segments,
|
* (this function) is called when there is only 2 connected segments,
|
||||||
*and if this point is not on a pad, it can be removed and the 2 segments will be merged
|
*and if this point is not on a pad, it can be removed and the 2 segments will be merged
|
||||||
*/
|
*/
|
||||||
if( aEndType == START )
|
if( aEndType == FLG_START )
|
||||||
{
|
{
|
||||||
// We must not have a pad, which is a always terminal point for a track
|
// We must not have a pad, which is a always terminal point for a track
|
||||||
if( aPcb->GetPadFast( aTrackRef->m_Start, aTrackRef->ReturnMaskLayer() ) )
|
if( aPcb->GetPadFast( aTrackRef->m_Start, aTrackRef->ReturnMaskLayer() ) )
|
||||||
|
@ -712,7 +713,7 @@ bool PCB_EDIT_FRAME::RemoveMisConnectedTracks()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
other = segment->GetTrace( GetBoard()->m_Track, NULL, START );
|
other = segment->GetTrace( GetBoard()->m_Track, NULL, FLG_START );
|
||||||
|
|
||||||
if( other )
|
if( other )
|
||||||
net_code_s = other->GetNet();
|
net_code_s = other->GetNet();
|
||||||
|
@ -730,7 +731,7 @@ bool PCB_EDIT_FRAME::RemoveMisConnectedTracks()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
other = segment->GetTrace( GetBoard()->m_Track, NULL, END );
|
other = segment->GetTrace( GetBoard()->m_Track, NULL, FLG_END );
|
||||||
|
|
||||||
if( other )
|
if( other )
|
||||||
net_code_e = other->GetNet();
|
net_code_e = other->GetNet();
|
||||||
|
@ -871,14 +872,14 @@ void ConnectDanglingEndToPad( PCB_EDIT_FRAME* aFrame )
|
||||||
if( aFrame->GetCanvas()->GetAbortRequest() )
|
if( aFrame->GetCanvas()->GetAbortRequest() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pad = aFrame->GetBoard()->GetPad( segment, START );
|
pad = aFrame->GetBoard()->GetPad( segment, FLG_START );
|
||||||
|
|
||||||
if( pad )
|
if( pad )
|
||||||
{
|
{
|
||||||
// test if the track start point is not exactly starting on the pad
|
// test if the track start point is not exactly starting on the pad
|
||||||
if( segment->m_Start != pad->GetPosition() )
|
if( segment->m_Start != pad->GetPosition() )
|
||||||
{
|
{
|
||||||
if( segment->GetTrace( aFrame->GetBoard()->m_Track, NULL, START ) == NULL )
|
if( segment->GetTrace( aFrame->GetBoard()->m_Track, NULL, FLG_START ) == NULL )
|
||||||
{
|
{
|
||||||
TRACK* newTrack = (TRACK*) segment->Clone();
|
TRACK* newTrack = (TRACK*) segment->Clone();
|
||||||
|
|
||||||
|
@ -893,14 +894,14 @@ void ConnectDanglingEndToPad( PCB_EDIT_FRAME* aFrame )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pad = aFrame->GetBoard()->GetPad( segment, END );
|
pad = aFrame->GetBoard()->GetPad( segment, FLG_END );
|
||||||
|
|
||||||
if( pad )
|
if( pad )
|
||||||
{
|
{
|
||||||
// test if the track end point is not exactly on the pad
|
// test if the track end point is not exactly on the pad
|
||||||
if( segment->m_End != pad->GetPosition() )
|
if( segment->m_End != pad->GetPosition() )
|
||||||
{
|
{
|
||||||
if( segment->GetTrace( aFrame->GetBoard()->m_Track, NULL, END ) == NULL )
|
if( segment->GetTrace( aFrame->GetBoard()->m_Track, NULL, FLG_END ) == NULL )
|
||||||
{
|
{
|
||||||
TRACK* newTrack = (TRACK*)segment->Clone();
|
TRACK* newTrack = (TRACK*)segment->Clone();
|
||||||
|
|
||||||
|
|
|
@ -263,7 +263,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC )
|
||||||
|
|
||||||
newTrack->SetState( BEGIN_ONPAD | END_ONPAD, OFF );
|
newTrack->SetState( BEGIN_ONPAD | END_ONPAD, OFF );
|
||||||
|
|
||||||
D_PAD* pad = GetBoard()->GetPad( previousTrack, END );
|
D_PAD* pad = GetBoard()->GetPad( previousTrack, FLG_END );
|
||||||
|
|
||||||
if( pad )
|
if( pad )
|
||||||
{
|
{
|
||||||
|
@ -1042,7 +1042,7 @@ void DeleteNullTrackSegments( BOARD* pcb, DLIST<TRACK>& aTrackList )
|
||||||
while( track != NULL )
|
while( track != NULL )
|
||||||
{
|
{
|
||||||
TRACK* next_track = track->Next();
|
TRACK* next_track = track->Next();
|
||||||
LockPoint = pcb->GetPad( track, END );
|
LockPoint = pcb->GetPad( track, FLG_END );
|
||||||
|
|
||||||
if( LockPoint )
|
if( LockPoint )
|
||||||
{
|
{
|
||||||
|
|
|
@ -1059,7 +1059,7 @@ void PCB_IO::format( ZONE_CONTAINER* aZone, int aNestLevel ) const
|
||||||
|
|
||||||
m_out->Print( 0, ")\n" );
|
m_out->Print( 0, ")\n" );
|
||||||
|
|
||||||
const std::vector< CPolyPt >& cv = aZone->m_Poly->corner;
|
const std::vector< CPolyPt >& cv = aZone->m_Poly->m_CornersList;
|
||||||
int newLine = 0;
|
int newLine = 0;
|
||||||
|
|
||||||
if( cv.size() )
|
if( cv.size() )
|
||||||
|
|
|
@ -3609,7 +3609,7 @@ void LEGACY_PLUGIN::saveZONE_CONTAINER( const ZONE_CONTAINER* me ) const
|
||||||
typedef std::vector< CPolyPt > CPOLY_PTS;
|
typedef std::vector< CPolyPt > CPOLY_PTS;
|
||||||
|
|
||||||
// Save the corner list
|
// Save the corner list
|
||||||
const CPOLY_PTS& cv = me->m_Poly->corner;
|
const CPOLY_PTS& cv = me->m_Poly->m_CornersList;
|
||||||
for( CPOLY_PTS::const_iterator it = cv.begin(); it != cv.end(); ++it )
|
for( CPOLY_PTS::const_iterator it = cv.begin(); it != cv.end(); ++it )
|
||||||
{
|
{
|
||||||
fprintf( m_fp, "ZCorner %s %d\n",
|
fprintf( m_fp, "ZCorner %s %d\n",
|
||||||
|
@ -3623,12 +3623,12 @@ void LEGACY_PLUGIN::saveZONE_CONTAINER( const ZONE_CONTAINER* me ) const
|
||||||
{
|
{
|
||||||
fprintf( m_fp, "$POLYSCORNERS\n" );
|
fprintf( m_fp, "$POLYSCORNERS\n" );
|
||||||
|
|
||||||
for( CPOLY_PTS::const_iterator it = fv.begin(); it != fv.end(); ++it )
|
for( CPOLY_PTS::const_iterator it = fv.begin(); it != fv.end(); ++it )
|
||||||
{
|
{
|
||||||
fprintf( m_fp, "%s %d %d\n",
|
fprintf( m_fp, "%s %d %d\n",
|
||||||
fmtBIUPair( it->x, it->y ).c_str(),
|
fmtBIUPair( it->x, it->y ).c_str(),
|
||||||
it->end_contour,
|
it->end_contour,
|
||||||
it->utility );
|
it->m_utility );
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf( m_fp, "$endPOLYSCORNERS\n" );
|
fprintf( m_fp, "$endPOLYSCORNERS\n" );
|
||||||
|
|
|
@ -887,7 +887,7 @@ void PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC
|
||||||
s_StartSegmentPresent = s_EndSegmentPresent = true;
|
s_StartSegmentPresent = s_EndSegmentPresent = true;
|
||||||
|
|
||||||
if( ( track->start == NULL ) || ( track->start->Type() == PCB_TRACE_T ) )
|
if( ( track->start == NULL ) || ( track->start->Type() == PCB_TRACE_T ) )
|
||||||
TrackToStartPoint = track->GetTrace( GetBoard()->m_Track, NULL, START );
|
TrackToStartPoint = track->GetTrace( GetBoard()->m_Track, NULL, FLG_START );
|
||||||
|
|
||||||
// Test if more than one segment is connected to this point
|
// Test if more than one segment is connected to this point
|
||||||
if( TrackToStartPoint )
|
if( TrackToStartPoint )
|
||||||
|
@ -895,14 +895,14 @@ void PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC
|
||||||
TrackToStartPoint->SetState( BUSY, ON );
|
TrackToStartPoint->SetState( BUSY, ON );
|
||||||
|
|
||||||
if( ( TrackToStartPoint->Type() == PCB_VIA_T )
|
if( ( TrackToStartPoint->Type() == PCB_VIA_T )
|
||||||
|| track->GetTrace( GetBoard()->m_Track, NULL, START ) )
|
|| track->GetTrace( GetBoard()->m_Track, NULL, FLG_START ) )
|
||||||
error = true;
|
error = true;
|
||||||
|
|
||||||
TrackToStartPoint->SetState( BUSY, OFF );
|
TrackToStartPoint->SetState( BUSY, OFF );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ( track->end == NULL ) || ( track->end->Type() == PCB_TRACE_T ) )
|
if( ( track->end == NULL ) || ( track->end->Type() == PCB_TRACE_T ) )
|
||||||
TrackToEndPoint = track->GetTrace( GetBoard()->m_Track, NULL, END );
|
TrackToEndPoint = track->GetTrace( GetBoard()->m_Track, NULL, FLG_END );
|
||||||
|
|
||||||
// Test if more than one segment is connected to this point
|
// Test if more than one segment is connected to this point
|
||||||
if( TrackToEndPoint )
|
if( TrackToEndPoint )
|
||||||
|
@ -910,7 +910,7 @@ void PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC
|
||||||
TrackToEndPoint->SetState( BUSY, ON );
|
TrackToEndPoint->SetState( BUSY, ON );
|
||||||
|
|
||||||
if( (TrackToEndPoint->Type() == PCB_VIA_T)
|
if( (TrackToEndPoint->Type() == PCB_VIA_T)
|
||||||
|| track->GetTrace( GetBoard()->m_Track, NULL, END ) )
|
|| track->GetTrace( GetBoard()->m_Track, NULL, FLG_END ) )
|
||||||
error = true;
|
error = true;
|
||||||
|
|
||||||
TrackToEndPoint->SetState( BUSY, OFF );
|
TrackToEndPoint->SetState( BUSY, OFF );
|
||||||
|
|
|
@ -25,8 +25,8 @@
|
||||||
#define VISIBLE_ONLY (1 << 3) ///< if module not on a visible layer, do not select
|
#define VISIBLE_ONLY (1 << 3) ///< if module not on a visible layer, do not select
|
||||||
|
|
||||||
|
|
||||||
#define START 0 /* Flag used in locate routines */
|
#define FLG_START 0 // Flag used in locate routines
|
||||||
#define END 1
|
#define FLG_END 1 // Flag used in locate routines
|
||||||
|
|
||||||
#define DIM_ANCRE_MODULE 3 /* Anchor size (footprint center) */
|
#define DIM_ANCRE_MODULE 3 /* Anchor size (footprint center) */
|
||||||
#define DIM_ANCRE_TEXTE 2 /* Anchor size (Text center) */
|
#define DIM_ANCRE_TEXTE 2 /* Anchor size (Text center) */
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
/*
|
|
||||||
* file polygons_defs.h
|
|
||||||
* definitions to use boost::polygon in KiCad.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _POLYGONS_DEFS_H_
|
|
||||||
#define _POLYGONS_DEFS_H_
|
|
||||||
|
|
||||||
#include <boost/polygon/polygon.hpp>
|
|
||||||
|
|
||||||
// Define some types used here from boost::polygon
|
|
||||||
namespace bpl = boost::polygon; // bpl = boost polygon library
|
|
||||||
using namespace bpl::operators; // +, -, =, ...
|
|
||||||
|
|
||||||
typedef int coordinate_type;
|
|
||||||
|
|
||||||
typedef bpl::polygon_data<int> KPolygon;
|
|
||||||
typedef std::vector<KPolygon> KPolygonSet;
|
|
||||||
|
|
||||||
typedef bpl::point_data<int> KPolyPoint;
|
|
||||||
#endif // #ifndef _POLYGONS_DEFS_H_
|
|
|
@ -1178,16 +1178,16 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard ) throw( IO_ERROR )
|
||||||
|
|
||||||
mainPolygon->layer_id = layerIds[ kicadLayer2pcb[ item->GetLayer() ] ];
|
mainPolygon->layer_id = layerIds[ kicadLayer2pcb[ item->GetLayer() ] ];
|
||||||
|
|
||||||
int count = item->m_Poly->corner.size();
|
int count = item->m_Poly->m_CornersList.size();
|
||||||
int ndx = 0; // used in 2 for() loops below
|
int ndx = 0; // used in 2 for() loops below
|
||||||
for( ; ndx<count; ++ndx )
|
for( ; ndx<count; ++ndx )
|
||||||
{
|
{
|
||||||
wxPoint point( item->m_Poly->corner[ndx].x,
|
wxPoint point( item->m_Poly->m_CornersList[ndx].x,
|
||||||
item->m_Poly->corner[ndx].y );
|
item->m_Poly->m_CornersList[ndx].y );
|
||||||
mainPolygon->AppendPoint( mapPt(point) );
|
mainPolygon->AppendPoint( mapPt(point) );
|
||||||
|
|
||||||
// this was the end of the main polygon
|
// this was the end of the main polygon
|
||||||
if( item->m_Poly->corner[ndx].end_contour )
|
if( item->m_Poly->m_CornersList[ndx].end_contour )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1197,7 +1197,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard ) throw( IO_ERROR )
|
||||||
// handle the cutouts
|
// handle the cutouts
|
||||||
for( ++ndx; ndx<count; ++ndx )
|
for( ++ndx; ndx<count; ++ndx )
|
||||||
{
|
{
|
||||||
if( item->m_Poly->corner[ndx-1].end_contour )
|
if( item->m_Poly->m_CornersList[ndx-1].end_contour )
|
||||||
{
|
{
|
||||||
window = new WINDOW( plane );
|
window = new WINDOW( plane );
|
||||||
plane->AddWindow( window );
|
plane->AddWindow( window );
|
||||||
|
@ -1211,8 +1211,8 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard ) throw( IO_ERROR )
|
||||||
wxASSERT( window );
|
wxASSERT( window );
|
||||||
wxASSERT( cutout );
|
wxASSERT( cutout );
|
||||||
|
|
||||||
wxPoint point(item->m_Poly->corner[ndx].x,
|
wxPoint point(item->m_Poly->m_CornersList[ndx].x,
|
||||||
item->m_Poly->corner[ndx].y );
|
item->m_Poly->m_CornersList[ndx].y );
|
||||||
cutout->AppendPoint( mapPt(point) );
|
cutout->AppendPoint( mapPt(point) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1253,16 +1253,16 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard ) throw( IO_ERROR )
|
||||||
|
|
||||||
mainPolygon->layer_id = layerIds[ kicadLayer2pcb[ item->GetLayer() ] ];
|
mainPolygon->layer_id = layerIds[ kicadLayer2pcb[ item->GetLayer() ] ];
|
||||||
|
|
||||||
int count = item->m_Poly->corner.size();
|
int count = item->m_Poly->m_CornersList.size();
|
||||||
int ndx = 0; // used in 2 for() loops below
|
int ndx = 0; // used in 2 for() loops below
|
||||||
for( ; ndx<count; ++ndx )
|
for( ; ndx<count; ++ndx )
|
||||||
{
|
{
|
||||||
wxPoint point( item->m_Poly->corner[ndx].x,
|
wxPoint point( item->m_Poly->m_CornersList[ndx].x,
|
||||||
item->m_Poly->corner[ndx].y );
|
item->m_Poly->m_CornersList[ndx].y );
|
||||||
mainPolygon->AppendPoint( mapPt(point) );
|
mainPolygon->AppendPoint( mapPt(point) );
|
||||||
|
|
||||||
// this was the end of the main polygon
|
// this was the end of the main polygon
|
||||||
if( item->m_Poly->corner[ndx].end_contour )
|
if( item->m_Poly->m_CornersList[ndx].end_contour )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1272,7 +1272,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard ) throw( IO_ERROR )
|
||||||
// handle the cutouts
|
// handle the cutouts
|
||||||
for( ++ndx; ndx<count; ++ndx )
|
for( ++ndx; ndx<count; ++ndx )
|
||||||
{
|
{
|
||||||
if( item->m_Poly->corner[ndx-1].end_contour )
|
if( item->m_Poly->m_CornersList[ndx-1].end_contour )
|
||||||
{
|
{
|
||||||
window = new WINDOW( keepout );
|
window = new WINDOW( keepout );
|
||||||
keepout->AddWindow( window );
|
keepout->AddWindow( window );
|
||||||
|
@ -1286,8 +1286,8 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard ) throw( IO_ERROR )
|
||||||
wxASSERT( window );
|
wxASSERT( window );
|
||||||
wxASSERT( cutout );
|
wxASSERT( cutout );
|
||||||
|
|
||||||
wxPoint point(item->m_Poly->corner[ndx].x,
|
wxPoint point(item->m_Poly->m_CornersList[ndx].x,
|
||||||
item->m_Poly->corner[ndx].y );
|
item->m_Poly->m_CornersList[ndx].y );
|
||||||
cutout->AppendPoint( mapPt(point) );
|
cutout->AppendPoint( mapPt(point) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,39 +89,12 @@ int ZONE_CONTAINER::BuildFilledPolysListData( BOARD* aPcb, std::vector <CPolyPt>
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_smoothedPoly->MakeKboolPoly( -1, -1, NULL, true );
|
if( aCornerBuffer )
|
||||||
int count = 0;
|
ConvertPolysListWithHolesToOnePolygon( m_smoothedPoly->m_CornersList,
|
||||||
while( m_smoothedPoly->GetKboolEngine()->StartPolygonGet() )
|
*aCornerBuffer );
|
||||||
{
|
else
|
||||||
CPolyPt corner( 0, 0, false );
|
ConvertPolysListWithHolesToOnePolygon( m_smoothedPoly->m_CornersList,
|
||||||
while( m_smoothedPoly->GetKboolEngine()->PolygonHasMorePoints() )
|
m_FilledPolysList );
|
||||||
{
|
|
||||||
corner.x = (int) m_smoothedPoly->GetKboolEngine()->GetPolygonXPoint();
|
|
||||||
corner.y = (int) m_smoothedPoly->GetKboolEngine()->GetPolygonYPoint();
|
|
||||||
corner.end_contour = false;
|
|
||||||
if( aCornerBuffer )
|
|
||||||
aCornerBuffer->push_back( corner );
|
|
||||||
else
|
|
||||||
m_FilledPolysList.push_back( corner );
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
|
|
||||||
corner.end_contour = true;
|
|
||||||
if( aCornerBuffer )
|
|
||||||
{
|
|
||||||
aCornerBuffer->pop_back();
|
|
||||||
aCornerBuffer->push_back( corner );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_FilledPolysList.pop_back();
|
|
||||||
m_FilledPolysList.push_back( corner );
|
|
||||||
}
|
|
||||||
m_smoothedPoly->GetKboolEngine()->EndPolygonGet();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_smoothedPoly->FreeKboolEngine();
|
|
||||||
|
|
||||||
/* For copper layers, we now must add holes in the Polygon list.
|
/* For copper layers, we now must add holes in the Polygon list.
|
||||||
* holes are pads and tracks with their clearance area
|
* holes are pads and tracks with their clearance area
|
||||||
*/
|
*/
|
||||||
|
@ -134,7 +107,7 @@ int ZONE_CONTAINER::BuildFilledPolysListData( BOARD* aPcb, std::vector <CPolyPt>
|
||||||
Fill_Zone_Areas_With_Segments( );
|
Fill_Zone_Areas_With_Segments( );
|
||||||
}
|
}
|
||||||
|
|
||||||
return count;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort function to build filled zones
|
// Sort function to build filled zones
|
||||||
|
@ -188,7 +161,7 @@ int ZONE_CONTAINER::Fill_Zone_Areas_With_Segments()
|
||||||
x_coordinates.clear();
|
x_coordinates.clear();
|
||||||
for( ics = istart, ice = iend; ics <= iend; ice = ics, ics++ )
|
for( ics = istart, ice = iend; ics <= iend; ice = ics, ics++ )
|
||||||
{
|
{
|
||||||
if ( m_FilledPolysList[ice].utility )
|
if ( m_FilledPolysList[ice].m_utility )
|
||||||
continue;
|
continue;
|
||||||
int seg_startX = m_FilledPolysList[ics].x;
|
int seg_startX = m_FilledPolysList[ics].x;
|
||||||
int seg_startY = m_FilledPolysList[ics].y;
|
int seg_startY = m_FilledPolysList[ics].y;
|
||||||
|
|
|
@ -81,14 +81,14 @@ extern void CreateThermalReliefPadPolygon( std::vector<CPolyPt>& aCornerBuffer,
|
||||||
int aThermalRot );
|
int aThermalRot );
|
||||||
|
|
||||||
// Local Functions: helper function to calculate solid areas
|
// Local Functions: helper function to calculate solid areas
|
||||||
static void AddPolygonCornersToKPolygonList( std::vector <CPolyPt>& aCornersBuffer,
|
static void AddPolygonCornersToKiPolygonList( std::vector <CPolyPt>& aCornersBuffer,
|
||||||
KPolygonSet& aKPolyList );
|
KI_POLYGON_SET& aKiPolyList );
|
||||||
|
|
||||||
static int CopyPolygonsFromKPolygonListToFilledPolysList( ZONE_CONTAINER* aZone,
|
static int CopyPolygonsFromKiPolygonListToFilledPolysList( ZONE_CONTAINER* aZone,
|
||||||
KPolygonSet& aKPolyList );
|
KI_POLYGON_SET& aKiPolyList );
|
||||||
|
|
||||||
static int CopyPolygonsFromFilledPolysListTotKPolygonList( ZONE_CONTAINER* aZone,
|
static int CopyPolygonsFromFilledPolysListToKiPolygonList( ZONE_CONTAINER* aZone,
|
||||||
KPolygonSet& aKPolyList );
|
KI_POLYGON_SET& aKiPolyList );
|
||||||
|
|
||||||
|
|
||||||
// Local Variables:
|
// Local Variables:
|
||||||
|
@ -148,8 +148,8 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
|
||||||
*/
|
*/
|
||||||
s_Correction = 1.0 / cos( 3.14159265 / s_CircleToSegmentsCount );
|
s_Correction = 1.0 / cos( 3.14159265 / s_CircleToSegmentsCount );
|
||||||
|
|
||||||
// This KPolygonSet is the area(s) to fill, with m_ZoneMinThickness/2
|
// This KI_POLYGON_SET is the area(s) to fill, with m_ZoneMinThickness/2
|
||||||
KPolygonSet polyset_zone_solid_areas;
|
KI_POLYGON_SET polyset_zone_solid_areas;
|
||||||
int margin = m_ZoneMinThickness / 2;
|
int margin = m_ZoneMinThickness / 2;
|
||||||
|
|
||||||
/* First, creates the main polygon (i.e. the filled area using only one outline)
|
/* First, creates the main polygon (i.e. the filled area using only one outline)
|
||||||
|
@ -160,7 +160,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
|
||||||
* the main polygon is stored in polyset_zone_solid_areas
|
* the main polygon is stored in polyset_zone_solid_areas
|
||||||
*/
|
*/
|
||||||
|
|
||||||
CopyPolygonsFromFilledPolysListTotKPolygonList( this, polyset_zone_solid_areas );
|
CopyPolygonsFromFilledPolysListToKiPolygonList( this, polyset_zone_solid_areas );
|
||||||
polyset_zone_solid_areas -= margin;
|
polyset_zone_solid_areas -= margin;
|
||||||
|
|
||||||
if( polyset_zone_solid_areas.size() == 0 )
|
if( polyset_zone_solid_areas.size() == 0 )
|
||||||
|
@ -431,15 +431,15 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
|
||||||
// Calculate now actual solid areas
|
// Calculate now actual solid areas
|
||||||
if( cornerBufferPolysToSubstract.size() > 0 )
|
if( cornerBufferPolysToSubstract.size() > 0 )
|
||||||
{
|
{
|
||||||
KPolygonSet polyset_holes;
|
KI_POLYGON_SET polyset_holes;
|
||||||
AddPolygonCornersToKPolygonList( cornerBufferPolysToSubstract, polyset_holes );
|
AddPolygonCornersToKiPolygonList( cornerBufferPolysToSubstract, polyset_holes );
|
||||||
// Remove holes from initial area.:
|
// Remove holes from initial area.:
|
||||||
polyset_zone_solid_areas -= polyset_holes;
|
polyset_zone_solid_areas -= polyset_holes;
|
||||||
}
|
}
|
||||||
|
|
||||||
// put solid areas in m_FilledPolysList:
|
// put solid areas in m_FilledPolysList:
|
||||||
m_FilledPolysList.clear();
|
m_FilledPolysList.clear();
|
||||||
CopyPolygonsFromKPolygonListToFilledPolysList( this, polyset_zone_solid_areas );
|
CopyPolygonsFromKiPolygonListToFilledPolysList( this, polyset_zone_solid_areas );
|
||||||
|
|
||||||
// Remove insulated islands:
|
// Remove insulated islands:
|
||||||
if( GetNet() > 0 )
|
if( GetNet() > 0 )
|
||||||
|
@ -455,13 +455,13 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
|
||||||
// remove copper areas
|
// remove copper areas
|
||||||
if( cornerBufferPolysToSubstract.size() )
|
if( cornerBufferPolysToSubstract.size() )
|
||||||
{
|
{
|
||||||
KPolygonSet polyset_holes;
|
KI_POLYGON_SET polyset_holes;
|
||||||
AddPolygonCornersToKPolygonList( cornerBufferPolysToSubstract, polyset_holes );
|
AddPolygonCornersToKiPolygonList( cornerBufferPolysToSubstract, polyset_holes );
|
||||||
polyset_zone_solid_areas -= polyset_holes;
|
polyset_zone_solid_areas -= polyset_holes;
|
||||||
|
|
||||||
// put these areas in m_FilledPolysList
|
// put these areas in m_FilledPolysList
|
||||||
m_FilledPolysList.clear();
|
m_FilledPolysList.clear();
|
||||||
CopyPolygonsFromKPolygonListToFilledPolysList( this, polyset_zone_solid_areas );
|
CopyPolygonsFromKiPolygonListToFilledPolysList( this, polyset_zone_solid_areas );
|
||||||
|
|
||||||
if( GetNet() > 0 )
|
if( GetNet() > 0 )
|
||||||
Test_For_Copper_Island_And_Remove_Insulated_Islands( aPcb );
|
Test_For_Copper_Island_And_Remove_Insulated_Islands( aPcb );
|
||||||
|
@ -470,12 +470,12 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
|
||||||
cornerBufferPolysToSubstract.clear();
|
cornerBufferPolysToSubstract.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddPolygonCornersToKPolygonList( std::vector <CPolyPt>& aCornersBuffer,
|
void AddPolygonCornersToKiPolygonList( std::vector <CPolyPt>& aCornersBuffer,
|
||||||
KPolygonSet& aKPolyList )
|
KI_POLYGON_SET& aKiPolyList )
|
||||||
{
|
{
|
||||||
unsigned ii;
|
unsigned ii;
|
||||||
|
|
||||||
std::vector<KPolyPoint> cornerslist;
|
std::vector<KI_POLY_POINT> cornerslist;
|
||||||
|
|
||||||
int polycount = 0;
|
int polycount = 0;
|
||||||
|
|
||||||
|
@ -485,49 +485,45 @@ void AddPolygonCornersToKPolygonList( std::vector <CPolyPt>& aCornersBuffer,
|
||||||
polycount++;
|
polycount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
aKPolyList.reserve( polycount );
|
aKiPolyList.reserve( polycount );
|
||||||
|
|
||||||
for( unsigned icnt = 0; icnt < aCornersBuffer.size(); )
|
for( unsigned icnt = 0; icnt < aCornersBuffer.size(); )
|
||||||
{
|
{
|
||||||
KPolygon poly;
|
KI_POLYGON poly;
|
||||||
cornerslist.clear();
|
cornerslist.clear();
|
||||||
|
|
||||||
for( ii = icnt; ii < aCornersBuffer.size(); ii++ )
|
for( ii = icnt; ii < aCornersBuffer.size(); ii++ )
|
||||||
{
|
{
|
||||||
cornerslist.push_back( KPolyPoint( aCornersBuffer[ii].x, aCornersBuffer[ii].y ) );
|
cornerslist.push_back( KI_POLY_POINT( aCornersBuffer[ii].x, aCornersBuffer[ii].y ) );
|
||||||
|
|
||||||
if( aCornersBuffer[ii].end_contour )
|
if( aCornersBuffer[ii].end_contour )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
bpl::set_points( poly, cornerslist.begin(), cornerslist.end() );
|
bpl::set_points( poly, cornerslist.begin(), cornerslist.end() );
|
||||||
aKPolyList.push_back( poly );
|
aKiPolyList.push_back( poly );
|
||||||
icnt = ii + 1;
|
icnt = ii + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int CopyPolygonsFromKPolygonListToFilledPolysList( ZONE_CONTAINER* aZone,
|
int CopyPolygonsFromKiPolygonListToFilledPolysList( ZONE_CONTAINER* aZone,
|
||||||
KPolygonSet& aKPolyList )
|
KI_POLYGON_SET& aKiPolyList )
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
std::vector<CPolyPt> polysList;
|
std::vector<CPolyPt> polysList;
|
||||||
|
|
||||||
for( unsigned ii = 0; ii < aKPolyList.size(); ii++ )
|
for( unsigned ii = 0; ii < aKiPolyList.size(); ii++ )
|
||||||
{
|
{
|
||||||
KPolygon& poly = aKPolyList[ii];
|
KI_POLYGON& poly = aKiPolyList[ii];
|
||||||
CPolyPt corner( 0, 0, false );
|
CPolyPt corner( 0, 0, false );
|
||||||
|
|
||||||
for( unsigned jj = 0; jj < poly.size(); jj++ )
|
for( unsigned jj = 0; jj < poly.size(); jj++ )
|
||||||
{
|
{
|
||||||
KPolyPoint point = *(poly.begin() + jj);
|
KI_POLY_POINT point = *(poly.begin() + jj);
|
||||||
corner.x = point.x();
|
corner.x = point.x();
|
||||||
corner.y = point.y();
|
corner.y = point.y();
|
||||||
corner.end_contour = false;
|
corner.end_contour = false;
|
||||||
|
|
||||||
// Flag this corner if starting a hole connection segment:
|
|
||||||
// This is used by draw functions to draw only useful segments (and not extra segments)
|
|
||||||
// corner.utility = (aBoolengine->GetPolygonPointEdgeType() == KB_FALSE_EDGE) ? 1 : 0;
|
|
||||||
polysList.push_back( corner );
|
polysList.push_back( corner );
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
@ -542,10 +538,10 @@ int CopyPolygonsFromKPolygonListToFilledPolysList( ZONE_CONTAINER* aZone,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int CopyPolygonsFromFilledPolysListTotKPolygonList( ZONE_CONTAINER* aZone,
|
int CopyPolygonsFromFilledPolysListToKiPolygonList( ZONE_CONTAINER* aZone,
|
||||||
KPolygonSet& aKPolyList )
|
KI_POLYGON_SET& aKiPolyList )
|
||||||
{
|
{
|
||||||
std::vector<CPolyPt> polysList = aZone->GetFilledPolysList();
|
const std::vector<CPolyPt>& polysList = aZone->GetFilledPolysList();
|
||||||
unsigned corners_count = polysList.size();
|
unsigned corners_count = polysList.size();
|
||||||
int count = 0;
|
int count = 0;
|
||||||
unsigned ic = 0;
|
unsigned ic = 0;
|
||||||
|
@ -554,35 +550,32 @@ int CopyPolygonsFromFilledPolysListTotKPolygonList( ZONE_CONTAINER* aZone,
|
||||||
|
|
||||||
for( unsigned ii = 0; ii < corners_count; ii++ )
|
for( unsigned ii = 0; ii < corners_count; ii++ )
|
||||||
{
|
{
|
||||||
CPolyPt* corner = &polysList[ic];
|
const CPolyPt& corner = polysList[ii];
|
||||||
|
|
||||||
if( corner->end_contour )
|
if( corner.end_contour )
|
||||||
polycount++;
|
polycount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
aKPolyList.reserve( polycount );
|
aKiPolyList.reserve( polycount );
|
||||||
std::vector<KPolyPoint> cornerslist;
|
std::vector<KI_POLY_POINT> cornerslist;
|
||||||
|
|
||||||
while( ic < corners_count )
|
while( ic < corners_count )
|
||||||
{
|
{
|
||||||
cornerslist.clear();
|
cornerslist.clear();
|
||||||
KPolygon poly;
|
KI_POLYGON poly;
|
||||||
{
|
{
|
||||||
for( ; ic < corners_count; ic++ )
|
while( ic < corners_count )
|
||||||
{
|
{
|
||||||
CPolyPt* corner = &polysList[ic];
|
const CPolyPt& corner = polysList[ic++];
|
||||||
cornerslist.push_back( KPolyPoint( corner->x, corner->y ) );
|
cornerslist.push_back( KI_POLY_POINT( corner.x, corner.y ) );
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
if( corner->end_contour )
|
if( corner.end_contour )
|
||||||
{
|
|
||||||
ic++;
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bpl::set_points( poly, cornerslist.begin(), cornerslist.end() );
|
bpl::set_points( poly, cornerslist.begin(), cornerslist.end() );
|
||||||
aKPolyList.push_back( poly );
|
aKiPolyList.push_back( poly );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ bool ZONE_CONTAINER::IsSame( const ZONE_CONTAINER& aZoneToCompare )
|
||||||
wxASSERT( m_Poly ); // m_Poly == NULL Should never happen
|
wxASSERT( m_Poly ); // m_Poly == NULL Should never happen
|
||||||
wxASSERT( aZoneToCompare.m_Poly );
|
wxASSERT( aZoneToCompare.m_Poly );
|
||||||
|
|
||||||
if( m_Poly->corner != aZoneToCompare.m_Poly->corner ) // Compare vector
|
if( m_Poly->m_CornersList != aZoneToCompare.m_Poly->m_CornersList ) // Compare vector
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -142,7 +142,7 @@ int BOARD::TestAreaPolygon( ZONE_CONTAINER* CurrArea )
|
||||||
// first, check for sides intersecting other sides, especially arcs
|
// first, check for sides intersecting other sides, especially arcs
|
||||||
bool bInt = false;
|
bool bInt = false;
|
||||||
bool bArcInt = false;
|
bool bArcInt = false;
|
||||||
int n_cont = p->GetNumContours();
|
int n_cont = p->GetContoursCount();
|
||||||
|
|
||||||
// make bounding rect for each contour
|
// make bounding rect for each contour
|
||||||
std::vector<CRect> cr;
|
std::vector<CRect> cr;
|
||||||
|
@ -550,7 +550,7 @@ bool BOARD::TestAreaIntersections( ZONE_CONTAINER* area_to_test )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// test for intersecting segments
|
// test for intersecting segments
|
||||||
for( int icont1 = 0; icont1<poly1->GetNumContours(); icont1++ )
|
for( int icont1 = 0; icont1<poly1->GetContoursCount(); icont1++ )
|
||||||
{
|
{
|
||||||
int is1 = poly1->GetContourStart( icont1 );
|
int is1 = poly1->GetContourStart( icont1 );
|
||||||
int ie1 = poly1->GetContourEnd( icont1 );
|
int ie1 = poly1->GetContourEnd( icont1 );
|
||||||
|
@ -574,7 +574,7 @@ bool BOARD::TestAreaIntersections( ZONE_CONTAINER* area_to_test )
|
||||||
|
|
||||||
style1 = poly1->GetSideStyle( ic1 );
|
style1 = poly1->GetSideStyle( ic1 );
|
||||||
|
|
||||||
for( int icont2 = 0; icont2 < poly2->GetNumContours(); icont2++ )
|
for( int icont2 = 0; icont2 < poly2->GetContoursCount(); icont2++ )
|
||||||
{
|
{
|
||||||
int is2 = poly2->GetContourStart( icont2 );
|
int is2 = poly2->GetContourStart( icont2 );
|
||||||
int ie2 = poly2->GetContourEnd( icont2 );
|
int ie2 = poly2->GetContourEnd( icont2 );
|
||||||
|
@ -668,7 +668,7 @@ int BOARD::TestAreaIntersection( ZONE_CONTAINER* area_ref, ZONE_CONTAINER* area_
|
||||||
bool bInt = false;
|
bool bInt = false;
|
||||||
bool bArcInt = false;
|
bool bArcInt = false;
|
||||||
|
|
||||||
for( int icont1 = 0; icont1<poly1->GetNumContours(); icont1++ )
|
for( int icont1 = 0; icont1<poly1->GetContoursCount(); icont1++ )
|
||||||
{
|
{
|
||||||
int is1 = poly1->GetContourStart( icont1 );
|
int is1 = poly1->GetContourStart( icont1 );
|
||||||
int ie1 = poly1->GetContourEnd( icont1 );
|
int ie1 = poly1->GetContourEnd( icont1 );
|
||||||
|
@ -692,7 +692,7 @@ int BOARD::TestAreaIntersection( ZONE_CONTAINER* area_ref, ZONE_CONTAINER* area_
|
||||||
|
|
||||||
style1 = poly1->GetSideStyle( ic1 );
|
style1 = poly1->GetSideStyle( ic1 );
|
||||||
|
|
||||||
for( int icont2 = 0; icont2<poly2->GetNumContours(); icont2++ )
|
for( int icont2 = 0; icont2<poly2->GetContoursCount(); icont2++ )
|
||||||
{
|
{
|
||||||
int is2 = poly2->GetContourStart( icont2 );
|
int is2 = poly2->GetContourStart( icont2 );
|
||||||
int ie2 = poly2->GetContourEnd( icont2 );
|
int ie2 = poly2->GetContourEnd( icont2 );
|
||||||
|
@ -781,142 +781,84 @@ int BOARD::TestAreaIntersection( ZONE_CONTAINER* area_ref, ZONE_CONTAINER* area_
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function CombineAreas
|
* Function CombineAreas
|
||||||
* If possible, combine 2 copper areas
|
* Merge 2 copper areas (which are expected intersecting)
|
||||||
* @param aDeletedList = a PICKED_ITEMS_LIST * where to store deleted areas (useful in undo
|
* @param aDeletedList = a PICKED_ITEMS_LIST * where to store deleted areas (useful in undo
|
||||||
* commands can be NULL
|
* commands can be NULL
|
||||||
* @param area_ref = tje main area (zone)
|
* @param area_ref = the main area (zone)
|
||||||
* @param area_to_combine = the zone that can be merged with area_ref
|
* @param area_to_combine = the zone that can be merged with area_ref
|
||||||
* area_ref must be BEFORE area_to_combine
|
* area_ref must be BEFORE area_to_combine
|
||||||
* area_to_combine will be deleted, if areas are combined
|
* area_to_combine will be deleted, if areas are combined
|
||||||
* @return : 0 if no intersection
|
* @return : 0 if no intersection
|
||||||
* 1 if intersection
|
* 1 if intersection
|
||||||
* 2 if arcs intersect
|
* 2 if arcs intersect (Currently not supported)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int BOARD::CombineAreas( PICKED_ITEMS_LIST* aDeletedList, ZONE_CONTAINER* area_ref,
|
int BOARD::CombineAreas( PICKED_ITEMS_LIST* aDeletedList, ZONE_CONTAINER* area_ref,
|
||||||
ZONE_CONTAINER* area_to_combine )
|
ZONE_CONTAINER* area_to_combine )
|
||||||
{
|
{
|
||||||
if( area_ref == area_to_combine )
|
if( area_ref == area_to_combine )
|
||||||
{
|
{
|
||||||
wxASSERT( 0 );
|
wxASSERT( 0 );
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// polygons intersect, combine them
|
// polygons intersect, combine them
|
||||||
std::vector<CArc> arc_array1;
|
// std::vector<CArc> arc_array1;
|
||||||
std::vector<CArc> arc_array2;
|
// std::vector<CArc> arc_array2;
|
||||||
bool keep_area_to_combine = false;
|
bool keep_area_to_combine = false; // TODO test if areas intersect
|
||||||
|
|
||||||
Bool_Engine* booleng = new Bool_Engine();
|
KI_POLYGON_WITH_HOLES areaRefPoly;
|
||||||
ArmBoolEng( booleng );
|
KI_POLYGON_WITH_HOLES areaToMergePoly;
|
||||||
|
CopyPolysListToKiPolygonWithHole( area_ref->m_Poly->m_CornersList, areaRefPoly );
|
||||||
|
CopyPolysListToKiPolygonWithHole( area_to_combine->m_Poly->m_CornersList, areaToMergePoly );
|
||||||
|
|
||||||
area_ref->m_Poly->AddPolygonsToBoolEng( booleng, GROUP_A, -1, -1 );
|
KI_POLYGON_WITH_HOLES_SET mergedOutlines;
|
||||||
area_to_combine->m_Poly->AddPolygonsToBoolEng( booleng, GROUP_B, -1, -1 );
|
mergedOutlines.push_back( areaRefPoly );
|
||||||
booleng->Do_Operation( BOOL_OR );
|
mergedOutlines += areaToMergePoly;
|
||||||
|
|
||||||
|
// We should have only one polygon with holes in mergedOutlines
|
||||||
|
// or the 2 initial outlines do not intersect
|
||||||
|
if( mergedOutlines.size() > 1 )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
areaRefPoly = mergedOutlines[0];
|
||||||
|
area_ref->m_Poly->RemoveAllContours();
|
||||||
|
|
||||||
|
KI_POLYGON_WITH_HOLES::iterator_type corner = areaRefPoly.begin();
|
||||||
// create area with external contour: Recreate only area edges, NOT holes
|
// create area with external contour: Recreate only area edges, NOT holes
|
||||||
if( booleng->StartPolygonGet() )
|
area_ref->m_Poly->Start( area_ref->GetLayer(), corner->x(), corner->y(),
|
||||||
|
area_ref->m_Poly->GetHatchStyle() );
|
||||||
|
while( ++corner != areaRefPoly.end() )
|
||||||
{
|
{
|
||||||
if( booleng->GetPolygonPointEdgeType() == KB_INSIDE_EDGE )
|
area_ref->m_Poly->AppendCorner( corner->x(), corner->y() );
|
||||||
|
}
|
||||||
|
|
||||||
|
area_ref->m_Poly->Close();
|
||||||
|
|
||||||
|
// add holes (set of polygons)
|
||||||
|
KI_POLYGON_WITH_HOLES::iterator_holes_type hole = areaRefPoly.begin_holes();
|
||||||
|
while( hole != areaRefPoly.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() )
|
||||||
{
|
{
|
||||||
DisplayError( NULL, wxT( "BOARD::CombineAreas() error: unexpected hole descriptor" ) );
|
area_ref->m_Poly->AppendCorner( hole_corner->x(), hole_corner->y() );
|
||||||
|
hole_corner++;
|
||||||
}
|
}
|
||||||
|
|
||||||
area_ref->m_Poly->RemoveAllContours();
|
|
||||||
|
|
||||||
// foreach point in the polygon
|
|
||||||
bool first = true;
|
|
||||||
|
|
||||||
while( booleng->PolygonHasMorePoints() )
|
|
||||||
{
|
|
||||||
int x = (int) booleng->GetPolygonXPoint();
|
|
||||||
int y = (int) booleng->GetPolygonYPoint();
|
|
||||||
|
|
||||||
if( first )
|
|
||||||
{
|
|
||||||
first = false;
|
|
||||||
area_ref->m_Poly->Start( area_ref->GetLayer(
|
|
||||||
), x, y, area_ref->m_Poly->GetHatchStyle() );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
area_ref->m_Poly->AppendCorner( x, y );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
booleng->EndPolygonGet();
|
|
||||||
area_ref->m_Poly->Close();
|
area_ref->m_Poly->Close();
|
||||||
|
hole++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recreate the area_to_combine if a second polygon exists
|
|
||||||
// if not exists , the first poly contains the 2 initial polygons
|
|
||||||
#if 0 // TestAreaIntersection must be called before combine areas, so
|
|
||||||
// 2 intersecting areas are expected, and only one outline contour after combining areas
|
|
||||||
else
|
|
||||||
{
|
|
||||||
area_to_combine->m_Poly->RemoveAllContours();
|
|
||||||
keep_area_to_combine = true;
|
|
||||||
|
|
||||||
// create area with external contour: Recreate only area edges, NOT holes (todo..)
|
|
||||||
{
|
|
||||||
// foreach point in the polygon
|
|
||||||
bool first = true;
|
|
||||||
while( booleng->PolygonHasMorePoints() )
|
|
||||||
{
|
|
||||||
int x = booleng->GetPolygonXPoint();
|
|
||||||
int y = booleng->GetPolygonYPoint();
|
|
||||||
|
|
||||||
if( first )
|
|
||||||
{
|
|
||||||
first = false;
|
|
||||||
area_to_combine->m_Poly->Start( area_ref->GetLayer(), x, y,
|
|
||||||
area_ref->m_Poly->GetHatchStyle() );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
area_to_combine->m_Poly->AppendCorner( x, y );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
booleng->EndPolygonGet();
|
|
||||||
area_to_combine->m_Poly->Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// add holes
|
|
||||||
bool show_error = true;
|
|
||||||
|
|
||||||
while( booleng->StartPolygonGet() )
|
|
||||||
{
|
|
||||||
// we expect all vertex are holes inside the main outline
|
|
||||||
if( booleng->GetPolygonPointEdgeType() != KB_INSIDE_EDGE )
|
|
||||||
{
|
|
||||||
if( show_error ) // show this error only once, if happens
|
|
||||||
DisplayError( NULL,
|
|
||||||
wxT( "BOARD::CombineAreas() error: unexpected outside contour descriptor" ) );
|
|
||||||
|
|
||||||
show_error = false;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
while( booleng->PolygonHasMorePoints() )
|
|
||||||
{
|
|
||||||
int x = (int) booleng->GetPolygonXPoint();
|
|
||||||
int y = (int) booleng->GetPolygonYPoint();
|
|
||||||
area_ref->m_Poly->AppendCorner( x, y );
|
|
||||||
}
|
|
||||||
|
|
||||||
area_ref->m_Poly->Close();
|
|
||||||
booleng->EndPolygonGet();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !keep_area_to_combine )
|
if( !keep_area_to_combine )
|
||||||
RemoveArea( aDeletedList, area_to_combine );
|
RemoveArea( aDeletedList, area_to_combine );
|
||||||
|
|
||||||
area_ref->utility = 1;
|
area_ref->utility = 1;
|
||||||
area_ref->m_Poly->RestoreArcs( &arc_array1 );
|
// area_ref->m_Poly->RestoreArcs( &arc_array1 );
|
||||||
area_ref->m_Poly->RestoreArcs( &arc_array2 );
|
// area_ref->m_Poly->RestoreArcs( &arc_array2 );
|
||||||
area_ref->m_Poly->Hatch();
|
area_ref->m_Poly->Hatch();
|
||||||
delete booleng;
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1024,7 +966,7 @@ int BOARD::Test_Drc_Areas_Outlines_To_Areas_Outlines( ZONE_CONTAINER* aArea_To_E
|
||||||
}
|
}
|
||||||
|
|
||||||
// now test spacing between areas
|
// now test spacing between areas
|
||||||
for( int icont = 0; icont < refSmoothedPoly->GetNumContours(); icont++ )
|
for( int icont = 0; icont < refSmoothedPoly->GetContoursCount(); icont++ )
|
||||||
{
|
{
|
||||||
int ic_start = refSmoothedPoly->GetContourStart( icont );
|
int ic_start = refSmoothedPoly->GetContourStart( icont );
|
||||||
int ic_end = refSmoothedPoly->GetContourEnd( icont );
|
int ic_end = refSmoothedPoly->GetContourEnd( icont );
|
||||||
|
@ -1048,7 +990,7 @@ int BOARD::Test_Drc_Areas_Outlines_To_Areas_Outlines( ZONE_CONTAINER* aArea_To_E
|
||||||
|
|
||||||
int astyle = refSmoothedPoly->GetSideStyle( ic );
|
int astyle = refSmoothedPoly->GetSideStyle( ic );
|
||||||
|
|
||||||
for( int icont2 = 0; icont2 < testSmoothedPoly->GetNumContours(); icont2++ )
|
for( int icont2 = 0; icont2 < testSmoothedPoly->GetContoursCount(); icont2++ )
|
||||||
{
|
{
|
||||||
int ic_start2 = testSmoothedPoly->GetContourStart( icont2 );
|
int ic_start2 = testSmoothedPoly->GetContourStart( icont2 );
|
||||||
int ic_end2 = testSmoothedPoly->GetContourEnd( icont2 );
|
int ic_end2 = testSmoothedPoly->GetContourEnd( icont2 );
|
||||||
|
@ -1128,7 +1070,7 @@ bool DRC::doEdgeZoneDrc( ZONE_CONTAINER* aArea, int aCornerIndex )
|
||||||
wxPoint end;
|
wxPoint end;
|
||||||
|
|
||||||
// Search the end point of the edge starting at aCornerIndex
|
// Search the end point of the edge starting at aCornerIndex
|
||||||
if( aArea->m_Poly->corner[aCornerIndex].end_contour == false
|
if( aArea->m_Poly->m_CornersList[aCornerIndex].end_contour == false
|
||||||
&& aCornerIndex < (aArea->GetNumCorners() - 1) )
|
&& aCornerIndex < (aArea->GetNumCorners() - 1) )
|
||||||
{
|
{
|
||||||
end = aArea->GetCornerPosition( aCornerIndex + 1 );
|
end = aArea->GetCornerPosition( aCornerIndex + 1 );
|
||||||
|
@ -1141,7 +1083,7 @@ bool DRC::doEdgeZoneDrc( ZONE_CONTAINER* aArea, int aCornerIndex )
|
||||||
|
|
||||||
while( ii >= 0 )
|
while( ii >= 0 )
|
||||||
{
|
{
|
||||||
if( aArea->m_Poly->corner[ii].end_contour )
|
if( aArea->m_Poly->m_CornersList[ii].end_contour )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
end = aArea->GetCornerPosition( ii );
|
end = aArea->GetCornerPosition( ii );
|
||||||
|
@ -1189,7 +1131,7 @@ bool DRC::doEdgeZoneDrc( ZONE_CONTAINER* aArea, int aCornerIndex )
|
||||||
int ax2 = end.x;
|
int ax2 = end.x;
|
||||||
int ay2 = end.y;
|
int ay2 = end.y;
|
||||||
|
|
||||||
for( int icont2 = 0; icont2 < area_to_test->m_Poly->GetNumContours(); icont2++ )
|
for( int icont2 = 0; icont2 < area_to_test->m_Poly->GetContoursCount(); icont2++ )
|
||||||
{
|
{
|
||||||
int ic_start2 = area_to_test->m_Poly->GetContourStart( icont2 );
|
int ic_start2 = area_to_test->m_Poly->GetContourStart( icont2 );
|
||||||
int ic_end2 = area_to_test->m_Poly->GetContourEnd( icont2 );
|
int ic_end2 = area_to_test->m_Poly->GetContourEnd( icont2 );
|
||||||
|
|
1172
polygon/PolyLine.cpp
1172
polygon/PolyLine.cpp
File diff suppressed because it is too large
Load Diff
|
@ -19,11 +19,12 @@
|
||||||
|
|
||||||
#include <kbool/include/kbool/booleng.h>
|
#include <kbool/include/kbool/booleng.h>
|
||||||
#include <pad_shapes.h>
|
#include <pad_shapes.h>
|
||||||
#include <wx/gdicmn.h>
|
#include <wx/gdicmn.h> // for wxPoint definition
|
||||||
|
|
||||||
|
#include <polygons_defs.h>
|
||||||
|
|
||||||
// inflection modes for DS_LINE and DS_LINE_VERTEX, used in math_for_graphics.cpp
|
// inflection modes for DS_LINE and DS_LINE_VERTEX, used in math_for_graphics.cpp
|
||||||
enum
|
enum {
|
||||||
{
|
|
||||||
IM_NONE = 0,
|
IM_NONE = 0,
|
||||||
IM_90_45,
|
IM_90_45,
|
||||||
IM_45_90,
|
IM_45_90,
|
||||||
|
@ -31,18 +32,6 @@ enum
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function ArmBoolEng
|
|
||||||
* Initialise parameters used in kbool
|
|
||||||
* @param aBooleng = pointer to the Bool_Engine to initialise
|
|
||||||
* @param aConvertHoles = mode for holes when a boolean operation is made
|
|
||||||
* true: holes are linked into outer contours by double overlapping segments
|
|
||||||
* false: holes are not linked: in this mode contours are added clockwise
|
|
||||||
* and polygons added counter clockwise are holes (default)
|
|
||||||
*/
|
|
||||||
void ArmBoolEng( Bool_Engine* aBooleng, bool aConvertHoles = false );
|
|
||||||
|
|
||||||
class CRect
|
class CRect
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -56,15 +45,16 @@ public:
|
||||||
wxPoint m_End;
|
wxPoint m_End;
|
||||||
|
|
||||||
CSegment() { };
|
CSegment() { };
|
||||||
CSegment( const wxPoint & aStart, const wxPoint & aEnd )
|
CSegment( const wxPoint& aStart, const wxPoint& aEnd )
|
||||||
{
|
{
|
||||||
m_Start = aStart;
|
m_Start = aStart;
|
||||||
m_End = aEnd;
|
m_End = aEnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
CSegment( int x0, int y0, int x1, int y1 )
|
CSegment( int x0, int y0, int x1, int y1 )
|
||||||
{
|
{
|
||||||
m_Start.x = x0; m_Start.y = y0;
|
m_Start.x = x0; m_Start.y = y0;
|
||||||
m_End.x = x1; m_End.y = y1;
|
m_End.x = x1; m_End.y = y1;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -75,10 +65,10 @@ class CArc
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum { ARC_STEPS = 16 }; // arc approximation step is 16 segm / 90 degres
|
enum { ARC_STEPS = 16 }; // arc approximation step is 16 segm / 90 degres
|
||||||
int style;
|
int style;
|
||||||
int xi, yi, xf, yf;
|
int xi, yi, xf, yf;
|
||||||
int n_steps; // number of straight-line segments in gpc_poly
|
int n_steps; // number of straight-line segments in gpc_poly
|
||||||
bool bFound;
|
bool bFound;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -86,27 +76,27 @@ class CPolyPt : public wxPoint
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CPolyPt( int aX = 0, int aY = 0, bool aEnd = false, int aUtility = 0 ) :
|
CPolyPt( int aX = 0, int aY = 0, bool aEnd = false, int aUtility = 0 ) :
|
||||||
wxPoint( aX, aY ), end_contour( aEnd ), utility( aUtility )
|
wxPoint( aX, aY ), end_contour( aEnd ), m_utility( aUtility )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/// Pure copy constructor is here to dis-ambiguate from the
|
// / Pure copy constructor is here to dis-ambiguate from the
|
||||||
/// specialized CPolyPt( const wxPoint& ) constructor version below.
|
// / specialized CPolyPt( const wxPoint& ) constructor version below.
|
||||||
CPolyPt( const CPolyPt& aPt ) :
|
CPolyPt( const CPolyPt& aPt ) :
|
||||||
wxPoint( aPt.x, aPt.y ), end_contour( aPt.end_contour ), utility( aPt.utility )
|
wxPoint( aPt.x, aPt.y ), end_contour( aPt.end_contour ), m_utility( aPt.m_utility )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
CPolyPt( const wxPoint& aPoint ) :
|
CPolyPt( const wxPoint& aPoint ) :
|
||||||
wxPoint( aPoint ), end_contour( false ), utility( 0 )
|
wxPoint( aPoint ), end_contour( false ), m_utility( 0 )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
bool end_contour;
|
bool end_contour;
|
||||||
int utility;
|
int m_utility;
|
||||||
|
|
||||||
bool operator == (const CPolyPt& cpt2 ) const
|
bool operator ==( const CPolyPt& cpt2 ) const
|
||||||
{ return (x == cpt2.x) && (y == cpt2.y) && (end_contour == cpt2.end_contour); }
|
{ return (x == cpt2.x) && (y == cpt2.y) && (end_contour == cpt2.end_contour); }
|
||||||
|
|
||||||
bool operator != (CPolyPt& cpt2 ) const
|
bool operator !=( CPolyPt& cpt2 ) const
|
||||||
{ return (x != cpt2.x) || (y != cpt2.y) || (end_contour != cpt2.end_contour); }
|
{ return (x != cpt2.x) || (y != cpt2.y) || (end_contour != cpt2.end_contour); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -116,7 +106,7 @@ public:
|
||||||
class CPolyLine
|
class CPolyLine
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum side_style { STRAIGHT, ARC_CW, ARC_CCW }; // side styles
|
enum m_SideStyle { STRAIGHT, ARC_CW, ARC_CCW }; // side styles
|
||||||
enum hatch_style { NO_HATCH, DIAGONAL_FULL, DIAGONAL_EDGE }; // hatch styles
|
enum hatch_style { NO_HATCH, DIAGONAL_FULL, DIAGONAL_EDGE }; // hatch styles
|
||||||
|
|
||||||
// constructors/destructor
|
// constructors/destructor
|
||||||
|
@ -124,13 +114,13 @@ public:
|
||||||
~CPolyLine();
|
~CPolyLine();
|
||||||
|
|
||||||
// functions for modifying polyline
|
// functions for modifying polyline
|
||||||
void Start( int layer, int x, int y, int hatch );
|
void Start( int layer, int x, int y, int hatch );
|
||||||
void AppendCorner( int x, int y, int style = STRAIGHT, bool bDraw = false );
|
void AppendCorner( int x, int y, int style = STRAIGHT, bool bDraw = false );
|
||||||
void InsertCorner( int ic, int x, int y );
|
void InsertCorner( int ic, int x, int y );
|
||||||
void DeleteCorner( int ic, bool bDraw = false );
|
void DeleteCorner( int ic, bool bDraw = false );
|
||||||
void MoveCorner( int ic, int x, int y );
|
void MoveCorner( int ic, int x, int y );
|
||||||
void Close( int style = STRAIGHT, bool bDraw = false );
|
void Close( int style = STRAIGHT, bool bDraw = false );
|
||||||
void RemoveContour( int icont );
|
void RemoveContour( int icont );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Chamfer
|
* Function Chamfer
|
||||||
|
@ -138,7 +128,7 @@ public:
|
||||||
* @param aDistance is the chamfering distance.
|
* @param aDistance is the chamfering distance.
|
||||||
* @return CPolyLine* - Pointer to new polygon.
|
* @return CPolyLine* - Pointer to new polygon.
|
||||||
*/
|
*/
|
||||||
CPolyLine* Chamfer( unsigned int aDistance );
|
CPolyLine* Chamfer( unsigned int aDistance );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Fillet
|
* Function Fillet
|
||||||
|
@ -147,108 +137,88 @@ public:
|
||||||
* @param aSegments is the number of segments / fillet.
|
* @param aSegments is the number of segments / fillet.
|
||||||
* @return CPolyLine* - Pointer to new polygon.
|
* @return CPolyLine* - Pointer to new polygon.
|
||||||
*/
|
*/
|
||||||
CPolyLine* Fillet( unsigned int aRadius, unsigned int aSegments );
|
CPolyLine* Fillet( unsigned int aRadius, unsigned int aSegments );
|
||||||
|
|
||||||
void RemoveAllContours( void );
|
void RemoveAllContours( void );
|
||||||
|
|
||||||
// Remove or create hatch
|
// Remove or create hatch
|
||||||
void UnHatch();
|
void UnHatch();
|
||||||
void Hatch();
|
void Hatch();
|
||||||
|
|
||||||
// Transform functions
|
// Transform functions
|
||||||
void MoveOrigin( int x_off, int y_off );
|
void MoveOrigin( int x_off, int y_off );
|
||||||
|
|
||||||
// misc. functions
|
// misc. functions
|
||||||
CRect GetBounds();
|
CRect GetBounds();
|
||||||
CRect GetCornerBounds();
|
CRect GetCornerBounds();
|
||||||
CRect GetCornerBounds( int icont );
|
CRect GetCornerBounds( int icont );
|
||||||
void Copy( CPolyLine* src );
|
void Copy( CPolyLine* src );
|
||||||
bool TestPointInside( int x, int y );
|
bool TestPointInside( int x, int y );
|
||||||
bool IsCutoutContour( int icont );
|
bool IsCutoutContour( int icont );
|
||||||
void AppendArc( int xi, int yi, int xf, int yf, int xc, int yc, int num );
|
void AppendArc( int xi, int yi, int xf, int yf, int xc, int yc, int num );
|
||||||
|
|
||||||
// access functions
|
// access functions
|
||||||
void SetLayer( int aLayer ) { m_layer = aLayer; }
|
void SetLayer( int aLayer ) { m_layer = aLayer; }
|
||||||
int GetLayer() { return m_layer; }
|
int GetLayer() { return m_layer; }
|
||||||
int GetNumCorners();
|
int GetNumCorners();
|
||||||
int GetNumSides();
|
int GetNumSides();
|
||||||
int GetClosed();
|
int GetClosed();
|
||||||
int GetNumContours();
|
int GetContoursCount();
|
||||||
int GetContour( int ic );
|
int GetContour( int ic );
|
||||||
int GetContourStart( int icont );
|
int GetContourStart( int icont );
|
||||||
int GetContourEnd( int icont );
|
int GetContourEnd( int icont );
|
||||||
int GetContourSize( int icont );
|
int GetContourSize( int icont );
|
||||||
|
|
||||||
int GetX( int ic ) const { return corner[ic].x; }
|
int GetX( int ic ) const { return m_CornersList[ic].x; }
|
||||||
int GetY( int ic ) const { return corner[ic].y; }
|
int GetY( int ic ) const { return m_CornersList[ic].y; }
|
||||||
|
|
||||||
const wxPoint& GetPos( int ic ) const { return corner[ic]; }
|
const wxPoint& GetPos( int ic ) const { return m_CornersList[ic]; }
|
||||||
|
|
||||||
int GetEndContour( int ic );
|
int GetEndContour( int ic );
|
||||||
|
|
||||||
|
int GetUtility( int ic ) { return m_CornersList[ic].m_utility; };
|
||||||
|
void SetUtility( int ic, int utility ) { m_CornersList[ic].m_utility = utility; };
|
||||||
|
int GetSideStyle( int is );
|
||||||
|
|
||||||
int GetUtility( int ic ) { return corner[ic].utility; };
|
|
||||||
void SetUtility( int ic, int utility ) { corner[ic].utility = utility; };
|
|
||||||
int GetSideStyle( int is );
|
|
||||||
int GetHatchPitch() { return m_hatchPitch; }
|
int GetHatchPitch() { return m_hatchPitch; }
|
||||||
int GetDefaultHatchPitchMils() { return 20; } // default hatch pitch value in mils
|
int GetDefaultHatchPitchMils() { return 20; } // default hatch pitch value in mils
|
||||||
|
|
||||||
enum hatch_style GetHatchStyle() { return m_hatchStyle; }
|
enum hatch_style GetHatchStyle() { return m_hatchStyle; }
|
||||||
void SetHatch( int hatch, int pitch )
|
void SetHatch( int hatch, int pitch )
|
||||||
{
|
{
|
||||||
SetHatchPitch( pitch );
|
SetHatchPitch( pitch );
|
||||||
m_hatchStyle = (enum hatch_style ) hatch;
|
m_hatchStyle = (enum hatch_style) hatch;
|
||||||
Hatch();
|
Hatch();
|
||||||
}
|
}
|
||||||
void SetX( int ic, int x );
|
|
||||||
void SetY( int ic, int y );
|
void SetX( int ic, int x );
|
||||||
void SetEndContour( int ic, bool end_contour );
|
void SetY( int ic, int y );
|
||||||
void SetSideStyle( int is, int style );
|
void SetEndContour( int ic, bool end_contour );
|
||||||
|
void SetSideStyle( int is, int style );
|
||||||
|
|
||||||
void SetHatchStyle( enum hatch_style style )
|
void SetHatchStyle( enum hatch_style style )
|
||||||
{
|
{
|
||||||
m_hatchStyle = style;
|
m_hatchStyle = style;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetHatchPitch( int pitch ) { m_hatchPitch = pitch; }
|
void SetHatchPitch( int pitch ) { m_hatchPitch = pitch; }
|
||||||
|
|
||||||
int RestoreArcs( std::vector<CArc> * arc_array, std::vector<CPolyLine*> * pa = NULL );
|
int RestoreArcs( std::vector<CArc>* arc_array, std::vector<CPolyLine*>* pa = NULL );
|
||||||
|
|
||||||
int NormalizeAreaOutlines( std::vector<CPolyLine*> * pa = NULL,
|
int NormalizeAreaOutlines( std::vector<CPolyLine*>* pa = NULL,
|
||||||
bool bRetainArcs = false );
|
bool bRetainArcs = false );
|
||||||
|
|
||||||
// KBOOL functions
|
// KBOOL functions
|
||||||
|
|
||||||
/**
|
|
||||||
* Function AddPolygonsToBoolEng
|
|
||||||
* and edges contours to a kbool engine, preparing a boolean op between polygons
|
|
||||||
* @param aStart_contour: starting contour number (-1 = all, 0 is the outlines of zone, > 1 = holes in zone
|
|
||||||
* @param aEnd_contour: ending contour number (-1 = all after aStart_contour)
|
|
||||||
* @param arc_array: arc connverted to poly (NULL if not exists)
|
|
||||||
* @param aBooleng : pointer on a bool engine (handle a set of polygons)
|
|
||||||
* @param aGroup : group to fill (aGroup = GROUP_A or GROUP_B) operations are made between GROUP_A and GROUP_B
|
|
||||||
*/
|
|
||||||
int AddPolygonsToBoolEng( Bool_Engine* aBooleng,
|
|
||||||
GroupType aGroup,
|
|
||||||
int aStart_contour = -1,
|
|
||||||
int aEnd_contour = -1,
|
|
||||||
std::vector<CArc> * arc_array = NULL );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function MakeKboolPoly
|
* Function MakeKboolPoly
|
||||||
* fill a kbool engine with a closed polyline contour
|
* fill a kbool engine with a closed polyline contour
|
||||||
* approximates arcs with multiple straight-line segments
|
* approximates arcs with multiple straight-line segments
|
||||||
* @param aStart_contour: starting contour number (-1 = all, 0 is the outlines of zone, > 1 = holes in zone
|
|
||||||
* @param aEnd_contour: ending contour number (-1 = all after aStart_contour)
|
|
||||||
* combining intersecting contours if possible
|
* combining intersecting contours if possible
|
||||||
* @param arc_array : return data on arcs in arc_array
|
* @param arc_array : return data on arcs in arc_array
|
||||||
* @param aConvertHoles = mode for holes when a boolean operation is made
|
|
||||||
* true: holes are linked into outer contours by double overlapping segments
|
|
||||||
* false: holes are not linked: in this mode contours are added clockwise
|
|
||||||
* and polygons added counter clockwise are holes (default)
|
|
||||||
* @return error: 0 if Ok, 1 if error
|
* @return error: 0 if Ok, 1 if error
|
||||||
*/
|
*/
|
||||||
int MakeKboolPoly( int aStart_contour = -1,
|
int MakeKboolPoly( std::vector<CArc>* arc_array = NULL );
|
||||||
int aEnd_contour = -1,
|
|
||||||
std::vector<CArc> * arc_array = NULL,
|
|
||||||
bool aConvertHoles = false);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function NormalizeWithKbool
|
* Function NormalizeWithKbool
|
||||||
|
@ -262,22 +232,11 @@ public:
|
||||||
* @param bRetainArcs == false, try to retain arcs in polys
|
* @param bRetainArcs == false, try to retain arcs in polys
|
||||||
* @return number of external contours, or -1 if error
|
* @return number of external contours, or -1 if error
|
||||||
*/
|
*/
|
||||||
int NormalizeWithKbool( std::vector<CPolyLine*> * aExtraPolyList, bool bRetainArcs );
|
int NormalizeWithKbool( std::vector<CPolyLine*>* aExtraPolyList, bool bRetainArcs );
|
||||||
|
|
||||||
/**
|
|
||||||
* Function GetKboolEngine
|
|
||||||
* @return the current used Kbool Engine (after normalization using kbool)
|
|
||||||
*/
|
|
||||||
Bool_Engine* GetKboolEngine( ) { return m_Kbool_Poly_Engine; }
|
|
||||||
/**
|
|
||||||
* Function FreeKboolEngine
|
|
||||||
* delete the current used Kbool Engine (free memory after normalization using kbool)
|
|
||||||
*/
|
|
||||||
void FreeKboolEngine( ) { delete m_Kbool_Poly_Engine; m_Kbool_Poly_Engine = NULL; }
|
|
||||||
|
|
||||||
// Bezier Support
|
// Bezier Support
|
||||||
void AppendBezier(int x1, int y1, int x2, int y2, int x3, int y3);
|
void AppendBezier( int x1, int y1, int x2, int y2, int x3, int y3 );
|
||||||
void AppendBezier(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
|
void AppendBezier( int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4 );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Distance
|
* Function Distance
|
||||||
|
@ -286,7 +245,7 @@ public:
|
||||||
* @return int = distance between the point and outline.
|
* @return int = distance between the point and outline.
|
||||||
* 0 if the point is inside
|
* 0 if the point is inside
|
||||||
*/
|
*/
|
||||||
int Distance( const wxPoint& aPoint );
|
int Distance( const wxPoint& aPoint );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Distance
|
* Function Distance
|
||||||
|
@ -297,22 +256,44 @@ public:
|
||||||
* @return int = distance between the segment and outline.
|
* @return int = distance between the segment and outline.
|
||||||
* 0 if segment intersects or is inside
|
* 0 if segment intersects or is inside
|
||||||
*/
|
*/
|
||||||
int Distance( wxPoint aStart, wxPoint aEnd, int aWidth );
|
int Distance( wxPoint aStart, wxPoint aEnd, int aWidth );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_layer; // layer to draw on
|
int m_layer; // layer to draw on
|
||||||
int m_Width; // lines width when drawing. Provided but not really used
|
int m_width; // lines width when drawing. Provided but not really used
|
||||||
enum hatch_style m_hatchStyle; // hatch style, see enum above
|
enum hatch_style m_hatchStyle; // hatch style, see enum above
|
||||||
int m_hatchPitch; // for DIAGONAL_EDGE hatched outlines, basic distance between 2 hatch lines
|
int m_hatchPitch; // for DIAGONAL_EDGE hatched outlines, basic distance between 2 hatch lines
|
||||||
// and the len of eacvh segment
|
// and the len of eacvh segment
|
||||||
// for DIAGONAL_FULL, the pitch is twice this value
|
// for DIAGONAL_FULL, the pitch is twice this value
|
||||||
int utility;
|
int m_utility; // a flag used in some calculations
|
||||||
Bool_Engine* m_Kbool_Poly_Engine; // polygons set in kbool engine data
|
Bool_Engine* m_Kbool_Poly_Engine; // polygons set in kbool engine data
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::vector <CPolyPt> corner; // array of points for corners
|
std::vector <CPolyPt> m_CornersList; // array of points for corners
|
||||||
std::vector <int> side_style; // array of styles for sides
|
std::vector <int> m_SideStyle; // array of styles for sides
|
||||||
std::vector <CSegment> m_HatchLines; // hatch lines
|
std::vector <CSegment> m_HatchLines; // hatch lines showing the polygon area
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // #ifndef POLYLINE_H
|
/**
|
||||||
|
* Function CopyPolysListToKiPolygonWithHole
|
||||||
|
* converts the outline contours aPolysList to a KI_POLYGON_WITH_HOLES
|
||||||
|
*
|
||||||
|
* @param aPolysList = the list of corners of contours
|
||||||
|
* @param aPolygoneWithHole = a KI_POLYGON_WITH_HOLES to populate
|
||||||
|
*/
|
||||||
|
void CopyPolysListToKiPolygonWithHole( const std::vector<CPolyPt>& aPolysList,
|
||||||
|
KI_POLYGON_WITH_HOLES& aPolygoneWithHole );
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function ConvertPolysListWithHolesToOnePolygon
|
||||||
|
* converts the outline contours aPolysListWithHoles with holes to one polygon
|
||||||
|
* with no holes (only one contour)
|
||||||
|
* holes are linked to main outlines by overlap segments, to give only one polygon
|
||||||
|
*
|
||||||
|
* @param aPolysListWithHoles = the list of corners of contours (haing holes
|
||||||
|
* @param aOnePolyList = a polygon with no holes
|
||||||
|
*/
|
||||||
|
void ConvertPolysListWithHolesToOnePolygon( const std::vector<CPolyPt>& aPolysListWithHoles,
|
||||||
|
std::vector<CPolyPt>& aOnePolyList );
|
||||||
|
|
||||||
|
#endif // #ifndef POLYLINE_H
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
/*
|
||||||
|
* file polygons_defs.h
|
||||||
|
* definitions to use boost::polygon in KiCad.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _POLYGONS_DEFS_H_
|
||||||
|
#define _POLYGONS_DEFS_H_
|
||||||
|
|
||||||
|
#include <boost/polygon/polygon.hpp>
|
||||||
|
|
||||||
|
// Define some types used here from boost::polygon
|
||||||
|
namespace bpl = boost::polygon; // bpl = boost polygon library
|
||||||
|
using namespace bpl::operators; // +, -, =, ...
|
||||||
|
|
||||||
|
// Definitions needed by boost::polygon
|
||||||
|
typedef int coordinate_type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* KI_POLYGON defines a single polygon ( boost::polygon_data type.
|
||||||
|
* When holes are created in a KPolygon, they are
|
||||||
|
* linked to main outline by overlapping segments,
|
||||||
|
* so there is always one polygon and one list of corners
|
||||||
|
* coordinates are int
|
||||||
|
*/
|
||||||
|
typedef bpl::polygon_data<int> KI_POLYGON;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* KI_POLYGON_SET defines a set of single KI_POLYGON.
|
||||||
|
* A KI_POLYGON_SET is used to store a set of polygons
|
||||||
|
* when performing operations between 2 polygons
|
||||||
|
* or 2 sets of polygons
|
||||||
|
* The result of operations like and, xor... between 2 polygons
|
||||||
|
* is always stored in a KI_POLYGON_SET, because these operations
|
||||||
|
* can create many polygons
|
||||||
|
*/
|
||||||
|
typedef std::vector<KI_POLYGON> KI_POLYGON_SET;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* KI_POLY_POINT defines a point for boost::polygon.
|
||||||
|
* KI_POLY_POINT store x and y coordinates (int)
|
||||||
|
*/
|
||||||
|
typedef bpl::point_data<int> KI_POLY_POINT;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* KI_POLYGON_WITH_HOLES defines a single polygon with holes
|
||||||
|
* When holes are created in a KI_POLYGON_WITH_HOLES, they are
|
||||||
|
* stored as separate single polygons,
|
||||||
|
* KI_POLYGON_WITH_HOLES store always one polygon for the external outline
|
||||||
|
* and one list of polygons (holes) which can be empty
|
||||||
|
*/
|
||||||
|
typedef bpl::polygon_with_holes_data<int> KI_POLYGON_WITH_HOLES;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* KI_POLYGON_WITH_HOLES_SET defines a set of KI_POLYGON_WITH_HOLES.
|
||||||
|
* A KI_POLYGON_WITH_HOLES_SET is used to store a set of polygons with holes
|
||||||
|
* when performing operations between 2 polygons
|
||||||
|
* or 2 sets of polygons with holes
|
||||||
|
* The result of operations like and, xor... between 2 polygons 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;
|
||||||
|
|
||||||
|
|
||||||
|
#endif // #ifndef _POLYGONS_DEFS_H_
|
Loading…
Reference in New Issue