slic3r / Slic3r

Open Source toolpath generator for 3D printers
https://slic3r.org/
GNU Affero General Public License v3.0
3.35k stars 1.29k forks source link

GSoC 2019 - SVGNest in Slicer #4812

Open lordofhyphens opened 5 years ago

lordofhyphens commented 5 years ago

Development log for GSoC 2019 project to implement #3237.

gege2b commented 5 years ago

Just FYI, there is a C version of SVGNest from the same author : Deepnest I don't know if it could be of any help

3bhady commented 5 years ago

Thanks @gege2b I'll try run it and test it. It would be really helpful to have a C implementation rather than JS :) It's mainly JS but the critical parts were rewritten in C.

3bhady commented 5 years ago

Today I'm investigating the auto-arrange code in slic3r.

supermerill commented 5 years ago

There may be two different entry point for auto-arrange:

Be sure to use the same check algo for both, or to be sure that the check can't trigger after an arrange.

3bhady commented 5 years ago

EDIT: Okay that was fast :D I think I got it. Cross product of the two vectors formed by the first 3 points (we only need the first 2 vectors) if its result is positive then the polygon is anti-clockwise. Let me know if I'm missing something or if anyone likes to add anything :)

I'm having some trouble finding if the polygon is clockwise or anti-clockwise.

If anyone can help point me to something I can read on that I'd be grateful.

What I understand so far is that clockwise means that it's stored in a way that it's points are going in clockwise direction, but I'm not sure how to calculate that. I'm guessing it has something to do with cross product of every two consecutive vectors or something like that.

Samir55 commented 5 years ago

You can check Polygon.hpp in xs/src/libslic3r as it has is_clockwise function https://github.com/slic3r/Slic3r/blob/master/xs/src/libslic3r/Polygon.hpp#L36

3bhady commented 5 years ago

Thanks @Samir55 :)

luzpaz commented 3 years ago

Did anything come of this? Asking for the FreeCAD folks who are interested in a similar function for the Path/CAM workbench.

bubnikv commented 3 years ago

You may want to look into the arrangement in PrusaSlicer, inspired by svgnest. Cura recently adopted our PrusaSlicer code.

luzpaz commented 3 years ago

@bubnikv cool, care to share a link ?

bosd commented 3 years ago

Als interested in a nesting feature for freecad, so came across this issue. @luzpaz This might be of interest to you: https://github.com/grotius-cnc/Nest4J Still java, no c++ but more interfacing features.

bosd commented 3 years ago

@luzpaz I think this is the link you were looking for to the nest2D library. https://github.com/tamasmeszaros/libnest2d

Theres also this porting attempt to c++ https://github.com/kallaballa/nestcpp

Basically you would want to have this but then for Freecad: https://github.com/NicoSchlueter/FuseNest