diff options
author | tamasmeszaros <meszaros.q@gmail.com> | 2018-07-04 15:36:14 +0300 |
---|---|---|
committer | tamasmeszaros <meszaros.q@gmail.com> | 2018-07-04 15:36:14 +0300 |
commit | b26d1ef5bf243f6282195a380211be52d8f5b5ee (patch) | |
tree | ca8afe2ba49e5c6227377b0c8ca5fbb915226ec9 /xs/src/libslic3r/Model.cpp | |
parent | 0b914c5ea33eda8e609ad818c3306342bc7c99e9 (diff) |
Some comments
Diffstat (limited to 'xs/src/libslic3r/Model.cpp')
-rw-r--r-- | xs/src/libslic3r/Model.cpp | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/xs/src/libslic3r/Model.cpp b/xs/src/libslic3r/Model.cpp index a74c89d16..6664020a3 100644 --- a/xs/src/libslic3r/Model.cpp +++ b/xs/src/libslic3r/Model.cpp @@ -476,13 +476,20 @@ bool arrange(Model &model, coordf_t dist, const Slic3r::BoundingBoxf* bb, using PConf = Arranger::PlacementConfig; using SConf = Arranger::SelectionConfig; - PConf pcfg; - SConf scfg; + PConf pcfg; // Placement configuration + SConf scfg; // Selection configuration + // Try inserting groups of 2, and 3 items in all possible order. scfg.try_reverse_order = true; + + // If there are more items that could possibly fit into one bin, + // use multiple threads. (Potencially decreased pack efficiency) scfg.allow_parallel = false; + + // Use multiple threads whenever possible scfg.force_parallel = false; + // Align the arranged pile into the center of the bin pcfg.alignment = PConf::Alignment::CENTER; // TODO cannot use rotations until multiple objects of same geometry can @@ -490,28 +497,45 @@ bool arrange(Model &model, coordf_t dist, const Slic3r::BoundingBoxf* bb, // arranger.useMinimumBoundigBoxRotation(); pcfg.rotations = { 0.0 }; + // Magic: we will specify what is the goal of arrangement... + // In this case we override the default object function because we + // (apparently) don't care about pack efficiency and all we care is that the + // larger items go into the center of the pile and smaller items orbit it + // so the resulting pile has a circle-like shape. + // This is good for the print bed's heat profile. + // As a side effect, the arrange procedure is a lot faster (we do not need + // to calculate the convex hulls) pcfg.object_function = [&bin]( - NfpPlacer::Pile pile, double /*area*/, double norm, double penality) + NfpPlacer::Pile pile, // The currently arranged pile + double /*area*/, // Sum area of items (not needed) + double norm, // A norming factor for physical dimensions + double penality) // Min penality in case of bad arrangement { auto bb = ShapeLike::boundingBox(pile); - // We will optimize to the diameter of the circle around the bounding box - double score = PointLike::distance(bb.minCorner(), bb.maxCorner()) / norm; + // We will optimize to the diameter of the circle around the bounding + // box and use the norming factor to get rid of the physical dimensions + double score = PointLike::distance(bb.minCorner(), + bb.maxCorner()) / norm; + // If it does not fit into the print bed we will beat it + // with a large penality if(!NfpPlacer::wouldFit(bb, bin)) score = 2*penality - score; return score; }; + // Create the arranger object Arranger arranger(bin, min_obj_distance, pcfg, scfg); + // Set the progress indicator for the arranger. arranger.progressIndicator(progressind); // std::cout << "Arranging model..." << std::endl; // bench.start(); + // Arrange and return the items with their respective indices within the // input sequence. - auto result = arranger.arrangeIndexed(shapes.begin(), shapes.end()); // bench.stop(); |