Implemented TriangleMesh->clone
This commit is contained in:
parent
9b12d6037a
commit
311eda7d42
@ -11,8 +11,23 @@
|
|||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
|
TriangleMesh::TriangleMesh(const TriangleMesh &other)
|
||||||
|
: stl(other.stl), repaired(other.repaired)
|
||||||
|
{
|
||||||
|
this->stl.heads = NULL;
|
||||||
|
this->stl.tail = NULL;
|
||||||
|
if (other.stl.facet_start != NULL)
|
||||||
|
std::copy(other.stl.facet_start, other.stl.facet_start + other.stl.stats.number_of_facets, this->stl.facet_start);
|
||||||
|
if (other.stl.neighbors_start != NULL)
|
||||||
|
std::copy(other.stl.neighbors_start, other.stl.neighbors_start + other.stl.stats.number_of_facets, this->stl.neighbors_start);
|
||||||
|
if (other.stl.v_indices != NULL)
|
||||||
|
std::copy(other.stl.v_indices, other.stl.v_indices + other.stl.stats.number_of_facets, this->stl.v_indices);
|
||||||
|
if (other.stl.v_shared != NULL)
|
||||||
|
std::copy(other.stl.v_shared, other.stl.v_shared + other.stl.stats.shared_vertices, this->stl.v_shared);
|
||||||
|
}
|
||||||
|
|
||||||
TriangleMesh::~TriangleMesh() {
|
TriangleMesh::~TriangleMesh() {
|
||||||
stl_close(&stl);
|
stl_close(&this->stl);
|
||||||
}
|
}
|
||||||
|
|
||||||
SV*
|
SV*
|
||||||
|
@ -16,6 +16,7 @@ class TriangleMesh
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TriangleMesh() : repaired(false) {};
|
TriangleMesh() : repaired(false) {};
|
||||||
|
TriangleMesh(const TriangleMesh &other);
|
||||||
~TriangleMesh();
|
~TriangleMesh();
|
||||||
SV* to_SV();
|
SV* to_SV();
|
||||||
void ReadSTLFile(char* input_file);
|
void ReadSTLFile(char* input_file);
|
||||||
|
@ -4,7 +4,7 @@ use strict;
|
|||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
use Slic3r::XS;
|
use Slic3r::XS;
|
||||||
use Test::More tests => 48;
|
use Test::More tests => 49;
|
||||||
|
|
||||||
is Slic3r::TriangleMesh::XS::hello_world(), 'Hello world!',
|
is Slic3r::TriangleMesh::XS::hello_world(), 'Hello world!',
|
||||||
'hello world';
|
'hello world';
|
||||||
@ -32,6 +32,11 @@ my $cube = {
|
|||||||
$m->scale(2);
|
$m->scale(2);
|
||||||
ok abs($m->stats->{volume} - 40*40*40) < 1E-2, 'scale';
|
ok abs($m->stats->{volume} - 40*40*40) < 1E-2, 'scale';
|
||||||
|
|
||||||
|
{
|
||||||
|
my $m2 = $m->clone;
|
||||||
|
ok abs($m->stats->{volume} - 40*40*40) < 1E-2, 'scale';
|
||||||
|
}
|
||||||
|
|
||||||
$m->scale_xyz([2,1,1]);
|
$m->scale_xyz([2,1,1]);
|
||||||
ok abs($m->stats->{volume} - 2*40*40*40) < 1E-2, 'scale_xyz';
|
ok abs($m->stats->{volume} - 2*40*40*40) < 1E-2, 'scale_xyz';
|
||||||
|
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
%name{Slic3r::TriangleMesh::XS} class TriangleMesh {
|
%name{Slic3r::TriangleMesh::XS} class TriangleMesh {
|
||||||
TriangleMesh();
|
TriangleMesh();
|
||||||
~TriangleMesh();
|
~TriangleMesh();
|
||||||
|
TriangleMesh* clone()
|
||||||
|
%code{% const char* CLASS = "Slic3r::TriangleMesh"; RETVAL = new TriangleMesh(*THIS); %};
|
||||||
void ReadSTLFile(char* input_file);
|
void ReadSTLFile(char* input_file);
|
||||||
void ReadFromPerl(SV* vertices, SV* facets);
|
void ReadFromPerl(SV* vertices, SV* facets);
|
||||||
void repair();
|
void repair();
|
||||||
|
Loading…
Reference in New Issue
Block a user