Commit 99b90d2f authored by jean-pierre charras's avatar jean-pierre charras

More work on a better support of polygons in Kicad (code cleaning).

parent ef5f1b9e
...@@ -561,15 +561,15 @@ void LIB_ARC::BeginEdit( int aEditMode, const wxPoint aPosition ) ...@@ -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 ) ...@@ -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 ) ...@@ -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; ...@@ -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. */
......
...@@ -1302,12 +1302,12 @@ static void AddNewTrace( PCB_EDIT_FRAME* pcbframe, wxDC* DC ) ...@@ -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 );
......
...@@ -1681,7 +1681,7 @@ D_PAD* BOARD::GetPad( TRACK* aTrace, int aEndPoint ) ...@@ -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 ...@@ -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 ) ...@@ -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;
......
...@@ -613,7 +613,7 @@ private: ...@@ -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 ) ...@@ -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 ) ...@@ -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 ) ...@@ -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 ) ...@@ -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 ) ...@@ -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 ) ...@@ -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 ) ...@@ -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 ) ...@@ -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 ) ...@@ -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 ) ...@@ -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 ...@@ -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() ...@@ -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() ...@@ -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 ) ...@@ -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 ) ...@@ -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 ) ...@@ -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 ) ...@@ -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 )
{ {
......
...@@ -887,7 +887,7 @@ void PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC ...@@ -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 ...@@ -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 ...@@ -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 @@ ...@@ -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) */
......
...@@ -89,39 +89,12 @@ int ZONE_CONTAINER::BuildFilledPolysListData( BOARD* aPcb, std::vector <CPolyPt> ...@@ -89,39 +89,12 @@ int ZONE_CONTAINER::BuildFilledPolysListData( BOARD* aPcb, std::vector <CPolyPt>
break; break;
} }
m_smoothedPoly->MakeKboolPoly( -1, -1, NULL, true );
int count = 0;
while( m_smoothedPoly->GetKboolEngine()->StartPolygonGet() )
{
CPolyPt corner( 0, 0, false );
while( m_smoothedPoly->GetKboolEngine()->PolygonHasMorePoints() )
{
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 ) if( aCornerBuffer )
{ ConvertPolysListWithHolesToOnePolygon( m_smoothedPoly->m_CornersList,
aCornerBuffer->pop_back(); *aCornerBuffer );
aCornerBuffer->push_back( corner );
}
else else
{ ConvertPolysListWithHolesToOnePolygon( m_smoothedPoly->m_CornersList,
m_FilledPolysList.pop_back(); m_FilledPolysList );
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> ...@@ -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
......
...@@ -524,10 +524,6 @@ int CopyPolygonsFromKiPolygonListToFilledPolysList( ZONE_CONTAINER* aZone, ...@@ -524,10 +524,6 @@ int CopyPolygonsFromKiPolygonListToFilledPolysList( ZONE_CONTAINER* aZone,
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++;
} }
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
*/ */
#include <fctsys.h> #include <fctsys.h>
#include <polygons_defs.h>
#include <common.h> #include <common.h>
#include <confirm.h> #include <confirm.h>
#include <class_undoredo_container.h> #include <class_undoredo_container.h>
...@@ -779,58 +778,6 @@ int BOARD::TestAreaIntersection( ZONE_CONTAINER* area_ref, ZONE_CONTAINER* area_ ...@@ -779,58 +778,6 @@ int BOARD::TestAreaIntersection( ZONE_CONTAINER* area_ref, ZONE_CONTAINER* area_
return 1; return 1;
} }
/**
* 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 )
{
unsigned corners_count = aPolysList.size();
std::vector<KI_POLY_POINT> cornerslist;
KI_POLYGON poly;
// Enter main outline: this is the first contour
unsigned ic = 0;
while( ic < corners_count )
{
const CPolyPt& corner = aPolysList[ic++];
cornerslist.push_back( KI_POLY_POINT( corner.x, corner.y ) );
if( corner.end_contour )
break;
}
aPolygoneWithHole.set( cornerslist.begin(), cornerslist.end() );
// Enter holes: they are next contours (when exist)
if( ic < corners_count )
{
KI_POLYGON_SET holePolyList;
while( ic < corners_count )
{
cornerslist.clear();
while( ic < corners_count )
{
const CPolyPt& corner = aPolysList[ic++];
cornerslist.push_back( KI_POLY_POINT( corner.x, corner.y ) );
if( corner.end_contour )
break;
}
bpl::set_points( poly, cornerslist.begin(), cornerslist.end() );
holePolyList.push_back( poly );
}
aPolygoneWithHole.set_holes( holePolyList.begin(), holePolyList.end() );
}
}
/** /**
* Function CombineAreas * Function CombineAreas
......
This diff is collapsed.
...@@ -19,11 +19,12 @@ ...@@ -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,
...@@ -44,11 +45,12 @@ public: ...@@ -44,11 +45,12 @@ 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;
...@@ -77,8 +79,8 @@ public: ...@@ -77,8 +79,8 @@ public:
wxPoint( aX, aY ), end_contour( aEnd ), m_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 ), m_utility( aPt.m_utility ) wxPoint( aPt.x, aPt.y ), end_contour( aPt.end_contour ), m_utility( aPt.m_utility )
{} {}
...@@ -91,10 +93,10 @@ public: ...@@ -91,10 +93,10 @@ public:
bool end_contour; bool end_contour;
int m_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); }
}; };
...@@ -177,6 +179,7 @@ public: ...@@ -177,6 +179,7 @@ public:
int GetUtility( int ic ) { return m_CornersList[ic].m_utility; }; int GetUtility( int ic ) { return m_CornersList[ic].m_utility; };
void SetUtility( int ic, int utility ) { m_CornersList[ic].m_utility = utility; }; void SetUtility( int ic, int utility ) { m_CornersList[ic].m_utility = utility; };
int GetSideStyle( int is ); 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
...@@ -184,59 +187,38 @@ public: ...@@ -184,59 +187,38 @@ public:
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 SetX( int ic, int x );
void SetY( int ic, int y ); void SetY( int ic, int y );
void SetEndContour( int ic, bool end_contour ); void SetEndContour( int ic, bool end_contour );
void SetSideStyle( int is, int style ); 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
...@@ -250,22 +232,11 @@ public: ...@@ -250,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
...@@ -296,11 +267,33 @@ private: ...@@ -296,11 +267,33 @@ private:
// for DIAGONAL_FULL, the pitch is twice this value // for DIAGONAL_FULL, the pitch is twice this value
int m_utility; // a flag used in some calculations 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> m_CornersList; // array of points for corners std::vector <CPolyPt> m_CornersList; // array of points for corners
std::vector <int> m_SideStyle; // array of styles for sides std::vector <int> m_SideStyle; // array of styles for sides
std::vector <CSegment> m_HatchLines; // hatch lines showing the polygon area std::vector <CSegment> m_HatchLines; // hatch lines showing the polygon area
}; };
/**
* 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 #endif // #ifndef POLYLINE_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment