mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-11-02 20:51:23 -07:00 
			
		
		
		
	FIX: sharp tail detection may fail
1. In small overhang detection, some sharp tail cases are missed because the max_layer was not compared. 2. In normal support, previously the lower layer's expolys were not right, should only keep the ones that won't vanish when extruding. Jira: STUDIO-1977, STUDIO-2200 Change-Id: Ia09ff1ab4870b7e3c199a827932536867644c76c (cherry picked from commit e3ba3a3114821e951d6eb00b4c95e6e63ffe00d4)
This commit is contained in:
		
							parent
							
								
									dce7751750
								
							
						
					
					
						commit
						017707e575
					
				
					 3 changed files with 27 additions and 12 deletions
				
			
		| 
						 | 
				
			
			@ -279,13 +279,14 @@ std::string SVG::get_path_d(const ClipperLib::Path &path, double scale, bool clo
 | 
			
		|||
    return d.str();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// font_size: font-size={font_size*10}px
 | 
			
		||||
void SVG::draw_text(const Point &pt, const char *text, const char *color, int font_size)
 | 
			
		||||
{
 | 
			
		||||
    fprintf(this->f,
 | 
			
		||||
        "<text x=\"%f\" y=\"%f\" font-family=\"sans-serif\" font-size=\"20px\" fill=\"%s\">%s</text>",
 | 
			
		||||
        "<text x=\"%f\" y=\"%f\" font-family=\"sans-serif\" font-size=\"%dpx\" fill=\"%s\">%s</text>",
 | 
			
		||||
        to_svg_x(pt(0)-origin(0)),
 | 
			
		||||
        to_svg_y(pt(1)-origin(1)),
 | 
			
		||||
        color, text);
 | 
			
		||||
        font_size*10, color, text);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void SVG::draw_legend(const Point &pt, const char *text, const char *color)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1535,7 +1535,17 @@ static inline Polygons detect_overhangs(
 | 
			
		|||
        // Generate overhang / contact_polygons for non-raft layers.
 | 
			
		||||
        const Layer &lower_layer  = *layer.lower_layer;
 | 
			
		||||
        const bool   has_enforcer = !annotations.enforcers_layers.empty() && !annotations.enforcers_layers[layer_id].empty();
 | 
			
		||||
        const ExPolygons& lower_layer_expolys = lower_layer.lslices;
 | 
			
		||||
        // Can't directly use lower_layer.lslices, or we'll miss some very sharp tails.
 | 
			
		||||
        // Filter out areas whose diameter that is smaller than extrusion_width. Do not use offset2() for this purpose!
 | 
			
		||||
        // FIXME if there are multiple regions with different extrusion width, the following code may not be right.
 | 
			
		||||
        float fw = float(layer.regions().front()->flow(frExternalPerimeter).scaled_width());
 | 
			
		||||
        ExPolygons lower_layer_expolys;
 | 
			
		||||
        for (const ExPolygon& expoly : lower_layer.lslices) {
 | 
			
		||||
            if (!offset_ex(expoly, -fw / 2).empty()) {
 | 
			
		||||
                lower_layer_expolys.emplace_back(expoly);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        const ExPolygons& lower_layer_sharptails = lower_layer.sharp_tails;
 | 
			
		||||
        auto& lower_layer_sharptails_height = lower_layer.sharp_tails_height;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -2265,7 +2275,7 @@ PrintObjectSupportMaterial::MyLayersPtr PrintObjectSupportMaterial::top_contact_
 | 
			
		|||
 | 
			
		||||
            // 3. check whether the small overhang is sharp tail
 | 
			
		||||
            bool is_sharp_tail = false;
 | 
			
		||||
            for (size_t layer_id = cluster.min_layer; layer_id < cluster.max_layer; layer_id++) {
 | 
			
		||||
            for (size_t layer_id = cluster.min_layer; layer_id <= cluster.max_layer; layer_id++) {
 | 
			
		||||
                const Layer& layer = *object.layers()[layer_id];
 | 
			
		||||
                if (!intersection_ex(layer.sharp_tails, cluster.merged_overhangs_dilated).empty()) {
 | 
			
		||||
                    is_sharp_tail = true;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -237,11 +237,15 @@ static void draw_contours_and_nodes_to_svg
 | 
			
		|||
    svg.draw_outline(outlines_below, colors[2]);
 | 
			
		||||
 | 
			
		||||
    // draw legend
 | 
			
		||||
    svg.draw_text(bbox.min + Point(scale_(0), scale_(0)), ("nPoints: "+std::to_string(layer_nodes.size())+"->").c_str(), "green", 4);
 | 
			
		||||
    svg.draw_text(bbox.min + Point(scale_(15), scale_(0)), std::to_string(lower_layer_nodes.size()).c_str(), "black", 4);
 | 
			
		||||
    svg.draw_text(bbox.min + Point(scale_(0), scale_(1)), legends[0].c_str(), colors[0].c_str(), 4);
 | 
			
		||||
    svg.draw_text(bbox.min + Point(scale_(0), scale_(2)), legends[1].c_str(), colors[1].c_str(), 4);
 | 
			
		||||
    svg.draw_text(bbox.min + Point(scale_(0), scale_(3)), legends[2].c_str(), colors[2].c_str(), 4);
 | 
			
		||||
    if (!lower_layer_nodes.empty()) {
 | 
			
		||||
        svg.draw_text(bbox.min + Point(scale_(0), scale_(0)), format("nPoints: %1%->%2%",layer_nodes.size(), lower_layer_nodes.size()).c_str(), "green", 2);
 | 
			
		||||
    }
 | 
			
		||||
    else {
 | 
			
		||||
        svg.draw_text(bbox.min + Point(scale_(0), scale_(0)), ("nPoints: " + std::to_string(layer_nodes.size())).c_str(), "green", 2);
 | 
			
		||||
    }
 | 
			
		||||
    svg.draw_text(bbox.min + Point(scale_(0), scale_(2)), legends[0].c_str(), colors[0].c_str(), 2);
 | 
			
		||||
    svg.draw_text(bbox.min + Point(scale_(0), scale_(4)), legends[1].c_str(), colors[1].c_str(), 2);
 | 
			
		||||
    svg.draw_text(bbox.min + Point(scale_(0), scale_(6)), legends[2].c_str(), colors[2].c_str(), 2);
 | 
			
		||||
 | 
			
		||||
    // draw layer nodes
 | 
			
		||||
    svg.draw(layer_pts, "green", coord_t(scale_(0.1)));
 | 
			
		||||
| 
						 | 
				
			
			@ -874,13 +878,13 @@ void TreeSupport::detect_overhangs()
 | 
			
		|||
            coordf_t lower_layer_offset = layer_nr < enforce_support_layers ? -0.15 * extrusion_width : (float)lower_layer->height / tan(threshold_rad);
 | 
			
		||||
            coordf_t support_offset_scaled = scale_(lower_layer_offset);
 | 
			
		||||
            // Filter out areas whose diameter that is smaller than extrusion_width. Do not use offset2() for this purpose!
 | 
			
		||||
            ExPolygons lower_polys;// = offset2_ex(lower_layer->lslices, -extrusion_width_scaled / 2, extrusion_width_scaled / 2);
 | 
			
		||||
            ExPolygons lower_polys;
 | 
			
		||||
            for (const ExPolygon& expoly : lower_layer->lslices) {
 | 
			
		||||
                if (!offset_ex(expoly, -extrusion_width_scaled / 2).empty()) {
 | 
			
		||||
                    lower_polys.emplace_back(expoly);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            ExPolygons curr_polys;// = offset2_ex(layer->lslices, -extrusion_width_scaled / 2, extrusion_width_scaled / 2);
 | 
			
		||||
            ExPolygons curr_polys;
 | 
			
		||||
            for (const ExPolygon& expoly : layer->lslices) {
 | 
			
		||||
                if (!offset_ex(expoly, -extrusion_width_scaled / 2).empty()) {
 | 
			
		||||
                    curr_polys.emplace_back(expoly);
 | 
			
		||||
| 
						 | 
				
			
			@ -1127,7 +1131,7 @@ void TreeSupport::detect_overhangs()
 | 
			
		|||
 | 
			
		||||
            // 3. check whether the small overhang is sharp tail
 | 
			
		||||
            bool is_sharp_tail = false;
 | 
			
		||||
            for (size_t layer_id = cluster.min_layer; layer_id < cluster.max_layer; layer_id++) {
 | 
			
		||||
            for (size_t layer_id = cluster.min_layer; layer_id <= cluster.max_layer; layer_id++) {
 | 
			
		||||
                Layer* layer = m_object->get_layer(layer_id);
 | 
			
		||||
                if (!intersection_ex(layer->sharp_tails, cluster.merged_poly).empty()) {
 | 
			
		||||
                    is_sharp_tail = true;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue