From 48e0caa4ffc44b78e0400b1b9bcd0b6b16d188b5 Mon Sep 17 00:00:00 2001 From: Michael Kirsch Date: Mon, 27 May 2019 21:51:05 +0200 Subject: [PATCH] change perl function to use mesh initalized in perl --- lib/Slic3r/GUI/3DScene.pm | 5 ++++- xs/src/libslic3r/Model.hpp | 2 -- xs/xsp/Model.xsp | 5 ++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index a71a65277..4247d9df5 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -1331,7 +1331,10 @@ sub load_object { my $volume = $model_object->volumes->[$volume_idx]; foreach my $instance_idx (@$instance_idxs) { my $instance = $model_object->instances->[$instance_idx]; - my $mesh = $volume->transformed_mesh($instance); + my $mesh = Slic3r::TriangleMesh->new(); + + # $mesh is the output argument, given as pointer + $volume->transformed_mesh($instance, $mesh); my $color_idx; if ($self->color_by eq 'volume') { diff --git a/xs/src/libslic3r/Model.hpp b/xs/src/libslic3r/Model.hpp index 6360454ec..96bff8ed3 100644 --- a/xs/src/libslic3r/Model.hpp +++ b/xs/src/libslic3r/Model.hpp @@ -470,8 +470,6 @@ class ModelVolume DynamicPrintConfig config; ///< Configuration parameters specific to an object model geometry or a modifier volume, ///< overriding the global Slic3r settings and the ModelObject settings. - - TriangleMesh transformed_mesh; ///< The transformed mesh only to be used by the perl binding /// Input file path needed for reloading the volume from disk std::string input_file; ///< Input file path diff --git a/xs/xsp/Model.xsp b/xs/xsp/Model.xsp index fab5bdcc3..735bd92b1 100644 --- a/xs/xsp/Model.xsp +++ b/xs/xsp/Model.xsp @@ -301,11 +301,10 @@ ModelMaterial::attributes() Ref mesh() %code%{ RETVAL = &THIS->mesh; %}; - Ref transformed_mesh(ModelInstance * instance) + void transformed_mesh(ModelInstance * instance, TriangleMesh * mesh) %code%{ TransformationMatrix trafo = instance->get_trafo_matrix(false); - THIS->transformed_mesh = THIS->get_transformed_mesh(&trafo); - RETVAL = &THIS->transformed_mesh; + *(mesh) = THIS->get_transformed_mesh(&trafo); %}; bool modifier()