[Drawkit] Tweaks to DKRouteFinder

Brad Larson larson at sonoplot.com
Wed Jun 24 15:10:44 PDT 2009


It's been a while, but I started working on some of our drawing code  
again and was able to improve some of the sorting functionality in the  
DKRouteFinder helper class.  The existing nearest-neighbor sorting  
every now and then would fail on grids of points and would rarely  
produce a high-quality path through lines, arcs, or other vector  
elements.

The attached version of DKRouteFinder uses a slightly different  
pathfinding process, where instead of one point being provided for  
each feature, two endpoints are used.  The nearest neighbor to an  
object is found by taking into account both of these endpoints,  
comparing distances based on the nearest of the two.  This seems to  
provide a better path through lines and other features, although the  
direction an object is pointed can throw off the sorting process a  
little.

For grids, rather than use the sweeping-based heuristic that's in  
there right now, if multiple objects are equidistant from the current  
object, the closest one is considered to be the one with the smallest  
change in vertical position from the current object.  When combined  
with starting the nearest-neighbor finding process at 0,0, this seems  
to properly order all grids that I've thrown at it.

I apologize for the roughness of the code, with much of the old code  
still there as comments.  I'll try to clean this up when I get the  
chance.
______________________
Brad Larson, Ph.D.
SonoPlot, Inc.
3030 Laura Lane, Suite 120
Middleton, WI 53562



-------------- next part --------------
A non-text attachment was scrubbed...
Name: DKRouteFinder.h
Type: application/octet-stream
Size: 3450 bytes
Desc: not available
URL: <http://lists.apptree.net/pipermail/drawkit-apptree.net/attachments/20090624/a9444c8d/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DKRouteFinder.m
Type: application/octet-stream
Size: 28923 bytes
Desc: not available
URL: <http://lists.apptree.net/pipermail/drawkit-apptree.net/attachments/20090624/a9444c8d/attachment-0003.obj>


More information about the Drawkit mailing list