Closed petrasvestartas closed 5 years ago
Yes, you can add seed number. In GeneticAlgorithm (line 95) :
Random r = new Random();
Replace with:
Random r = new Random(1);
Or any other seed number.
Thank you it works perfectly. I noticed that in current version it is possible to nest inside circle, rectangle and rhombus shapes, does it mean that there is already an implementation to choose arbitrary shape as a sheet?
Yes, you can use arbitrary shapes now (last commit). But all holes will be ignored. I'll fix it later.
Thank you, works as usual - perfectly.
I would like to ask your advice about polygons that have large amount of points. If polygons have something like 60 points, nesting even small number of let say 15 polygons that have 60 points becomes slow. I do understand that this is a linear calculation: the more points you have the slower it is. Hence I would like to ask what is the best strategies to nest more complex polygons? One thing is to simplify the outline (reduce number of points), do you have other suggestions? Even the answer is no, the more points you have the slower it is, your code is super awesome!
First to all, try to measure nesting time of your test in original DeepNest program. It may be better time there (let me know then), because there are some bugs in cache algorithm in my code now. So maybe later when i'll fix it, performance will be increased.
Ensure that your same shapes and sheets has the same NFP.source value. It is very important, because all caches use it. If you have 15 identical polygons, but they have different 'source' value, performance will be awful.
Of course, simplification of outlines is the best choice in general.
Eliminating small holes is good practice too.
You can also use 'rough approximation' (convex hull approximation) option in some cases.
Ensure you have Background.UseParallel=true
Thank you for reply. Following one of your points for instance when you have the same sheets id it runs faster because you do not need to recalculate nfp for each sheet.
But here I have question. When I add 100 same sheets with source id 1, there is no translation of sheets (all 100 sheets are at the same location and not move by x axis as a consequence nested parts too).
To translate elements afterwards I would like to know the sheet number each part belongs to. Which property I should use for part sheet id?
I added NFP.sheet property. It will contain a reference to the owner sheet after nesting.
Thanks. Would NFP. Sheet. ID would return id source id of sheet which in the setup is the same for all sheets or actual array id of all sheets?
Same sheets should has same 'source' but different 'id'. So NFP.Sheet.Id give you exactly specific sheet instance. When you use the NestIterate method, it automatically reassigns the ids of all sheets according to their positions in Context.Sheets array.
public void NestIterate()
{
..............
for (int i = 0; i < Sheets.Count; i++)
{
Sheets[i].id = i;
}
So, NFP.sheet.id=2 is equivalent to Context.Sheets[2].
Works perfectly, thank you.
One more question.
I noticed that now clipper scaling works and user can change it. I would like to ask what is the difference between these two values:
SvgNest.Config.clipperScale = 1e7 (very large number)
SvgNest.Config.scale = 25 (small number)
SvgNest.Config.scale is not used now.
Hi,
Every time application run results - placement of elements are different (I am not talking about each iteration but each time application is run).
I believe that this happens because of Random function inside some of the methods. Is there a possibility to add seed number, so that result would stay the same if I run application once, then close it and open it again? Or it is a bit more complex than simple seed number as it uses genetic algorithm?