Commit 2cdce05d authored by jean-pierre charras's avatar jean-pierre charras

Pcbnew: minor code cleanup and enhancement in zone filling. Commit patch from...

Pcbnew: minor code cleanup and enhancement in zone filling. Commit patch from Marco Mattila. Eeschema: minor bug fix about dangling ends. removed obsolete file
parent e3b4eeb1
This diff is collapsed.
...@@ -920,6 +920,8 @@ bool SCH_LINE::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemLi ...@@ -920,6 +920,8 @@ bool SCH_LINE::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemLi
bool previousStartState = m_StartIsDangling; bool previousStartState = m_StartIsDangling;
bool previousEndState = m_EndIsDangling; bool previousEndState = m_EndIsDangling;
m_StartIsDangling = m_EndIsDangling = true;
if( GetLayer() == LAYER_WIRE ) if( GetLayer() == LAYER_WIRE )
{ {
BOOST_FOREACH( DANGLING_END_ITEM item, aItemList ) BOOST_FOREACH( DANGLING_END_ITEM item, aItemList )
......
...@@ -586,6 +586,7 @@ bool SCH_TEXT::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemLi ...@@ -586,6 +586,7 @@ bool SCH_TEXT::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemLi
return false; return false;
bool previousState = m_IsDangling; bool previousState = m_IsDangling;
m_IsDangling = true;
for( unsigned ii = 0; ii < aItemList.size(); ii++ ) for( unsigned ii = 0; ii < aItemList.size(); ii++ )
{ {
......
...@@ -175,6 +175,7 @@ set(PCBNEW_SRCS ...@@ -175,6 +175,7 @@ set(PCBNEW_SRCS
work.cpp work.cpp
xchgmod.cpp xchgmod.cpp
${PCBNEW_SRC_FILL_ZONE} ${PCBNEW_SRC_FILL_ZONE}
zones_convert_to_polygons_aux_functions.cpp
zones_by_polygon.cpp zones_by_polygon.cpp
zones_by_polygon_fill_functions.cpp zones_by_polygon_fill_functions.cpp
zone_filling_algorithm.cpp zone_filling_algorithm.cpp
......
...@@ -419,6 +419,22 @@ void TEXTE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, ...@@ -419,6 +419,22 @@ void TEXTE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
size, m_HJustify, m_VJustify, width, m_Italic, m_Bold ); size, m_HJustify, m_VJustify, width, m_Italic, m_Bold );
} }
void TEXTE_MODULE::DrawUmbilical( WinEDA_DrawPanel* aPanel,
wxDC* aDC,
int aDrawMode,
const wxPoint& aOffset )
{
MODULE* parent = (MODULE*) GetParent();
if( !parent )
return;
GRSetDrawMode( aDC, GR_XOR );
GRLine( &aPanel->m_ClipBox, aDC,
parent->GetPosition().x, parent->GetPosition().y,
GetPosition().x + aOffset.x,
GetPosition().y + aOffset.y,
0, UMBILICAL_COLOR);
}
/* Return text rotation for drawings and plotting /* Return text rotation for drawings and plotting
*/ */
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#define TEXT_is_VALUE 1 #define TEXT_is_VALUE 1
#define TEXT_is_DIVERS 2 #define TEXT_is_DIVERS 2
#define UMBILICAL_COLOR LIGHTBLUE
class TEXTE_MODULE : public BOARD_ITEM, public EDA_TextStruct class TEXTE_MODULE : public BOARD_ITEM, public EDA_TextStruct
{ {
...@@ -94,6 +95,19 @@ public: TEXTE_MODULE( MODULE* parent, int text_type = TEXT_is_DIVERS ); ...@@ -94,6 +95,19 @@ public: TEXTE_MODULE( MODULE* parent, int text_type = TEXT_is_DIVERS );
int aDrawMode, int aDrawMode,
const wxPoint& offset = ZeroOffset ); const wxPoint& offset = ZeroOffset );
/**
* Function DrawUmbilical
* draws a line from the TEXTE_MODULE origin
* to parent MODULE origin.
* @param aPanel = the current DrawPanel
* @param aDC = the current device context
* @param aDrawMode = drawing mode, typically GR_XOR
* @param aOffset = offset for TEXTE_MODULE
*/
void DrawUmbilical( WinEDA_DrawPanel* aPanel,
wxDC* aDC,
int aDrawMode,
const wxPoint& aOffset = ZeroOffset );
/** /**
* Function DisplayInfo * Function DisplayInfo
......
...@@ -139,6 +139,7 @@ static void AbortMoveTextModule( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -139,6 +139,7 @@ static void AbortMoveTextModule( WinEDA_DrawPanel* Panel, wxDC* DC )
Module = (MODULE*) Text->GetParent(); Module = (MODULE*) Text->GetParent();
Text->DrawUmbilical( Panel, DC, GR_XOR, -MoveVector );
Text->Draw( Panel, DC, GR_XOR, MoveVector ); Text->Draw( Panel, DC, GR_XOR, MoveVector );
// If the text was moved (the move does not change internal data) // If the text was moved (the move does not change internal data)
...@@ -175,9 +176,16 @@ void WinEDA_BasePcbFrame::StartMoveTexteModule( TEXTE_MODULE* Text, wxDC* DC ) ...@@ -175,9 +176,16 @@ void WinEDA_BasePcbFrame::StartMoveTexteModule( TEXTE_MODULE* Text, wxDC* DC )
MoveVector.x = MoveVector.y = 0; MoveVector.x = MoveVector.y = 0;
DrawPanel->CursorOff( DC );
TextInitialPosition = Text->m_Pos; TextInitialPosition = Text->m_Pos;
TextInitialOrientation = Text->m_Orient; TextInitialOrientation = Text->m_Orient;
// Center cursor on initial position of text
GetScreen()->m_Curseur = TextInitialPosition;
DrawPanel->MouseToCursorSchema();
DrawPanel->CursorOn( DC );
Text->DisplayInfo( this ); Text->DisplayInfo( this );
SetCurItem( Text ); SetCurItem( Text );
...@@ -195,6 +203,7 @@ void WinEDA_BasePcbFrame::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC ) ...@@ -195,6 +203,7 @@ void WinEDA_BasePcbFrame::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC )
if( Text != NULL ) if( Text != NULL )
{ {
DrawPanel->PostDirtyRect( Text->GetBoundingBox() ); DrawPanel->PostDirtyRect( Text->GetBoundingBox() );
Text->DrawUmbilical( DrawPanel, DC, GR_XOR, -MoveVector );
/* Update the coordinates for anchor. */ /* Update the coordinates for anchor. */
MODULE* Module = (MODULE*) Text->GetParent(); MODULE* Module = (MODULE*) Text->GetParent();
...@@ -242,12 +251,18 @@ static void Show_MoveTexte_Module( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -242,12 +251,18 @@ static void Show_MoveTexte_Module( WinEDA_DrawPanel* panel, wxDC* DC,
if( Text == NULL ) if( Text == NULL )
return; return;
/* Undraw the text */ // Erase umbilical and text if necessary
if( erase ) if( erase )
{
Text->DrawUmbilical( panel, DC, GR_XOR, -MoveVector );
Text->Draw( panel, DC, GR_XOR, MoveVector ); Text->Draw( panel, DC, GR_XOR, MoveVector );
}
MoveVector = TextInitialPosition - screen->m_Curseur; MoveVector = TextInitialPosition - screen->m_Curseur;
/* Redraw the text */ // Draw umbilical if text moved
if( MoveVector.x || MoveVector.y )
Text->DrawUmbilical( panel, DC, GR_XOR, -MoveVector );
// Redraw text
Text->Draw( panel, DC, GR_XOR, MoveVector ); Text->Draw( panel, DC, GR_XOR, MoveVector );
} }
...@@ -35,6 +35,10 @@ ...@@ -35,6 +35,10 @@
#include "PolyLine.h" #include "PolyLine.h"
extern void BuildUnconnectedThermalStubsPolygonList( std::vector<CPolyPt>& aCornerBuffer,
BOARD* aPcb, ZONE_CONTAINER* aZone,
double aArcCorrection,
int aRoundPadThermalRotation);
extern void Test_For_Copper_Island_And_Remove( BOARD* aPcb, extern void Test_For_Copper_Island_And_Remove( BOARD* aPcb,
ZONE_CONTAINER* aZone_container ); ZONE_CONTAINER* aZone_container );
extern void CreateThermalReliefPadPolygon( std::vector<CPolyPt>& aCornerBuffer, extern void CreateThermalReliefPadPolygon( std::vector<CPolyPt>& aCornerBuffer,
...@@ -54,8 +58,6 @@ static int CopyPolygonsFromKPolygonListToFilledPolysList( ZONE_CONTAINER* aZone ...@@ -54,8 +58,6 @@ static int CopyPolygonsFromKPolygonListToFilledPolysList( ZONE_CONTAINER* aZone
KPolygonSet& aKPolyList ); KPolygonSet& aKPolyList );
static int CopyPolygonsFromFilledPolysListTotKPolygonList( ZONE_CONTAINER* aZone, static int CopyPolygonsFromFilledPolysListTotKPolygonList( ZONE_CONTAINER* aZone,
KPolygonSet& aKPolyList ); KPolygonSet& aKPolyList );
static void AddUnconnectedThermalStubsToKPolygonList( std::vector<CPolyPt>& aCornerBuffer,
BOARD* aPcb, ZONE_CONTAINER* aZone );
// Local Variables: // Local Variables:
...@@ -162,7 +164,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) ...@@ -162,7 +164,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
EDA_Rect zone_boundingbox = GetBoundingBox(); EDA_Rect zone_boundingbox = GetBoundingBox();
int biggest_clearance = aPcb->GetBiggestClearanceValue(); int biggest_clearance = aPcb->GetBiggestClearanceValue();
biggest_clearance = MAX( biggest_clearance, zone_clearance ); biggest_clearance = MAX( biggest_clearance, zone_clearance );
zone_boundingbox.Inflate( biggest_clearance, biggest_clearance ); zone_boundingbox.Inflate( biggest_clearance );
/* /*
* First : Add pads. Note: pads having the same net as zone are left in zone. * First : Add pads. Note: pads having the same net as zone are left in zone.
...@@ -367,7 +369,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) ...@@ -367,7 +369,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
// Test thermal stubs connections and add polygons to remove unconnected stubs. // Test thermal stubs connections and add polygons to remove unconnected stubs.
cornerBufferPolysToSubstract.clear(); cornerBufferPolysToSubstract.clear();
AddUnconnectedThermalStubsToKPolygonList( cornerBufferPolysToSubstract, aPcb, this ); BuildUnconnectedThermalStubsPolygonList( cornerBufferPolysToSubstract, aPcb, this, s_Correction, s_thermalRot );
/* remove copper areas */ /* remove copper areas */
if( cornerBufferPolysToSubstract.size() ) if( cornerBufferPolysToSubstract.size() )
...@@ -387,128 +389,6 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) ...@@ -387,128 +389,6 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
} }
void AddUnconnectedThermalStubsToKPolygonList( std::vector<CPolyPt>& aCornerBuffer,
BOARD* aPcb,
ZONE_CONTAINER* aZone )
{
// polygon buffer
std::vector<wxPoint> corners_buffer;
corners_buffer.reserve( 4 );
wxPoint ptTest[4];
int margin = aZone->m_ZoneMinThickness / 2;
int zone_clearance = max( aZone->m_ZoneClearance, aZone->GetClearance() );
zone_clearance += margin;
EDA_Rect item_boundingbox;
EDA_Rect zone_boundingbox = aZone->GetBoundingBox();
int biggest_clearance = aPcb->GetBiggestClearanceValue();
biggest_clearance = MAX( biggest_clearance, zone_clearance );
zone_boundingbox.Inflate( biggest_clearance );
int iDTRC = ( aZone->m_ThermalReliefCopperBridgeValue - aZone->m_ZoneMinThickness ) / 2;
for( MODULE* module = aPcb->m_Modules; module; module = module->Next() )
{
for( D_PAD* pad = module->m_Pads; pad != NULL; pad = pad->Next() )
{
// check
if( !pad->IsOnLayer( aZone->GetLayer() ) )
continue;
if( pad->GetNet() != aZone->GetNet() )
continue;
item_boundingbox = pad->GetBoundingBox();
item_boundingbox.Inflate( aZone->m_ThermalReliefGapValue );
if( !( item_boundingbox.Intersects( zone_boundingbox ) ) )
continue;
// test point
int dx = ( pad->m_Size.x / 2 ) + aZone->m_ThermalReliefGapValue;
int dy = ( pad->m_Size.y / 2 ) + aZone->m_ThermalReliefGapValue;
// This is CIRCLE pad tweak (for circle pads the thermal stubs are at 45 deg)
int fAngle = pad->m_Orient;
if( pad->m_PadShape == PAD_CIRCLE )
{
dx = (int) ( dx * s_Correction );
dy = dx;
fAngle = s_thermalRot;
}
// compute north, south, west and east points for zone connection.
// Add a small value to ensure point is inside (or outside) zone, not on an edge
ptTest[0] = wxPoint( 0, 3 + dy + margin );
ptTest[1] = wxPoint( 0, -(3 + dy + margin) );
ptTest[2] = wxPoint( 3 + dx + margin, 0 );
ptTest[3] = wxPoint( -(3 + dx + margin), 0 );
// Test all sides
for( int i = 0; i<4; i++ )
{
// rotate point
RotatePoint( &ptTest[i], fAngle );
// translate point
ptTest[i] += pad->ReturnShapePos();
if( aZone->HitTestFilledArea( ptTest[i] ) )
continue;
corners_buffer.clear();
// polygons are rectangles with width of copper bridge value
// contour line width has to be taken into calculation to avoid "thermal stub bleed"
switch( i )
{
case 0:
corners_buffer.push_back( wxPoint( -iDTRC, dy ) );
corners_buffer.push_back( wxPoint( +iDTRC, dy ) );
corners_buffer.push_back( wxPoint( +iDTRC, iDTRC ) );
corners_buffer.push_back( wxPoint( -iDTRC, iDTRC ) );
break;
case 1:
corners_buffer.push_back( wxPoint( -iDTRC, -dy ) );
corners_buffer.push_back( wxPoint( +iDTRC, -dy ) );
corners_buffer.push_back( wxPoint( +iDTRC, -iDTRC ) );
corners_buffer.push_back( wxPoint( -iDTRC, -iDTRC ) );
break;
case 2:
corners_buffer.push_back( wxPoint( dx, -iDTRC ) );
corners_buffer.push_back( wxPoint( dx, iDTRC ) );
corners_buffer.push_back( wxPoint( +iDTRC, iDTRC ) );
corners_buffer.push_back( wxPoint( +iDTRC, -iDTRC ) );
break;
case 3:
corners_buffer.push_back( wxPoint( -dx, -iDTRC ) );
corners_buffer.push_back( wxPoint( -dx, iDTRC ) );
corners_buffer.push_back( wxPoint( -iDTRC, iDTRC ) );
corners_buffer.push_back( wxPoint( -iDTRC, -iDTRC ) );
break;
}
// add computed polygon to list
for( unsigned ic = 0; ic < corners_buffer.size(); ic++ )
{
wxPoint cpos = corners_buffer[ic];
RotatePoint( &cpos, fAngle ); // Rotate according to module orientation
cpos += pad->ReturnShapePos(); // Shift origin to position
CPolyPt corner;
corner.x = cpos.x;
corner.y = cpos.y;
corner.end_contour = ( ic < (corners_buffer.size() - 1) ) ? 0 : 1;
aCornerBuffer.push_back( corner );
}
}
}
}
}
void AddPolygonCornersToKPolygonList( std::vector <CPolyPt>& void AddPolygonCornersToKPolygonList( std::vector <CPolyPt>&
aCornersBuffer, aCornersBuffer,
KPolygonSet& aKPolyList ) KPolygonSet& aKPolyList )
......
...@@ -44,6 +44,10 @@ ...@@ -44,6 +44,10 @@
// See debug_kbool_key_file_fct.h // See debug_kbool_key_file_fct.h
extern void BuildUnconnectedThermalStubsPolygonList( std::vector<CPolyPt>& aCornerBuffer,
BOARD* aPcb, ZONE_CONTAINER* aZone,
double aArcCorrection,
int aRoundPadThermalRotation);
extern void Test_For_Copper_Island_And_Remove( BOARD* aPcb, extern void Test_For_Copper_Island_And_Remove( BOARD* aPcb,
ZONE_CONTAINER* aZone_container ); ZONE_CONTAINER* aZone_container );
extern void CreateThermalReliefPadPolygon( std::vector<CPolyPt>& aCornerBuffer, extern void CreateThermalReliefPadPolygon( std::vector<CPolyPt>& aCornerBuffer,
...@@ -483,117 +487,12 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) ...@@ -483,117 +487,12 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
#define REMOVE_UNUSED_THERMAL_STUBS // Can be commented to skip unused thermal stubs calculations #define REMOVE_UNUSED_THERMAL_STUBS // Can be commented to skip unused thermal stubs calculations
#ifdef REMOVE_UNUSED_THERMAL_STUBS #ifdef REMOVE_UNUSED_THERMAL_STUBS
// Test thermal stubs connections and add polygons to remove unconnected stubs.
booleng = new Bool_Engine(); booleng = new Bool_Engine();
ArmBoolEng( booleng, true ); ArmBoolEng( booleng, true );
cornerBufferPolysToSubstract.clear(); cornerBufferPolysToSubstract.clear();
// Test thermal stubs connections and add polygons to remove unconnected stubs. BuildUnconnectedThermalStubsPolygonList( cornerBufferPolysToSubstract, aPcb, this, s_Correction, s_thermalRot );
for( MODULE* module = aPcb->m_Modules; module; module = module->Next() ) /* remove copper areas */
{
for( D_PAD* pad = module->m_Pads; pad != NULL; pad = pad->Next() )
{
// check
if( !pad->IsOnLayer( GetLayer() ) )
continue;
if( pad->GetNet() != GetNet() )
continue;
item_boundingbox = pad->GetBoundingBox();
item_boundingbox.Inflate( m_ThermalReliefGapValue );
if( !( item_boundingbox.Intersects( zone_boundingbox ) ) )
continue;
// test point
int dx =
( pad->m_Size.x / 2 ) + m_ThermalReliefGapValue;
int dy =
( pad->m_Size.y / 2 ) + m_ThermalReliefGapValue;
// This is CIRCLE pad tweak (for circle pads the thermal stubs are at 45 deg)
int fAngle = pad->m_Orient;
if( pad->m_PadShape == PAD_CIRCLE )
{
dx = (int) ( dx * s_Correction );
dy = dx;
fAngle = s_thermalRot;
}
// compute north, south, west and east points for zone connection.
// Add a small value to ensure point is inside (or outside) zone, not on an edge
wxPoint ptTest[4];
ptTest[0] = wxPoint( 0, 3 + dy + margin );
ptTest[1] = wxPoint( 0, -(3 + dy + margin) );
ptTest[2] = wxPoint( 3 + dx + margin, 0 );
ptTest[3] = wxPoint( -(3 + dx + margin), 0 );
// Test all sides
for( int i = 0; i<4; i++ )
{
// rotate point
RotatePoint( &ptTest[i], fAngle );
// translate point
ptTest[i] += pad->ReturnShapePos();
if( HitTestFilledArea( ptTest[i] ) )
continue;
// polygon buffer
std::vector<wxPoint> corners_buffer;
// polygons are rectangles with width of copper bridge value
// contour line width has to be taken into calculation to avoid "thermal stub bleed"
const int iDTRC =
( m_ThermalReliefCopperBridgeValue - m_ZoneMinThickness ) / 2;
switch( i )
{
case 0:
corners_buffer.push_back( wxPoint( -iDTRC, dy ) );
corners_buffer.push_back( wxPoint( +iDTRC, dy ) );
corners_buffer.push_back( wxPoint( +iDTRC, iDTRC ) );
corners_buffer.push_back( wxPoint( -iDTRC, iDTRC ) );
break;
case 1:
corners_buffer.push_back( wxPoint( -iDTRC, -dy ) );
corners_buffer.push_back( wxPoint( +iDTRC, -dy ) );
corners_buffer.push_back( wxPoint( +iDTRC, -iDTRC ) );
corners_buffer.push_back( wxPoint( -iDTRC, -iDTRC ) );
break;
case 2:
corners_buffer.push_back( wxPoint( dx, -iDTRC ) );
corners_buffer.push_back( wxPoint( dx, iDTRC ) );
corners_buffer.push_back( wxPoint( +iDTRC, iDTRC ) );
corners_buffer.push_back( wxPoint( +iDTRC, -iDTRC ) );
break;
case 3:
corners_buffer.push_back( wxPoint( -dx, -iDTRC ) );
corners_buffer.push_back( wxPoint( -dx, iDTRC ) );
corners_buffer.push_back( wxPoint( -iDTRC, iDTRC ) );
corners_buffer.push_back( wxPoint( -iDTRC, -iDTRC ) );
break;
}
// add computed polygon to list
for( unsigned ic = 0; ic < corners_buffer.size(); ic++ )
{
wxPoint cpos = corners_buffer[ic];
RotatePoint( &cpos, fAngle ); // Rotate according to module orientation
cpos += pad->ReturnShapePos(); // Shift origin to position
CPolyPt corner;
corner.x = cpos.x;
corner.y = cpos.y;
corner.end_contour = ( ic < (corners_buffer.size() - 1) ) ? 0 : 1;
cornerBufferPolysToSubstract.push_back( corner );
}
}
}
}
/* compute copper areas */
if( cornerBufferPolysToSubstract.size() ) if( cornerBufferPolysToSubstract.size() )
{ {
/* Add the main corrected polygon (i.e. the filled area using only one outline) /* Add the main corrected polygon (i.e. the filled area using only one outline)
......
/***********************************************/
/* zones_convert_to_polygons_aux_functions.cpp */
/***********************************************/
/* auxiliary functions used to calculare filled copper zones areas
*/
#include <vector>
#include "fctsys.h"
#include "polygons_defs.h"
#include "common.h"
#include "pcbnew.h"
#include "wxPcbStruct.h"
#include "trigo.h"
#include "zones.h"
#include "PolyLine.h"
/**
* Function BuildUnconnectedThermalStubsPolygonList
* Creates a set of polygons corresponding to stubs created by thermal shapes on pads
* which are not connected to a zone (dangling bridges)
* @param aCornerBuffer = a std::vector<CPolyPt> where to store polygons
* @param aPcb = the board.
* @param aZone = a pointer to the ZONE_CONTAINER to examine.
* @param aArcCorrection = a pointer to the ZONE_CONTAINER to examine.
* @param aRoundPadThermalRotation = the rotation in 1.0 degree for thermal stubs in round pads
*/
void BuildUnconnectedThermalStubsPolygonList( std::vector<CPolyPt>& aCornerBuffer,
BOARD* aPcb,
ZONE_CONTAINER* aZone,
double aArcCorrection,
int aRoundPadThermalRotation)
{
std::vector<wxPoint> corners_buffer; // a local polygon buffer to store one stub
corners_buffer.reserve( 4 );
wxPoint ptTest[4];
int zone_clearance = aZone->m_ZoneClearance;
EDA_Rect item_boundingbox;
EDA_Rect zone_boundingbox = aZone->GetBoundingBox();
int biggest_clearance = aPcb->GetBiggestClearanceValue();
biggest_clearance = MAX( biggest_clearance, zone_clearance );
zone_boundingbox.Inflate( biggest_clearance );
// Calculate thermal bridge half width
int iDTRC = aZone->m_ThermalReliefCopperBridgeValue / 2;
// half size of the pen used to draw/plot zones outlines
int pen_radius = aZone->m_ZoneMinThickness / 2;
for( MODULE* module = aPcb->m_Modules; module; module = module->Next() )
{
for( D_PAD* pad = module->m_Pads; pad != NULL; pad = pad->Next() )
{
// check
if( !pad->IsOnLayer( aZone->GetLayer() ) )
continue;
if( pad->GetNet() != aZone->GetNet() )
continue;
item_boundingbox = pad->GetBoundingBox();
item_boundingbox.Inflate( aZone->m_ThermalReliefGapValue );
if( !( item_boundingbox.Intersects( zone_boundingbox ) ) )
continue;
// test point
int dx = ( pad->m_Size.x / 2 ) + aZone->m_ThermalReliefGapValue;
int dy = ( pad->m_Size.y / 2 ) + aZone->m_ThermalReliefGapValue;
// This is CIRCLE pad tweak (for circle pads the thermal stubs are at 45 deg)
int fAngle = pad->m_Orient;
if( pad->m_PadShape == PAD_CIRCLE )
{
dx = (int) ( dx * aArcCorrection );
dy = dx;
fAngle = aRoundPadThermalRotation;
}
// contour line width has to be taken into calculation to avoid "thermal stub bleed"
dx += pen_radius;
dy += pen_radius;
// compute north, south, west and east points for zone connection.
ptTest[0] = wxPoint( 0, dy );
ptTest[1] = wxPoint( 0, -dy );
ptTest[2] = wxPoint( dx, 0 );
ptTest[3] = wxPoint( -dx, 0 );
// Test all sides
for( int i = 0; i < 4; i++ )
{
// rotate point
RotatePoint( &ptTest[i], fAngle );
// translate point
ptTest[i] += pad->ReturnShapePos();
if( aZone->HitTestFilledArea( ptTest[i] ) )
continue;
corners_buffer.clear();
// polygons are rectangles with width of copper bridge value
switch( i )
{
case 0:
corners_buffer.push_back( wxPoint( -iDTRC, dy ) );
corners_buffer.push_back( wxPoint( +iDTRC, dy ) );
corners_buffer.push_back( wxPoint( +iDTRC, iDTRC ) );
corners_buffer.push_back( wxPoint( -iDTRC, iDTRC ) );
break;
case 1:
corners_buffer.push_back( wxPoint( -iDTRC, -dy ) );
corners_buffer.push_back( wxPoint( +iDTRC, -dy ) );
corners_buffer.push_back( wxPoint( +iDTRC, -iDTRC ) );
corners_buffer.push_back( wxPoint( -iDTRC, -iDTRC ) );
break;
case 2:
corners_buffer.push_back( wxPoint( dx, -iDTRC ) );
corners_buffer.push_back( wxPoint( dx, iDTRC ) );
corners_buffer.push_back( wxPoint( +iDTRC, iDTRC ) );
corners_buffer.push_back( wxPoint( +iDTRC, -iDTRC ) );
break;
case 3:
corners_buffer.push_back( wxPoint( -dx, -iDTRC ) );
corners_buffer.push_back( wxPoint( -dx, iDTRC ) );
corners_buffer.push_back( wxPoint( -iDTRC, iDTRC ) );
corners_buffer.push_back( wxPoint( -iDTRC, -iDTRC ) );
break;
}
// add computed polygon to list
for( unsigned ic = 0; ic < corners_buffer.size(); ic++ )
{
wxPoint cpos = corners_buffer[ic];
RotatePoint( &cpos, fAngle ); // Rotate according to module orientation
cpos += pad->ReturnShapePos(); // Shift origin to position
CPolyPt corner;
corner.x = cpos.x;
corner.y = cpos.y;
corner.end_contour = ( ic < (corners_buffer.size() - 1) ) ? 0 : 1;
aCornerBuffer.push_back( corner );
}
}
}
}
}
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