mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2026-02-11 19:19:28 -07:00
New ReadFromPerl() method
This commit is contained in:
parent
bb656ea72c
commit
6373322b84
6 changed files with 137 additions and 78 deletions
|
|
@ -10,6 +10,38 @@ TriangleMesh::ReadSTLFile(char* input_file) {
|
|||
stl_open(&stl, input_file);
|
||||
}
|
||||
|
||||
void TriangleMesh::ReadFromPerl(SV* vertices, SV* facets)
|
||||
{
|
||||
stl_initialize(&stl);
|
||||
stl.stats.type = inmemory;
|
||||
|
||||
// count facets and allocate memory
|
||||
AV* facets_av = (AV*)SvRV(facets);
|
||||
stl.stats.number_of_facets = av_len(facets_av)+1;
|
||||
stl.stats.original_num_facets = stl.stats.number_of_facets;
|
||||
stl_allocate(&stl);
|
||||
|
||||
// read geometry
|
||||
AV* vertices_av = (AV*)SvRV(vertices);
|
||||
for (unsigned int i = 0; i < stl.stats.number_of_facets; i++) {
|
||||
AV* facet_av = (AV*)SvRV(*av_fetch(facets_av, i, 0));
|
||||
stl_facet facet;
|
||||
facet.normal.x = NULL;
|
||||
facet.normal.y = NULL;
|
||||
facet.normal.z = NULL;
|
||||
for (unsigned int v = 0; v <= 2; v++) {
|
||||
AV* vertex_av = (AV*)SvRV(*av_fetch(vertices_av, SvIV(*av_fetch(facet_av, v, 0)), 0));
|
||||
facet.vertex[v].x = SvNV(*av_fetch(vertex_av, 0, 0));
|
||||
facet.vertex[v].y = SvNV(*av_fetch(vertex_av, 1, 0));
|
||||
facet.vertex[v].z = SvNV(*av_fetch(vertex_av, 2, 0));
|
||||
}
|
||||
facet.extra[0] = NULL;
|
||||
facet.extra[1] = NULL;
|
||||
|
||||
stl.facet_start[i] = facet;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TriangleMesh::Repair() {
|
||||
int i;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue