Show repair stats in object info dialog

This commit is contained in:
Alessandro Ranellucci 2013-07-13 20:23:03 +02:00
parent 00683195c8
commit 6affa23297
5 changed files with 28 additions and 6 deletions

View file

@ -13,7 +13,7 @@ sub read_file {
my ($vertices, $facets) = @{$tmesh->ToPerl};
my $model = Slic3r::Model->new;
my $object = $model->add_object(vertices => $vertices);
my $object = $model->add_object(vertices => $vertices, mesh_stats => $tmesh->stats);
my $volume = $object->add_volume(facets => $facets);
return $model;
}

View file

@ -317,6 +317,7 @@ sub load_file {
input_file => $input_file,
input_file_object_id => $i,
model_object => $model->objects->[$i],
mesh_stats => $model->objects->[$i]->mesh_stats, # so that we can free model_object
instances => [
$model->objects->[$i]->instances
? (map $_->offset, @{$model->objects->[$i]->instances})
@ -1084,6 +1085,7 @@ has 'thumbnail' => (is => 'rw', trigger => \&_transform_thumbnail);
has 'transformed_thumbnail' => (is => 'rw');
has 'thumbnail_scaling_factor' => (is => 'rw', trigger => \&_transform_thumbnail);
has 'layer_height_ranges' => (is => 'rw', default => sub { [] }); # [ z_min, z_max, layer_height ]
has 'mesh_stats' => (is => 'rw');
# statistics
has 'facets' => (is => 'rw');

View file

@ -10,7 +10,7 @@ use base 'Wx::Dialog';
sub new {
my $class = shift;
my ($parent, %params) = @_;
my $self = $class->SUPER::new($parent, -1, "Object", wxDefaultPosition, [500,350], wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
my $self = $class->SUPER::new($parent, -1, "Object", wxDefaultPosition, [500,500], wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
$self->{object} = $params{object};
$self->{tabpanel} = Wx::Notebook->new($self, -1, wxDefaultPosition, wxDefaultSize, wxNB_TOP | wxTAB_TRAVERSAL);
@ -50,7 +50,7 @@ sub new {
my $self = $class->SUPER::new($parent, -1, wxDefaultPosition, wxDefaultSize);
$self->{object} = $params{object};
my $grid_sizer = Wx::FlexGridSizer->new(3, 2, 10, 5);
my $grid_sizer = Wx::FlexGridSizer->new(3, 2, 5, 5);
$grid_sizer->SetFlexibleDirection(wxHORIZONTAL);
$grid_sizer->AddGrowableCol(1);
@ -76,14 +76,34 @@ sub get_properties {
my $self = shift;
my $object = $self->{object};
return [
my $properties = [
['Name' => $object->name],
['Size' => sprintf "%.2f x %.2f x %.2f", @{$object->transformed_size}],
['Facets' => $object->facets],
['Vertices' => $object->vertices],
['Materials' => $object->materials],
['Two-Manifold' => $object->is_manifold ? 'Yes' : 'No'],
];
if (my $stats = $object->mesh_stats) {
push @$properties,
[ 'Shells' => $stats->{number_of_parts} ],
[ 'Volume' => sprintf('%.2f', $stats->{volume} * ($object->scale**3)) ],
[ 'Degenerate facets' => $stats->{degenerate_facets} ],
[ 'Edges fixed' => $stats->{edges_fixed} ],
[ 'Facets removed' => $stats->{facets_removed} ],
[ 'Facets added' => $stats->{facets_added} ],
[ 'Facets reversed' => $stats->{facets_reversed} ],
[ 'Backwards edges' => $stats->{backwards_edges} ],
# we don't show normals_fixed because we never provide normals
# to admesh, so it generates normals for all facets
;
} else {
push @$properties,
['Two-Manifold' => $object->is_manifold ? 'Yes' : 'No'],
;
}
return $properties;
}
package Slic3r::GUI::Plater::ObjectDialog::PreviewTab;

View file

@ -297,6 +297,7 @@ has 'vertices' => (is => 'ro', default => sub { [] });
has 'volumes' => (is => 'ro', default => sub { [] });
has 'instances' => (is => 'rw');
has 'layer_height_ranges' => (is => 'rw', default => sub { [] }); # [ z_min, z_max, layer_height ]
has 'mesh_stats' => (is => 'rw');
has '_bounding_box' => (is => 'rw');
sub add_volume {

View file

@ -29,7 +29,6 @@ TriangleMesh::stats()
(void)hv_stores( hv, "facets_reversed", newSViv(THIS->stl.stats.facets_reversed) );
(void)hv_stores( hv, "backwards_edges", newSViv(THIS->stl.stats.backwards_edges) );
(void)hv_stores( hv, "normals_fixed", newSViv(THIS->stl.stats.normals_fixed) );
(void)hv_stores( hv, "facets_reversed", newSViv(THIS->stl.stats.facets_reversed) );
RETVAL = (SV*)newRV_noinc((SV*)hv);
OUTPUT:
RETVAL