diff --git a/src/libslic3r/SLA/SLABoostAdapter.hpp b/src/libslic3r/SLA/SLABoostAdapter.hpp index a31bfe60c..1e9daf461 100644 --- a/src/libslic3r/SLA/SLABoostAdapter.hpp +++ b/src/libslic3r/SLA/SLABoostAdapter.hpp @@ -26,7 +26,7 @@ template<> struct coordinate_system { template<> struct dimension: boost::mpl::int_<2> {}; -template struct access { +template struct access { static inline coord_t get(Slic3r::Point const& a) { return a(d); } @@ -52,7 +52,7 @@ template<> struct coordinate_system { template<> struct dimension: boost::mpl::int_<2> {}; -template struct access { +template struct access { static inline double get(Slic3r::Vec2d const& a) { return a(d); } @@ -78,7 +78,7 @@ template<> struct coordinate_system { template<> struct dimension: boost::mpl::int_<3> {}; -template struct access { +template struct access { static inline double get(Slic3r::Vec3d const& a) { return a(d); } diff --git a/src/libslic3r/SLA/SLASpatIndex.hpp b/src/libslic3r/SLA/SLASpatIndex.hpp index dfe5e03a0..792e86c85 100644 --- a/src/libslic3r/SLA/SLASpatIndex.hpp +++ b/src/libslic3r/SLA/SLASpatIndex.hpp @@ -13,67 +13,6 @@ namespace sla { typedef Eigen::Matrix Vec3d; using SpatElement = std::pair; -/** - * This class is intended for enhancing range based for loops with indexing. - * So instead of this: - * { int i = 0; for(auto c : container) { process(c, i); ++i; } - * - * you can use this: - * for(auto ic : container) process(ic.value, ic.index); - */ -template class Enumerable { - Container&& m; - using C = typename std::remove_reference::type; - using CC = typename std::remove_const::type; - - template struct get_iterator {}; - template<> struct get_iterator { using type = typename CC::iterator; }; - template<> struct get_iterator { - using type = typename CC::const_iterator; - }; - - template struct _Pair { - Vref value; - size_t index; - _Pair(Vref v, size_t i) : value(v), index(i) {} - operator Vref() { return value; } - }; - - template - class _iterator { - Cit start; - Cit it; - using Pair = _Pair::reference>; - public: - _iterator(Cit b, Cit i): start(b), it(i) {} - _iterator& operator++() { ++it; return *this;} - _iterator operator++(int) { auto tmp = it; ++it; return tmp;} - - bool operator!=(_iterator other) { return it != other.it; } - Pair operator*() { return Pair(*it, it - start); } - using value_type = typename Enumerable::value_type; - }; - -public: - - Enumerable(Container&& c): m(c) {} - - using value_type = typename CC::value_type; - - using iterator = _iterator::type>; - using const_iterator = _iterator; - - iterator begin() { return iterator(m.begin(), m.begin()); } - iterator end() { return iterator(m.begin(), m.end()); } - const_iterator begin() const {return const_iterator(m.cbegin(), m.cbegin());} - const_iterator end() const { return const_iterator(m.cbegin(), m.cend());} - -}; - -template inline Enumerable enumerate(C&& c) { - return Enumerable(std::forward(c)); -} - class SpatIndex { class Impl; diff --git a/src/libslic3r/SLA/SLASupportTree.cpp b/src/libslic3r/SLA/SLASupportTree.cpp index 1cf3194b3..0be3e7680 100644 --- a/src/libslic3r/SLA/SLASupportTree.cpp +++ b/src/libslic3r/SLA/SLASupportTree.cpp @@ -61,15 +61,15 @@ inline Portion make_portion(double a, double b) { return std::make_tuple(a, b); } +template double distance(const Vec& p) { + return std::sqrt(p.transpose() * p); +} + template double distance(const Vec& pp1, const Vec& pp2) { auto p = pp2 - pp1; return distance(p); } -template double distance(const Vec& p) { - return std::sqrt(p.transpose() * p); -} - /// The horizontally projected 2D boundary of the model as individual line /// segments. This can be used later to create a spatial index of line segments /// and query for possible pillar positions for non-ground facing support points @@ -1181,10 +1181,10 @@ bool SLASupportTree::generate(const PointSet &points, // now we will go through the clusters ones again and connect the // sidepoints with the cluster centroid (which is a ground pillar) // or a nearby pillar if the centroid is unreachable. - for(auto cle : enumerate(gnd_clusters)) { - auto cl = cle.value; - auto cidx = cl_centroids[cle.index]; - cl_centroids[cle.index] = cl[cidx]; + long ci = 0; + for(auto cl : gnd_clusters) { + auto cidx = cl_centroids[ci]; + cl_centroids[ci++] = cl[cidx]; long index_to_heads = gndidx[cl[cidx]]; auto& head = result.head(index_to_heads); @@ -1317,7 +1317,7 @@ bool SLASupportTree::generate(const PointSet &points, auto newring = pts_convex_hull(rem, [gnd_head_pt](unsigned i) { - auto& p = gnd_head_pt(i); + auto&& p = gnd_head_pt(i); return Vec2d(p(X), p(Y)); // project to 2D in along Z axis });