diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 0b850ac6a..a83f4c053 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -1271,9 +1271,8 @@ sub _trigger_model_object { my $mesh = $model_object->mesh; $mesh->repair; $self->convex_hull(Slic3r::Polygon->new(@{Math::ConvexHull::MonotoneChain::convex_hull($mesh->vertices)})); - $self->facets(scalar @{$mesh->facets}); + $self->facets($mesh->facets_count); $self->vertices(scalar @{$mesh->vertices}); - $self->materials($model_object->materials_count); } } diff --git a/lib/Slic3r/GUI/PreviewCanvas.pm b/lib/Slic3r/GUI/PreviewCanvas.pm index 6bad5552e..2cfa1c4e9 100644 --- a/lib/Slic3r/GUI/PreviewCanvas.pm +++ b/lib/Slic3r/GUI/PreviewCanvas.pm @@ -49,13 +49,14 @@ sub new { color => COLORS->[ $color_idx % scalar(@{&COLORS}) ], }; + my ($vertices, $facets) = ($mesh->vertices, $mesh->facets); { - my @verts = map @{ $mesh->vertices->[$_] }, map @$_, @{$mesh->facets}; + my @verts = map @{ $vertices->[$_] }, map @$_, @$facets; $v->{verts} = OpenGL::Array->new_list(GL_FLOAT, @verts); } { - my @norms = map { @$_, @$_, @$_ } map normalize(triangle_normal(map $mesh->vertices->[$_], @$_)), @{$mesh->facets}; + my @norms = map { @$_, @$_, @$_ } map normalize(triangle_normal(map $vertices->[$_], @$_)), @$facets; $v->{norms} = OpenGL::Array->new_list(GL_FLOAT, @norms); } } diff --git a/xs/src/TriangleMesh.cpp b/xs/src/TriangleMesh.cpp index 81cebb7d8..db7120689 100644 --- a/xs/src/TriangleMesh.cpp +++ b/xs/src/TriangleMesh.cpp @@ -11,6 +11,12 @@ namespace Slic3r { +TriangleMesh::TriangleMesh() + : repaired(false) +{ + stl_initialize(&this->stl); +} + TriangleMesh::TriangleMesh(const TriangleMesh &other) : stl(other.stl), repaired(other.repaired) { @@ -64,7 +70,6 @@ TriangleMesh::write_binary(char* output_file) void TriangleMesh::ReadFromPerl(SV* vertices, SV* facets) { - stl_initialize(&stl); stl.stats.type = inmemory; // count facets and allocate memory @@ -559,7 +564,6 @@ TriangleMesh::split() const TriangleMesh* mesh = new TriangleMesh; meshes.push_back(mesh); - stl_initialize(&mesh->stl); mesh->stl.stats.type = inmemory; mesh->stl.stats.number_of_facets = facets.size(); mesh->stl.stats.original_num_facets = mesh->stl.stats.number_of_facets; diff --git a/xs/src/TriangleMesh.hpp b/xs/src/TriangleMesh.hpp index 30729bf63..c8bec55e0 100644 --- a/xs/src/TriangleMesh.hpp +++ b/xs/src/TriangleMesh.hpp @@ -15,7 +15,7 @@ typedef std::vector TriangleMeshPtrs; class TriangleMesh { public: - TriangleMesh() : repaired(false) {}; + TriangleMesh(); TriangleMesh(const TriangleMesh &other); ~TriangleMesh(); SV* to_SV();