From f3259bb8999ba2340fb87526b190ceb108610ab5 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Wed, 20 Jul 2016 22:11:09 +0200 Subject: [PATCH] Fix regression in volume not being displayed in the GUI. #3431 --- lib/Slic3r/GUI/Plater.pm | 6 ++++-- xs/xsp/TriangleMesh.xsp | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index f10ca1314..fb1a36004 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -1640,8 +1640,10 @@ sub selection_changed { $self->{object_info_size}->SetLabel(sprintf("%.2f x %.2f x %.2f", @{$model_object->instance_bounding_box(0)->size})); $self->{object_info_materials}->SetLabel($model_object->materials_count); - if (my $stats = $model_object->raw_mesh->stats) { - $self->{object_info_volume}->SetLabel(sprintf('%.2f', $stats->{volume} * ($model_instance->scaling_factor**3))); + my $raw_mesh = $model_object->raw_mesh; + $raw_mesh->repair; # this calculates number_of_parts + if (my $stats = $raw_mesh->stats) { + $self->{object_info_volume}->SetLabel(sprintf('%.2f', $raw_mesh->volume * ($model_instance->scaling_factor**3))); $self->{object_info_facets}->SetLabel(sprintf('%d (%d shells)', $model_object->facets_count, $stats->{number_of_parts})); if (my $errors = sum(@$stats{qw(degenerate_facets edges_fixed facets_removed facets_added facets_reversed backwards_edges)})) { $self->{object_info_manifold}->SetLabel(sprintf("Auto-repaired (%d errors)", $errors)); diff --git a/xs/xsp/TriangleMesh.xsp b/xs/xsp/TriangleMesh.xsp index 7c13cb7f4..3b8f1022c 100644 --- a/xs/xsp/TriangleMesh.xsp +++ b/xs/xsp/TriangleMesh.xsp @@ -13,7 +13,9 @@ void ReadSTLFile(std::string input_file); void write_ascii(std::string output_file); void write_binary(std::string output_file); + void check_topology(); void repair(); + float volume(); void WriteOBJFile(std::string output_file); void scale(float factor); void scale_xyz(Pointf3* versor)