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

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/libnest2d/include/libnest2d/placers/nfpplacer.hpp')
-rw-r--r--src/libnest2d/include/libnest2d/placers/nfpplacer.hpp67
1 files changed, 7 insertions, 60 deletions
diff --git a/src/libnest2d/include/libnest2d/placers/nfpplacer.hpp b/src/libnest2d/include/libnest2d/placers/nfpplacer.hpp
index 83f7bd246..00f6a999f 100644
--- a/src/libnest2d/include/libnest2d/placers/nfpplacer.hpp
+++ b/src/libnest2d/include/libnest2d/placers/nfpplacer.hpp
@@ -20,59 +20,9 @@
// temporary
//#include "../tools/svgtools.hpp"
-#ifdef USE_TBB
-#include <tbb/parallel_for.h>
-#elif defined(_OPENMP)
-#include <omp.h>
-#endif
+#include <libnest2d/parallel.hpp>
namespace libnest2d {
-
-namespace __parallel {
-
-using std::function;
-using std::iterator_traits;
-template<class It>
-using TIteratorValue = typename iterator_traits<It>::value_type;
-
-template<class Iterator>
-inline void enumerate(
- Iterator from, Iterator to,
- function<void(TIteratorValue<Iterator>, size_t)> fn,
- std::launch policy = std::launch::deferred | std::launch::async)
-{
- using TN = size_t;
- auto iN = to-from;
- TN N = iN < 0? 0 : TN(iN);
-
-#ifdef USE_TBB
- if((policy & std::launch::async) == std::launch::async) {
- tbb::parallel_for<TN>(0, N, [from, fn] (TN n) { fn(*(from + n), n); } );
- } else {
- for(TN n = 0; n < N; n++) fn(*(from + n), n);
- }
-#elif defined(_OPENMP)
- if((policy & std::launch::async) == std::launch::async) {
- #pragma omp parallel for
- for(int n = 0; n < int(N); n++) fn(*(from + n), TN(n));
- }
- else {
- for(TN n = 0; n < N; n++) fn(*(from + n), n);
- }
-#else
- std::vector<std::future<void>> rets(N);
-
- auto it = from;
- for(TN b = 0; b < N; b++) {
- rets[b] = std::async(policy, fn, *it++, unsigned(b));
- }
-
- for(TN fi = 0; fi < N; ++fi) rets[fi].wait();
-#endif
-}
-
-}
-
namespace placers {
template<class RawShape>
@@ -300,8 +250,8 @@ template<class RawShape> class EdgeCache {
Vertex ret = edge.first();
// Get the point on the edge which lies in ed distance from the start
- ret += { static_cast<Coord>(std::round(ed*std::cos(angle))),
- static_cast<Coord>(std::round(ed*std::sin(angle))) };
+ ret += Vertex(static_cast<Coord>(std::round(ed*std::cos(angle))),
+ static_cast<Coord>(std::round(ed*std::sin(angle))));
return ret;
}
@@ -627,7 +577,7 @@ private:
template<class Level>
- Shapes calcnfp(const Item &trsh, Level)
+ Shapes calcnfp(const Item &/*trsh*/, Level)
{ // Function for arbitrary level of nfp implementation
// TODO: implement
@@ -774,8 +724,7 @@ private:
auto rawobjfunc = [_objfunc, iv, startpos]
(Vertex v, Item& itm)
{
- auto d = v - iv;
- d += startpos;
+ auto d = (v - iv) + startpos;
itm.translation(d);
return _objfunc(itm);
};
@@ -792,8 +741,7 @@ private:
&item, &bin, &iv, &startpos] (const Optimum& o)
{
auto v = getNfpPoint(o);
- auto d = v - iv;
- d += startpos;
+ auto d = (v - iv) + startpos;
item.translation(d);
merged_pile.emplace_back(item.transformedShape());
@@ -927,8 +875,7 @@ private:
}
if( best_score < global_score ) {
- auto d = getNfpPoint(optimum) - iv;
- d += startpos;
+ auto d = (getNfpPoint(optimum) - iv) + startpos;
final_tr = d;
final_rot = initial_rot + rot;
can_pack = true;