[Drawkit] Now with added testing. (was Re: For the brave ; -)
Brad Larson
larson at sonoplot.com
Wed Jul 30 16:08:14 PDT 2008
Holy crap. I was just looking for a suggestion, not a full route-
finding class! What's next, using a genetic algorithm to improve
sorting performance?
I've attached the file handling category with the added sorting
functionality built in. If you overwrite the files in the Beta 1
source with these and add the DKRouteFinder to the project, it should
add in the sorting before saving. So far, I'm getting odd results,
but I can't tell if that's entirely on my end or what. I've attached
two simple examples, one a box made of lines and the other a grid of
spots. These were saved using this code. For the grid of spots,
rather than rastering across the rows and columns like the optimal
path should be, the spots are placed in a snaking order.
Lines are trickier. Since our system operates like a pen plotter,
we'd like to have lines or arcs that touch one another be drawn in a
single stroke, rather than draw a line, pick up the pen, and draw
another line somewhere else. First off, this means that the start and
end points of the line have to be in the right order. As a kludge, I
created a method that goes through the objects in an array, checks to
see if a line's end point touches the end point of a previously drawn
line, and if so swaps the starting and ending points of the line so
that its starting point matches the other object's ending point. I
run this before the sort, hoping that the route finding through the
starting points will sort in the proper order. As can be seen in the
box example, that isn't the case right now. In fact, the elements
look like they might in the opposite order from what I expected.
I'm just starting to test this, but I thought I'd let you know what
I'm seeing so far. There's a lot more experimentation that I need to
do.
Again, thanks.
On Jul 30, 2008, at 8:45 AM, Graham Cox wrote:
> I've now tested the route-finder and it works very nicely - hope
> it's useful to someone out there.
>
> Revised code attached. Note that most of the names have been changed
> to something more descriptive from the first pass, and I've added
> sanity checking of inputs and so on. Also, a way to get progress
> feedback. However, I've tested it with hundreds of objects and until
> you get to about 1000 or so, the time it takes seems almost instant,
> so progress feedback is not really needed.
>
> I also discovered that it crashes on less than 4 objects, so the
> code now tests for that and does nothing with < 4. (If you can't
> route 3 objects you'd be in trouble anyway I guess).
>
> For testing I added a simple category to the Draw Demo which
> implements an action that just routes the active layer's objects,
> creates a path from the resulting points and adds that on top, thus
> showing the computed route. This code is not intended as anything
> other than a quick test.
>
> cheers, Graham
>
>
> <DKRouteFinder.m><DKRouteFinder.h><GCDrawDemoDocument
> +ShortestRoute.m><GCDrawDemoDocument
> +ShortestRoute.h>_______________________________________________
> Drawkit mailing list
> Drawkit at lists.apptree.net
> http://lists.apptree.net/listinfo.cgi/drawkit-apptree.net
______________________
Brad Larson
SonoPlot, Inc.
3030 Laura Lane, Suite 120
Middleton, WI 53562
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DKDrawing+FiletypePattern.h
Type: application/octet-stream
Size: 1436 bytes
Desc: not available
URL: <http://lists.apptree.net/pipermail/drawkit-apptree.net/attachments/20080730/f30c0d8a/attachment-0004.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DKDrawing+FiletypePattern.m
Type: application/octet-stream
Size: 35328 bytes
Desc: not available
URL: <http://lists.apptree.net/pipermail/drawkit-apptree.net/attachments/20080730/f30c0d8a/attachment-0005.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: box.pattern
Type: application/octet-stream
Size: 911 bytes
Desc: not available
URL: <http://lists.apptree.net/pipermail/drawkit-apptree.net/attachments/20080730/f30c0d8a/attachment-0006.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testspots3.pattern
Type: application/octet-stream
Size: 4161 bytes
Desc: not available
URL: <http://lists.apptree.net/pipermail/drawkit-apptree.net/attachments/20080730/f30c0d8a/attachment-0007.obj>
More information about the Drawkit
mailing list