mirror of
https://git.mirrors.martin98.com/https://github.com/SoftFever/OrcaSlicer.git
synced 2025-08-14 04:15:54 +08:00
Ported TriangleMesh->scale
This commit is contained in:
parent
a0bd152243
commit
515d5707c9
@ -102,4 +102,9 @@ TriangleMesh::WriteOBJFile(char* output_file) {
|
|||||||
stl_write_obj(&stl, output_file);
|
stl_write_obj(&stl, output_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TriangleMesh::scale(float factor)
|
||||||
|
{
|
||||||
|
stl_scale(&(this->stl), factor);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ class TriangleMesh
|
|||||||
void ReadFromPerl(SV* vertices, SV* facets);
|
void ReadFromPerl(SV* vertices, SV* facets);
|
||||||
void Repair();
|
void Repair();
|
||||||
void WriteOBJFile(char* output_file);
|
void WriteOBJFile(char* output_file);
|
||||||
|
void scale(float factor);
|
||||||
stl_file stl;
|
stl_file stl;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -106,6 +106,7 @@ stl_scale(stl_file *stl, float factor)
|
|||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
|
// scale extents
|
||||||
stl->stats.min.x *= factor;
|
stl->stats.min.x *= factor;
|
||||||
stl->stats.min.y *= factor;
|
stl->stats.min.y *= factor;
|
||||||
stl->stats.min.z *= factor;
|
stl->stats.min.z *= factor;
|
||||||
@ -113,6 +114,11 @@ stl_scale(stl_file *stl, float factor)
|
|||||||
stl->stats.max.y *= factor;
|
stl->stats.max.y *= factor;
|
||||||
stl->stats.max.z *= factor;
|
stl->stats.max.z *= factor;
|
||||||
|
|
||||||
|
// scale volume
|
||||||
|
if (stl->stats.volume > 0.0) {
|
||||||
|
stl->stats.volume *= (factor * factor * factor);
|
||||||
|
}
|
||||||
|
|
||||||
for(i = 0; i < stl->stats.number_of_facets; i++)
|
for(i = 0; i < stl->stats.number_of_facets; i++)
|
||||||
{
|
{
|
||||||
for(j = 0; j < 3; j++)
|
for(j = 0; j < 3; j++)
|
||||||
|
@ -4,7 +4,7 @@ use strict;
|
|||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
use Slic3r::XS;
|
use Slic3r::XS;
|
||||||
use Test::More tests => 5;
|
use Test::More tests => 6;
|
||||||
|
|
||||||
is Slic3r::TriangleMesh::XS::hello_world(), 'Hello world!',
|
is Slic3r::TriangleMesh::XS::hello_world(), 'Hello world!',
|
||||||
'hello world';
|
'hello world';
|
||||||
@ -23,9 +23,14 @@ my $cube = {
|
|||||||
is_deeply $vertices, $cube->{vertices}, 'vertices arrayref roundtrip';
|
is_deeply $vertices, $cube->{vertices}, 'vertices arrayref roundtrip';
|
||||||
is_deeply $facets, $cube->{facets}, 'facets arrayref roundtrip';
|
is_deeply $facets, $cube->{facets}, 'facets arrayref roundtrip';
|
||||||
|
|
||||||
my $stats = $m->stats;
|
{
|
||||||
is $stats->{number_of_facets}, scalar(@{ $cube->{facets} }), 'stats.number_of_facets';
|
my $stats = $m->stats;
|
||||||
ok abs($stats->{volume} - 20*20*20) < 1E-3, 'stats.volume';
|
is $stats->{number_of_facets}, scalar(@{ $cube->{facets} }), 'stats.number_of_facets';
|
||||||
|
ok abs($stats->{volume} - 20*20*20) < 1E-2, 'stats.volume';
|
||||||
|
}
|
||||||
|
|
||||||
|
$m->scale(2);
|
||||||
|
ok abs($m->stats->{volume} - 40*40*40) < 1E-2, 'scale';
|
||||||
}
|
}
|
||||||
|
|
||||||
__END__
|
__END__
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
void ReadFromPerl(SV* vertices, SV* facets);
|
void ReadFromPerl(SV* vertices, SV* facets);
|
||||||
void Repair();
|
void Repair();
|
||||||
void WriteOBJFile(char* output_file);
|
void WriteOBJFile(char* output_file);
|
||||||
|
void scale(float factor);
|
||||||
%{
|
%{
|
||||||
|
|
||||||
SV*
|
SV*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user