2013-06-23 13:33:07 +00:00
|
|
|
%module{Slic3r::XS};
|
2013-06-24 17:35:49 +00:00
|
|
|
|
|
|
|
%{
|
|
|
|
#include <myinit.h>
|
2013-07-06 13:26:32 +00:00
|
|
|
#include "TriangleMesh.hpp"
|
2013-06-24 17:35:49 +00:00
|
|
|
%}
|
|
|
|
|
|
|
|
%name{Slic3r::TriangleMesh::XS} class TriangleMesh {
|
|
|
|
TriangleMesh();
|
|
|
|
~TriangleMesh();
|
|
|
|
void ReadSTLFile(char* input_file);
|
2013-07-03 09:38:01 +00:00
|
|
|
void ReadFromPerl(SV* vertices, SV* facets);
|
2013-06-24 17:35:49 +00:00
|
|
|
void Repair();
|
|
|
|
void WriteOBJFile(char* output_file);
|
2013-08-04 19:34:26 +00:00
|
|
|
void scale(float factor);
|
2013-08-05 08:48:38 +00:00
|
|
|
void translate(float x, float y, float z);
|
2013-08-05 17:22:33 +00:00
|
|
|
void align_to_origin();
|
2013-08-05 17:52:37 +00:00
|
|
|
void rotate(double angle, Point* center);
|
2013-07-13 16:51:49 +00:00
|
|
|
%{
|
|
|
|
|
|
|
|
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) );
|
2013-07-13 17:00:38 +00:00
|
|
|
(void)hv_stores( hv, "volume", newSVnv(THIS->stl.stats.volume) );
|
2013-07-13 16:51:49 +00:00
|
|
|
(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) );
|
|
|
|
RETVAL = (SV*)newRV_noinc((SV*)hv);
|
|
|
|
OUTPUT:
|
|
|
|
RETVAL
|
|
|
|
|
2013-08-04 19:23:27 +00:00
|
|
|
SV*
|
|
|
|
TriangleMesh::vertices()
|
|
|
|
CODE:
|
2013-08-05 17:17:13 +00:00
|
|
|
if (THIS->stl.v_shared == NULL)
|
2013-08-04 19:23:27 +00:00
|
|
|
stl_generate_shared_vertices(&(THIS->stl));
|
|
|
|
|
|
|
|
// vertices
|
|
|
|
AV* vertices = newAV();
|
|
|
|
av_extend(vertices, THIS->stl.stats.shared_vertices);
|
|
|
|
for (int i = 0; i < THIS->stl.stats.shared_vertices; i++) {
|
|
|
|
AV* vertex = newAV();
|
|
|
|
av_store(vertices, i, newRV_noinc((SV*)vertex));
|
|
|
|
av_extend(vertex, 2);
|
|
|
|
av_store(vertex, 0, newSVnv(THIS->stl.v_shared[i].x));
|
|
|
|
av_store(vertex, 1, newSVnv(THIS->stl.v_shared[i].y));
|
|
|
|
av_store(vertex, 2, newSVnv(THIS->stl.v_shared[i].z));
|
|
|
|
}
|
|
|
|
|
|
|
|
RETVAL = newRV_noinc((SV*)vertices);
|
|
|
|
OUTPUT:
|
|
|
|
RETVAL
|
|
|
|
|
|
|
|
SV*
|
|
|
|
TriangleMesh::facets()
|
|
|
|
CODE:
|
2013-08-05 17:17:13 +00:00
|
|
|
if (THIS->stl.v_shared == NULL)
|
2013-08-04 19:23:27 +00:00
|
|
|
stl_generate_shared_vertices(&(THIS->stl));
|
|
|
|
|
|
|
|
// facets
|
|
|
|
AV* facets = newAV();
|
|
|
|
av_extend(facets, THIS->stl.stats.number_of_facets);
|
|
|
|
for (int i = 0; i < THIS->stl.stats.number_of_facets; i++) {
|
|
|
|
AV* facet = newAV();
|
|
|
|
av_store(facets, i, newRV_noinc((SV*)facet));
|
|
|
|
av_extend(facet, 2);
|
|
|
|
av_store(facet, 0, newSVnv(THIS->stl.v_indices[i].vertex[0]));
|
|
|
|
av_store(facet, 1, newSVnv(THIS->stl.v_indices[i].vertex[1]));
|
|
|
|
av_store(facet, 2, newSVnv(THIS->stl.v_indices[i].vertex[2]));
|
|
|
|
}
|
|
|
|
|
|
|
|
RETVAL = newRV_noinc((SV*)facets);
|
|
|
|
OUTPUT:
|
|
|
|
RETVAL
|
|
|
|
|
2013-08-05 17:39:10 +00:00
|
|
|
SV*
|
|
|
|
TriangleMesh::size()
|
|
|
|
CODE:
|
|
|
|
AV* size = newAV();
|
|
|
|
av_extend(size, 2);
|
|
|
|
av_store(size, 0, newSVnv(THIS->stl.stats.size.x));
|
|
|
|
av_store(size, 1, newSVnv(THIS->stl.stats.size.y));
|
|
|
|
av_store(size, 2, newSVnv(THIS->stl.stats.size.z));
|
|
|
|
RETVAL = newRV_noinc((SV*)size);
|
|
|
|
OUTPUT:
|
|
|
|
RETVAL
|
|
|
|
|
2013-07-13 16:51:49 +00:00
|
|
|
%}
|
2013-06-24 17:35:49 +00:00
|
|
|
};
|
|
|
|
|
2013-06-22 15:16:45 +00:00
|
|
|
%package{Slic3r::TriangleMesh::XS};
|
|
|
|
|
|
|
|
%{
|
|
|
|
PROTOTYPES: DISABLE
|
|
|
|
|
|
|
|
std::string
|
|
|
|
hello_world()
|
|
|
|
CODE:
|
|
|
|
RETVAL = "Hello world!";
|
|
|
|
OUTPUT:
|
|
|
|
RETVAL
|
|
|
|
%}
|