diff --git a/src/libnest2d/include/libnest2d/placers/nfpplacer.hpp b/src/libnest2d/include/libnest2d/placers/nfpplacer.hpp index 9e0e7149eb..2cf356401f 100644 --- a/src/libnest2d/include/libnest2d/placers/nfpplacer.hpp +++ b/src/libnest2d/include/libnest2d/placers/nfpplacer.hpp @@ -922,27 +922,28 @@ private: #ifdef SVGTOOLS_HPP svg::SVGWriter svgwriter; + svgwriter.setSize(binbb); svgwriter.writeShape(box2RawShape(binbb), "none", "black"); for (int i = 0; i < nfps.size(); i++) svgwriter.writeShape(nfps[i], "none", "blue"); for (int i = 0; i < items_.size(); i++) svgwriter.writeItem(items_[i], "none", "black"); - //for (int i = 0; i < merged_pile_.size(); i++) - // svgwriter.writeShape(merged_pile_[i], "none", "yellow"); + for (int i = 0; i < merged_pile_.size(); i++) + svgwriter.writeShape(merged_pile_[i], "none", "yellow"); + svgwriter.writeItem(item, "none", "red", 2); - svgwriter.writeItem(item, "none", "red"); std::stringstream ss; ss.setf(std::ios::fixed | std::ios::showpoint); ss.precision(1); - ss << "trans=" << round(item.translation().x() / 1e6) << "," << round(item.translation().y() / 1e6) - << "-rot=" << round(item.rotation().toDegrees()) - << "-score=" << round(global_score); + ss << "t=" << round(item.translation().x() / 1e6) << "," << round(item.translation().y() / 1e6) + //<< "-rot=" << round(item.rotation().toDegrees()) + << "-sco=" << round(global_score); svgwriter.draw_text(20, 20, ss.str(), "blue", 20); ss.str(""); ss << "items.size=" << items_.size() << "-merged_pile.size=" << merged_pile_.size(); svgwriter.draw_text(20, 40, ss.str(), "blue", 20); - svgwriter.save("SVG/nfpplacer_" + std::to_string(plate_id) + "_" + item.name + "_" + ss.str()); + svgwriter.save(boost::filesystem::path("SVG")/ ("nfpplacer_" + std::to_string(plate_id) + "_" + ss.str() + "_" + item.name + ".svg")); #endif if(can_pack) { diff --git a/src/libnest2d/tools/svgtools.hpp b/src/libnest2d/tools/svgtools.hpp index 012c489bbe..d00a74227f 100644 --- a/src/libnest2d/tools/svgtools.hpp +++ b/src/libnest2d/tools/svgtools.hpp @@ -5,6 +5,7 @@ #include #include +#include #include namespace libnest2d { namespace svg { @@ -27,9 +28,10 @@ public: OrigoLocation origo_location; Coord mm_in_coord_units; double width, height; + double x0, y0; Config(): origo_location(BOTTOMLEFT), mm_in_coord_units(1000000), - width(500), height(500) {} + width(500), height(500),x0(100) {} }; @@ -42,10 +44,12 @@ public: SVGWriter(const Config& conf = Config()): conf_(conf) {} - void setSize(const Box& box) { - conf_.height = static_cast(box.height()) / + void setSize(const Box &box) { + conf_.x0 = box.width() / 5; + conf_.x0 = box.height() / 5; + conf_.height = static_cast(box.height() + conf_.y0*2) / conf_.mm_in_coord_units; - conf_.width = static_cast(box.width()) / + conf_.width = static_cast(box.width() + conf_.x0*2) / conf_.mm_in_coord_units; } @@ -56,11 +60,17 @@ public: std::round(conf_.height*conf_.mm_in_coord_units) ); auto& contour = shapelike::contour(tsh); - for(auto& v : contour) setY(v, -getY(v) + d); + for (auto &v : contour) { + setX(v, getX(v) + conf_.x0); // right shift so we can draw outside the bounding box + setY(v, -getY(v) + d + conf_.y0); + } auto& holes = shapelike::holes(tsh); - for(auto& h : holes) for(auto& v : h) setY(v, -getY(v) + d); - + for (auto &h : holes) + for (auto &v : h) { + setX(v, getX(v) + conf_.x0); + setY(v, -getY(v) + d + conf_.y0); + } } currentLayer() += shapelike::serialize(tsh, @@ -126,6 +136,22 @@ public: }; } + // save svg in utf-8 file name + void save(const boost::filesystem::path &filepath) + { + size_t lyrc = svg_layers_.size() > 1 ? 1 : 0; + size_t last = svg_layers_.size() > 1 ? svg_layers_.size() : 0; + + for (auto &lyr : svg_layers_) { + boost::filesystem::ofstream out(filepath, std::fstream::out); + if (out.is_open()) out << lyr; + if (lyrc == last && !finished_) out << "\n\n"; + out.flush(); + out.close(); + lyrc++; + }; + } + private: std::string& currentLayer() { return svg_layers_.back(); } diff --git a/src/libslic3r/Arrange.cpp b/src/libslic3r/Arrange.cpp index b9c1fa52da..e08a3c2086 100644 --- a/src/libslic3r/Arrange.cpp +++ b/src/libslic3r/Arrange.cpp @@ -436,10 +436,12 @@ protected: if (!params.allow_multi_materials_on_same_plate) score += LARGE_COST_TO_REJECT * (item.extrude_id != p.extrude_id); } + // for layered printing, we want extruder change as few as possible + // this has very weak effect, CAN NOT use a large weight if (!params.is_seq_print) { extruder_ids.insert(item.extrude_id); - score += 0.2 * LARGE_COST_TO_REJECT * std::max(0, ((int)extruder_ids.size() - 1)); + score += 1 * std::max(0, ((int)extruder_ids.size() - 1)); } return std::make_tuple(score, fullbb); diff --git a/src/libslic3r/ModelArrange.cpp b/src/libslic3r/ModelArrange.cpp index 6501799029..7e280d76b2 100644 --- a/src/libslic3r/ModelArrange.cpp +++ b/src/libslic3r/ModelArrange.cpp @@ -138,11 +138,9 @@ ArrangePolygon get_instance_arrange_poly(ModelInstance* instance, const Slic3r:: ap.print_temp = config.opt_int("nozzle_temperature", ap.extrude_ids.back() - 1); if (config.has("nozzle_temperature_initial_layer")) //get the nozzle_temperature_initial_layer ap.first_print_temp = config.opt_int("nozzle_temperature_initial_layer", ap.extrude_ids.back() - 1); - // BBS: since first_bed_temp packs all 3 temperatures, vitrify_temp should follow same routine + if (config.has("temperature_vitrification")) { - int tmp = config.opt_int("temperature_vitrification", ap.extrude_ids.back() - 1); - for (int i = 0; i < BedType::btCount; i++) - ap.vitrify_temp += tmp * pow(100, BedType::btCount - i - 1); + ap.vitrify_temp = config.opt_int("temperature_vitrification", ap.extrude_ids.back() - 1); } // get brim width