Open Jacajack opened 3 years ago
Hi, thanks for the suggestions, let me address them in same order:
I'm not totally opposed to implementing something like this but usability issues need to be considered thoroughly. For example question of "how much zoom" can be answered with either "let user zoom in once and set it as preferred zoom" or "heuristically determine zoom for each component as bounding box taking 10% of viewport area or being 20px on longest dimension, whichever is smaller". Question of "how can user understand which piece of board is zoomed in" is typically resolved with drawing a minimap of the image in a corner with a rectangle representing viewport area.
If you'd like to help then the proximity thing will be in python but autozoom feature will be entirely in javascript.
Thanks for your quick and detailed response
n
in the filter field instead. This can also be solved by adding another "mark as placed" shortcut, for example Alt+N. Sorry for not being specific about the issue here in the first place.n_components/area
. Inside the leaves, sort the components by either x or y coordinate depending on whether the leaf is wider or longer. Then just determine the final order by traversing the BVH. In my imagination this works quite well and is the best one of these three. I could implement a proof of concept when I have some more time.As for the spatial ordering, here's what I got using the BVH so far:
It's not perfect and there are still a couple of things to tweak, but I think it looks quite good already.
Alt+[1-9]
shortcuts already exist and work when focus is in text field. They don't advance the row like N
does but Alt+char
is used in some locales to enter variations of the character so I'd like to avoid using such shortcut.
Regarding spatial ordering, first of all: awesome discussion. You never know when some hardcore CS stuff will pop into relevance even in something so utilitarian in function as bom generation.
Second, I like your ideas and BVH graph looks a lot better than random. I also pondered on your MST idea with BFS and I think it can be improved quite a bit:
This should be pretty good and maybe some more optimization can be added if we visualize it.
Another thing we can do for any algorithm as post optimization:
Say the path we found is A1
..An
, say the longest edge is Ai
-Ai+1
Try to find 0<j<i
such that if we take subpath Aj
-Ai
and reverse it in place so that resulting path will be A1
..Aj-1
-Ai
-Ai-1
..Aj
-Ai+1
..An
and it's total length is less than initial path. Do the same on the other side of the longest edge.
Repeat the operation reasonable amount of times thus continually reducing overall length.
Each optimization attempt for an edge should be O(n) so for n<300 we can try about n^2 optimizations. There won't be too many large groups on any board anyway.
What do you think?
Alt+[1-9] shortcuts already exist and work when focus is in text field. They don't advance the row like N does but Alt+char is used in some locales to enter variations of the character so I'd like to avoid using such shortcut.
That's right, I didn't think of that, but unfortunately unlike N these shortcuts do not advance the selection. One little thing, though - in Firefox Alt+1...9 are used to switch between tabs by default and it seems that you forgot to override the default behavior with preventDefault()
. I just fixed that and will submit a pull request in a second (#247).
Regarding spatial ordering, first of all: awesome discussion. You never know when some hardcore CS stuff will pop into relevance even in something so utilitarian in function as bom generation.
That's exactly what I though too! I never thought I would ever have to write a BVH tree to optimize component placement :)
As for the MST method, you're right - DFS will probably be better. Initially I thought it would be more "jumpy" than BFS, but if you start at the end of the longest path in the tree, it should be better. I like the idea of sorting the nodes by relative angle too. I might implement that later and see how it performs. Right now, I'm still playing around with the BVH and I think I can improve it by a lot by changing the order in which the nodes are visited at the end. Maybe the MST-based algorithm will come useful here? We'll see...
Another thing we can do for any algorithm as post optimization: [...]
Sounds like something worth trying, but I have to admit that it's hard for me to visualize in my head how effective that will be. Still, definitely a something to keep in mind :)
Sounds like something worth trying, but I have to admit that it's hard for me to visualize in my head how effective that will be. Still, definitely a something to keep in mind :)
The idea here is to see if we can get rid of long jumps between tight sections by flipping start and end points of some tight sections. Here is a visualization (forgive my scribbles in the most advanced graphics editor ever known, ms paint):
When applied a lot of times it will have a tendency to also uncross all overlapping edges and "unwind" the spiral into more of a zigzag.
I think this approach can be generalized a bit and replaced with a genetic algorithm (for approximating TSP solution). Maybe then we could determine the optimal order in three passes:
What do you think about that?
I don't think it will work too well because
TSP heuristics page has a MST based algorithm and it even has decent upper bound on solution deviation from optimum.
Unsurprisingly someone thought of the edge replacement optimization long before me, it is described on the same page, see "Pairwise exchange" section.
I vote for not treading a new path in this well researched problem.
One advantage of following BVH path is that it may generate a route that feels more "natural" even if other algorithm provides a shorter path. We may have to build the alternative and compare the results visually to make a call on that.
Okay, I'll try out the k-opt technique and maybe the BVH+TSP combo too if I have some time this week. I'll let you know when I have some results.
Hi,
First of all, thank you for this great project - it's really helpful and helps to save a lot of time.
Today I used the interactive BOM during assembly of two rather large PCBs (~350 BOM entries each). Based on my first impressions, I came up with a list of suggestions that could make manual assembly process a bit smoother. I just wanted to know if there's any chance that these could be implemented in the future versions:
120
all the1206
footprints will be selected too. Searching only the values is especially useful if you don't follow any strict placement order and just grab one bag of parts after another in random order and then just search the BOM for whatever fell into your hands.This was my first time using this tool, so I suppose some of the features I mentioned might already exist, but I could have just missed them. In any case, if you think that any of these are worth having, I could try (I'm not very good with Python) to implement some of them and open a PR.
Thanks