Welcome to mirror list, hosted at ThFree Co, Russian Federation.

view-toolpaths.pl « utils - github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e064885ca3c83cd3716e77c7e3e1a12ae6fe790d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/perl
# This script displays 3D preview of a mesh

use strict;
use warnings;

BEGIN {
    use FindBin;
    use lib "$FindBin::Bin/../lib";
    use local::lib "$FindBin::Bin/../local-lib";
}

use Getopt::Long qw(:config no_auto_abbrev);
use Slic3r;
use Slic3r::GUI;
use Slic3r::GUI::3DScene;
$|++;

my %opt = ();
{
    my %options = (
        'help'                  => sub { usage() },
        'load=s'                => \$opt{load},
        '3D'                    => \$opt{d3},
        'duplicate=i'           => \$opt{duplicate},
    );
    GetOptions(%options) or usage(1);
    $ARGV[0] or usage(1);
}

{
    # load model
    my $model = Slic3r::Model->read_from_file($ARGV[0]);
    
    # load config
    my $config = Slic3r::Config::new_from_defaults;
    if ($opt{load}) {
        $config->apply(Slic3r::Config::load($opt{load}));
    }
    
    # init print
    my $sprint = Slic3r::Print::Simple->new;
    $sprint->duplicate($opt{duplicate} // 1);
    $sprint->apply_config($config);
    $sprint->set_model($model);
    $sprint->process;
    
    # visualize toolpaths
    $Slic3r::ViewToolpaths::print = $sprint->_print;
    $Slic3r::ViewToolpaths::d3 = $opt{d3};
    my $app = Slic3r::ViewToolpaths->new;
    $app->MainLoop;
}


sub usage {
    my ($exit_code) = @_;
    
    print <<"EOF";
Usage: view-toolpaths.pl [ OPTIONS ] file.stl

    --help              Output this usage screen and exit
    --load CONFIG       Loads the supplied config file
    
EOF
    exit ($exit_code || 0);
}


package Slic3r::ViewToolpaths;
use Wx qw(:sizer);
use base qw(Wx::App Class::Accessor);

our $print;
our $d3;

sub OnInit {
    my $self = shift;
    
    my $frame = Wx::Frame->new(undef, -1, 'Toolpaths', [-1, -1], [500, 500]);
    my $panel = Wx::Panel->new($frame, -1);
    
    my $canvas;
    if ($d3) {
        $canvas = Slic3r::GUI::3DScene->new($panel);
        $canvas->set_bed_shape($print->config->bed_shape);
        $canvas->load_print_toolpaths($print);
        
        foreach my $object (@{$print->objects}) {
            #$canvas->load_print_object_slices($object);
            $canvas->load_print_object_toolpaths($object);
            #$canvas->load_object($object->model_object);
        }
        $canvas->zoom_to_volumes;
    } else {
        $canvas = Slic3r::GUI::Plater::2DToolpaths->new($panel, $print);
    }
    
    my $sizer = Wx::BoxSizer->new(wxVERTICAL);
    $sizer->Add($canvas, 1, wxEXPAND, 0);
    $panel->SetSizer($sizer);
    
    $frame->Show(1);
}

__END__