mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-11-02 20:51:23 -07:00 
			
		
		
		
	Slic3r should now be able to detect optimal bridging direction for any kind of bridge. #58
This commit is contained in:
		
							parent
							
								
									5375f5fef4
								
							
						
					
					
						commit
						792960aae1
					
				
					 9 changed files with 117 additions and 42 deletions
				
			
		| 
						 | 
				
			
			@ -9,6 +9,7 @@ our @EXPORT_OK = qw(explode_expolygon explode_expolygons safety_offset offset
 | 
			
		|||
    is_counter_clockwise);
 | 
			
		||||
 | 
			
		||||
use Math::Clipper 1.02 ':all';
 | 
			
		||||
use Slic3r::Geometry qw(scale);
 | 
			
		||||
our $clipper = Math::Clipper->new;
 | 
			
		||||
 | 
			
		||||
sub explode_expolygon {
 | 
			
		||||
| 
						 | 
				
			
			@ -23,15 +24,15 @@ sub explode_expolygons {
 | 
			
		|||
 | 
			
		||||
sub safety_offset {
 | 
			
		||||
    my ($polygons) = @_;
 | 
			
		||||
    return Math::Clipper::offset($polygons, 100, 100, JT_MITER, 2);
 | 
			
		||||
    return Math::Clipper::offset($polygons, scale 1e-05, 100, JT_MITER, 2);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sub diff_ex {
 | 
			
		||||
    my ($subject, $clip) = @_;
 | 
			
		||||
    my ($subject, $clip, $safety_offset) = @_;
 | 
			
		||||
    
 | 
			
		||||
    $clipper->clear;
 | 
			
		||||
    $clipper->add_subject_polygons($subject);
 | 
			
		||||
    $clipper->add_clip_polygons($clip);
 | 
			
		||||
    $clipper->add_clip_polygons($safety_offset ? safety_offset($clip) : $clip);
 | 
			
		||||
    return [
 | 
			
		||||
        map Slic3r::ExPolygon->new($_),
 | 
			
		||||
            @{ $clipper->ex_execute(CT_DIFFERENCE, PFT_NONZERO, PFT_NONZERO) },
 | 
			
		||||
| 
						 | 
				
			
			@ -43,10 +44,10 @@ sub diff {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
sub union_ex {
 | 
			
		||||
    my ($polygons, $jointype) = @_;
 | 
			
		||||
    my ($polygons, $jointype, $safety_offset) = @_;
 | 
			
		||||
    $jointype = PFT_NONZERO unless defined $jointype;
 | 
			
		||||
    $clipper->clear;
 | 
			
		||||
    $clipper->add_subject_polygons($polygons);
 | 
			
		||||
    $clipper->add_subject_polygons($safety_offset ? safety_offset($polygons) : $polygons);
 | 
			
		||||
    return [
 | 
			
		||||
        map Slic3r::ExPolygon->new($_),
 | 
			
		||||
            @{ $clipper->ex_execute(CT_UNION, $jointype, $jointype) },
 | 
			
		||||
| 
						 | 
				
			
			@ -54,11 +55,11 @@ sub union_ex {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
sub intersection_ex {
 | 
			
		||||
    my ($subject, $clip, $jointype) = @_;
 | 
			
		||||
    my ($subject, $clip, $jointype, $safety_offset) = @_;
 | 
			
		||||
    $jointype = PFT_NONZERO unless defined $jointype;
 | 
			
		||||
    $clipper->clear;
 | 
			
		||||
    $clipper->add_subject_polygons($subject);
 | 
			
		||||
    $clipper->add_clip_polygons($clip);
 | 
			
		||||
    $clipper->add_clip_polygons($safety_offset ? safety_offset($clip) : $clip);
 | 
			
		||||
    return [
 | 
			
		||||
        map Slic3r::ExPolygon->new($_),
 | 
			
		||||
            @{ $clipper->ex_execute(CT_INTERSECTION, $jointype, $jointype) },
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue