Slic3r icon indicating copy to clipboard operation
Slic3r copied to clipboard

Improve auto-arrange algorithm with SVGNest

Open triffid opened this issue 8 years ago • 18 comments

https://github.com/Jack000/SVGnest looks perfect for improving slic3r auto-arrange!

triffid avatar Feb 11 '16 04:02 triffid

Definitely! It would be nice to have a C or C++ port... I can't merge JavaScript :-( https://github.com/Jack000/SVGnest/issues/6

alranel avatar Mar 13 '16 21:03 alranel

Some considerations:

SVGnest doesn't have a termination clause; it keeps going until the user stops it. For our needs we would (probably) want to run some N iterations of the algorithm with each "Auto Arrange" click, removing the existing state if objects are added/removed/scaled/rotated by the user.

We'd also need to calculate the bounding boxes with holes to allow it to properly nest objects inside other objects.

Additionally, this will add a bunch of GUI configuration options to the plater.

lordofhyphens avatar Sep 07 '17 19:09 lordofhyphens

It's open source, I'm sure upstream would accept a patch to limit runs if it doesn't already export a single iteration method

On 8 Sep 2017 03:29, "Joseph Lenox" [email protected] wrote:

Some considerations:

SVGnest doesn't have a termination clause; it keeps going until the user stops it. For our needs we would (probably) want to run some N iterations of the algorithm with each "Auto Arrange" click, removing the existing state if objects are added/removed/scaled/rotated by the user.

We'd also need to calculate the bounding boxes with holes to allow it to properly nest objects inside other objects.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/alexrj/Slic3r/issues/3237#issuecomment-327899926, or mute the thread https://github.com/notifications/unsubscribe-auth/AAKBGogEMMmXzx0eTn-aCtTVYFVRa8fIks5sgEQBgaJpZM4HX5mj .

triffid avatar Sep 07 '17 23:09 triffid

@triffid we have to port/reimplement it anyway for Slic3r (as @alexrj noted, we're not merging javascript into Slic3r), so my comment was more of an note when implementing, not as an objection.

lordofhyphens avatar Sep 08 '17 00:09 lordofhyphens

One proposal I'd have is to set the minimum distance between parts to be 5mm more than the distance threshold to retract before move; this would be to avoid more artifacts on external walls. The extra 5mm is to ensure that even you set it to 0 prints wouldn't be right on top of each other.

lordofhyphens avatar Sep 11 '17 16:09 lordofhyphens

We'll also need to resolve the bounding box to closer in the shape if we want to be able to properly nest things in other things. Initially though I think it would be fine to leave them as opaque.

Other notes:

  • Extra UI would be likely desired to lock rotation on individual items on the bed in Z (that is, the profile only changes on the XY plane). I don't think we should rotate the piece along the X or Y axes at all; most parts have the layer alignment as a strength requirement.
  • We'd need to be able to decouple copies from the main (individual rotate); I think that copies currently share rotates.

lordofhyphens avatar Sep 11 '17 16:09 lordofhyphens

I'm working on porting svgnest to C++: https://github.com/kallaballa/nestcpp/blob/master/src/util/geometry_util.cpp

At the moment i'm translating one function after the other. Anyone wants to join the effort?

kallaballa avatar Jan 18 '18 12:01 kallaballa

Hey, I wonder if this issue is still available for GSoC 2018 If so, it'd be great to have a hint where to start xD @alexrj

FatemaKhalid avatar Mar 21 '18 10:03 FatemaKhalid

We at Prusa3D plan to give it as a first assignment to a guy joining us this week.

On Wed, Mar 21, 2018 at 11:38 AM, FatemaKhalid [email protected] wrote:

Hey, I wonder if this issue is still available for GSoC 2018 xD If so, it'd be great to have a hint where to start xD

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/alexrj/Slic3r/issues/3237#issuecomment-374894632, or mute the thread https://github.com/notifications/unsubscribe-auth/AFj5I2ZPyCmZGRDjr9Ywv6Kyp-xNhVWxks5tgi2UgaJpZM4HX5mj .

bubnikv avatar Mar 21 '18 10:03 bubnikv

Thank you for fast response :smile:

FatemaKhalid avatar Mar 21 '18 11:03 FatemaKhalid

@bubnikv Has this task been implemented in Prusa3D, so we can port this to Slic3r ?

Samir55 avatar Jun 17 '18 14:06 Samir55

We are still working on that.

On Sun, Jun 17, 2018 at 4:37 PM, Ahmed Samir [email protected] wrote:

@bubnikv https://github.com/bubnikv Has this task been implemented in Prusa3D, so we can port this to Slic3r ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/slic3r/Slic3r/issues/3237#issuecomment-397883086, or mute the thread https://github.com/notifications/unsubscribe-auth/AFj5I0p7UwdKERelCYzcf4imjTQe3-QEks5t9mmMgaJpZM4HX5mj .

bubnikv avatar Jun 17 '18 21:06 bubnikv

Looks like it might be in Slic3r Prusa Edition 1.4.1 , which has faster and better 'arrange' than previously.

laird avatar Nov 02 '18 12:11 laird

Hello, an implementation of the nesting has been developed in the form of a C++ library. It is inspired by SVGNest but not based on it in any way. Slic3r Prusa Edition 1.41 has the first working version integrated.

At this stage it works only for convex polygons which was sufficient for the first release. A proper NFP implementation is still a work in progress. A have tried to integrate @kallaballa 's libnfporb library but it crashed with some examples. I will try it again with a newer version sometimes when my time will allow.

At its current stage the nesting library lives on github: https://github.com/tamasmeszaros/libnest2d and its also part of the Slic3r prusa edition codebase. Any improvements would be welcome, especially a robust implementation of the no fit polygon for non-convex shapes with holes.

tamasmeszaros avatar Nov 02 '18 13:11 tamasmeszaros

@tamasmeszaros, I will try to use libnfporb in libnest2d , but can't pack anything, should you give me some example code?thanks.

jjqcat avatar Nov 25 '18 08:11 jjqcat

I see what's wrong, the nfp polygon's ’orientation is reversed.

jjqcat avatar Nov 25 '18 13:11 jjqcat

@jjqcat: Sorry for the late reply. If you have any trouble with libnest2d, please let me know I will try my best to help you. Also, if you make any progress with the libnfporb integration, please feel free to share your results on the libnest2d github page. It would be a valuable info in any case.

tamasmeszaros avatar Mar 04 '19 12:03 tamasmeszaros

I'd like to bring to your attention that I've finally put the necessary work into libnfporb to make it robust. There are still issues remaining: https://github.com/kallaballa/libnfporb/issues but they are rare and not critical. Also floating-point and arbitrary precision both yield the same result in the tests though that parity might break with a mix of very small and very large geometries.

kallaballa avatar Sep 11 '21 12:09 kallaballa