From 43773d77010492453473797e77e83e9a4630c25f Mon Sep 17 00:00:00 2001 From: "lane.wei" Date: Sat, 23 Nov 2024 12:26:54 +0800 Subject: [PATCH] ENH: buildvolume: add logic to support extruder_printable_height jira: no-jira Change-Id: I962c4aed8c536c0fd8b89ae090cd0463c5d645db --- src/BambuStudio.cpp | 8 ++++++-- src/libslic3r/BuildVolume.cpp | 13 +++++++++---- src/libslic3r/BuildVolume.hpp | 4 +++- src/libslic3r/GCode/GCodeProcessor.hpp | 1 + src/libslic3r/Support/TreeSupport3D.cpp | 4 ++-- src/slic3r/GUI/3DBed.cpp | 11 ++++++----- src/slic3r/GUI/3DBed.hpp | 3 ++- src/slic3r/GUI/3DScene.cpp | 3 ++- src/slic3r/GUI/3DScene.hpp | 1 + src/slic3r/GUI/BedShapeDialog.cpp | 2 +- src/slic3r/GUI/GCodeViewer.cpp | 5 ++++- src/slic3r/GUI/GLCanvas3D.cpp | 12 ++++++++++++ src/slic3r/GUI/MainFrame.cpp | 2 +- src/slic3r/GUI/PartPlate.cpp | 24 +++++++++++++----------- src/slic3r/GUI/PartPlate.hpp | 7 +++++-- src/slic3r/GUI/Plater.cpp | 17 +++++++++-------- src/slic3r/GUI/Plater.hpp | 2 +- src/slic3r/Utils/CalibUtils.cpp | 3 ++- 18 files changed, 80 insertions(+), 42 deletions(-) diff --git a/src/BambuStudio.cpp b/src/BambuStudio.cpp index dcfc117c4..6f1ef7aeb 100644 --- a/src/BambuStudio.cpp +++ b/src/BambuStudio.cpp @@ -3462,6 +3462,7 @@ int CLI::run(int argc, char **argv) std::vector current_extruder_areas; //update part plate's size double print_height = m_print_config.opt_float("printable_height"); + std::vector current_extruder_print_heights; double height_to_lid = m_print_config.opt_float("extruder_clearance_height_to_lid"); double height_to_rod = m_print_config.opt_float("extruder_clearance_height_to_rod"); double cleareance_radius = m_print_config.opt_float("extruder_clearance_max_radius"); @@ -3471,6 +3472,9 @@ int CLI::run(int argc, char **argv) if (m_print_config.opt("extruder_printable_area")) { current_extruder_areas = m_print_config.opt("extruder_printable_area")->values; } + if (m_print_config.opt("extruder_printable_height")) { + current_extruder_print_heights = m_print_config.opt("extruder_printable_height")->values; + } current_printable_width = current_printable_area[2].x() - current_printable_area[0].x(); current_printable_depth = current_printable_area[2].y() - current_printable_area[0].y(); current_printable_height = print_height; @@ -3521,7 +3525,7 @@ int CLI::run(int argc, char **argv) else { partplate_list.reset_size(old_printable_width, old_printable_depth, old_printable_height, false); } - partplate_list.set_shapes(current_printable_area, current_exclude_area, current_extruder_areas, bed_texture, height_to_lid, height_to_rod); + partplate_list.set_shapes(current_printable_area, current_exclude_area, current_extruder_areas, current_extruder_print_heights, bed_texture, height_to_lid, height_to_rod); //plate_stride = partplate_list.plate_stride_x(); } @@ -5431,7 +5435,7 @@ int CLI::run(int argc, char **argv) BOOST_LOG_TRIVIAL(info) << boost::format("print_volume {%1%,%2%,%3%}->{%4%, %5%, %6%}") % print_volume.min(0) % print_volume.min(1) % print_volume.min(2) % print_volume.max(0) % print_volume.max(1) % print_volume.max(2) << std::endl; #else - BuildVolume build_volume(part_plate->get_shape(), print_height, part_plate->get_extruder_areas()); + BuildVolume build_volume(part_plate->get_shape(), print_height, part_plate->get_extruder_areas(), current_extruder_print_heights); //model.update_print_volume_state(build_volume); unsigned int count = model.update_print_volume_state(build_volume); diff --git a/src/libslic3r/BuildVolume.cpp b/src/libslic3r/BuildVolume.cpp index e582c5007..0445bad88 100644 --- a/src/libslic3r/BuildVolume.cpp +++ b/src/libslic3r/BuildVolume.cpp @@ -9,9 +9,11 @@ namespace Slic3r { -BuildVolume::BuildVolume(const std::vector &printable_area, const double printable_height, const std::vector> &extruder_areas) : m_bed_shape(printable_area), m_max_print_height(printable_height), m_extruder_shapes(extruder_areas) +BuildVolume::BuildVolume(const std::vector &printable_area, const double printable_height, const std::vector> &extruder_areas, const std::vector& extruder_printable_heights) + : m_bed_shape(printable_area), m_max_print_height(printable_height), m_extruder_shapes(extruder_areas), m_extruder_printable_height(extruder_printable_heights) { assert(printable_height >= 0); + assert(extruder_printable_heights.size() == extruder_areas.size()); m_polygon = Polygon::new_scale(printable_area); @@ -82,6 +84,7 @@ BuildVolume::BuildVolume(const std::vector &printable_area, const double m_shared_volume.data[1] = m_bboxf.min.y(); m_shared_volume.data[2] = m_bboxf.max.x(); m_shared_volume.data[3] = m_bboxf.max.y(); + m_shared_volume.zs[1] = m_bboxf.max.z(); for (unsigned int index = 0; index < m_extruder_shapes.size(); index++) { std::vector& extruder_shape = m_extruder_shapes[index]; @@ -96,7 +99,7 @@ BuildVolume::BuildVolume(const std::vector &printable_area, const double return; } - if (extruder_shape == printable_area) { + if ((extruder_shape == printable_area)&&(extruder_printable_heights[index] == printable_height)) { extruder_volume.same_with_bed = true; extruder_volume.type = m_type; extruder_volume.bbox = m_bbox; @@ -109,7 +112,7 @@ BuildVolume::BuildVolume(const std::vector &printable_area, const double double poly_area = poly.area(); extruder_volume.bbox = get_extents(poly); BoundingBoxf temp_bboxf = get_extents(extruder_shape); - extruder_volume.bboxf = BoundingBoxf3{ to_3d(temp_bboxf.min, 0.), to_3d(temp_bboxf.max, printable_height) }; + extruder_volume.bboxf = BoundingBoxf3{ to_3d(temp_bboxf.min, 0.), to_3d(temp_bboxf.max, extruder_printable_heights[index]) }; if (extruder_shape.size() >= 4 && std::abs((poly_area - double(extruder_volume.bbox.size().x()) * double(extruder_volume.bbox.size().y()))) < sqr(SCALED_EPSILON)) { @@ -160,11 +163,13 @@ BuildVolume::BuildVolume(const std::vector &printable_area, const double m_shared_volume.data[2] = extruder_volume.bboxf.max.x(); if (m_shared_volume.data[3] > extruder_volume.bboxf.max.y()) m_shared_volume.data[3] = extruder_volume.bboxf.max.y(); + if (m_shared_volume.zs[1] > extruder_volume.bboxf.max.z()) + m_shared_volume.zs[1] = extruder_volume.bboxf.max.z(); } m_shared_volume.type = static_cast(m_type); m_shared_volume.zs[0] = 0.f; - m_shared_volume.zs[1] = printable_height; + //m_shared_volume.zs[1] = printable_height; } BOOST_LOG_TRIVIAL(debug) << "BuildVolume printable_area clasified as: " << this->type_name(); diff --git a/src/libslic3r/BuildVolume.hpp b/src/libslic3r/BuildVolume.hpp index 6be3aa7c2..2e57d9efb 100644 --- a/src/libslic3r/BuildVolume.hpp +++ b/src/libslic3r/BuildVolume.hpp @@ -56,12 +56,13 @@ public: // Initialized to empty, all zeros, Invalid. BuildVolume() {} // Initialize from PrintConfig::printable_area and PrintConfig::printable_height - BuildVolume(const std::vector &printable_area, const double printable_height, const std::vector> &extruder_areas); + BuildVolume(const std::vector &printable_area, const double printable_height, const std::vector> &extruder_areas, const std::vector& extruder_printable_heights); // Source data, unscaled coordinates. const std::vector& printable_area() const { return m_bed_shape; } double printable_height() const { return m_max_print_height; } const std::vector>& extruder_areas() const { return m_extruder_shapes; } + const std::vector& extruder_heights() const { return m_extruder_printable_height; } const BuildSharedVolume& get_shared_volume() const { return m_shared_volume; } // Derived data @@ -137,6 +138,7 @@ private: BuildSharedVolume m_shared_volume; //used for rendering // Source definition of the print volume height (PrintConfig::printable_height) double m_max_print_height { 0.f }; + std::vector m_extruder_printable_height; // Derived values. Type m_type { Type::Invalid }; diff --git a/src/libslic3r/GCode/GCodeProcessor.hpp b/src/libslic3r/GCode/GCodeProcessor.hpp index 7a4d846bd..8f3ad7d76 100644 --- a/src/libslic3r/GCode/GCodeProcessor.hpp +++ b/src/libslic3r/GCode/GCodeProcessor.hpp @@ -225,6 +225,7 @@ namespace Slic3r { //BBS: add bed exclude area Pointfs bed_exclude_area; std::vector extruder_areas; + std::vector extruder_heights; //BBS: add toolpath_outside bool toolpath_outside; //BBS: add object_label_enabled diff --git a/src/libslic3r/Support/TreeSupport3D.cpp b/src/libslic3r/Support/TreeSupport3D.cpp index 38152f00a..27f55b007 100644 --- a/src/libslic3r/Support/TreeSupport3D.cpp +++ b/src/libslic3r/Support/TreeSupport3D.cpp @@ -4341,7 +4341,7 @@ static void generate_support_areas(Print &print, TreeSupport* tree_support, cons print.set_status(69, _L("Generating support")); generate_support_toolpaths(print_object.support_layers(), print_object.config(), support_params, print_object.slicing_parameters(), raft_layers, bottom_contacts, top_contacts, intermediate_layers, interface_layers, base_interface_layers); - + auto t_end = std::chrono::high_resolution_clock::now(); BOOST_LOG_TRIVIAL(info) << "Total time of organic tree support: " << 0.001 * std::chrono::duration_cast(t_end - t_start).count() << " ms"; #if 0 @@ -4817,7 +4817,7 @@ void generate_tree_support_3D(PrintObject &print_object, TreeSupport* tree_suppo Points bedpts = tree_support->m_machine_border.contour.points; Pointfs bedptsf; std::transform(bedpts.begin(), bedpts.end(), std::back_inserter(bedptsf), [](const Point &p) { return unscale(p); }); - BuildVolume build_volume{ bedptsf, tree_support->m_print_config->printable_height, {}}; + BuildVolume build_volume{ bedptsf, tree_support->m_print_config->printable_height, {}, {} }; TreeSupport3D::generate_support_areas(*print_object.print(), tree_support, build_volume, { idx }, throw_on_cancel); } diff --git a/src/slic3r/GUI/3DBed.cpp b/src/slic3r/GUI/3DBed.cpp index 7d915cc4a..5fc724ae5 100644 --- a/src/slic3r/GUI/3DBed.cpp +++ b/src/slic3r/GUI/3DBed.cpp @@ -189,7 +189,7 @@ void Bed3D::Axes::render() const } //BBS: add part plate logic -bool Bed3D::set_shape(const Pointfs& printable_area, const double printable_height, std::vector extruder_areas, const std::string& custom_model, bool force_as_custom, +bool Bed3D::set_shape(const Pointfs& printable_area, const double printable_height, std::vector extruder_areas, std::vector extruder_heights, const std::string& custom_model, bool force_as_custom, const Vec2d position, bool with_reset) { /*auto check_texture = [](const std::string& texture) { @@ -227,7 +227,7 @@ bool Bed3D::set_shape(const Pointfs& printable_area, const double printable_heig } //BBS: add position related logic - if (m_bed_shape == printable_area && m_build_volume.printable_height() == printable_height && m_type == type && m_model_filename == model_filename && position == m_position && m_extruder_shapes == extruder_areas) + if (m_bed_shape == printable_area && m_build_volume.printable_height() == printable_height && m_type == type && m_model_filename == model_filename && position == m_position && m_extruder_shapes == extruder_areas && m_extruder_heights == extruder_heights) // No change, no need to update the UI. return false; @@ -236,6 +236,7 @@ bool Bed3D::set_shape(const Pointfs& printable_area, const double printable_heig m_position = position; m_bed_shape = printable_area; m_extruder_shapes = extruder_areas; + m_extruder_heights = extruder_heights; if ((position(0) != 0) || (position(1) != 0)) { Pointfs new_bed_shape; for (const Vec2d& p : m_bed_shape) { @@ -251,10 +252,10 @@ bool Bed3D::set_shape(const Pointfs& printable_area, const double printable_heig } new_extruder_shapes.push_back(new_extruder_shape); } - m_build_volume = BuildVolume { new_bed_shape, printable_height, new_extruder_shapes }; + m_build_volume = BuildVolume { new_bed_shape, printable_height, new_extruder_shapes, m_extruder_heights }; } else - m_build_volume = BuildVolume { printable_area, printable_height, m_extruder_shapes }; + m_build_volume = BuildVolume { printable_area, printable_height, m_extruder_shapes, m_extruder_heights }; m_type = type; //m_texture_filename = texture_filename; m_model_filename = model_filename; @@ -303,7 +304,7 @@ bool Bed3D::set_shape(const Pointfs& printable_area, const double printable_heig //BBS: add api to set position for partplate related bed void Bed3D::set_position(Vec2d& position) { - set_shape(m_bed_shape, m_build_volume.printable_height(), m_extruder_shapes, m_model_filename, false, position, false); + set_shape(m_bed_shape, m_build_volume.printable_height(), m_extruder_shapes, m_extruder_heights, m_model_filename, false, position, false); } void Bed3D::set_axes_mode(bool origin) diff --git a/src/slic3r/GUI/3DBed.hpp b/src/slic3r/GUI/3DBed.hpp index 3b98cdf1a..538ea965d 100644 --- a/src/slic3r/GUI/3DBed.hpp +++ b/src/slic3r/GUI/3DBed.hpp @@ -106,6 +106,7 @@ private: Vec2d m_position{ Vec2d::Zero() }; std::vector m_bed_shape; std::vector> m_extruder_shapes; + std::vector m_extruder_heights; bool m_is_dark = false; public: @@ -117,7 +118,7 @@ public: //FIXME if the build volume max print height is updated, this function still returns zero // as this class does not use it, thus there is no need to update the UI. // BBS - bool set_shape(const Pointfs& printable_area, const double printable_height, std::vector extruder_areas, const std::string& custom_model, bool force_as_custom = false, + bool set_shape(const Pointfs& printable_area, const double printable_height, std::vector extruder_areas, std::vector extruder_heights, const std::string& custom_model, bool force_as_custom = false, const Vec2d position = Vec2d::Zero(), bool with_reset = true); void set_position(Vec2d& position); diff --git a/src/slic3r/GUI/3DScene.cpp b/src/slic3r/GUI/3DScene.cpp index 182e2fc9c..702f606f8 100644 --- a/src/slic3r/GUI/3DScene.cpp +++ b/src/slic3r/GUI/3DScene.cpp @@ -1734,7 +1734,7 @@ bool GLVolumeCollection::check_outside_state(const BuildVolume &build_volume, Mo GUI::PartPlate* curr_plate = GUI::wxGetApp().plater()->get_partplate_list().get_selected_plate(); const Pointfs& pp_bed_shape = curr_plate->get_shape(); - BuildVolume plate_build_volume(pp_bed_shape, build_volume.printable_height(), build_volume.extruder_areas()); + BuildVolume plate_build_volume(pp_bed_shape, build_volume.printable_height(), build_volume.extruder_areas(), build_volume.extruder_heights()); const std::vector& exclude_areas = curr_plate->get_exclude_areas(); std::map>> objects_unprintable_filaments; @@ -1943,6 +1943,7 @@ bool GLVolumeCollection::check_outside_state(const BuildVolume &build_volume, Mo if (filament_maps[filament - 1] == extruder_id) { object_filament_info.manual_filaments.emplace(filament, extruder_id); + object_results->filament_maps[filament] = extruder_id; conflict_filaments_set.emplace(filament); } } diff --git a/src/slic3r/GUI/3DScene.hpp b/src/slic3r/GUI/3DScene.hpp index e7ac4e726..17dfc260c 100644 --- a/src/slic3r/GUI/3DScene.hpp +++ b/src/slic3r/GUI/3DScene.hpp @@ -63,6 +63,7 @@ struct ObjectFilamentInfo { struct ObjectFilamentResults { FilamentMapMode mode; std::vector filaments; //filaments has conflicts + std::map filament_maps; //filament maps std::vector partly_outside_objects; //partly outside objects std::vector object_filaments; diff --git a/src/slic3r/GUI/BedShapeDialog.cpp b/src/slic3r/GUI/BedShapeDialog.cpp index ee3edd8ab..8c2990be4 100644 --- a/src/slic3r/GUI/BedShapeDialog.cpp +++ b/src/slic3r/GUI/BedShapeDialog.cpp @@ -22,7 +22,7 @@ namespace GUI { BedShape::BedShape(const ConfigOptionPoints& points) { - m_build_volume = { points.values, 0.f, {} }; + m_build_volume = { points.values, 0.f, {}, {} }; } static std::string get_option_label(BedShape::Parameter param) diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index be1a069fd..c07486921 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -1060,6 +1060,7 @@ void GCodeViewer::load(const GCodeProcessorResult& gcode_result, const Print& pr //BBS: add bed exclude area Pointfs bed_exclude_area = Pointfs(); std::vector extruder_areas; + std::vector extruder_heights; std::string texture; std::string model; @@ -1081,8 +1082,10 @@ void GCodeViewer::load(const GCodeProcessorResult& gcode_result, const Print& pr if (!gcode_result.extruder_areas.empty()) extruder_areas = gcode_result.extruder_areas; + if (!gcode_result.extruder_heights.empty()) + extruder_heights = gcode_result.extruder_heights; - wxGetApp().plater()->set_bed_shape(printable_area, bed_exclude_area, gcode_result.printable_height, extruder_areas, texture, model, gcode_result.printable_area.empty()); + wxGetApp().plater()->set_bed_shape(printable_area, bed_exclude_area, gcode_result.printable_height, extruder_areas, extruder_heights, texture, model, gcode_result.printable_area.empty()); } /*else { // adjust printbed size in dependence of toolpaths bbox diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 0f3aa9076..2b2276ee1 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1420,6 +1420,18 @@ void GLCanvas3D::construct_error_string(ObjectFilamentResults& object_result, st error_string += _u8L("Please solve the problem by moving them within the build volume.\n"); } else { + error_string += _u8L("In the Filament manual-matching mode, Following filament->extruder maps: \n"); + for (auto& filament: object_result.filaments) + { + error_string += std::to_string(filament) + "->" + std::to_string(object_result.filament_maps[filament]) + "\n"; + } + error_string += "cannot be printed as they are placed in the unprintable area of the corresponding extruder. This may be caused by the following objects:\n"; + for(ObjectFilamentInfo& object_filament: object_result.object_filaments) + { + error_string += object_filament.object->name; + error_string += "\n"; + } + error_string += _u8L("Please solve the problem by moving them within the build volume.\n"); } } } diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 5e3d2ac7a..8c7afd289 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -835,7 +835,7 @@ void MainFrame::update_layout() { m_main_sizer->Add(m_plater, 1, wxEXPAND); //BBS: add bed exclude area - m_plater->set_bed_shape({ { 0.0, 0.0 }, { 200.0, 0.0 }, { 200.0, 200.0 }, { 0.0, 200.0 } }, {}, 0.0, {}, {}, {}, true); + m_plater->set_bed_shape({ { 0.0, 0.0 }, { 200.0, 0.0 }, { 200.0, 200.0 }, { 0.0, 200.0 } }, {}, 0.0, {}, {}, {}, {}, true); m_plater->get_collapse_toolbar().set_enabled(false); m_plater->collapse_sidebar(true); m_plater->Show(); diff --git a/src/slic3r/GUI/PartPlate.cpp b/src/slic3r/GUI/PartPlate.cpp index c97f6f2de..151fe696c 100644 --- a/src/slic3r/GUI/PartPlate.cpp +++ b/src/slic3r/GUI/PartPlate.cpp @@ -2319,10 +2319,11 @@ void PartPlate::generate_exclude_polygon(ExPolygon &exclude_polygon) } } -bool PartPlate::set_shape(const Pointfs& shape, const Pointfs& exclude_areas, const std::vector& extruder_areas, Vec2d position, float height_to_lid, float height_to_rod) +bool PartPlate::set_shape(const Pointfs& shape, const Pointfs& exclude_areas, const std::vector& extruder_areas, const std::vector& extruder_heights, Vec2d position, float height_to_lid, float height_to_rod) { Pointfs new_shape, new_exclude_areas; m_raw_shape = shape; + m_extruder_heights = extruder_heights; for (const Vec2d& p : shape) { new_shape.push_back(Vec2d(p.x() + position.x(), p.y() + position.y())); } @@ -3588,7 +3589,7 @@ void PartPlateList::reset_size(int width, int depth, int height, bool reload_obj m_plate_height = height; update_all_plates_pos_and_size(false, false, true); if (update_shapes) { - set_shapes(m_shape, m_exclude_areas, m_extruder_areas, m_logo_texture_filename, m_height_to_lid, m_height_to_rod); + set_shapes(m_shape, m_exclude_areas, m_extruder_areas, m_extruder_heights, m_logo_texture_filename, m_height_to_lid, m_height_to_rod); } if (reload_objects) reload_all_objects(); @@ -3673,7 +3674,7 @@ void PartPlateList::reinit() //reset plate 0's position Vec2d pos = compute_shape_position(0, m_plate_cols); - m_plate_list[0]->set_shape(m_shape, m_exclude_areas, m_extruder_areas, pos, m_height_to_lid, m_height_to_rod); + m_plate_list[0]->set_shape(m_shape, m_exclude_areas, m_extruder_areas, m_extruder_heights, pos, m_height_to_lid, m_height_to_rod); //reset unprintable plate's position Vec3d origin2 = compute_origin_for_unprintable(); unprintable_plate.set_pos_and_size(origin2, m_plate_width, m_plate_depth, m_plate_height, false); @@ -3720,7 +3721,7 @@ int PartPlateList::create_plate(bool adjust_position) plate->set_index(new_index); Vec2d pos = compute_shape_position(new_index, cols); - plate->set_shape(m_shape, m_exclude_areas, m_extruder_areas, pos, m_height_to_lid, m_height_to_rod); + plate->set_shape(m_shape, m_exclude_areas, m_extruder_areas, m_extruder_heights, pos, m_height_to_lid, m_height_to_rod); m_plate_list.emplace_back(plate); update_plate_cols(); if (old_cols != cols) @@ -3728,7 +3729,7 @@ int PartPlateList::create_plate(bool adjust_position) BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << boost::format(":old_cols %1% -> new_cols %2%") % old_cols % cols; //update the origin of each plate update_all_plates_pos_and_size(adjust_position, false); - set_shapes(m_shape, m_exclude_areas, m_extruder_areas, m_logo_texture_filename, m_height_to_lid, m_height_to_rod); + set_shapes(m_shape, m_exclude_areas, m_extruder_areas, m_extruder_heights, m_logo_texture_filename, m_height_to_lid, m_height_to_rod); if (m_plater) { Vec2d pos = compute_shape_position(m_current_plate, cols); @@ -3875,7 +3876,7 @@ int PartPlateList::delete_plate(int index) //update render shapes Vec2d pos = compute_shape_position(i, m_plate_cols); - plate->set_shape(m_shape, m_exclude_areas, m_extruder_areas, pos, m_height_to_lid, m_height_to_rod); + plate->set_shape(m_shape, m_exclude_areas, m_extruder_areas, m_extruder_heights, pos, m_height_to_lid, m_height_to_rod); } //update current_plate if delete current @@ -3898,7 +3899,7 @@ int PartPlateList::delete_plate(int index) { //update the origin of each plate update_all_plates_pos_and_size(); - set_shapes(m_shape, m_exclude_areas, m_extruder_areas, m_logo_texture_filename, m_height_to_lid, m_height_to_rod); + set_shapes(m_shape, m_exclude_areas, m_extruder_areas, m_extruder_heights, m_logo_texture_filename, m_height_to_lid, m_height_to_rod); } else { @@ -5195,12 +5196,13 @@ void PartPlateList::select_plate_view() m_plater->get_camera().select_view("topfront"); } -bool PartPlateList::set_shapes(const Pointfs& shape, const Pointfs& exclude_areas, const std::vector& extruder_areas, const std::string& texture_filename, float height_to_lid, float height_to_rod) +bool PartPlateList::set_shapes(const Pointfs& shape, const Pointfs& exclude_areas, const std::vector& extruder_areas, const std::vector& extruder_heights, const std::string& texture_filename, float height_to_lid, float height_to_rod) { const std::lock_guard local_lock(m_plates_mutex); m_shape = shape; m_exclude_areas = exclude_areas; m_extruder_areas = extruder_areas; + m_extruder_heights = extruder_heights; m_height_to_lid = height_to_lid; m_height_to_rod = height_to_rod; @@ -5214,7 +5216,7 @@ bool PartPlateList::set_shapes(const Pointfs& shape, const Pointfs& exclude_area Vec2d pos; pos = compute_shape_position(i, m_plate_cols); - plate->set_shape(shape, exclude_areas, extruder_areas, pos, height_to_lid, height_to_rod); + plate->set_shape(shape, exclude_areas, extruder_areas, extruder_heights, pos, height_to_lid, height_to_rod); } is_load_bedtype_textures = false; //reload textures is_load_extruder_only_area_textures = false; // reload textures @@ -5413,7 +5415,7 @@ int PartPlateList::rebuild_plates_after_deserialize(std::vector& previous_ for (unsigned int i = 0; i < (unsigned int) m_plate_list.size(); ++i) { m_plate_list[i]->m_partplate_list = this; }//set_shapes api: every plate use m_partplate_list - set_shapes(m_shape, m_exclude_areas, m_extruder_areas, m_logo_texture_filename, m_height_to_lid, m_height_to_rod); + set_shapes(m_shape, m_exclude_areas, m_extruder_areas, m_extruder_heights, m_logo_texture_filename, m_height_to_lid, m_height_to_rod); for (unsigned int i = 0; i < (unsigned int)m_plate_list.size(); ++i){ bool need_reset_print = false; m_plate_list[i]->m_plater = this->m_plater; @@ -5750,7 +5752,7 @@ int PartPlateList::load_gcode_files() //BoundingBoxf3 print_volume = m_plate_list[i]->get_bounding_box(false); //print_volume.max(2) = this->m_plate_height; //print_volume.min(2) = -1e10; - m_model->update_print_volume_state({m_plate_list[i]->get_shape(), (double)this->m_plate_height, m_plate_list[i]->get_extruder_areas() }); + m_model->update_print_volume_state({m_plate_list[i]->get_shape(), (double)this->m_plate_height, m_plate_list[i]->get_extruder_areas(), m_plate_list[i]->get_extruder_heights() }); if (!m_plate_list[i]->load_gcode_from_file(m_plate_list[i]->m_gcode_path_from_3mf)) ret ++; diff --git a/src/slic3r/GUI/PartPlate.hpp b/src/slic3r/GUI/PartPlate.hpp index 84e2b4057..a6e261574 100644 --- a/src/slic3r/GUI/PartPlate.hpp +++ b/src/slic3r/GUI/PartPlate.hpp @@ -121,6 +121,7 @@ private: Pointfs m_shape; Pointfs m_exclude_area; std::vector m_extruder_areas; + std::vector m_extruder_heights; BoundingBoxf3 m_bounding_box; BoundingBoxf3 m_extended_bounding_box; BoundingBoxf3 m_cur_bed_boundingbox; @@ -349,8 +350,9 @@ public: /*rendering related functions*/ const Pointfs& get_shape() const { return m_shape; } - bool set_shape(const Pointfs& shape, const Pointfs& exclude_areas, const std::vector& extruder_areas, Vec2d position, float height_to_lid, float height_to_rod); + bool set_shape(const Pointfs& shape, const Pointfs& exclude_areas, const std::vector& extruder_areas, const std::vector& extruder_heights, Vec2d position, float height_to_lid, float height_to_rod); const std::vector& get_extruder_areas() const { return m_extruder_areas; } + const std::vector& get_extruder_heights() const { return m_extruder_heights; } bool contains(const Vec3d& point) const; bool contains(const GLVolume& v) const; bool contains(const BoundingBoxf3& bb) const; @@ -563,6 +565,7 @@ class PartPlateList : public ObjectBase Pointfs m_shape; Pointfs m_exclude_areas; std::vector m_extruder_areas; + std::vector m_extruder_heights; BoundingBoxf3 m_bounding_box; bool m_intialized; std::string m_logo_texture_filename; @@ -868,7 +871,7 @@ public: int select_plate_by_obj(int obj_index, int instance_index); void calc_bounding_boxes(); void select_plate_view(); - bool set_shapes(const Pointfs& shape, const Pointfs& exclude_areas, const std::vector& extruder_areas, const std::string& custom_texture, float height_to_lid, float height_to_rod); + bool set_shapes(const Pointfs& shape, const Pointfs& exclude_areas, const std::vector& extruder_areas, const std::vector& extruder_heights, const std::string& custom_texture, float height_to_lid, float height_to_rod); void set_hover_id(int id); void reset_hover_id(); bool intersects(const BoundingBoxf3 &bb); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 79a9c7ccf..c217c53cd 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -3019,7 +3019,7 @@ struct Plater::priv // fills the m_bed.m_grid_lines and sets m_bed.m_origin. // Sets m_bed.m_polygon to limit the object placement. //BBS: add bed exclude area - void set_bed_shape(const Pointfs& shape, const Pointfs& exclude_areas, const double printable_height, std::vector extruder_areas, const std::string& custom_texture, const std::string& custom_model, bool force_as_custom = false); + void set_bed_shape(const Pointfs& shape, const Pointfs& exclude_areas, const double printable_height, std::vector extruder_areas, std::vector extruder_heights, const std::string& custom_texture, const std::string& custom_model, bool force_as_custom = false); bool can_delete() const; bool can_delete_all() const; @@ -5597,7 +5597,7 @@ void Plater::priv::update_print_volume_state() { //BBS: use the plate's bounding box instead of the bed's PartPlate* pp = partplate_list.get_curr_plate(); - BuildVolume build_volume(pp->get_shape(), this->bed.build_volume().printable_height(), this->bed.build_volume().extruder_areas()); + BuildVolume build_volume(pp->get_shape(), this->bed.build_volume().printable_height(), this->bed.build_volume().extruder_areas(), this->bed.build_volume().extruder_heights()); this->model.update_print_volume_state(build_volume); } @@ -8820,11 +8820,11 @@ bool Plater::priv::show_publish_dlg(bool show) } //BBS: add bed exclude area -void Plater::priv::set_bed_shape(const Pointfs& shape, const Pointfs& exclude_areas, const double printable_height, std::vector extruder_areas, const std::string& custom_texture, const std::string& custom_model, bool force_as_custom) +void Plater::priv::set_bed_shape(const Pointfs& shape, const Pointfs& exclude_areas, const double printable_height, std::vector extruder_areas, std::vector extruder_heights, const std::string& custom_texture, const std::string& custom_model, bool force_as_custom) { //BBS: add shape position Vec2d shape_position = partplate_list.get_current_shape_position(); - bool new_shape = bed.set_shape(shape, printable_height, extruder_areas, custom_model, force_as_custom, shape_position); + bool new_shape = bed.set_shape(shape, printable_height, extruder_areas, extruder_heights, custom_model, force_as_custom, shape_position); float prev_height_lid, prev_height_rod; partplate_list.get_height_limits(prev_height_lid, prev_height_rod); @@ -8848,11 +8848,11 @@ void Plater::priv::set_bed_shape(const Pointfs& shape, const Pointfs& exclude_ar //Pointfs& exclude_areas = config->option("bed_exclude_area")->values; partplate_list.reset_size(max.x() - min.x() - Bed3D::Axes::DefaultTipRadius, max.y() - min.y() - Bed3D::Axes::DefaultTipRadius, z); - partplate_list.set_shapes(shape, exclude_areas, extruder_areas, custom_texture, height_to_lid, height_to_rod); + partplate_list.set_shapes(shape, exclude_areas, extruder_areas, extruder_heights, custom_texture, height_to_lid, height_to_rod); Vec2d new_shape_position = partplate_list.get_current_shape_position(); if (shape_position != new_shape_position) - bed.set_shape(shape, printable_height, extruder_areas, custom_model, force_as_custom, new_shape_position); + bed.set_shape(shape, printable_height, extruder_areas, extruder_heights, custom_model, force_as_custom, new_shape_position); } } @@ -13791,14 +13791,15 @@ void Plater::set_bed_shape() const p->config->option("bed_exclude_area")->values, p->config->option("printable_height")->value, p->config->option("extruder_printable_area")->values, + p->config->option("extruder_printable_height")->values, p->config->option("bed_custom_texture")->value.empty() ? texture_filename : p->config->option("bed_custom_texture")->value, p->config->option("bed_custom_model")->value); } //BBS: add bed exclude area -void Plater::set_bed_shape(const Pointfs& shape, const Pointfs& exclude_area, const double printable_height, std::vector extruder_areas, const std::string& custom_texture, const std::string& custom_model, bool force_as_custom) const +void Plater::set_bed_shape(const Pointfs& shape, const Pointfs& exclude_area, const double printable_height, std::vector extruder_areas, std::vector extruder_heights, const std::string& custom_texture, const std::string& custom_model, bool force_as_custom) const { - p->set_bed_shape(shape, exclude_area, printable_height, extruder_areas, custom_texture, custom_model, force_as_custom); + p->set_bed_shape(shape, exclude_area, printable_height, extruder_areas, extruder_heights, custom_texture, custom_model, force_as_custom); } void Plater::force_filament_colors_update() diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index a4833d5ae..25c3c4b7a 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -628,7 +628,7 @@ public: void update_flush_volume_matrix(size_t old_nozzle_size, size_t new_nozzle_size); //BBS: add bed exclude area void set_bed_shape() const; - void set_bed_shape(const Pointfs& shape, const Pointfs& exclude_area, const double printable_height, std::vector extruder_areas, const std::string& custom_texture, const std::string& custom_model, bool force_as_custom = false) const; + void set_bed_shape(const Pointfs& shape, const Pointfs& exclude_area, const double printable_height, std::vector extruder_areas, std::vector extruder_heights, const std::string& custom_texture, const std::string& custom_model, bool force_as_custom = false) const; const NotificationManager* get_notification_manager() const; NotificationManager* get_notification_manager(); diff --git a/src/slic3r/Utils/CalibUtils.cpp b/src/slic3r/Utils/CalibUtils.cpp index 4f0e97491..f4298c10c 100644 --- a/src/slic3r/Utils/CalibUtils.cpp +++ b/src/slic3r/Utils/CalibUtils.cpp @@ -1050,6 +1050,7 @@ bool CalibUtils::process_and_store_3mf(Model *model, const DynamicPrintConfig &f { Pointfs bedfs = full_config.opt("printable_area")->values; std::vector extruder_areas = full_config.option("extruder_printable_area")->values; + std::vector extruder_heights = full_config.option("extruder_printable_height")->values; double print_height = full_config.opt_float("printable_height"); double current_width = bedfs[2].x() - bedfs[0].x(); double current_depth = bedfs[2].y() - bedfs[0].y(); @@ -1096,7 +1097,7 @@ bool CalibUtils::process_and_store_3mf(Model *model, const DynamicPrintConfig &f int print_index; part_plate->get_print(&print, &gcode_result, &print_index); - BuildVolume build_volume(bedfs, print_height, extruder_areas); + BuildVolume build_volume(bedfs, print_height, extruder_areas, extruder_heights); unsigned int count = model->update_print_volume_state(build_volume); if (count == 0) { error_message = _L("Unable to calibrate: maybe because the set calibration value range is too large, or the step is too small");