mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-23 16:51:21 -06:00
Use XS Point everywhere
This commit is contained in:
parent
d0701cdcd4
commit
9af2a1c007
37 changed files with 238 additions and 303 deletions
|
@ -8,48 +8,20 @@ extern "C" {
|
|||
#include "ppport.h"
|
||||
}
|
||||
|
||||
#include <vector>
|
||||
#include "Polyline.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
class Polygon : public Polyline {};
|
||||
class Polygon : public Polyline {
|
||||
protected:
|
||||
char* perl_class() {
|
||||
return (char*)"Slic3r::Polygon";
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::vector<Polygon> Polygons;
|
||||
|
||||
void
|
||||
perl2polygon(SV* poly_sv, Polygon& poly)
|
||||
{
|
||||
AV* poly_av = (AV*)SvRV(poly_sv);
|
||||
const unsigned int num_points = av_len(poly_av)+1;
|
||||
poly.points.resize(num_points);
|
||||
|
||||
for (unsigned int i = 0; i < num_points; i++) {
|
||||
SV** point_sv = av_fetch(poly_av, i, 0);
|
||||
perl2point(*point_sv, poly.points[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
perl2polygon_check(SV* poly_sv, Polygon& poly)
|
||||
{
|
||||
if (sv_isobject(poly_sv) && (SvTYPE(SvRV(poly_sv)) == SVt_PVMG)) {
|
||||
poly = *(Polygon*)SvIV((SV*)SvRV( poly_sv ));
|
||||
} else {
|
||||
perl2polygon(poly_sv, poly);
|
||||
}
|
||||
}
|
||||
|
||||
SV*
|
||||
polygon2perl(Polygon& poly) {
|
||||
const unsigned int num_points = poly.points.size();
|
||||
AV* av = newAV();
|
||||
av_extend(av, num_points-1);
|
||||
for (unsigned int i = 0; i < num_points; i++) {
|
||||
av_store(av, i, point2perl(poly.points[i]));
|
||||
}
|
||||
return sv_bless(newRV_noinc((SV*)av), gv_stashpv("Slic3r::Polygon", GV_ADD));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue