mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-11-02 20:51:23 -07:00 
			
		
		
		
	New Slic3r::Surface::Collection class
This commit is contained in:
		
							parent
							
								
									0099218f61
								
							
						
					
					
						commit
						5885be881c
					
				
					 8 changed files with 115 additions and 16 deletions
				
			
		| 
						 | 
				
			
			@ -36,7 +36,7 @@ has 'thin_walls' => (is => 'rw', default => sub { [] });
 | 
			
		|||
has 'thin_fills' => (is => 'rw', default => sub { [] });
 | 
			
		||||
 | 
			
		||||
# collection of surfaces for infill generation
 | 
			
		||||
has 'fill_surfaces' => (is => 'rw', default => sub { [] });
 | 
			
		||||
has 'fill_surfaces' => (is => 'rw', default => sub { Slic3r::Surface::Collection->new });
 | 
			
		||||
 | 
			
		||||
# ordered collection of extrusion paths/loops to build all perimeters
 | 
			
		||||
has 'perimeters' => (is => 'rw', default => sub { [] });
 | 
			
		||||
| 
						 | 
				
			
			@ -158,7 +158,7 @@ sub make_perimeters {
 | 
			
		|||
    my $gap_area_threshold  = $self->perimeter_flow->scaled_width ** 2;
 | 
			
		||||
    
 | 
			
		||||
    $self->perimeters([]);
 | 
			
		||||
    $self->fill_surfaces([]);
 | 
			
		||||
    $self->fill_surfaces->clear;
 | 
			
		||||
    $self->thin_fills([]);
 | 
			
		||||
    
 | 
			
		||||
    my @contours    = ();    # array of Polygons with ccw orientation
 | 
			
		||||
| 
						 | 
				
			
			@ -208,12 +208,14 @@ sub make_perimeters {
 | 
			
		|||
        # we offset by half the perimeter spacing (to get to the actual infill boundary)
 | 
			
		||||
        # and then we offset back and forth by the infill spacing to only consider the
 | 
			
		||||
        # non-collapsing regions
 | 
			
		||||
        push @{ $self->fill_surfaces },
 | 
			
		||||
            offset2_ex(
 | 
			
		||||
        # use a bogus surface_type
 | 
			
		||||
        $self->fill_surfaces->append(
 | 
			
		||||
            map Slic3r::Surface->new(expolygon => $_, surface_type => S_TYPE_TOP), offset2_ex(
 | 
			
		||||
                [ map $_->simplify(&Slic3r::SCALED_RESOLUTION), @last ],
 | 
			
		||||
                -($perimeter_spacing/2 + $infill_spacing),
 | 
			
		||||
                +$infill_spacing,
 | 
			
		||||
            );
 | 
			
		||||
            )
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    $self->_fill_gaps(\@gaps);
 | 
			
		||||
| 
						 | 
				
			
			@ -452,7 +454,8 @@ sub process_external_surfaces {
 | 
			
		|||
                [ map $_->p, @new_surfaces ],
 | 
			
		||||
            )};
 | 
			
		||||
        }
 | 
			
		||||
        @{$self->fill_surfaces} = @new_surfaces;
 | 
			
		||||
        $self->fill_surfaces->clear;
 | 
			
		||||
        $self->fill_surfaces->append(@new_surfaces);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    # detect bridge direction (skip bottom layer)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -428,7 +428,7 @@ sub export_gcode {
 | 
			
		|||
    }
 | 
			
		||||
    
 | 
			
		||||
    # free memory (note that support material needs fill_surfaces)
 | 
			
		||||
    $_->fill_surfaces(undef) for map @{$_->regions}, map @{$_->layers}, @{$self->objects};
 | 
			
		||||
    $_->fill_surfaces->clear for map @{$_->regions}, map @{$_->layers}, @{$self->objects};
 | 
			
		||||
    
 | 
			
		||||
    # make skirt
 | 
			
		||||
    $status_cb->(88, "Generating skirt");
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -427,16 +427,16 @@ sub detect_surfaces_type {
 | 
			
		|||
        # clip surfaces to the fill boundaries
 | 
			
		||||
        foreach my $layer (@{$self->layers}) {
 | 
			
		||||
            my $layerm = $layer->regions->[$region_id];
 | 
			
		||||
            my $fill_boundaries = [ map @$_, @{$layerm->fill_surfaces} ];
 | 
			
		||||
            @{$layerm->fill_surfaces} = ();
 | 
			
		||||
            my $fill_boundaries = [ map $_->p, @{$layerm->fill_surfaces} ];
 | 
			
		||||
            $layerm->fill_surfaces->clear;
 | 
			
		||||
            foreach my $surface (@{$layerm->slices}) {
 | 
			
		||||
                my $intersection = intersection_ex(
 | 
			
		||||
                    [ $surface->p ],
 | 
			
		||||
                    $fill_boundaries,
 | 
			
		||||
                );
 | 
			
		||||
                push @{$layerm->fill_surfaces}, map Slic3r::Surface->new
 | 
			
		||||
                $layerm->fill_surfaces->append(map Slic3r::Surface->new
 | 
			
		||||
                    (expolygon => $_, surface_type => $surface->surface_type),
 | 
			
		||||
                    @$intersection;
 | 
			
		||||
                    @$intersection);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -465,10 +465,12 @@ sub clip_fill_surfaces {
 | 
			
		|||
                    [ map @$_, @overhangs ],
 | 
			
		||||
                    [ map @{$_->expolygon}, grep $_->surface_type == S_TYPE_INTERNAL, @{$layerm->fill_surfaces} ],
 | 
			
		||||
                )};
 | 
			
		||||
            @{$layerm->fill_surfaces} = (
 | 
			
		||||
            my @new_surfaces = (
 | 
			
		||||
                @new_internal,
 | 
			
		||||
                (grep $_->surface_type != S_TYPE_INTERNAL, @{$layerm->fill_surfaces}),
 | 
			
		||||
            );
 | 
			
		||||
            $layerm->fill_surfaces->clear;
 | 
			
		||||
            $layerm->fill_surfaces->append(@new_surfaces);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        # get this layer's overhangs
 | 
			
		||||
| 
						 | 
				
			
			@ -523,7 +525,8 @@ sub bridge_over_infill {
 | 
			
		|||
                        [ map @$_, @$to_bridge ],
 | 
			
		||||
                        1,
 | 
			
		||||
                    )};
 | 
			
		||||
                @{$layerm->fill_surfaces} = @new_surfaces;
 | 
			
		||||
                $layerm->fill_surfaces->clear;
 | 
			
		||||
                $layerm->fill_surfaces->append(@new_surfaces);
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
            # exclude infill from the layers below if needed
 | 
			
		||||
| 
						 | 
				
			
			@ -550,7 +553,8 @@ sub bridge_over_infill {
 | 
			
		|||
                                [ map @$_, @$to_bridge ],
 | 
			
		||||
                            )};
 | 
			
		||||
                        }
 | 
			
		||||
                        @{$lower_layerm->fill_surfaces} = @new_surfaces;
 | 
			
		||||
                        $lower_layerm->fill_surfaces->clear;
 | 
			
		||||
                        $lower_layerm->fill_surfaces->append(@new_surfaces);
 | 
			
		||||
                    }
 | 
			
		||||
                    
 | 
			
		||||
                    $excess -= $self->layers->[$i]->height;
 | 
			
		||||
| 
						 | 
				
			
			@ -779,7 +783,8 @@ sub combine_infill {
 | 
			
		|||
                            )};
 | 
			
		||||
                    }
 | 
			
		||||
                    
 | 
			
		||||
                    @{$layerm->fill_surfaces} = (@new_this_type, @other_types);
 | 
			
		||||
                    $layerm->fill_surfaces->clear;
 | 
			
		||||
                    $layerm->fill_surfaces->append(@new_this_type, @other_types);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue