The g-code optimizer (gopt.py) can improve gcode files which have
special annotations within comments.

Lines outside of an annotation are copied verbatim to the output.

The "block" annotation
----------------------

Format:
    (Begin block ...)
    section 1
    section 2
    ...
    section N
    (End block ...)

Sections within a block may be arbitrarily re-ordered, and no line within
a block is not part of a section.

The "section" annotation
------------------------

    (Begin section X Y ...)
    line 1
    line 2
    ...
    line N
    (End section ...)

The section annotation must appear within a block annotation.
Lines within a section are copied verbatim to the output, except that the
sections themselves may be re-ordered within their containing block.
For the purposes of optimization, "line 1" is assumed to move to the
coordinates given in the (Begin section) comment, and "line N" is assumed
to return to this location and return to the safety height.  This is true,
for instance, when milling outside a trace on a circuit board, or when
using a G82 cycle to drill a hole.


The Optimization
----------------

When an (End block) annotation is encountered, gopt computes an order
to execute sections within the block which is close to optimal in
terms of the amount of X and Y motion.  The solution the program finds
is guaranteed to be no worse than twice as long as the best solution
possible.

In practice, the code has been able to eliminate 33% of the length of
all moves in milling one side of a particular circuit board, which would
have shortened the milling time by an hour if rapid moves are at 10IPM.
Run-time in this case was 4.5 seconds on a 2.4GHz machine, with the largest
block consisting of 1232 sections.

As the number of sections within a block increases, run-time for the
program increases.  A practical limit seems to be above 4500 sections,
which gives a run-time of about 5 minutes on this 2.4GHz machine.
