mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-11-02 20:51:23 -07:00 
			
		
		
		
	Anchoring of sparse infills can now be disabled.
This commit is contained in:
		
							parent
							
								
									03b336145f
								
							
						
					
					
						commit
						8d1e13fccd
					
				
					 11 changed files with 35 additions and 36 deletions
				
			
		| 
						 | 
				
			
			@ -33,12 +33,11 @@ struct SurfaceFillParams
 | 
			
		|||
 | 
			
		||||
    // FillParams
 | 
			
		||||
    float       	density = 0.f;
 | 
			
		||||
    // Don't connect the fill lines around the inner perimeter.
 | 
			
		||||
    bool        	dont_connect = false;
 | 
			
		||||
    // Don't adjust spacing to fill the space evenly.
 | 
			
		||||
    bool        	dont_adjust = false;
 | 
			
		||||
    // Length of the infill anchor along the perimeter line.
 | 
			
		||||
    float 			anchor_length = std::numeric_limits<float>::max();
 | 
			
		||||
    // 1000mm is roughly the maximum length line that fits into a 32bit coord_t.
 | 
			
		||||
    float 			anchor_length = 1000.f;
 | 
			
		||||
 | 
			
		||||
    // width, height of extrusion, nozzle diameter, is bridge
 | 
			
		||||
    // For the output, for fill generator.
 | 
			
		||||
| 
						 | 
				
			
			@ -67,7 +66,6 @@ struct SurfaceFillParams
 | 
			
		|||
		RETURN_COMPARE_NON_EQUAL(overlap);
 | 
			
		||||
		RETURN_COMPARE_NON_EQUAL(angle);
 | 
			
		||||
		RETURN_COMPARE_NON_EQUAL(density);
 | 
			
		||||
		RETURN_COMPARE_NON_EQUAL_TYPED(unsigned, dont_connect);
 | 
			
		||||
		RETURN_COMPARE_NON_EQUAL_TYPED(unsigned, dont_adjust);
 | 
			
		||||
		RETURN_COMPARE_NON_EQUAL(anchor_length);
 | 
			
		||||
		RETURN_COMPARE_NON_EQUAL(flow.width);
 | 
			
		||||
| 
						 | 
				
			
			@ -86,7 +84,6 @@ struct SurfaceFillParams
 | 
			
		|||
				this->overlap 			== rhs.overlap 			&&
 | 
			
		||||
				this->angle   			== rhs.angle   			&&
 | 
			
		||||
				this->density   		== rhs.density   		&&
 | 
			
		||||
				this->dont_connect  	== rhs.dont_connect 	&&
 | 
			
		||||
				this->dont_adjust   	== rhs.dont_adjust 		&&
 | 
			
		||||
				this->anchor_length		== rhs.anchor_length    &&
 | 
			
		||||
				this->flow 				== rhs.flow 			&&
 | 
			
		||||
| 
						 | 
				
			
			@ -154,7 +151,11 @@ std::vector<SurfaceFill> group_fills(const Layer &layer)
 | 
			
		|||
		        );
 | 
			
		||||
		        
 | 
			
		||||
		        // Calculate flow spacing for infill pattern generation.
 | 
			
		||||
		        if (! surface.is_solid() && ! is_bridge) {
 | 
			
		||||
		        if (surface.is_solid() || is_bridge) {
 | 
			
		||||
		            params.spacing = params.flow.spacing();
 | 
			
		||||
		            // Don't limit anchor length for solid or bridging infill.
 | 
			
		||||
		            params.anchor_length = 1000.f;
 | 
			
		||||
		        } else {
 | 
			
		||||
		            // it's internal infill, so we can calculate a generic flow spacing 
 | 
			
		||||
		            // for all layers, for avoiding the ugly effect of
 | 
			
		||||
		            // misaligned infill on first layer because of different extrusion width and
 | 
			
		||||
| 
						 | 
				
			
			@ -167,12 +168,11 @@ std::vector<SurfaceFill> group_fills(const Layer &layer)
 | 
			
		|||
			                -1,     // auto width
 | 
			
		||||
			                *layer.object()
 | 
			
		||||
			            ).spacing();
 | 
			
		||||
		        } else
 | 
			
		||||
		            params.spacing = params.flow.spacing();
 | 
			
		||||
 | 
			
		||||
		        params.anchor_length = float(region_config.infill_anchor);
 | 
			
		||||
		        if (region_config.infill_anchor.percent)
 | 
			
		||||
		        	params.anchor_length *= 0.01 * params.spacing;
 | 
			
		||||
		            // Anchor a sparse infill to inner perimeters with the following anchor length:
 | 
			
		||||
			        params.anchor_length = float(region_config.infill_anchor);
 | 
			
		||||
			        if (region_config.infill_anchor.percent)
 | 
			
		||||
			        	params.anchor_length *= 0.01 * params.spacing;
 | 
			
		||||
		        }
 | 
			
		||||
 | 
			
		||||
		        auto it_params = set_surface_params.find(params);
 | 
			
		||||
		        if (it_params == set_surface_params.end())
 | 
			
		||||
| 
						 | 
				
			
			@ -543,8 +543,6 @@ void Layer::make_ironing()
 | 
			
		|||
    fill.z 					 = this->print_z;
 | 
			
		||||
    fill.overlap 			 = 0;
 | 
			
		||||
    fill_params.density 	 = 1.;
 | 
			
		||||
//    fill_params.dont_connect = true;
 | 
			
		||||
    fill_params.dont_connect = false;
 | 
			
		||||
    fill_params.monotonic    = true;
 | 
			
		||||
 | 
			
		||||
	for (size_t i = 0; i < by_extruder.size(); ++ i) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -165,7 +165,7 @@ void Fill3DHoneycomb::_fill_surface_single(
 | 
			
		|||
    polylines = intersection_pl(polylines, to_polygons(expolygon));
 | 
			
		||||
 | 
			
		||||
    // connect lines if needed
 | 
			
		||||
    if (params.dont_connect || polylines.size() <= 1)
 | 
			
		||||
    if (params.dont_connect() || polylines.size() <= 1)
 | 
			
		||||
        append(polylines_out, chain_polylines(std::move(polylines)));
 | 
			
		||||
    else
 | 
			
		||||
        this->connect_infill(std::move(polylines), expolygon, polylines_out, this->spacing, params);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1332,7 +1332,7 @@ void Filler::_fill_surface_single(
 | 
			
		|||
    }
 | 
			
		||||
#endif /* ADAPTIVE_CUBIC_INFILL_DEBUG_OUTPUT */
 | 
			
		||||
 | 
			
		||||
    if (params.dont_connect || all_polylines_with_hooks.size() <= 1)
 | 
			
		||||
    if (params.dont_connect() || all_polylines_with_hooks.size() <= 1)
 | 
			
		||||
        append(polylines_out, chain_polylines(std::move(all_polylines_with_hooks)));
 | 
			
		||||
    else
 | 
			
		||||
        connect_infill(std::move(all_polylines_with_hooks), expolygon, polylines_out, this->spacing, params);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1067,6 +1067,7 @@ void Fill::connect_infill(Polylines &&infill_ordered, const Polygons &boundary_s
 | 
			
		|||
void Fill::connect_infill(Polylines &&infill_ordered, const std::vector<const Polygon*> &boundary_src, const BoundingBox &bbox, Polylines &polylines_out, const double spacing, const FillParams ¶ms)
 | 
			
		||||
{
 | 
			
		||||
	assert(! infill_ordered.empty());
 | 
			
		||||
    assert(params.anchor_length >= 0.01f);
 | 
			
		||||
    const auto anchor_length = float(scale_(params.anchor_length));
 | 
			
		||||
 | 
			
		||||
#if 0
 | 
			
		||||
| 
						 | 
				
			
			@ -1239,7 +1240,6 @@ void Fill::connect_infill(Polylines &&infill_ordered, const std::vector<const Po
 | 
			
		|||
        return std::numeric_limits<size_t>::max();
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    const float take_max_length = anchor_length > 0.f ? anchor_length : std::numeric_limits<float>::max();
 | 
			
		||||
    const float line_half_width = 0.5f * scale_(spacing);
 | 
			
		||||
 | 
			
		||||
#if 0
 | 
			
		||||
| 
						 | 
				
			
			@ -1276,7 +1276,7 @@ void Fill::connect_infill(Polylines &&infill_ordered, const std::vector<const Po
 | 
			
		|||
        idx_first = get_and_update_merged_with(idx_first);
 | 
			
		||||
        assert(idx_first < idx_second);
 | 
			
		||||
        assert(idx_second == merged_with[idx_second]);
 | 
			
		||||
        if (could_connect && (anchor_length == 0.f || length < anchor_length * 2.5)) {
 | 
			
		||||
        if (could_connect && length < anchor_length * 2.5) {
 | 
			
		||||
            // Take the complete contour.
 | 
			
		||||
            // Connect the two polygons using the boundary contour.
 | 
			
		||||
            take(infill_ordered[idx_first], infill_ordered[idx_second], boundary[cp1->contour_idx], cp1, cp2, connection_cost.reversed);
 | 
			
		||||
| 
						 | 
				
			
			@ -1285,8 +1285,8 @@ void Fill::connect_infill(Polylines &&infill_ordered, const std::vector<const Po
 | 
			
		|||
            infill_ordered[idx_second].points.clear();
 | 
			
		||||
        } else {
 | 
			
		||||
            // Try to connect cp1 resp. cp2 with a piece of perimeter line.
 | 
			
		||||
            take_limited(infill_ordered[idx_first],  boundary[cp1->contour_idx], boundary_params[cp1->contour_idx], cp1, cp2, connection_cost.reversed, take_max_length, line_half_width);
 | 
			
		||||
            take_limited(infill_ordered[idx_second], boundary[cp1->contour_idx], boundary_params[cp1->contour_idx], cp2, cp1, ! connection_cost.reversed, take_max_length, line_half_width);
 | 
			
		||||
            take_limited(infill_ordered[idx_first],  boundary[cp1->contour_idx], boundary_params[cp1->contour_idx], cp1, cp2, connection_cost.reversed, anchor_length, line_half_width);
 | 
			
		||||
            take_limited(infill_ordered[idx_second], boundary[cp1->contour_idx], boundary_params[cp1->contour_idx], cp2, cp1, ! connection_cost.reversed, anchor_length, line_half_width);
 | 
			
		||||
        }
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			@ -1314,7 +1314,7 @@ void Fill::connect_infill(Polylines &&infill_ordered, const std::vector<const Po
 | 
			
		|||
            if (polyline_idx1 != polyline_idx2) {
 | 
			
		||||
                Polyline &polyline1 = infill_ordered[polyline_idx1];
 | 
			
		||||
                Polyline &polyline2 = infill_ordered[polyline_idx2];
 | 
			
		||||
                if (anchor_length == 0.f || arc.arc_length < anchor_length * 2.5) {
 | 
			
		||||
                if (arc.arc_length < anchor_length * 2.5) {
 | 
			
		||||
                    // Not closing a loop, connecting the lines.
 | 
			
		||||
                    assert(contour[cp1->point_idx] == polyline1.points.front() || contour[cp1->point_idx] == polyline1.points.back());
 | 
			
		||||
                    if (contour[cp1->point_idx] == polyline1.points.front())
 | 
			
		||||
| 
						 | 
				
			
			@ -1359,7 +1359,7 @@ void Fill::connect_infill(Polylines &&infill_ordered, const std::vector<const Po
 | 
			
		|||
            assert(contour[contour_point.point_idx] == polyline.points.front() || contour[contour_point.point_idx] == polyline.points.back());
 | 
			
		||||
            bool connected = false;
 | 
			
		||||
            for (float l : { std::min(lprev, lnext), std::max(lprev, lnext) }) {
 | 
			
		||||
                if (l == std::numeric_limits<float>::max() || (anchor_length > 0.f && l > anchor_length * 2.5))
 | 
			
		||||
                if (l == std::numeric_limits<float>::max() || l > anchor_length * 2.5)
 | 
			
		||||
                    break;
 | 
			
		||||
                // Take the complete contour.
 | 
			
		||||
                bool      reversed      = l == lprev;
 | 
			
		||||
| 
						 | 
				
			
			@ -1400,9 +1400,9 @@ void Fill::connect_infill(Polylines &&infill_ordered, const std::vector<const Po
 | 
			
		|||
                float l = std::max(contour_point.contour_not_taken_length_prev, contour_point.contour_not_taken_length_next);
 | 
			
		||||
                if (l > SCALED_EPSILON) {
 | 
			
		||||
                    if (contour_point.contour_not_taken_length_prev > contour_point.contour_not_taken_length_next)
 | 
			
		||||
                        take_limited(polyline, contour, contour_params, &contour_point, contour_point.prev_on_contour, true, take_max_length, line_half_width);
 | 
			
		||||
                        take_limited(polyline, contour, contour_params, &contour_point, contour_point.prev_on_contour, true, anchor_length, line_half_width);
 | 
			
		||||
                    else
 | 
			
		||||
                        take_limited(polyline, contour, contour_params, &contour_point, contour_point.next_on_contour, false, take_max_length, line_half_width);
 | 
			
		||||
                        take_limited(polyline, contour, contour_params, &contour_point, contour_point.next_on_contour, false, anchor_length, line_half_width);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -33,15 +33,15 @@ public:
 | 
			
		|||
struct FillParams
 | 
			
		||||
{
 | 
			
		||||
    bool        full_infill() const { return density > 0.9999f; }
 | 
			
		||||
    // Don't connect the fill lines around the inner perimeter.
 | 
			
		||||
    bool        dont_connect() const { return anchor_length < 0.05f; }
 | 
			
		||||
 | 
			
		||||
    // Fill density, fraction in <0, 1>
 | 
			
		||||
    float       density 		{ 0.f };
 | 
			
		||||
 | 
			
		||||
    // Length of an infill anchor along the perimeter.
 | 
			
		||||
    float       anchor_length   { std::numeric_limits<float>::max() };
 | 
			
		||||
 | 
			
		||||
    // Don't connect the fill lines around the inner perimeter.
 | 
			
		||||
    bool        dont_connect 	{ false };
 | 
			
		||||
    // 1000mm is roughly the maximum length line that fits into a 32bit coord_t.
 | 
			
		||||
    float       anchor_length   { 1000.f };
 | 
			
		||||
 | 
			
		||||
    // Don't adjust spacing to fill the space evenly.
 | 
			
		||||
    bool        dont_adjust 	{ true };
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -192,7 +192,7 @@ void FillGyroid::_fill_surface_single(
 | 
			
		|||
	if (! polylines.empty()) {
 | 
			
		||||
		// connect lines
 | 
			
		||||
		size_t polylines_out_first_idx = polylines_out.size();
 | 
			
		||||
		if (params.dont_connect)
 | 
			
		||||
		if (params.dont_connect())
 | 
			
		||||
        	append(polylines_out, chain_polylines(polylines));
 | 
			
		||||
        else
 | 
			
		||||
            this->connect_infill(std::move(polylines), expolygon, polylines_out, this->spacing, params);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -74,7 +74,7 @@ void FillHoneycomb::_fill_surface_single(
 | 
			
		|||
    }
 | 
			
		||||
    
 | 
			
		||||
    all_polylines = intersection_pl(std::move(all_polylines), to_polygons(expolygon));
 | 
			
		||||
    if (params.dont_connect || all_polylines.size() <= 1)
 | 
			
		||||
    if (params.dont_connect() || all_polylines.size() <= 1)
 | 
			
		||||
        append(polylines_out, chain_polylines(std::move(all_polylines)));
 | 
			
		||||
    else
 | 
			
		||||
        connect_infill(std::move(all_polylines), expolygon, polylines_out, this->spacing, params);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -76,7 +76,7 @@ void FillLine::_fill_surface_single(
 | 
			
		|||
    size_t n_polylines_out_old = polylines_out.size();
 | 
			
		||||
 | 
			
		||||
    // connect lines
 | 
			
		||||
    if (! params.dont_connect && ! polylines.empty()) { // prevent calling leftmost_point() on empty collections
 | 
			
		||||
    if (! params.dont_connect() && ! polylines.empty()) { // prevent calling leftmost_point() on empty collections
 | 
			
		||||
        // offset the expolygon by max(min_spacing/2, extra)
 | 
			
		||||
        ExPolygon expolygon_off;
 | 
			
		||||
        {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -46,7 +46,7 @@ void FillPlanePath::_fill_surface_single(
 | 
			
		|||
//      intersection(polylines_src, offset((Polygons)expolygon, scale_(0.02)), &polylines);
 | 
			
		||||
        polylines = intersection_pl(std::move(polylines), to_polygons(expolygon));
 | 
			
		||||
        Polylines chained;
 | 
			
		||||
        if (params.dont_connect || params.density > 0.5 || polylines.size() <= 1)
 | 
			
		||||
        if (params.dont_connect() || params.density > 0.5 || polylines.size() <= 1)
 | 
			
		||||
            chained = chain_polylines(std::move(polylines));
 | 
			
		||||
        else
 | 
			
		||||
            connect_infill(std::move(polylines), expolygon, chained, this->spacing, params);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1109,7 +1109,7 @@ static void connect_segment_intersections_by_contours(
 | 
			
		|||
	            }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
			if (params.dont_connect) {
 | 
			
		||||
			if (params.dont_connect()) {
 | 
			
		||||
				if (itsct.prev_on_contour_quality == SegmentIntersection::LinkQuality::Valid)
 | 
			
		||||
					itsct.prev_on_contour_quality = SegmentIntersection::LinkQuality::TooLong;
 | 
			
		||||
				if (itsct.next_on_contour_quality == SegmentIntersection::LinkQuality::Valid)
 | 
			
		||||
| 
						 | 
				
			
			@ -2820,7 +2820,7 @@ bool FillRectilinear::fill_surface_by_multilines(const Surface *surface, FillPar
 | 
			
		|||
            }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (params.dont_connect || fill_lines.size() <= 1) {
 | 
			
		||||
    if (params.dont_connect() || fill_lines.size() <= 1) {
 | 
			
		||||
        if (fill_lines.size() > 1)
 | 
			
		||||
            fill_lines = chain_polylines(std::move(fill_lines));
 | 
			
		||||
        append(polylines_out, std::move(fill_lines));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue