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

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/xs
diff options
context:
space:
mode:
authortamasmeszaros <meszaros.q@gmail.com>2018-07-13 12:26:59 +0300
committertamasmeszaros <meszaros.q@gmail.com>2018-07-13 12:26:59 +0300
commit256d44cc43aaf30e18f7fc3f3472d516cd3bd0c8 (patch)
tree0e9091a3ae91b92f548939a90bd41f0e90063259 /xs
parentb26d1ef5bf243f6282195a380211be52d8f5b5ee (diff)
Disabling reverse order checks in DJD selection. It causes unacceptable running times for large number of objects.
Diffstat (limited to 'xs')
-rw-r--r--xs/src/libslic3r/Model.cpp96
1 files changed, 94 insertions, 2 deletions
diff --git a/xs/src/libslic3r/Model.cpp b/xs/src/libslic3r/Model.cpp
index 6664020a3..c1d58f963 100644
--- a/xs/src/libslic3r/Model.cpp
+++ b/xs/src/libslic3r/Model.cpp
@@ -21,6 +21,7 @@
#include <boost/algorithm/string/replace.hpp>
// #include <benchmark.h>
+#include "SVG.hpp"
namespace Slic3r {
@@ -308,6 +309,86 @@ namespace arr {
using namespace libnest2d;
+std::string toString(const Model& model) {
+ std::stringstream ss;
+
+ ss << "{\n";
+
+ for(auto objptr : model.objects) {
+ if(!objptr) continue;
+
+ auto rmesh = objptr->raw_mesh();
+
+ for(auto objinst : objptr->instances) {
+ if(!objinst) continue;
+
+ Slic3r::TriangleMesh tmpmesh = rmesh;
+ tmpmesh.scale(objinst->scaling_factor);
+ objinst->transform_mesh(&tmpmesh);
+ ExPolygons expolys = tmpmesh.horizontal_projection();
+ for(auto& expoly_complex : expolys) {
+
+ auto tmp = expoly_complex.simplify(1.0/SCALING_FACTOR);
+ if(tmp.empty()) continue;
+ auto expoly = tmp.front();
+ expoly.contour.make_clockwise();
+ for(auto& h : expoly.holes) h.make_counter_clockwise();
+
+ ss << "\t{\n";
+ ss << "\t\t{\n";
+
+ for(auto v : expoly.contour.points) ss << "\t\t\t{"
+ << v.x << ", "
+ << v.y << "},\n";
+ {
+ auto v = expoly.contour.points.front();
+ ss << "\t\t\t{" << v.x << ", " << v.y << "},\n";
+ }
+ ss << "\t\t},\n";
+
+ // Holes:
+ ss << "\t\t{\n";
+// for(auto h : expoly.holes) {
+// ss << "\t\t\t{\n";
+// for(auto v : h.points) ss << "\t\t\t\t{"
+// << v.x << ", "
+// << v.y << "},\n";
+// {
+// auto v = h.points.front();
+// ss << "\t\t\t\t{" << v.x << ", " << v.y << "},\n";
+// }
+// ss << "\t\t\t},\n";
+// }
+ ss << "\t\t},\n";
+
+ ss << "\t},\n";
+ }
+ }
+ }
+
+ ss << "}\n";
+
+ return ss.str();
+}
+
+void toSVG(SVG& svg, const Model& model) {
+ for(auto objptr : model.objects) {
+ if(!objptr) continue;
+
+ auto rmesh = objptr->raw_mesh();
+
+ for(auto objinst : objptr->instances) {
+ if(!objinst) continue;
+
+ Slic3r::TriangleMesh tmpmesh = rmesh;
+ tmpmesh.scale(objinst->scaling_factor);
+ objinst->transform_mesh(&tmpmesh);
+ ExPolygons expolys = tmpmesh.horizontal_projection();
+ svg.draw(expolys);
+ }
+ }
+}
+
// A container which stores a pointer to the 3D object and its projected
// 2D shape from top view.
using ShapeData2D =
@@ -480,15 +561,17 @@ bool arrange(Model &model, coordf_t dist, const Slic3r::BoundingBoxf* bb,
SConf scfg; // Selection configuration
// Try inserting groups of 2, and 3 items in all possible order.
- scfg.try_reverse_order = true;
+ scfg.try_reverse_order = false;
// If there are more items that could possibly fit into one bin,
// use multiple threads. (Potencially decreased pack efficiency)
- scfg.allow_parallel = false;
+ scfg.allow_parallel = true;
// Use multiple threads whenever possible
scfg.force_parallel = false;
+ scfg.waste_increment = 0.01;
+
// Align the arranged pile into the center of the bin
pcfg.alignment = PConf::Alignment::CENTER;
@@ -605,6 +688,15 @@ bool Model::arrange_objects(coordf_t dist, const BoundingBoxf* bb,
bool ret = false;
if(bb != nullptr && bb->defined) {
ret = arr::arrange(*this, dist, bb, false, progressind);
+// std::fstream out("out.cpp", std::fstream::out);
+// if(out.good()) {
+// out << "const TestData OBJECTS = \n";
+// out << arr::toString(*this);
+// }
+// out.close();
+// SVG svg("out.svg");
+// arr::toSVG(svg, *this);
+// svg.Close();
} else {
// get the (transformed) size of each instance so that we take
// into account their different transformations when packing