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 | |
parent | b2867f92275205b8e617b3eff0ccbba28f6a2f0f (diff) |
Further refactoring
-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 | ||||
-rw-r--r-- | src/libslic3r/Arrange.cpp | 8 | ||||
-rw-r--r-- | src/slic3r/GUI/Plater.cpp | 2 |
5 files changed, 24 insertions, 28 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()); diff --git a/src/libslic3r/Arrange.cpp b/src/libslic3r/Arrange.cpp index bc3eedb63..b02efa55c 100644 --- a/src/libslic3r/Arrange.cpp +++ b/src/libslic3r/Arrange.cpp @@ -66,10 +66,6 @@ using Circle = _Circle<clppr::IntPoint>; using Segment = _Segment<clppr::IntPoint>; using MultiPolygon = TMultiShape<clppr::Polygon>; -// The return value of nesting, a vector (for each logical bed) of Item -// reference vectors. -using PackGroup = _PackGroup<clppr::Polygon>; - // Summon the spatial indexing facilities from boost namespace bgi = boost::geometry::index; using SpatElement = std::pair<Box, unsigned>; @@ -102,7 +98,7 @@ void fillConfig(PConf& pcfg) { pcfg.parallel = true; } -// Apply penality to object function result. This is used only when alignment +// Apply penalty to object function result. This is used only when alignment // after arrange is explicitly disabled (PConfig::Alignment::DONT_ALIGN) double fixed_overfit(const std::tuple<double, Box>& result, const Box &binbb) { @@ -123,7 +119,7 @@ public: // Useful type shortcuts... using Placer = typename placers::_NofitPolyPlacer<clppr::Polygon, TBin>; using Selector = selections::_FirstFitSelection<clppr::Polygon>; - using Packer = Nester<Placer, Selector>; + using Packer = _Nester<Placer, Selector>; using PConfig = typename Packer::PlacementConfig; using Distance = TCoord<PointImpl>; diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index d4697e7b3..58f0db292 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1609,7 +1609,7 @@ struct Plater::priv if (m_selected.empty()) m_selected.swap(m_unselected); // The strides have to be removed from the fixed items. For the - // arrangeable (selected) items it bed_idx is ignored and the + // arrangeable (selected) items bed_idx is ignored and the // translation is irrelevant. for (auto &p : m_unselected) p.translation(X) -= p.bed_idx * stride; } |