mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-11-02 04:31:17 -07:00
Replace TriangleMesh with the XS port
This commit is contained in:
parent
311eda7d42
commit
566d38a472
14 changed files with 77 additions and 256 deletions
|
|
@ -16,14 +16,22 @@ TriangleMesh::TriangleMesh(const TriangleMesh &other)
|
|||
{
|
||||
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)
|
||||
if (other.stl.facet_start != NULL) {
|
||||
this->stl.facet_start = new stl_facet[other.stl.stats.number_of_facets];
|
||||
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) {
|
||||
this->stl.neighbors_start = new stl_neighbors[other.stl.stats.number_of_facets];
|
||||
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);
|
||||
}
|
||||
if (other.stl.v_indices != NULL) {
|
||||
this->stl.v_indices = new v_indices_struct[other.stl.stats.number_of_facets];
|
||||
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) {
|
||||
this->stl.v_shared = new stl_vertex[other.stl.stats.shared_vertices];
|
||||
std::copy(other.stl.v_shared, other.stl.v_shared + other.stl.stats.shared_vertices, this->stl.v_shared);
|
||||
}
|
||||
}
|
||||
|
||||
TriangleMesh::~TriangleMesh() {
|
||||
|
|
@ -33,7 +41,7 @@ TriangleMesh::~TriangleMesh() {
|
|||
SV*
|
||||
TriangleMesh::to_SV() {
|
||||
SV* sv = newSV(0);
|
||||
sv_setref_pv( sv, "Slic3r::TriangleMesh::XS", (void*)this );
|
||||
sv_setref_pv( sv, "Slic3r::TriangleMesh", (void*)this );
|
||||
return sv;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ use strict;
|
|||
use warnings;
|
||||
|
||||
use Slic3r::XS;
|
||||
use Test::More tests => 49;
|
||||
use Test::More tests => 50;
|
||||
|
||||
is Slic3r::TriangleMesh::XS::hello_world(), 'Hello world!',
|
||||
is Slic3r::TriangleMesh::hello_world(), 'Hello world!',
|
||||
'hello world';
|
||||
|
||||
my $cube = {
|
||||
|
|
@ -15,7 +15,7 @@ my $cube = {
|
|||
};
|
||||
|
||||
{
|
||||
my $m = Slic3r::TriangleMesh::XS->new;
|
||||
my $m = Slic3r::TriangleMesh->new;
|
||||
$m->ReadFromPerl($cube->{vertices}, $cube->{facets});
|
||||
$m->repair;
|
||||
my ($vertices, $facets) = ($m->vertices, $m->facets);
|
||||
|
|
@ -23,6 +23,13 @@ my $cube = {
|
|||
is_deeply $vertices, $cube->{vertices}, 'vertices arrayref roundtrip';
|
||||
is_deeply $facets, $cube->{facets}, 'facets arrayref roundtrip';
|
||||
|
||||
{
|
||||
my $m2 = $m->clone;
|
||||
is_deeply $m2->vertices, $cube->{vertices}, 'cloned vertices arrayref roundtrip';
|
||||
is_deeply $m2->facets, $cube->{facets}, 'cloned facets arrayref roundtrip';
|
||||
$m2->scale(3); # check that it does not affect $m
|
||||
}
|
||||
|
||||
{
|
||||
my $stats = $m->stats;
|
||||
is $stats->{number_of_facets}, scalar(@{ $cube->{facets} }), 'stats.number_of_facets';
|
||||
|
|
@ -32,11 +39,6 @@ my $cube = {
|
|||
$m->scale(2);
|
||||
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]);
|
||||
ok abs($m->stats->{volume} - 2*40*40*40) < 1E-2, 'scale_xyz';
|
||||
|
||||
|
|
@ -55,10 +57,10 @@ my $cube = {
|
|||
{
|
||||
my $meshes = $m->split;
|
||||
is scalar(@$meshes), 1, 'split';
|
||||
isa_ok $meshes->[0], 'Slic3r::TriangleMesh::XS', 'split';
|
||||
isa_ok $meshes->[0], 'Slic3r::TriangleMesh', 'split';
|
||||
}
|
||||
|
||||
my $m2 = Slic3r::TriangleMesh::XS->new;
|
||||
my $m2 = Slic3r::TriangleMesh->new;
|
||||
$m2->ReadFromPerl($cube->{vertices}, $cube->{facets});
|
||||
$m2->repair;
|
||||
$m->merge($m2);
|
||||
|
|
@ -72,7 +74,7 @@ my $cube = {
|
|||
}
|
||||
|
||||
{
|
||||
my $m = Slic3r::TriangleMesh::XS->new;
|
||||
my $m = Slic3r::TriangleMesh->new;
|
||||
$m->ReadFromPerl($cube->{vertices}, $cube->{facets});
|
||||
$m->repair;
|
||||
my @z = (2,4,8,6,8,10,12,14,16,18,20);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#include "TriangleMesh.hpp"
|
||||
%}
|
||||
|
||||
%name{Slic3r::TriangleMesh::XS} class TriangleMesh {
|
||||
%name{Slic3r::TriangleMesh} class TriangleMesh {
|
||||
TriangleMesh();
|
||||
~TriangleMesh();
|
||||
TriangleMesh* clone()
|
||||
|
|
@ -127,7 +127,7 @@ TriangleMesh::slice(z)
|
|||
%}
|
||||
};
|
||||
|
||||
%package{Slic3r::TriangleMesh::XS};
|
||||
%package{Slic3r::TriangleMesh};
|
||||
|
||||
%{
|
||||
PROTOTYPES: DISABLE
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue