PrusaSlicer-NonPlainar/lib/Slic3r.pm

165 lines
4.4 KiB
Perl
Raw Normal View History

2011-09-01 19:06:28 +00:00
package Slic3r;
2012-01-18 19:04:18 +00:00
# Copyright holder: Alessandro Ranellucci
# This application is licensed under the GNU Affero General Public License, version 3
2011-09-01 19:06:28 +00:00
use strict;
use warnings;
2012-01-22 12:56:15 +00:00
require v5.10;
2011-09-01 19:06:28 +00:00
2012-03-11 19:07:54 +00:00
our $VERSION = "0.7.2-dev";
2011-11-13 21:57:58 +00:00
2011-09-05 11:33:09 +00:00
our $debug = 0;
sub debugf {
printf @_ if $debug;
}
2012-04-09 10:29:47 +00:00
use Config;
2011-10-03 09:55:32 +00:00
use Slic3r::Config;
use Slic3r::ExPolygon;
use Slic3r::Extruder;
use Slic3r::ExtrusionLoop;
use Slic3r::ExtrusionPath;
use Slic3r::ExtrusionPath::Arc;
2011-09-26 08:52:58 +00:00
use Slic3r::ExtrusionPath::Collection;
2011-09-05 10:21:27 +00:00
use Slic3r::Fill;
use Slic3r::Format::AMF;
use Slic3r::Format::STL;
use Slic3r::Geometry qw(PI);
2011-09-01 19:06:28 +00:00
use Slic3r::Layer;
use Slic3r::Line;
2011-09-02 19:10:20 +00:00
use Slic3r::Perimeter;
2011-09-01 19:06:28 +00:00
use Slic3r::Point;
use Slic3r::Polygon;
2011-09-01 19:06:28 +00:00
use Slic3r::Polyline;
use Slic3r::Print;
2011-10-03 09:55:32 +00:00
use Slic3r::Skein;
2011-09-01 19:06:28 +00:00
use Slic3r::Surface;
use Slic3r::TriangleMesh;
use Slic3r::TriangleMesh::IntersectionLine;
2011-09-01 19:06:28 +00:00
our $have_threads = $Config{useithreads} && eval "use threads; use Thread::Queue; 1";
our $threads = $have_threads ? 4 : undef;
2012-01-28 15:27:52 +00:00
# miscellaneous options
our $notes = '';
# output options
our $output_filename_format = '[input_filename_base].gcode';
our $post_process = [];
# printer options
2011-10-05 19:25:17 +00:00
our $nozzle_diameter = 0.5;
our $print_center = [100,100]; # object will be centered around this point
our $z_offset = 0;
our $gcode_flavor = 'reprap';
our $use_relative_e_distances = 0;
our $extrusion_axis = 'E';
our $gcode_arcs = 0;
our $g0 = 0;
our $gcode_comments = 0;
2011-09-05 11:33:09 +00:00
# filament options
our $filament_diameter = 3; # mm
our $extrusion_multiplier = 1;
our $temperature = 200;
2012-02-26 13:54:38 +00:00
our $first_layer_temperature;
our $bed_temperature = 0;
our $first_layer_bed_temperature;
# speed options
2012-02-18 21:36:13 +00:00
our $travel_speed = 130; # mm/s
our $perimeter_speed = 30; # mm/s
our $small_perimeter_speed = 30; # mm/s
our $infill_speed = 60; # mm/s
our $solid_infill_speed = 60; # mm/s
our $bridge_speed = 60; # mm/s
2011-10-01 16:10:33 +00:00
our $bottom_layer_speed_ratio = 0.3;
2012-02-10 13:53:44 +00:00
# acceleration options
our $acceleration = 0;
2012-02-18 21:36:13 +00:00
our $perimeter_acceleration = 25; # mm/s^2
our $infill_acceleration = 50; # mm/s^2
2012-02-10 13:53:44 +00:00
# accuracy options
our $scaling_factor = 0.00000001;
our $small_perimeter_area = ((6.5 / $scaling_factor)**2)*PI;
our $layer_height = 0.4;
our $first_layer_height_ratio = 1;
our $infill_every_layers = 1;
# flow options
our $extrusion_width_ratio = 0;
our $bridge_flow_ratio = 1;
our $overlap_factor = 0.5;
our $flow_width;
our $min_flow_spacing;
our $flow_spacing;
# print options
our $perimeters = 3;
our $solid_layers = 3;
our $fill_pattern = 'rectilinear';
our $solid_fill_pattern = 'rectilinear';
our $fill_density = 0.4; # 1 = 100%
2011-12-08 09:33:05 +00:00
our $fill_angle = 45;
2012-02-19 11:03:36 +00:00
our $support_material = 0;
2012-02-19 16:02:49 +00:00
our $support_material_tool = 0;
our $start_gcode = "G28 ; home all axes";
our $end_gcode = <<"END";
M104 S0 ; turn off temperature
G28 X0 ; home X axis
M84 ; disable motors
END
our $layer_gcode = '';
2011-09-03 18:47:38 +00:00
# retraction options
2011-10-01 16:10:33 +00:00
our $retract_length = 1; # mm
our $retract_restart_extra = 0; # mm
2012-02-18 21:36:13 +00:00
our $retract_speed = 30; # mm/s
2011-10-06 13:24:21 +00:00
our $retract_before_travel = 2; # mm
our $retract_lift = 0; # mm
2012-02-25 20:01:00 +00:00
# cooling options
our $cooling = 0;
2012-02-25 20:01:00 +00:00
our $min_fan_speed = 35;
our $max_fan_speed = 100;
our $bridge_fan_speed = 100;
our $fan_below_layer_time = 60;
our $slowdown_below_layer_time = 15;
our $min_print_speed = 10;
our $disable_fan_first_layers = 1;
2012-03-03 21:21:30 +00:00
our $fan_always_on = 0;
2012-02-25 20:01:00 +00:00
# skirt options
our $skirts = 1;
2011-09-05 18:00:59 +00:00
our $skirt_distance = 6; # mm
2011-11-13 17:41:12 +00:00
our $skirt_height = 1; # layers
2011-09-05 18:00:59 +00:00
2011-09-26 10:07:29 +00:00
# transform options
our $scale = 1;
2011-09-26 14:07:12 +00:00
our $rotate = 0;
2012-04-11 15:38:56 +00:00
our $duplicate_mode = 'no';
our $duplicate = 1;
2012-04-11 14:30:58 +00:00
our $bed_size = [200,200];
our $duplicate_grid = [1,1];
2011-11-07 14:49:07 +00:00
our $duplicate_distance = 6; # mm
2011-09-26 10:07:29 +00:00
2012-04-09 10:29:47 +00:00
sub parallelize {
my %params = @_;
if (!$params{disable} && $Slic3r::have_threads && $Slic3r::threads > 1) {
2012-04-09 10:29:47 +00:00
my $q = Thread::Queue->new;
$q->enqueue(@{ $params{items} }, (map undef, 1..$Slic3r::threads));
my $thread_cb = sub { $params{thread_cb}->($q) };
foreach my $th (map threads->create($thread_cb), 1..$Slic3r::threads) {
$params{collect_cb}->($th->join);
}
} else {
$params{no_threads_cb}->();
}
}
2011-09-01 19:06:28 +00:00
1;