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
path: root/xs
diff options
context:
space:
mode:
authorAlessandro Ranellucci <aar@cpan.org>2013-07-13 21:00:38 +0400
committerAlessandro Ranellucci <aar@cpan.org>2013-07-13 21:00:38 +0400
commit00683195c85c1479d15c1792179eba1149dcc36d (patch)
tree66f97bebb4c75713581d632edd7ca1f1d12158e1 /xs
parentb709acf10f88561fc8f80f20e00b0ff81edf4819 (diff)
Add two more repair actions and add volume to stats
Diffstat (limited to 'xs')
-rw-r--r--xs/src/TriangleMesh.cpp6
-rw-r--r--xs/t/01_trianglemesh.t3
-rw-r--r--xs/xsp/TriangleMesh.xsp1
3 files changed, 9 insertions, 1 deletions
diff --git a/xs/src/TriangleMesh.cpp b/xs/src/TriangleMesh.cpp
index 546a2dfe5..901bdfa47 100644
--- a/xs/src/TriangleMesh.cpp
+++ b/xs/src/TriangleMesh.cpp
@@ -88,6 +88,12 @@ TriangleMesh::Repair() {
// normal_values
stl_fix_normal_values(&stl);
+
+ // always calculate the volume and reverse all normals if volume is negative
+ stl_calculate_volume(&stl);
+
+ // neighbors
+ stl_verify_neighbors(&stl);
}
void
diff --git a/xs/t/01_trianglemesh.t b/xs/t/01_trianglemesh.t
index 306617238..42ed11145 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 => 4;
+use Test::More tests => 5;
is Slic3r::TriangleMesh::XS::hello_world(), 'Hello world!',
'hello world';
@@ -24,6 +24,7 @@ my $cube = {
my $stats = $m->stats;
is $stats->{number_of_facets}, scalar(@{ $cube->{facets} }), 'stats.number_of_facets';
+ ok abs($stats->{volume} - 20*20*20) < 1E-3, 'stats.volume';
}
__END__
diff --git a/xs/xsp/TriangleMesh.xsp b/xs/xsp/TriangleMesh.xsp
index a0e5d08f5..e053102c7 100644
--- a/xs/xsp/TriangleMesh.xsp
+++ b/xs/xsp/TriangleMesh.xsp
@@ -21,6 +21,7 @@ TriangleMesh::stats()
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, "volume", newSVnv(THIS->stl.stats.volume) );
(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) );