mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-07-30 08:32:02 +08:00
reinstate old testing plus transformation test
This commit is contained in:
parent
ad7a1696f0
commit
00b836b3da
@ -18,7 +18,6 @@ my $cube = {
|
||||
|
||||
{
|
||||
my $m = Slic3r::TriangleMesh->new;
|
||||
my $trafo = Slic3r::TransformationMatrix->new;
|
||||
$m->ReadFromPerl($cube->{vertices}, $cube->{facets});
|
||||
$m->repair;
|
||||
my ($vertices, $facets) = ($m->vertices, $m->facets);
|
||||
@ -31,10 +30,9 @@ my $cube = {
|
||||
my $m2 = $m->clone;
|
||||
is_deeply $m2->vertices, $cube->{vertices}, 'cloned vertices arrayref roundtrip';
|
||||
is_deeply $m2->facets, $cube->{facets}, 'cloned facets arrayref roundtrip';
|
||||
# check that it does not affect $m
|
||||
$trafo->set_scale_uni(3);
|
||||
$m2->transform($trafo);
|
||||
$m2->scale(3); # check that it does not affect $m
|
||||
ok $m2->stats->{volume} != $m->stats->{volume}, 'cloned transform not affecting original'
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
@ -43,9 +41,23 @@ my $cube = {
|
||||
ok abs($stats->{volume} - 20*20*20) < 1E-2, 'stats.volume';
|
||||
}
|
||||
|
||||
$trafo->set_scale_uni(2);
|
||||
$m->transform($trafo);
|
||||
ok abs($m->stats->{volume} - 40*40*40) < 1E-2, 'transform';
|
||||
$m->scale(2);
|
||||
ok abs($m->stats->{volume} - 40*40*40) < 1E-2, 'scale';
|
||||
|
||||
$m->scale_xyz(Slic3r::Pointf3->new(2,1,1));
|
||||
ok abs($m->stats->{volume} - 2*40*40*40) < 1E-2, 'scale_xyz';
|
||||
|
||||
$m->translate(5,10,0);
|
||||
is_deeply $m->vertices->[0], [85,50,0], 'translate';
|
||||
|
||||
$m->align_to_origin;
|
||||
is_deeply $m->vertices->[2], [0,0,0], 'align_to_origin';
|
||||
|
||||
is_deeply $m->size, [80,40,40], 'size';
|
||||
|
||||
$m->scale_xyz(Slic3r::Pointf3->new(0.5,1,1));
|
||||
$m->rotate(45, Slic3r::Point->new(20,20));
|
||||
ok abs($m->size->[0] - sqrt(2)*40) < 1E-4, 'rotate';
|
||||
|
||||
{
|
||||
my $meshes = $m->split;
|
||||
@ -67,6 +79,19 @@ my $cube = {
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
my $m = Slic3r::TriangleMesh->new;
|
||||
$m->ReadFromPerl($cube->{vertices}, $cube->{facets});
|
||||
$m->repair;
|
||||
|
||||
my $trafo = Slic3r::TransformationMatrix->new;
|
||||
$trafo->set_scale_uni(2);
|
||||
|
||||
$m->transform($trafo);
|
||||
|
||||
ok abs($m->stats->{volume} - 40*40*40) < 1E-2, 'general purpose transformation';
|
||||
}
|
||||
|
||||
{
|
||||
my $m = Slic3r::TriangleMesh->new;
|
||||
$m->ReadFromPerl($cube->{vertices}, $cube->{facets});
|
||||
@ -92,9 +117,7 @@ my $cube = {
|
||||
my $slices = $m->slice([ 5, 10 ]);
|
||||
is $slices->[0][0]->area, $slices->[1][0]->area, 'slicing a top tangent plane includes its area';
|
||||
}
|
||||
my $trafo = Slic3r::TransformationMatrix->new;
|
||||
$trafo->set_mirror_xyz(Z);
|
||||
$m->transform($trafo);
|
||||
$m->mirror_z;
|
||||
{
|
||||
# this second test also checks that performing a second slice on a mesh after
|
||||
# a transformation works properly (shared_vertices is correctly invalidated);
|
||||
|
Loading…
x
Reference in New Issue
Block a user