Feature Request: Optimize track after routing (gloss, reroute)

Description

Sometimes, tracks will be come segmented due to the shoving router. In this case, one continuous straight line gets broken up into multiple segments. Functionally this is fine, however it is not ideal, mostly because the extra segments makes using the Drag command challenging as extra corners are created.

Kicad already has the ability to combine tracks, which it does as part of live routing. For example, grabbing a track and wiggling it slightly causes two adjacent tracks to be combined into one.

It would be nice if there were a way to select a track to re-run this router to try and improve the track.

An example of a candidate track:

image

It would be nice if this algorithm prioritized reducing the number of segments. For example, this track could stand to be collapsed into a single segment rather than three or more:

image

Similarly, this jog could stand to be removed, which could be done if the optimizer tried to minimize both the number of segments and the track length:

image

Steps to reproduce

  1. Create a track
  2. Push the track with e.g. a via
  3. Remove the via

The track will have additional segments. The track can be dragged back to the original location, but it would be nice to be able to have the track length optimized like when the track was first placed.

KiCad Version

Application: KiCad PCB Editor (64-bit)

Version: (6.0.0-rc1-76-g1e8284bc1a), release build

Libraries:
	wxWidgets 3.1.5
	libcurl/7.78.0-DEV Schannel zlib/1.2.11

Platform: Windows 10 (build 22000), 64-bit edition, 64 bit, Little endian, wxMSW

Build Info:
	Date: Nov 20 2021 12:01:26
	wxWidgets: 3.1.5 (wchar_t,wx containers)
	Boost: 1.76.0
	OCC: 7.5.0
	Curl: 7.78.0-DEV
	ngspice: 35
	Compiler: Visual C++ 1929 without C++ ABI

Build settings:
	KICAD_USE_OCC=ON
	KICAD_SPICE=ON
Edited by Jon Evans