Commit e44bf712 authored by charras's avatar charras

Fixed a subtle problem in zone filling calculations (see changelog)

parent b92dc298
...@@ -5,6 +5,16 @@ Started 2007-June-11 ...@@ -5,6 +5,16 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. email address.
2008-Sep-14 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
+pcbnew:
Fixed a problem in zone filling algo: due tu differents ways to truncate coordinates
between 2 functions (one round coordinates, and others truncate coordinates),
some start points used to fill zones can be inside the zone outlines,
but placed outside when init matrix parameters when rounding them instead of truncate.
So zone was filled inside and outside when happens.
2008-Sep-9 UPDATE Dick Hollenbeck <dick@softplc.com> 2008-Sep-9 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================ ================================================================================
+eeschema +eeschema
......
...@@ -9,7 +9,7 @@ COMMON_GLOBL wxString g_BuildVersion ...@@ -9,7 +9,7 @@ COMMON_GLOBL wxString g_BuildVersion
# include "config.h" # include "config.h"
(wxT(KICAD_SVN_VERSION)) (wxT(KICAD_SVN_VERSION))
# else # else
(wxT("(20080825)")) /* main program version */ (wxT("(20080912)")) /* main program version */
# endif # endif
#endif #endif
; ;
...@@ -20,7 +20,7 @@ COMMON_GLOBL wxString g_BuildAboutVersion ...@@ -20,7 +20,7 @@ COMMON_GLOBL wxString g_BuildAboutVersion
# include "config.h" # include "config.h"
(wxT(KICAD_ABOUT_VERSION)) (wxT(KICAD_ABOUT_VERSION))
# else # else
(wxT("(20080825-final)")) /* svn date & rev (normally overridden) */ (wxT("(20080912)")) /* svn date & rev (normally overridden) */
# endif # endif
#endif #endif
; ;
......
...@@ -13,24 +13,24 @@ ...@@ -13,24 +13,24 @@
#include "trigo.h" #include "trigo.h"
#include "cell.h" #include "cell.h"
/* Exported functions */
int ToMatrixCoordinate ( int aPhysicalCoordinate);
void TraceLignePcb( int x0, int y0, int x1, int y1, int layer, int color );
void TraceArc( int ux0, int uy0, int ux1, int uy1, int ArcAngle, int lg, int layer,
int color, int op_logique );
/* Routines externes */
/* routines internes */ /* Local functions */
void TraceLignePcb( int x0, int y0, int x1, int y1, int layer, int color ); static void DrawSegmentQcq( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
void DrawSegmentQcq( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
int color, int op_logique ); int color, int op_logique );
void DrawHVSegment( int ux0, int uy0, int ux1, int uy1, int demi_largeur, int layer, static void DrawHVSegment( int ux0, int uy0, int ux1, int uy1, int demi_largeur, int layer,
int color, int op_logique ); int color, int op_logique );
void TraceFilledCercle( BOARD* Pcb, int cx, int cy, int rayon, int masque_layer, static void TraceFilledCercle( BOARD* Pcb, int cx, int cy, int rayon, int masque_layer,
int color, int op_logique ); int color, int op_logique );
void TraceCercle( int ux0, int uy0, int ux1, int uy1, int lg, int layer, static void TraceCercle( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
int color, int op_logique ); int color, int op_logique );
void TraceArc( int ux0, int uy0, int ux1, int uy1, int ArcAngle, int lg, int layer,
int color, int op_logique );
/* Macro d'appel de mise a jour de cellules */ /* Macro d'appel de mise a jour de cellules */
#define OP_CELL( layer, dy, dx ) { if( layer < 0 ) \ #define OP_CELL( layer, dy, dx ) { if( layer < 0 ) \
{ \ { \
...@@ -46,6 +46,15 @@ void TraceArc( int ux0, int uy0, int ux1, int uy1, int ArcAngle, int lg, int ...@@ -46,6 +46,15 @@ void TraceArc( int ux0, int uy0, int ux1, int uy1, int ArcAngle, int lg, int
WriteCell( dy, dx, TOP, color );\ WriteCell( dy, dx, TOP, color );\
} } } }
int ToMatrixCoordinate ( int aPhysicalCoordinate)
/** Function ToMatrixCoordinate
* compute the coordinate in the routing matrix from the real (board) value
* @param aPhysicalCoordinate = value to convert
* @return the coordinate relative to the matrix
*/
{
return aPhysicalCoordinate / g_GridRoutingSize;
}
/******************************************************************************/ /******************************************************************************/
void Place_1_Pad_Board( BOARD* Pcb, D_PAD* pt_pad, int color, int marge, int op_logique ) void Place_1_Pad_Board( BOARD* Pcb, D_PAD* pt_pad, int color, int marge, int op_logique )
...@@ -349,7 +358,8 @@ void TraceLignePcb( int x0, int y0, int x1, int y1, int layer, int color, int op ...@@ -349,7 +358,8 @@ void TraceLignePcb( int x0, int y0, int x1, int y1, int layer, int color, int op
{ {
if( y1 < y0 ) if( y1 < y0 )
EXCHG( y0, y1 ); EXCHG( y0, y1 );
dy = y0 / g_GridRoutingSize; lim = y1 / g_GridRoutingSize; dy = y0 / g_GridRoutingSize;
lim = y1 / g_GridRoutingSize;
dx = x0 / g_GridRoutingSize; dx = x0 / g_GridRoutingSize;
/* Clipping aux limites du board */ /* Clipping aux limites du board */
if( (dx < 0) || (dx >= Ncols) ) if( (dx < 0) || (dx >= Ncols) )
...@@ -370,7 +380,8 @@ void TraceLignePcb( int x0, int y0, int x1, int y1, int layer, int color, int op ...@@ -370,7 +380,8 @@ void TraceLignePcb( int x0, int y0, int x1, int y1, int layer, int color, int op
{ {
if( x1 < x0 ) if( x1 < x0 )
EXCHG( x0, x1 ); EXCHG( x0, x1 );
dx = x0 / g_GridRoutingSize; lim = x1 / g_GridRoutingSize; dx = x0 / g_GridRoutingSize;
lim = x1 / g_GridRoutingSize;
dy = y0 / g_GridRoutingSize; dy = y0 / g_GridRoutingSize;
/* Clipping aux limites du board */ /* Clipping aux limites du board */
if( (dy < 0) || (dy >= Nrows) ) if( (dy < 0) || (dy >= Nrows) )
...@@ -395,7 +406,8 @@ void TraceLignePcb( int x0, int y0, int x1, int y1, int layer, int color, int op ...@@ -395,7 +406,8 @@ void TraceLignePcb( int x0, int y0, int x1, int y1, int layer, int color, int op
EXCHG( x1, x0 ); EXCHG( y1, y0 ); EXCHG( x1, x0 ); EXCHG( y1, y0 );
} }
dx = x0 / g_GridRoutingSize; lim = x1 / g_GridRoutingSize; dx = x0 / g_GridRoutingSize;
lim = x1 / g_GridRoutingSize;
dy = y0 / g_GridRoutingSize; dy = y0 / g_GridRoutingSize;
inc = 1; if( y1 < y0 ) inc = 1; if( y1 < y0 )
inc = -1; inc = -1;
...@@ -421,7 +433,8 @@ void TraceLignePcb( int x0, int y0, int x1, int y1, int layer, int color, int op ...@@ -421,7 +433,8 @@ void TraceLignePcb( int x0, int y0, int x1, int y1, int layer, int color, int op
EXCHG( x1, x0 ); EXCHG( y1, y0 ); EXCHG( x1, x0 ); EXCHG( y1, y0 );
} }
dy = y0 / g_GridRoutingSize; lim = y1 / g_GridRoutingSize; dy = y0 / g_GridRoutingSize;
lim = y1 / g_GridRoutingSize;
dx = x0 / g_GridRoutingSize; dx = x0 / g_GridRoutingSize;
inc = 1; if( x1 < x0 ) inc = 1; if( x1 < x0 )
inc = -1; inc = -1;
......
...@@ -145,9 +145,9 @@ int ZONE_CONTAINER::Fill_Zone( WinEDA_PcbFrame* frame, wxDC* DC, bool verbose ) ...@@ -145,9 +145,9 @@ int ZONE_CONTAINER::Fill_Zone( WinEDA_PcbFrame* frame, wxDC* DC, bool verbose )
if( m_Poly->TestPointInside( pos.x, pos.y ) ) if( m_Poly->TestPointInside( pos.x, pos.y ) )
{ {
pos -= Pcb->m_BoundaryBox.m_Pos; pos -= Pcb->m_BoundaryBox.m_Pos;
ZoneStartFill.x = ( pos.x + (g_GridRoutingSize / 2) ) / g_GridRoutingSize; ZoneStartFill.x = pos.x / g_GridRoutingSize;
ZoneStartFill.y = ( pos.y + (g_GridRoutingSize / 2) ) / g_GridRoutingSize; ZoneStartFill.y = pos.y / g_GridRoutingSize;
BoardCell cell = GetCell( ZoneStartFill.y, ZoneStartFill.x, BOTTOM ); BoardCell cell = GetCell( ZoneStartFill.y, ZoneStartFill.x, BOTTOM );
if ( (cell & CELL_is_EDGE) == 0 ) if ( (cell & CELL_is_EDGE) == 0 )
{ {
...@@ -167,9 +167,9 @@ int ZONE_CONTAINER::Fill_Zone( WinEDA_PcbFrame* frame, wxDC* DC, bool verbose ) ...@@ -167,9 +167,9 @@ int ZONE_CONTAINER::Fill_Zone( WinEDA_PcbFrame* frame, wxDC* DC, bool verbose )
if( m_Poly->TestPointInside( pos.x, pos.y ) ) if( m_Poly->TestPointInside( pos.x, pos.y ) )
{ {
pos -= Pcb->m_BoundaryBox.m_Pos; pos -= Pcb->m_BoundaryBox.m_Pos;
ZoneStartFill.x = ( pos.x + (g_GridRoutingSize / 2) ) / g_GridRoutingSize; ZoneStartFill.x = pos.x / g_GridRoutingSize;
ZoneStartFill.y = ( pos.y + (g_GridRoutingSize / 2) ) / g_GridRoutingSize; ZoneStartFill.y = pos.y / g_GridRoutingSize;
BoardCell cell = GetCell( ZoneStartFill.y, ZoneStartFill.x, BOTTOM ); BoardCell cell = GetCell( ZoneStartFill.y, ZoneStartFill.x, BOTTOM );
if ( (cell & CELL_is_EDGE) == 0 ) if ( (cell & CELL_is_EDGE) == 0 )
{ {
...@@ -181,9 +181,9 @@ int ZONE_CONTAINER::Fill_Zone( WinEDA_PcbFrame* frame, wxDC* DC, bool verbose ) ...@@ -181,9 +181,9 @@ int ZONE_CONTAINER::Fill_Zone( WinEDA_PcbFrame* frame, wxDC* DC, bool verbose )
if( m_Poly->TestPointInside( pos.x, pos.y ) ) if( m_Poly->TestPointInside( pos.x, pos.y ) )
{ {
pos -= Pcb->m_BoundaryBox.m_Pos; pos -= Pcb->m_BoundaryBox.m_Pos;
ZoneStartFill.x = ( pos.x + (g_GridRoutingSize / 2) ) / g_GridRoutingSize; ZoneStartFill.x = pos.x / g_GridRoutingSize;
ZoneStartFill.y = ( pos.y + (g_GridRoutingSize / 2) ) / g_GridRoutingSize; ZoneStartFill.y = pos.y / g_GridRoutingSize;
BoardCell cell = GetCell( ZoneStartFill.y, ZoneStartFill.x, BOTTOM ); BoardCell cell = GetCell( ZoneStartFill.y, ZoneStartFill.x, BOTTOM );
if ( (cell & CELL_is_EDGE) == 0 ) if ( (cell & CELL_is_EDGE) == 0 )
{ {
...@@ -277,9 +277,9 @@ int ZONE_CONTAINER::Fill_Zone( WinEDA_PcbFrame* frame, wxDC* DC, bool verbose ) ...@@ -277,9 +277,9 @@ int ZONE_CONTAINER::Fill_Zone( WinEDA_PcbFrame* frame, wxDC* DC, bool verbose )
if( m_Poly->TestPointInside( pos.x, pos.y ) ) if( m_Poly->TestPointInside( pos.x, pos.y ) )
{ {
pos -= Pcb->m_BoundaryBox.m_Pos; pos -= Pcb->m_BoundaryBox.m_Pos;
ZoneStartFill.x = ( pos.x + (g_GridRoutingSize / 2) ) / g_GridRoutingSize; ZoneStartFill.x = pos.x / g_GridRoutingSize;
ZoneStartFill.y = ( pos.y + (g_GridRoutingSize / 2) ) / g_GridRoutingSize; ZoneStartFill.y = pos.y / g_GridRoutingSize;
BoardCell cell = GetCell( ZoneStartFill.y, ZoneStartFill.x, BOTTOM ); BoardCell cell = GetCell( ZoneStartFill.y, ZoneStartFill.x, BOTTOM );
if ( (cell & CELL_is_EDGE) == 0 ) if ( (cell & CELL_is_EDGE) == 0 )
OrCell( ZoneStartFill.y, ZoneStartFill.x, BOTTOM, CELL_is_ZONE ); OrCell( ZoneStartFill.y, ZoneStartFill.x, BOTTOM, CELL_is_ZONE );
......
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