diff --git a/MANIFEST b/MANIFEST index 02faef124..ca9cacc02 100644 --- a/MANIFEST +++ b/MANIFEST @@ -71,6 +71,7 @@ t/cooling.t t/custom_gcode.t t/dynamic.t t/fill.t +t/freeze.t t/gcode.t t/geometry.t t/layers.t diff --git a/lib/Slic3r/Test.pm b/lib/Slic3r/Test.pm index a8bcd2426..dcb95d130 100644 --- a/lib/Slic3r/Test.pm +++ b/lib/Slic3r/Test.pm @@ -57,9 +57,15 @@ sub model { ], } + my $mesh = Slic3r::TriangleMesh->new( + vertices => $vertices, + facets => $facets, + ); + $mesh->scale($params{scale}) if $params{scale}; + my $model = Slic3r::Model->new; - my $object = $model->add_object(vertices => $vertices); - $object->add_volume(facets => $facets); + my $object = $model->add_object(vertices => $mesh->vertices); + $object->add_volume(facets => $mesh->facets); $object->add_instance( offset => [0,0], rotation => $params{rotation} // 0, diff --git a/t/freeze.t b/t/freeze.t new file mode 100644 index 000000000..f48cf04c8 --- /dev/null +++ b/t/freeze.t @@ -0,0 +1,29 @@ +use Test::More tests => 1; +use strict; +use warnings; + +BEGIN { + use FindBin; + use lib "$FindBin::Bin/../lib"; +} + +use Slic3r; +use Slic3r::Test; +use Storable qw(nstore retrieve); +use Time::HiRes qw(gettimeofday tv_interval); + +{ + my $t0 = [gettimeofday]; + my $print = Slic3r::Test::init_print('20mm_cube', scale => 2); + my $gcode = Slic3r::Test::gcode($print); + diag sprintf 'Slicing took %s seconds', tv_interval($t0); + + my $t1 = [gettimeofday]; + nstore $print, 'print.dat'; + $print = retrieve 'print.dat'; + diag sprintf 'Freezing and retrieving took %s seconds', tv_interval($t1); + + isa_ok $print, 'Slic3r::Print', 'restored Print object'; +} + +__END__