diff options
author | bubnikv <bubnikv@gmail.com> | 2016-11-04 17:03:51 +0300 |
---|---|---|
committer | bubnikv <bubnikv@gmail.com> | 2016-11-04 17:03:51 +0300 |
commit | 6217622865eac20a00b0a1a55dfddd2dffd51ceb (patch) | |
tree | 48e83b41785a5db90105645f9b2b1b357414f9b6 /xs/src/libslic3r/Geometry.cpp | |
parent | 3fc57ba8d85bef0ea6419cffe884e3ee151531ba (diff) |
Hopefully a fix of https://github.com/prusa3d/Slic3r/issues/11
Replaced eval { die } construct with a bool return value indicating
success or failure of an automatic arrangement of parts on the print bed.
Don't know exactly what is happening here, but throwing a "die" inside
a XS function and then catching it inside an eval {} block is suspcious.
Diffstat (limited to 'xs/src/libslic3r/Geometry.cpp')
-rw-r--r-- | xs/src/libslic3r/Geometry.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/xs/src/libslic3r/Geometry.cpp b/xs/src/libslic3r/Geometry.cpp index 15b68e96a..31a6dfb22 100644 --- a/xs/src/libslic3r/Geometry.cpp +++ b/xs/src/libslic3r/Geometry.cpp @@ -424,9 +424,12 @@ class ArrangeItemIndex { ArrangeItem item; ArrangeItemIndex(coordf_t _index, ArrangeItem _item) : index(_index), item(_item) {}; }; -Pointfs -arrange(size_t total_parts, const Pointf &part_size, coordf_t dist, const BoundingBoxf* bb) + +bool +arrange(size_t total_parts, const Pointf &part_size, coordf_t dist, const BoundingBoxf* bb, Pointfs &positions) { + positions.clear(); + Pointf part = part_size; // use actual part size (the largest) plus separation distance (half on each side) in spacing algorithm @@ -446,7 +449,7 @@ arrange(size_t total_parts, const Pointf &part_size, coordf_t dist, const Boundi size_t cellw = floor((area.x + dist) / part.x); size_t cellh = floor((area.y + dist) / part.y); if (total_parts > (cellw * cellh)) - CONFESS(PRINTF_ZU " parts won't fit in your print area!\n", total_parts); + return false; // total space used by cells Pointf cells(cellw * part.x, cellh * part.y); @@ -527,7 +530,6 @@ arrange(size_t total_parts, const Pointf &part_size, coordf_t dist, const Boundi } } // now we actually place objects into cells, positioned such that the left and bottom borders are at 0 - Pointfs positions; for (size_t i = 1; i <= total_parts; ++i) { ArrangeItemIndex c = cellsorder.front(); cellsorder.erase(cellsorder.begin()); @@ -544,7 +546,7 @@ arrange(size_t total_parts, const Pointf &part_size, coordf_t dist, const Boundi } } - return positions; + return true; } #endif |