Ported horizontal_projection() to XS

This commit is contained in:
Alessandro Ranellucci 2013-11-23 19:41:40 +01:00
parent e75dbf37fa
commit 4d5d003ba7
4 changed files with 27 additions and 20 deletions

View file

@ -1,4 +1,5 @@
#include "TriangleMesh.hpp"
#include "ClipperUtils.hpp"
#include <queue>
#include <deque>
#include <set>
@ -575,6 +576,28 @@ TriangleMesh::merge(const TriangleMesh* mesh)
stl_get_size(&this->stl);
}
/* this will return scaled ExPolygons */
void
TriangleMesh::horizontal_projection(ExPolygons &retval) const
{
Polygons pp;
pp.reserve(this->stl.stats.number_of_facets);
for (int i = 0; i < this->stl.stats.number_of_facets; i++) {
stl_facet* facet = &this->stl.facet_start[i];
Polygon p;
p.points.resize(3);
p.points[0] = Point(facet->vertex[0].x / SCALING_FACTOR, facet->vertex[0].y / SCALING_FACTOR);
p.points[1] = Point(facet->vertex[1].x / SCALING_FACTOR, facet->vertex[1].y / SCALING_FACTOR);
p.points[2] = Point(facet->vertex[2].x / SCALING_FACTOR, facet->vertex[2].y / SCALING_FACTOR);
p.make_counter_clockwise(); // do this after scaling, as winding order might change while doing that
pp.push_back(p);
}
// the offset factor was tuned using groovemount.stl
offset(pp, pp, 0.01 / SCALING_FACTOR);
union_(pp, retval, true);
}
#ifdef SLIC3RXS
SV*
TriangleMesh::to_SV() {