mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 20:51:12 -06:00 
			
		
		
		
	Implement lower_bound() and upper_bound() methods for ZTable
This commit is contained in:
		
							parent
							
								
									e29aca3553
								
							
						
					
					
						commit
						b1147861dd
					
				
					 3 changed files with 43 additions and 4 deletions
				
			
		|  | @ -16,7 +16,7 @@ has 'copies'            => (is => 'rw', trigger => 1);  # in scaled coordinates | |||
| has 'layers'            => (is => 'rw', default => sub { [] }); | ||||
| has 'layer_height_ranges' => (is => 'rw', default => sub { [] }); # [ z_min, z_max, layer_height ] | ||||
| has 'fill_maker'        => (is => 'lazy'); | ||||
| has '_z_table'          => (is => 'lazy'); | ||||
| has '_slice_z_table'    => (is => 'lazy'); | ||||
| 
 | ||||
| sub BUILD { | ||||
|     my $self = shift; | ||||
|  | @ -84,7 +84,7 @@ sub _build_fill_maker { | |||
|     return Slic3r::Fill->new(object => $self); | ||||
| } | ||||
| 
 | ||||
| sub _build__z_table { | ||||
| sub _build__slice_z_table { | ||||
|     my $self = shift; | ||||
|     return Slic3r::Object::XS::ZTable->new([ map $_->slice_z, @{$self->layers} ]); | ||||
| } | ||||
|  | @ -105,7 +105,13 @@ sub layer_count { | |||
| 
 | ||||
| sub get_layer_range { | ||||
|     my $self = shift; | ||||
|     return @{ $self->_z_table->get_range(@_) }; | ||||
|     my ($min_z, $max_z) = @_; | ||||
|      | ||||
|     my $min_layer = $self->_slice_z_table->lower_bound($min_z); # first layer whose slice_z is >= $min_z | ||||
|     return ( | ||||
|         $min_layer, | ||||
|         $self->_slice_z_table->upper_bound($max_z, $min_layer)-1, # last layer whose slice_z is <= $max_z | ||||
|     ); | ||||
| } | ||||
| 
 | ||||
| sub bounding_box { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Alessandro Ranellucci
						Alessandro Ranellucci