diff options
author | tamasmeszaros <meszaros.q@gmail.com> | 2019-07-18 18:31:11 +0300 |
---|---|---|
committer | tamasmeszaros <meszaros.q@gmail.com> | 2019-07-18 18:31:27 +0300 |
commit | 6ae50a710a97e8379cb2f85392b0a6c90abd7d40 (patch) | |
tree | 4e5a52f4dbc43ffe611952f94d0dfc7ab497dd22 /src/libnest2d | |
parent | b2867f92275205b8e617b3eff0ccbba28f6a2f0f (diff) |
Further refactoring
Diffstat (limited to 'src/libnest2d')
-rw-r--r-- | src/libnest2d/include/libnest2d.h | 4 | ||||
-rw-r--r-- | src/libnest2d/include/libnest2d/libnest2d.hpp | 34 | ||||
-rw-r--r-- | src/libnest2d/tests/test.cpp | 4 |
3 files changed, 21 insertions, 21 deletions
diff --git a/src/libnest2d/include/libnest2d.h b/src/libnest2d/include/libnest2d.h index 5f7a29dfb..4661b4574 100644 --- a/src/libnest2d/include/libnest2d.h +++ b/src/libnest2d/include/libnest2d.h @@ -65,7 +65,7 @@ void nest(Iterator from, Iterator to, const typename Placer::Config& pconf = {}, const typename Selector::Config& sconf = {}) { - Nester<Placer, Selector> nester(bin, dist, pconf, sconf); + _Nester<Placer, Selector> nester(bin, dist, pconf, sconf); nester.execute(from, to); } @@ -80,7 +80,7 @@ void nest(Iterator from, Iterator to, const typename Placer::Config& pconf = {}, const typename Selector::Config& sconf = {}) { - Nester<Placer, Selector> nester(bin, dist, pconf, sconf); + _Nester<Placer, Selector> nester(bin, dist, pconf, sconf); if(prg) nester.progressIndicator(prg); if(scond) nester.stopCondition(scond); nester.execute(from, to); diff --git a/src/libnest2d/include/libnest2d/libnest2d.hpp b/src/libnest2d/include/libnest2d/libnest2d.hpp index d0d91838f..29d52c10f 100644 --- a/src/libnest2d/include/libnest2d/libnest2d.hpp +++ b/src/libnest2d/include/libnest2d/libnest2d.hpp @@ -741,12 +741,11 @@ public: }; /** - * The Arranger is the front-end class for the libnest2d library. It takes the - * input items and outputs the items with the proper transformations to be - * inside the provided bin. + * The _Nester is the front-end class for the libnest2d library. It takes the + * input items and changes their transformations to be inside the provided bin. */ template<class PlacementStrategy, class SelectionStrategy > -class Nester { +class _Nester { using TSel = SelectionStrategyLike<SelectionStrategy>; TSel selector_; public: @@ -771,12 +770,12 @@ private: using TSItem = remove_cvref_t<SItem>; StopCondition stopfn_; - - template<class It> using TVal = remove_cvref_t<typename It::value_type>; + + template<class It> using TVal = remove_ref_t<typename It::value_type>; template<class It, class Out> - using ConvertibleOnly = - enable_if_t< std::is_convertible<TVal<It>, TPItem>::value, void>; + using ItemIteratorOnly = + enable_if_t<std::is_convertible<TVal<It>&, TPItem&>::value, Out>; public: @@ -789,10 +788,8 @@ public: template<class TBinType = BinType, class PConf = PlacementConfig, class SConf = SelectionConfig> - Nester( TBinType&& bin, - Coord min_obj_distance = 0, - const PConf& pconfig = PConf(), - const SConf& sconfig = SConf()): + _Nester(TBinType&& bin, Coord min_obj_distance = 0, + const PConf& pconfig = PConf(), const SConf& sconfig = SConf()): bin_(std::forward<TBinType>(bin)), pconfig_(pconfig), min_obj_distance_(min_obj_distance) @@ -817,14 +814,17 @@ public: } /** - * \brief Arrange an input sequence and return a PackGroup object with - * the packed groups corresponding to the bins. + * \brief Arrange an input sequence of _Item-s. + * + * To get the result, call the translation(), rotation() and binId() + * methods of each item. If only the transformed polygon is needed, call + * transformedShape() to get the properly transformed shapes. * * The number of groups in the pack group is the number of bins opened by * the selection algorithm. */ template<class It> - inline ConvertibleOnly<It, void> execute(It from, It to) + inline ItemIteratorOnly<It, void> execute(It from, It to) { auto infl = static_cast<Coord>(std::ceil(min_obj_distance_/2.0)); if(infl > 0) std::for_each(from, to, [this, infl](Item& item) { @@ -840,13 +840,13 @@ public: } /// Set a progress indicator function object for the selector. - inline Nester& progressIndicator(ProgressFunction func) + inline _Nester& progressIndicator(ProgressFunction func) { selector_.progressIndicator(func); return *this; } /// Set a predicate to tell when to abort nesting. - inline Nester& stopCondition(StopCondition fn) + inline _Nester& stopCondition(StopCondition fn) { stopfn_ = fn; selector_.stopCondition(fn); return *this; } diff --git a/src/libnest2d/tests/test.cpp b/src/libnest2d/tests/test.cpp index 6891b16e1..29577344d 100644 --- a/src/libnest2d/tests/test.cpp +++ b/src/libnest2d/tests/test.cpp @@ -370,7 +370,7 @@ TEST(GeometryAlgorithms, ArrangeRectanglesTight) ASSERT_EQ(getX(bin.center()), 105); ASSERT_EQ(getY(bin.center()), 125); - Nester<BottomLeftPlacer, DJDHeuristic> arrange(bin); + _Nester<BottomLeftPlacer, DJDHeuristic> arrange(bin); arrange.execute(rects.begin(), rects.end()); @@ -438,7 +438,7 @@ TEST(GeometryAlgorithms, ArrangeRectanglesLoose) Coord min_obj_distance = 5; - Nester<BottomLeftPlacer, DJDHeuristic> arrange(bin, min_obj_distance); + _Nester<BottomLeftPlacer, DJDHeuristic> arrange(bin, min_obj_distance); arrange.execute(rects.begin(), rects.end()); |