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-06-14 18:26:58 +00:00
|
|
|
our $VERSION = "0.8.4-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-05-19 18:25:59 +00:00
|
|
|
# load threads before Moo as required by it
|
2012-05-21 17:16:42 +00:00
|
|
|
our $have_threads;
|
2012-05-21 16:44:31 +00:00
|
|
|
BEGIN {
|
|
|
|
use Config;
|
2012-05-21 17:16:42 +00:00
|
|
|
$have_threads = $Config{useithreads} && eval "use threads; use Thread::Queue; 1";
|
2012-05-21 16:44:31 +00:00
|
|
|
}
|
2012-05-19 18:25:59 +00:00
|
|
|
|
2012-05-29 12:19:14 +00:00
|
|
|
use FindBin;
|
|
|
|
our $var = "$FindBin::Bin/var";
|
|
|
|
|
2012-05-19 18:25:59 +00:00
|
|
|
use Moo;
|
2011-10-03 09:55:32 +00:00
|
|
|
use Slic3r::Config;
|
2011-10-15 09:36:05 +00:00
|
|
|
use Slic3r::ExPolygon;
|
2011-09-26 09:42:08 +00:00
|
|
|
use Slic3r::Extruder;
|
2011-09-25 21:15:45 +00:00
|
|
|
use Slic3r::ExtrusionLoop;
|
2011-09-04 10:04:01 +00:00
|
|
|
use Slic3r::ExtrusionPath;
|
2011-10-20 16:11:59 +00:00
|
|
|
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;
|
2012-06-06 16:05:03 +00:00
|
|
|
use Slic3r::Flow;
|
2012-02-25 16:35:25 +00:00
|
|
|
use Slic3r::Format::AMF;
|
2012-05-20 09:40:37 +00:00
|
|
|
use Slic3r::Format::OBJ;
|
2012-02-25 16:35:25 +00:00
|
|
|
use Slic3r::Format::STL;
|
2011-12-07 18:33:59 +00:00
|
|
|
use Slic3r::Geometry qw(PI);
|
2011-09-01 19:06:28 +00:00
|
|
|
use Slic3r::Layer;
|
|
|
|
use Slic3r::Line;
|
|
|
|
use Slic3r::Point;
|
2011-10-15 09:36:05 +00:00
|
|
|
use Slic3r::Polygon;
|
2011-09-01 19:06:28 +00:00
|
|
|
use Slic3r::Polyline;
|
|
|
|
use Slic3r::Print;
|
2012-04-29 10:51:20 +00:00
|
|
|
use Slic3r::Print::Object;
|
2011-09-01 19:06:28 +00:00
|
|
|
use Slic3r::Surface;
|
2011-11-27 10:40:03 +00:00
|
|
|
use Slic3r::TriangleMesh;
|
2012-05-29 12:19:14 +00:00
|
|
|
eval "use Slic3r::Build";
|
2011-09-01 19:06:28 +00:00
|
|
|
|
2012-05-20 15:21:31 +00:00
|
|
|
our $threads = $have_threads ? 2 : 1;
|
2012-01-28 15:27:52 +00:00
|
|
|
|
2012-02-05 19:55:17 +00:00
|
|
|
# miscellaneous options
|
|
|
|
our $notes = '';
|
|
|
|
|
2011-12-26 09:20:45 +00:00
|
|
|
# output options
|
|
|
|
our $output_filename_format = '[input_filename_base].gcode';
|
2012-02-20 11:50:05 +00:00
|
|
|
our $post_process = [];
|
2011-12-26 09:20:45 +00:00
|
|
|
|
2011-09-06 09:10:12 +00:00
|
|
|
# printer options
|
2011-10-05 19:25:17 +00:00
|
|
|
our $nozzle_diameter = 0.5;
|
2011-09-06 09:10:12 +00:00
|
|
|
our $print_center = [100,100]; # object will be centered around this point
|
2012-02-20 10:44:30 +00:00
|
|
|
our $z_offset = 0;
|
|
|
|
our $gcode_flavor = 'reprap';
|
2011-09-06 09:10:12 +00:00
|
|
|
our $use_relative_e_distances = 0;
|
2011-12-01 21:34:21 +00:00
|
|
|
our $extrusion_axis = 'E';
|
2011-10-20 16:11:59 +00:00
|
|
|
our $gcode_arcs = 0;
|
2011-11-14 11:15:32 +00:00
|
|
|
our $g0 = 0;
|
2011-12-14 18:49:21 +00:00
|
|
|
our $gcode_comments = 0;
|
2011-09-05 11:33:09 +00:00
|
|
|
|
2011-09-06 09:10:12 +00:00
|
|
|
# filament options
|
|
|
|
our $filament_diameter = 3; # mm
|
2011-11-25 10:15:20 +00:00
|
|
|
our $extrusion_multiplier = 1;
|
2011-10-14 14:24:55 +00:00
|
|
|
our $temperature = 200;
|
2012-06-18 20:27:57 +00:00
|
|
|
our $first_layer_temperature = $temperature;
|
2012-03-03 22:14:40 +00:00
|
|
|
our $bed_temperature = 0;
|
2012-06-18 20:27:57 +00:00
|
|
|
our $first_layer_bed_temperature = $bed_temperature;
|
2011-09-06 09:10:12 +00:00
|
|
|
|
|
|
|
# speed options
|
2012-06-06 17:57:16 +00:00
|
|
|
our $travel_speed = 130; # mm/s
|
|
|
|
our $perimeter_speed = 30; # mm/s
|
|
|
|
our $small_perimeter_speed = 30; # mm/s or %
|
|
|
|
our $infill_speed = 60; # mm/s
|
|
|
|
our $solid_infill_speed = 60; # mm/s or %
|
|
|
|
our $top_solid_infill_speed = 50; # mm/s or %
|
|
|
|
our $bridge_speed = 60; # mm/s
|
|
|
|
our $first_layer_speed = '30%'; # mm/s or %
|
2011-09-06 09:10:12 +00:00
|
|
|
|
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
|
|
|
|
2011-09-06 09:10:12 +00:00
|
|
|
# accuracy options
|
2012-05-19 15:57:38 +00:00
|
|
|
our $scaling_factor = 0.000001;
|
2012-05-01 09:41:08 +00:00
|
|
|
our $resolution = 0.01;
|
2012-05-13 22:30:52 +00:00
|
|
|
our $small_perimeter_length = (6.5 / $scaling_factor)*2*PI;
|
2011-10-06 15:11:59 +00:00
|
|
|
our $layer_height = 0.4;
|
2012-06-06 14:11:38 +00:00
|
|
|
our $first_layer_height = '100%'; # mm or %
|
|
|
|
our $_first_layer_height = undef; # mm (computed)
|
2011-10-18 13:57:53 +00:00
|
|
|
our $infill_every_layers = 1;
|
2011-12-07 18:33:59 +00:00
|
|
|
|
|
|
|
# flow options
|
2012-06-06 16:05:03 +00:00
|
|
|
our $extrusion_width = 0;
|
|
|
|
our $first_layer_extrusion_width = 0;
|
|
|
|
our $perimeters_extrusion_width = 0;
|
|
|
|
our $infill_extrusion_width = 0;
|
|
|
|
our $bridge_flow_ratio = 1;
|
|
|
|
our $overlap_factor = 0.5;
|
|
|
|
our $flow = Slic3r::Flow->new;
|
|
|
|
our $first_layer_flow = undef;
|
|
|
|
our $perimeters_flow = Slic3r::Flow->new;
|
|
|
|
our $infill_flow = Slic3r::Flow->new;
|
2011-09-06 09:10:12 +00:00
|
|
|
|
|
|
|
# print options
|
2011-11-17 09:38:23 +00:00
|
|
|
our $perimeters = 3;
|
2011-09-25 20:11:56 +00:00
|
|
|
our $solid_layers = 3;
|
2011-11-13 17:14:02 +00:00
|
|
|
our $fill_pattern = 'rectilinear';
|
|
|
|
our $solid_fill_pattern = 'rectilinear';
|
2011-09-05 16:52:09 +00:00
|
|
|
our $fill_density = 0.4; # 1 = 100%
|
2011-12-08 09:33:05 +00:00
|
|
|
our $fill_angle = 45;
|
2012-05-19 20:36:29 +00:00
|
|
|
our $randomize_start = 1;
|
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;
|
2011-10-14 14:24:55 +00:00
|
|
|
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
|
2012-03-26 10:14:15 +00:00
|
|
|
our $layer_gcode = '';
|
2011-09-03 18:47:38 +00:00
|
|
|
|
2011-09-06 09:10:12 +00:00
|
|
|
# retraction options
|
2011-10-01 16:10:33 +00:00
|
|
|
our $retract_length = 1; # mm
|
2011-09-05 16:52:09 +00:00
|
|
|
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
|
2011-11-07 14:58:47 +00:00
|
|
|
our $retract_lift = 0; # mm
|
2011-09-05 16:52:09 +00:00
|
|
|
|
2012-02-25 20:01:00 +00:00
|
|
|
# cooling options
|
2012-02-25 20:56:36 +00:00
|
|
|
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
|
|
|
|
2011-09-06 09:10:12 +00:00
|
|
|
# skirt options
|
2011-09-25 20:11:56 +00:00
|
|
|
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';
|
2012-03-06 03:55:21 +00:00
|
|
|
our $duplicate = 1;
|
2012-04-11 14:30:58 +00:00
|
|
|
our $bed_size = [200,200];
|
2012-04-11 13:58:09 +00:00
|
|
|
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-05-23 09:47:52 +00:00
|
|
|
# sequential printing
|
|
|
|
our $complete_objects = 0;
|
|
|
|
our $extruder_clearance_radius = 20; # mm
|
|
|
|
our $extruder_clearance_height = 20; # mm
|
|
|
|
|
2012-06-18 20:27:57 +00:00
|
|
|
our $Defaults = Slic3r::Config->current;
|
2012-06-19 16:11:51 +00:00
|
|
|
our $Settings = { presets => {} }; # application settings
|
2012-06-18 20:27:57 +00:00
|
|
|
|
2012-04-09 10:29:47 +00:00
|
|
|
sub parallelize {
|
|
|
|
my %params = @_;
|
|
|
|
|
2012-04-10 14:26:56 +00:00
|
|
|
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;
|