Unicode handling:
Removed the Perl dependencies on Encode, Encode::Locale and Unicode::Normalize. Added dependency on boost::locale. Added encode_path, decode_path, normalize_utf8 functions to Slic3r.xs Slic3r.xs has been made mostly utf8 safe by using the boost::nowide library, thanks to @alexrj for the idea. Simplified the encode_path / decode_path stuff: wxWidgets are unicode already, so there is no need to decode_path() from it. Perl / win32 interfacing is non-unicode, so decode_path() is executed on ARGV just at the beginning of the perl scripts.
This commit is contained in:
parent
31085fb1d7
commit
1385018724
33 changed files with 236 additions and 186 deletions
14
slic3r.pl
14
slic3r.pl
|
@ -18,6 +18,9 @@ use Time::HiRes qw(gettimeofday tv_interval);
|
|||
$|++;
|
||||
binmode STDOUT, ':utf8';
|
||||
|
||||
# Convert all parameters from the local code page to utf8 on Windows.
|
||||
@ARGV = map Slic3r::decode_path($_), @ARGV if $^O eq 'MSWin32';
|
||||
|
||||
our %opt = ();
|
||||
my %cli_options = ();
|
||||
{
|
||||
|
@ -65,7 +68,6 @@ my %cli_options = ();
|
|||
my @external_configs = ();
|
||||
if ($opt{load}) {
|
||||
foreach my $configfile (@{$opt{load}}) {
|
||||
$configfile = Slic3r::decode_path($configfile);
|
||||
if (-e $configfile) {
|
||||
push @external_configs, Slic3r::Config->load($configfile);
|
||||
} elsif (-e "$FindBin::Bin/$configfile") {
|
||||
|
@ -102,7 +104,7 @@ my $gui;
|
|||
if ((!@ARGV || $opt{gui}) && !$opt{save} && eval "require Slic3r::GUI; 1") {
|
||||
{
|
||||
no warnings 'once';
|
||||
$Slic3r::GUI::datadir = Slic3r::decode_path($opt{datadir} // '');
|
||||
$Slic3r::GUI::datadir = $opt{datadir} // '';
|
||||
$Slic3r::GUI::no_controller = $opt{no_controller};
|
||||
$Slic3r::GUI::no_plater = $opt{no_plater};
|
||||
$Slic3r::GUI::autosave = $opt{autosave};
|
||||
|
@ -111,7 +113,7 @@ if ((!@ARGV || $opt{gui}) && !$opt{save} && eval "require Slic3r::GUI; 1") {
|
|||
setlocale(LC_NUMERIC, 'C');
|
||||
$gui->{mainframe}->load_config_file($_) for @{$opt{load}};
|
||||
$gui->{mainframe}->load_config($cli_config);
|
||||
my @input_files = map Slic3r::decode_path($_), @ARGV;
|
||||
my @input_files = @ARGV;
|
||||
$gui->{mainframe}{plater}->load_files(\@input_files) unless $opt{no_plater};
|
||||
$gui->MainLoop;
|
||||
exit;
|
||||
|
@ -123,7 +125,6 @@ if (@ARGV) { # slicing from command line
|
|||
|
||||
if ($opt{repair}) {
|
||||
foreach my $file (@ARGV) {
|
||||
$file = Slic3r::decode_path($file);
|
||||
die "Repair is currently supported only on STL files\n"
|
||||
if $file !~ /\.[sS][tT][lL]$/;
|
||||
|
||||
|
@ -139,7 +140,6 @@ if (@ARGV) { # slicing from command line
|
|||
|
||||
if ($opt{cut}) {
|
||||
foreach my $file (@ARGV) {
|
||||
$file = Slic3r::decode_path($file);
|
||||
my $model = Slic3r::Model->read_from_file($file);
|
||||
my $mesh = $model->mesh;
|
||||
$mesh->translate(0, 0, -$mesh->bounding_box->z_min);
|
||||
|
@ -158,7 +158,6 @@ if (@ARGV) { # slicing from command line
|
|||
|
||||
if ($opt{split}) {
|
||||
foreach my $file (@ARGV) {
|
||||
$file = Slic3r::decode_path($file);
|
||||
my $model = Slic3r::Model->read_from_file($file);
|
||||
my $mesh = $model->mesh;
|
||||
$mesh->repair;
|
||||
|
@ -167,14 +166,13 @@ if (@ARGV) { # slicing from command line
|
|||
foreach my $new_mesh (@{$mesh->split}) {
|
||||
my $output_file = sprintf '%s_%02d.stl', $file, ++$part_count;
|
||||
printf "Writing to %s\n", basename($output_file);
|
||||
$new_mesh->write_binary(Slic3r::encode_path($output_file));
|
||||
$new_mesh->write_binary($output_file);
|
||||
}
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
while (my $input_file = shift @ARGV) {
|
||||
$input_file = Slic3r::decode_path($input_file);
|
||||
my $model;
|
||||
if ($opt{merge}) {
|
||||
my @models = map Slic3r::Model->read_from_file($_), $input_file, (splice @ARGV, 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue