diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 40d1aa2d3..a3ed0a940 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -4793,6 +4793,26 @@ Points get_bed_shape(const PrintConfig &cfg) Points get_bed_shape(const SLAPrinterConfig &cfg) { return to_points(cfg.printable_area.values); } +Polygon get_bed_shape_with_excluded_area(const PrintConfig& cfg) +{ + Polygon bed_poly; + bed_poly.points = get_bed_shape(cfg); + + Points excluse_area_points = to_points(cfg.bed_exclude_area.values); + Polygons exclude_polys; + Polygon exclude_poly; + for (int i = 0; i < excluse_area_points.size(); i++) { + auto pt = excluse_area_points[i]; + exclude_poly.points.emplace_back(pt); + if (i % 4 == 3) { // exclude areas are always rectangle + exclude_polys.push_back(exclude_poly); + exclude_poly.points.clear(); + } + } + auto tmp = diff({ bed_poly }, exclude_polys); + if (!tmp.empty()) bed_poly = tmp[0]; + return bed_poly; +} } // namespace Slic3r #include diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 1565b2553..31730987b 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -18,7 +18,7 @@ #include "libslic3r.h" #include "Config.hpp" - +#include "Polygon.hpp" #include #include #include @@ -1241,6 +1241,7 @@ private: Points get_bed_shape(const DynamicPrintConfig &cfg); Points get_bed_shape(const PrintConfig &cfg); Points get_bed_shape(const SLAPrinterConfig &cfg); +Slic3r::Polygon get_bed_shape_with_excluded_area(const PrintConfig& cfg); // ModelConfig is a wrapper around DynamicPrintConfig with an addition of a timestamp. // Each change of ModelConfig is tracked by assigning a new timestamp from a global counter. diff --git a/src/libslic3r/TreeSupport.cpp b/src/libslic3r/TreeSupport.cpp index f36a00808..0aa517826 100644 --- a/src/libslic3r/TreeSupport.cpp +++ b/src/libslic3r/TreeSupport.cpp @@ -704,6 +704,13 @@ TreeSupport::TreeSupport(PrintObject& object, const SlicingParameters &slicing_p tree_support_branch_diameter_angle = 5.0;//is_slim ? 10.0 : 5.0; // by default tree support needs no infill, unless it's tree hybrid which contains normal nodes. with_infill = support_pattern != smpNone && support_pattern != smpDefault; + const PrintConfig& print_config = m_object->print()->config(); + m_machine_border.contour = get_bed_shape_with_excluded_area(print_config); + m_machine_border.translate(-m_object->instances().front().shift); // align with the centered object +#ifdef SUPPORT_TREE_DEBUG_TO_SVG + SVG svg("SVG/machine_boarder.svg", m_object->bounding_box()); + if (svg.is_opened()) svg.draw(m_machine_border, "yellow"); +#endif } @@ -2210,18 +2217,20 @@ void TreeSupport::draw_circles(const std::vector>& contact_no //roof_areas = std::move(diff_ex(roof_areas, avoid_region_interface)); //roof_1st_layer = std::move(diff_ex(roof_1st_layer, avoid_region_interface)); roof_areas = avoid_object_remove_extra_small_parts(roof_areas, avoid_region_interface); + roof_areas = intersection_ex(roof_areas, m_machine_border); roof_1st_layer = avoid_object_remove_extra_small_parts(roof_1st_layer, avoid_region_interface); // roof_1st_layer and roof_areas may intersect, so need to subtract roof_areas from roof_1st_layer roof_1st_layer = std::move(diff_ex(roof_1st_layer, roof_areas)); + roof_1st_layer = intersection_ex(roof_1st_layer, m_machine_border); // let supports touch objects when brim is on auto avoid_region = m_ts_data->get_collision((layer_nr == 0 && has_brim) ? config.brim_object_gap : m_ts_data->m_xy_distance, layer_nr); - // base_areas = std::move(diff_ex(base_areas, avoid_region)); base_areas = avoid_object_remove_extra_small_parts(base_areas, avoid_region); base_areas = std::move(diff_ex(base_areas, roof_areas)); base_areas = std::move(diff_ex(base_areas, roof_1st_layer)); base_areas = std::move(diff_ex(base_areas, roof_gap_areas)); + base_areas = intersection_ex(base_areas, m_machine_border); if (SQUARE_SUPPORT) { // simplify support contours @@ -3504,16 +3513,6 @@ void TreeSupport::generate_contact_points(std::vector& nodes_layer, Node* p_node) diff --git a/src/libslic3r/TreeSupport.hpp b/src/libslic3r/TreeSupport.hpp index 6b5a0de6b..2ac4802ba 100644 --- a/src/libslic3r/TreeSupport.hpp +++ b/src/libslic3r/TreeSupport.hpp @@ -125,11 +125,6 @@ private: */ const ExPolygons& calculate_avoidance(const RadiusLayerPair& key) const; - /*! - * \brief Polygons representing the limits of the printable area of the - * machine - */ - ExPolygon m_machine_border; public: bool is_slim = false; @@ -401,6 +396,12 @@ private: bool with_infill = false; + /*! + * \brief Polygons representing the limits of the printable area of the + * machine + */ + ExPolygon m_machine_border; + /*! * \brief Draws circles around each node of the tree into the final support. *