Welcome to mirror list, hosted at ThFree Co, Russian Federation.

selection_boilerplate.hpp « selections « libnest2d « libnest2d « src « xs - github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 05bbae658e2dc4af739bcba6fae5edb651d46263 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#ifndef SELECTION_BOILERPLATE_HPP
#define SELECTION_BOILERPLATE_HPP

#include "../libnest2d.hpp"

namespace libnest2d { namespace selections {

template<class RawShape>
class SelectionBoilerplate {
public:
    using Item = _Item<RawShape>;
    using ItemRef = std::reference_wrapper<Item>;
    using ItemGroup = std::vector<ItemRef>;
    using PackGroup = std::vector<ItemGroup>;

    size_t binCount() const { return packed_bins_.size(); }

    ItemGroup itemsForBin(size_t binIndex) {
        assert(binIndex < packed_bins_.size());
        return packed_bins_[binIndex];
    }

    inline const ItemGroup itemsForBin(size_t binIndex) const {
        assert(binIndex < packed_bins_.size());
        return packed_bins_[binIndex];
    }

    inline void progressIndicator(ProgressFunction fn) {
        progress_ = fn;
    }

protected:

    PackGroup packed_bins_;
    ProgressFunction progress_ = [](unsigned){};
};

}
}

#endif // SELECTION_BOILERPLATE_HPP