← Back to team overview

kicad-developers team mailing list archive

Re: HPGL

 

Hello,

the real pen plotter love long lines without interrupts. The attached patch glues some short line together to a long line at the area filling. This is not limited to HPGL plotters.

Regards, Andreas
=== modified file pcbnew/plot_brditems_plotter.cpp
--- pcbnew/plot_brditems_plotter.cpp	2013-01-13 00:04:00 +0000
+++ pcbnew/plot_brditems_plotter.cpp	2013-02-17 20:48:39 +0000
@@ -566,8 +566,55 @@
                 }
                 else                            // We are using areas filled by
                 {                               // segments: plot them )
+                    wxPoint ia, ie, ja, je;
                     for( unsigned iseg = 0; iseg < aZone->m_FillSegmList.size(); iseg++ )
                     {
+                        // make one long filling line from some short filling lines with equal start/end points
+                        ia = aZone->m_FillSegmList[iseg].m_Start;
+                        ie = aZone->m_FillSegmList[iseg].m_End;
+                        // search for lines with equal points
+                        for( unsigned jseg = iseg; jseg < aZone->m_FillSegmList.size(); jseg++ )
+                        {
+                            if( iseg == jseg ) // only for other lines
+                                continue;
+                            ja = aZone->m_FillSegmList[jseg].m_Start;
+                            je = aZone->m_FillSegmList[jseg].m_End;
+                            int newend = 0;
+                            int newstart = 0;
+                            if( ia == ja ) // same start
+                            {
+                                ia = je; // new start
+                                newstart = 1;
+                            }
+                            else if( ia == je ) // same start/end
+                            {
+                                ia = ja; // new start
+                                newstart = 1;
+                            }
+                            else if( ie == ja ) // same end/start
+                            {
+                                ie = je; // new end
+                                newend = 1;
+                            }
+                            else if( ie == je ) // same end
+                            {
+                                ie = ja; // new end
+                                newend = 1;
+                            }
+                            if( newend == 1 )
+                            {
+                                aZone->m_FillSegmList[iseg].m_End = ie; // save new end
+                                aZone->m_FillSegmList.erase( aZone->m_FillSegmList.begin() + jseg ); // delete other line
+                                jseg -= 1;
+                            }
+                            else if( newstart == 1 )
+                            {
+                                aZone->m_FillSegmList[iseg].m_Start = ia; // save new start
+                                aZone->m_FillSegmList.erase( aZone->m_FillSegmList.begin() + jseg ); // delete other line
+                                jseg -= 1;
+                            }
+                            //
+                        }
                         wxPoint start = aZone->m_FillSegmList[iseg].m_Start;
                         wxPoint end   = aZone->m_FillSegmList[iseg].m_End;
                         m_plotter->ThickSegment( start, end,


References