Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessandro Ranellucci <aar@cpan.org>2013-07-13 20:51:49 +0400
committerAlessandro Ranellucci <aar@cpan.org>2013-07-13 20:51:49 +0400
commitb709acf10f88561fc8f80f20e00b0ff81edf4819 (patch)
treeebc23beb9d8dfe9d8cb80f1eb25e61e337b3be79
parent98726fdef45263a8423e6b7ebe49c15dd26621d7 (diff)
New TriangleMesh::XS->stats method
-rw-r--r--xs/src/TriangleMesh.hpp1
-rw-r--r--xs/t/01_trianglemesh.t5
-rw-r--r--xs/xsp/TriangleMesh.xsp21
3 files changed, 25 insertions, 2 deletions
diff --git a/xs/src/TriangleMesh.hpp b/xs/src/TriangleMesh.hpp
index 90e98d90a..ec0869117 100644
--- a/xs/src/TriangleMesh.hpp
+++ b/xs/src/TriangleMesh.hpp
@@ -22,7 +22,6 @@ class TriangleMesh
void Repair();
void WriteOBJFile(char* output_file);
AV* ToPerl();
- private:
stl_file stl;
};
diff --git a/xs/t/01_trianglemesh.t b/xs/t/01_trianglemesh.t
index 8d3c5dd0d..306617238 100644
--- a/xs/t/01_trianglemesh.t
+++ b/xs/t/01_trianglemesh.t
@@ -4,7 +4,7 @@ use strict;
use warnings;
use Slic3r::XS;
-use Test::More tests => 3;
+use Test::More tests => 4;
is Slic3r::TriangleMesh::XS::hello_world(), 'Hello world!',
'hello world';
@@ -21,6 +21,9 @@ my $cube = {
my ($vertices, $facets) = @{$m->ToPerl};
is_deeply $vertices, $cube->{vertices}, 'vertices 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';
}
__END__
diff --git a/xs/xsp/TriangleMesh.xsp b/xs/xsp/TriangleMesh.xsp
index 6952dfdbd..a0e5d08f5 100644
--- a/xs/xsp/TriangleMesh.xsp
+++ b/xs/xsp/TriangleMesh.xsp
@@ -13,6 +13,27 @@
void Repair();
void WriteOBJFile(char* output_file);
AV* ToPerl();
+%{
+
+SV*
+TriangleMesh::stats()
+ CODE:
+ HV* hv = newHV();
+ (void)hv_stores( hv, "number_of_facets", newSViv(THIS->stl.stats.number_of_facets) );
+ (void)hv_stores( hv, "number_of_parts", newSViv(THIS->stl.stats.number_of_parts) );
+ (void)hv_stores( hv, "degenerate_facets", newSViv(THIS->stl.stats.degenerate_facets) );
+ (void)hv_stores( hv, "edges_fixed", newSViv(THIS->stl.stats.edges_fixed) );
+ (void)hv_stores( hv, "facets_removed", newSViv(THIS->stl.stats.facets_removed) );
+ (void)hv_stores( hv, "facets_added", newSViv(THIS->stl.stats.facets_added) );
+ (void)hv_stores( hv, "facets_reversed", newSViv(THIS->stl.stats.facets_reversed) );
+ (void)hv_stores( hv, "backwards_edges", newSViv(THIS->stl.stats.backwards_edges) );
+ (void)hv_stores( hv, "normals_fixed", newSViv(THIS->stl.stats.normals_fixed) );
+ (void)hv_stores( hv, "facets_reversed", newSViv(THIS->stl.stats.facets_reversed) );
+ RETVAL = (SV*)newRV_noinc((SV*)hv);
+ OUTPUT:
+ RETVAL
+
+%}
};
%package{Slic3r::TriangleMesh::XS};