New automatic built-in STL repair
This commit is contained in:
parent
f62896a77a
commit
2a2633da0a
7 changed files with 131 additions and 9 deletions
|
@ -26,6 +26,7 @@ use constant MI_QUICK_SLICE => &Wx::NewId;
|
|||
use constant MI_REPEAT_QUICK => &Wx::NewId;
|
||||
use constant MI_QUICK_SAVE_AS => &Wx::NewId;
|
||||
use constant MI_SLICE_SVG => &Wx::NewId;
|
||||
use constant MI_REPAIR_STL => &Wx::NewId;
|
||||
use constant MI_COMBINE_STLS => &Wx::NewId;
|
||||
|
||||
use constant MI_PLATER_EXPORT_GCODE => &Wx::NewId;
|
||||
|
@ -112,6 +113,7 @@ sub OnInit {
|
|||
$fileMenu->AppendSeparator();
|
||||
$fileMenu->Append(MI_SLICE_SVG, "Slice to SV&G…\tCtrl+G", 'Slice file to SVG');
|
||||
$fileMenu->AppendSeparator();
|
||||
$fileMenu->Append(MI_REPAIR_STL, "Repair STL file…", 'Automatically repair an STL file');
|
||||
$fileMenu->Append(MI_COMBINE_STLS, "Combine multi-material STL files…", 'Combine multiple STL files into a single multi-material AMF file');
|
||||
$fileMenu->AppendSeparator();
|
||||
$fileMenu->Append(wxID_PREFERENCES, "Preferences…", 'Application preferences');
|
||||
|
@ -125,6 +127,7 @@ sub OnInit {
|
|||
EVT_MENU($frame, MI_QUICK_SAVE_AS, sub { $self->{skeinpanel}->quick_slice(save_as => 1);
|
||||
$repeat->Enable(defined $Slic3r::GUI::SkeinPanel::last_input_file) });
|
||||
EVT_MENU($frame, MI_SLICE_SVG, sub { $self->{skeinpanel}->quick_slice(save_as => 1, export_svg => 1) });
|
||||
EVT_MENU($frame, MI_REPAIR_STL, sub { $self->{skeinpanel}->repair_stl });
|
||||
EVT_MENU($frame, MI_COMBINE_STLS, sub { $self->{skeinpanel}->combine_stls });
|
||||
EVT_MENU($frame, wxID_PREFERENCES, sub { Slic3r::GUI::Preferences->new($frame)->ShowModal });
|
||||
EVT_MENU($frame, wxID_EXIT, sub {$_[0]->Close(0)});
|
||||
|
|
|
@ -192,6 +192,38 @@ sub quick_slice {
|
|||
Slic3r::GUI::catch_error($self, sub { $process_dialog->Destroy if $process_dialog });
|
||||
}
|
||||
|
||||
sub repair_stl {
|
||||
my $self = shift;
|
||||
|
||||
my $input_file;
|
||||
{
|
||||
my $dir = $Slic3r::GUI::Settings->{recent}{skein_directory} || $Slic3r::GUI::Settings->{recent}{config_directory} || '';
|
||||
my $dialog = Wx::FileDialog->new($self, 'Select the STL file to repair:', $dir, "", FILE_WILDCARDS->{stl}, wxFD_OPEN | wxFD_FILE_MUST_EXIST);
|
||||
if ($dialog->ShowModal != wxID_OK) {
|
||||
$dialog->Destroy;
|
||||
return;
|
||||
}
|
||||
$input_file = $dialog->GetPaths;
|
||||
$dialog->Destroy;
|
||||
}
|
||||
|
||||
my $output_file = $input_file;
|
||||
{
|
||||
$output_file =~ s/\.stl$/_fixed.obj/i;
|
||||
my $dlg = Wx::FileDialog->new($self, "Save OBJ file (less prone to coordinate errors than STL) as:", dirname($output_file),
|
||||
basename($output_file), &Slic3r::GUI::SkeinPanel::FILE_WILDCARDS->{obj}, wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
||||
if ($dlg->ShowModal != wxID_OK) {
|
||||
$dlg->Destroy;
|
||||
return undef;
|
||||
}
|
||||
$output_file = $dlg->GetPath;
|
||||
$dlg->Destroy;
|
||||
}
|
||||
|
||||
Slic3r::TriangleMesh::XS::stl_repair($input_file, $output_file);
|
||||
Slic3r::GUI::show_info($self, "Your file was repaired.", "Repair");
|
||||
}
|
||||
|
||||
sub init_print {
|
||||
my $self = shift;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue