← Back to team overview

kicad-developers team mailing list archive

Re: Zone fill issue

 

Dick Hollenbeck wrote:

> My concern:
> Zone filling and drawing is way too slow now. This patch would affect
> the basic drawing on screen of zones also I presume.
> 

I presume the answer is yes. I'm using a fast PC and tested it only 
small boards, so it's difficult to see if the drawing is appreciably 
slower. Just for curiosity, I'll do more tests.
My patch was more an excuse to start studying kicad sources than a 
useful tool :-)

> I have some very elaborate boards for which it takes 3 minutes to fill
> zones even on a fast computer. It takes 2 seconds to draw these boards
> on screen onces the zones rasters are in place, again on a fast computer.
> 

Just to give you an example, it takes about 7 secs to fill the 
pic_programmer board... so I guess that with your board it will take 
ages to fill :-)

> Until then, perhaps the electrons will not complain about their
> playground having a ragged fence around it.
> 

eh eh, no they will not! (at least in the MHz domain)


By the way, the braves (or the lazy employees which need an excuse to 
take a coffee break) will find the patch attached.


Thank you for your time and best regards, Gabriele
 --------------000003080601060004050003 Content-Type: text/x-diff;
name="zone_filling_algorithm.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="zone_filling_algorithm.patch"

--- zone_filling_algorithm_ORIG.cpp	2008-09-09 18:24:23.000000000 +0200
+++ zone_filling_algorithm.cpp	2008-09-09 18:24:23.000000000 +0200
@@ -15,6 +15,7 @@

/* Local functions */
static void Genere_Segments_Zone( WinEDA_PcbFrame* frame, wxDC* DC, int net_code, int layer );
+static void Smooth_Segments_Zone( WinEDA_PcbFrame* frame, wxDC* DC, int net_code, int layer );

/* Local variables */
static bool Zone_Debug = false;
@@ -332,7 +333,6 @@
return error_level;
}

-
/*******************************************************************************************/
static void Genere_Segments_Zone( WinEDA_PcbFrame* frame, wxDC* DC, int net_code, int layer )
/*******************************************************************************************/
@@ -360,6 +360,8 @@
int nbsegm = 0;
wxString msg;

+ printf("Genre_Segments_Zone, s_Timestamp= %lu\n", s_TimeStamp);
+
/* Create horizontal segments */
Affiche_1_Parametre( frame, 64, wxT( "Segm H" ), wxT( "0" ), BROWN );
for( row = 0; row < Nrows; row++ )
@@ -452,6 +454,101 @@
msg.Printf( wxT( "%d" ), nbsegm );
Affiche_1_Parametre( frame, -1, wxEmptyString, msg, BROWN );
}
+
+ // Comment this out to enable the smooth function
+ Smooth_Segments_Zone( frame, DC, net_code, layer );
+}
+
+
+// TODO: add comments and doxygen documentation
+// XXX: ZONE_CONTAINER::Fill_Zone() set s_TimeStamp for us. So, be sure to set s_TimeStamp to something with sense if
+// you wish to call this function from outside.
+static void Smooth_Segments_Zone( WinEDA_PcbFrame* frame, wxDC* DC, int net_code, int layer )
+{
+ int dx, dy;
+ SEGZONE* pt_track;
+ int size = g_GridRoutingSize + 1;
+
+ //printf("Smoothing...\n");
+ //printf("g_GridRoutingSize=%i\n", g_GridRoutingSize);
+
+ //printf("size=%i\n", size);
+ for( SEGZONE* zone = frame->m_Pcb->m_Zone; zone != NULL; zone = zone->Next() )
+ {
+ //printf("(%i,%i -> %i,%i)\n", (zone->m_Start).x, (zone->m_Start).y, (zone->m_End).x, (zone->m_End).y);
+ for( SEGZONE* z = zone->Next(); z != NULL; z = z->Next() )
+ {
+ dx = abs((zone->m_Start).x - (z->m_Start).x);
+ dy = abs((zone->m_Start).y - (z->m_Start).y);
+ if ( (dx > 5) && (dy > 5) && (dx < size) && (dy < size) )
+ {
+ //printf("\tSS (%i,%i)%i,%i\n", (z->m_Start).x, (z->m_Start).y, dx, dy);
+ pt_track = new SEGZONE( frame->m_Pcb );
+ pt_track->SetLayer( layer );
+ pt_track->SetNet( net_code );
+ pt_track->m_Width = g_GridRoutingSize;
+ pt_track->m_Start = zone->m_Start;
+ pt_track->m_End = z->m_Start;
+ pt_track->m_TimeStamp = s_TimeStamp;
+ pt_track->Insert( frame->m_Pcb, NULL );
+ if ( DC )
+ pt_track->Draw( frame->DrawPanel, DC, GR_OR );
+ }
+
+ dx = abs((zone->m_End).x - (z->m_End).x);
+ dy = abs((zone->m_End).y - (z->m_End).y);
+ if ( (dx > 5) && (dy > 5) && (dx < size) && (dy < size) )
+ {
+ //printf("\tEE (%i,%i)%i,%i\n", (z->m_End).x, (z->m_End).y, dx, dy);
+ pt_track = new SEGZONE( frame->m_Pcb );
+ pt_track->SetLayer( layer );
+ pt_track->SetNet( net_code );
+ pt_track->m_Width = g_GridRoutingSize;
+ pt_track->m_Start = zone->m_End;
+ pt_track->m_End = z->m_End;
+ pt_track->m_TimeStamp = s_TimeStamp;
+ pt_track->Insert( frame->m_Pcb, NULL );
+ if ( DC )
+ pt_track->Draw( frame->DrawPanel, DC, GR_OR );
+ }
+
+ dx = abs((zone->m_Start).x - (z->m_End).x);
+ dy = abs((zone->m_Start).y - (z->m_End).y);
+ if ( (dx > 5) && (dy > 5) && (dx < size) && (dy < size) )
+ {
+ //printf("\tSE (%i,%i)%i,%i\n", (z->m_End).x, (z->m_End).y, dx, dy);
+ pt_track = new SEGZONE( frame->m_Pcb );
+ pt_track->SetLayer( layer );
+ pt_track->SetNet( net_code );
+ pt_track->m_Width = g_GridRoutingSize;
+ pt_track->m_Start = zone->m_Start;
+ pt_track->m_End = z->m_End;
+ pt_track->m_TimeStamp = s_TimeStamp;
+ pt_track->Insert( frame->m_Pcb, NULL );
+ if ( DC )
+ pt_track->Draw( frame->DrawPanel, DC, GR_OR );
+ }
+
+ dx = abs((zone->m_End).x - (z->m_Start).x);
+ dy = abs((zone->m_End).y - (z->m_Start).y);
+ if ( (dx > 5) && (dy > 5) && (dx < size) && (dy < size) )
+ {
+ //printf("\tES (%i,%i)%i,%i\n", (z->m_Start).x, (z->m_Start).y, dx, dy);
+ pt_track = new SEGZONE( frame->m_Pcb );
+ pt_track->SetLayer( layer );
+ pt_track->SetNet( net_code );
+ pt_track->m_Width = g_GridRoutingSize;
+ pt_track->m_Start = zone->m_End;
+ pt_track->m_End = z->m_Start;
+ pt_track->m_TimeStamp = s_TimeStamp;
+ pt_track->Insert( frame->m_Pcb, NULL );
+ if ( DC )
+ pt_track->Draw( frame->DrawPanel, DC, GR_OR );
+ }
+ }
+ }
+
+ //printf("Finished smoothing\n");
}


 --------------000003080601060004050003-- 




Follow ups

References