Make plater work with new XS code

This commit is contained in:
Alessandro Ranellucci 2013-09-11 20:00:51 +02:00
parent 4c96a52012
commit d4512a12df
4 changed files with 11 additions and 7 deletions

View File

@ -1271,9 +1271,8 @@ sub _trigger_model_object {
my $mesh = $model_object->mesh;
$mesh->repair;
$self->convex_hull(Slic3r::Polygon->new(@{Math::ConvexHull::MonotoneChain::convex_hull($mesh->vertices)}));
$self->facets(scalar @{$mesh->facets});
$self->facets($mesh->facets_count);
$self->vertices(scalar @{$mesh->vertices});
$self->materials($model_object->materials_count);
}
}

View File

@ -49,13 +49,14 @@ sub new {
color => COLORS->[ $color_idx % scalar(@{&COLORS}) ],
};
my ($vertices, $facets) = ($mesh->vertices, $mesh->facets);
{
my @verts = map @{ $mesh->vertices->[$_] }, map @$_, @{$mesh->facets};
my @verts = map @{ $vertices->[$_] }, map @$_, @$facets;
$v->{verts} = OpenGL::Array->new_list(GL_FLOAT, @verts);
}
{
my @norms = map { @$_, @$_, @$_ } map normalize(triangle_normal(map $mesh->vertices->[$_], @$_)), @{$mesh->facets};
my @norms = map { @$_, @$_, @$_ } map normalize(triangle_normal(map $vertices->[$_], @$_)), @$facets;
$v->{norms} = OpenGL::Array->new_list(GL_FLOAT, @norms);
}
}

View File

@ -11,6 +11,12 @@
namespace Slic3r {
TriangleMesh::TriangleMesh()
: repaired(false)
{
stl_initialize(&this->stl);
}
TriangleMesh::TriangleMesh(const TriangleMesh &other)
: stl(other.stl), repaired(other.repaired)
{
@ -64,7 +70,6 @@ TriangleMesh::write_binary(char* output_file)
void TriangleMesh::ReadFromPerl(SV* vertices, SV* facets)
{
stl_initialize(&stl);
stl.stats.type = inmemory;
// count facets and allocate memory
@ -559,7 +564,6 @@ TriangleMesh::split() const
TriangleMesh* mesh = new TriangleMesh;
meshes.push_back(mesh);
stl_initialize(&mesh->stl);
mesh->stl.stats.type = inmemory;
mesh->stl.stats.number_of_facets = facets.size();
mesh->stl.stats.original_num_facets = mesh->stl.stats.number_of_facets;

View File

@ -15,7 +15,7 @@ typedef std::vector<TriangleMesh*> TriangleMeshPtrs;
class TriangleMesh
{
public:
TriangleMesh() : repaired(false) {};
TriangleMesh();
TriangleMesh(const TriangleMesh &other);
~TriangleMesh();
SV* to_SV();