Remove any Perl related code from libslic3r

This commit is contained in:
Alessandro Ranellucci 2015-12-08 00:39:54 +01:00
parent 3fac8cd77e
commit 4913e90e10
105 changed files with 907 additions and 1066 deletions

View file

@ -219,10 +219,4 @@ BoundingBox3Base<PointClass>::center() const
}
template Pointf3 BoundingBox3Base<Pointf3>::center() const;
#ifdef SLIC3RXS
REGISTER_CLASS(BoundingBox, "Geometry::BoundingBox");
REGISTER_CLASS(BoundingBoxf, "Geometry::BoundingBoxf");
REGISTER_CLASS(BoundingBoxf3, "Geometry::BoundingBoxf3");
#endif
}

View file

@ -1,7 +1,7 @@
#ifndef slic3r_BoundingBox_hpp_
#define slic3r_BoundingBox_hpp_
#include <myinit.h>
#include "libslic3r.h"
#include "Point.hpp"
#include "Polygon.hpp"

View file

@ -327,8 +327,4 @@ BridgeDetector::unsupported_edges(double angle) const
return pp;
}
#ifdef SLIC3RXS
REGISTER_CLASS(BridgeDetector, "BridgeDetector");
#endif
}

View file

@ -1,7 +1,7 @@
#ifndef slic3r_BridgeDetector_hpp_
#define slic3r_BridgeDetector_hpp_
#include <myinit.h>
#include "libslic3r.h"
#include "ExPolygon.hpp"
#include "ExPolygonCollection.hpp"
#include <string>

View file

@ -689,35 +689,4 @@ void safety_offset(ClipperLib::Paths* paths)
scaleClipperPolygons(*paths, 1.0/CLIPPER_OFFSET_SCALE);
}
///////////////////////
#ifdef SLIC3RXS
SV*
polynode_children_2_perl(const ClipperLib::PolyNode& node)
{
AV* av = newAV();
const int len = node.ChildCount();
if (len > 0) av_extend(av, len-1);
for (int i = 0; i < len; ++i) {
av_store(av, i, polynode2perl(*node.Childs[i]));
}
return (SV*)newRV_noinc((SV*)av);
}
SV*
polynode2perl(const ClipperLib::PolyNode& node)
{
HV* hv = newHV();
Slic3r::Polygon p;
ClipperPath_to_Slic3rMultiPoint(node.Contour, &p);
if (node.IsHole()) {
(void)hv_stores( hv, "hole", Slic3r::perl_to_SV_clone_ref(p) );
} else {
(void)hv_stores( hv, "outer", Slic3r::perl_to_SV_clone_ref(p) );
}
(void)hv_stores( hv, "children", polynode_children_2_perl(node) );
return (SV*)newRV_noinc((SV*)hv);
}
#endif
}

View file

@ -1,7 +1,7 @@
#ifndef slic3r_ClipperUtils_hpp_
#define slic3r_ClipperUtils_hpp_
#include <myinit.h>
#include <libslic3r.h>
#include "clipper.hpp"
#include "ExPolygon.hpp"
#include "Polygon.hpp"
@ -134,13 +134,6 @@ void simplify_polygons(const Slic3r::Polygons &subject, Slic3r::ExPolygons* retv
void safety_offset(ClipperLib::Paths* paths);
/////////////////
#ifdef SLIC3RXS
SV* polynode_children_2_perl(const ClipperLib::PolyNode& node);
SV* polynode2perl(const ClipperLib::PolyNode& node);
#endif
}
#endif

View file

@ -149,219 +149,6 @@ ConfigBase::setenv_()
#endif
}
#ifdef SLIC3RXS
SV*
ConfigBase::as_hash() {
HV* hv = newHV();
t_config_option_keys opt_keys = this->keys();
for (t_config_option_keys::const_iterator it = opt_keys.begin(); it != opt_keys.end(); ++it)
(void)hv_store( hv, it->c_str(), it->length(), this->get(*it), 0 );
return newRV_noinc((SV*)hv);
}
SV*
ConfigBase::get(t_config_option_key opt_key) {
ConfigOption* opt = this->option(opt_key);
if (opt == NULL) return &PL_sv_undef;
const ConfigOptionDef* def = this->def->get(opt_key);
if (def->type == coFloat) {
ConfigOptionFloat* optv = dynamic_cast<ConfigOptionFloat*>(opt);
return newSVnv(optv->value);
} else if (def->type == coFloats) {
ConfigOptionFloats* optv = dynamic_cast<ConfigOptionFloats*>(opt);
AV* av = newAV();
av_fill(av, optv->values.size()-1);
for (std::vector<double>::iterator it = optv->values.begin(); it != optv->values.end(); ++it)
av_store(av, it - optv->values.begin(), newSVnv(*it));
return newRV_noinc((SV*)av);
} else if (def->type == coPercent) {
ConfigOptionPercent* optv = dynamic_cast<ConfigOptionPercent*>(opt);
return newSVnv(optv->value);
} else if (def->type == coInt) {
ConfigOptionInt* optv = dynamic_cast<ConfigOptionInt*>(opt);
return newSViv(optv->value);
} else if (def->type == coInts) {
ConfigOptionInts* optv = dynamic_cast<ConfigOptionInts*>(opt);
AV* av = newAV();
av_fill(av, optv->values.size()-1);
for (std::vector<int>::iterator it = optv->values.begin(); it != optv->values.end(); ++it)
av_store(av, it - optv->values.begin(), newSViv(*it));
return newRV_noinc((SV*)av);
} else if (def->type == coString) {
ConfigOptionString* optv = dynamic_cast<ConfigOptionString*>(opt);
// we don't serialize() because that would escape newlines
return newSVpvn_utf8(optv->value.c_str(), optv->value.length(), true);
} else if (def->type == coStrings) {
ConfigOptionStrings* optv = dynamic_cast<ConfigOptionStrings*>(opt);
AV* av = newAV();
av_fill(av, optv->values.size()-1);
for (std::vector<std::string>::iterator it = optv->values.begin(); it != optv->values.end(); ++it)
av_store(av, it - optv->values.begin(), newSVpvn_utf8(it->c_str(), it->length(), true));
return newRV_noinc((SV*)av);
} else if (def->type == coPoint) {
ConfigOptionPoint* optv = dynamic_cast<ConfigOptionPoint*>(opt);
return perl_to_SV_clone_ref(optv->value);
} else if (def->type == coPoints) {
ConfigOptionPoints* optv = dynamic_cast<ConfigOptionPoints*>(opt);
AV* av = newAV();
av_fill(av, optv->values.size()-1);
for (Pointfs::iterator it = optv->values.begin(); it != optv->values.end(); ++it)
av_store(av, it - optv->values.begin(), perl_to_SV_clone_ref(*it));
return newRV_noinc((SV*)av);
} else if (def->type == coBool) {
ConfigOptionBool* optv = dynamic_cast<ConfigOptionBool*>(opt);
return newSViv(optv->value ? 1 : 0);
} else if (def->type == coBools) {
ConfigOptionBools* optv = dynamic_cast<ConfigOptionBools*>(opt);
AV* av = newAV();
av_fill(av, optv->values.size()-1);
for (std::vector<bool>::iterator it = optv->values.begin(); it != optv->values.end(); ++it)
av_store(av, it - optv->values.begin(), newSViv(*it ? 1 : 0));
return newRV_noinc((SV*)av);
} else {
std::string serialized = opt->serialize();
return newSVpvn_utf8(serialized.c_str(), serialized.length(), true);
}
}
SV*
ConfigBase::get_at(t_config_option_key opt_key, size_t i) {
ConfigOption* opt = this->option(opt_key);
if (opt == NULL) return &PL_sv_undef;
const ConfigOptionDef* def = this->def->get(opt_key);
if (def->type == coFloats) {
ConfigOptionFloats* optv = dynamic_cast<ConfigOptionFloats*>(opt);
return newSVnv(optv->get_at(i));
} else if (def->type == coInts) {
ConfigOptionInts* optv = dynamic_cast<ConfigOptionInts*>(opt);
return newSViv(optv->get_at(i));
} else if (def->type == coStrings) {
ConfigOptionStrings* optv = dynamic_cast<ConfigOptionStrings*>(opt);
// we don't serialize() because that would escape newlines
std::string val = optv->get_at(i);
return newSVpvn_utf8(val.c_str(), val.length(), true);
} else if (def->type == coPoints) {
ConfigOptionPoints* optv = dynamic_cast<ConfigOptionPoints*>(opt);
return perl_to_SV_clone_ref(optv->get_at(i));
} else if (def->type == coBools) {
ConfigOptionBools* optv = dynamic_cast<ConfigOptionBools*>(opt);
return newSViv(optv->get_at(i) ? 1 : 0);
} else {
return &PL_sv_undef;
}
}
bool
ConfigBase::set(t_config_option_key opt_key, SV* value) {
ConfigOption* opt = this->option(opt_key, true);
if (opt == NULL) CONFESS("Trying to set non-existing option");
const ConfigOptionDef* def = this->def->get(opt_key);
if (def->type == coFloat) {
if (!looks_like_number(value)) return false;
ConfigOptionFloat* optv = dynamic_cast<ConfigOptionFloat*>(opt);
optv->value = SvNV(value);
} else if (def->type == coFloats) {
ConfigOptionFloats* optv = dynamic_cast<ConfigOptionFloats*>(opt);
std::vector<double> values;
AV* av = (AV*)SvRV(value);
const size_t len = av_len(av)+1;
for (size_t i = 0; i < len; i++) {
SV** elem = av_fetch(av, i, 0);
if (elem == NULL || !looks_like_number(*elem)) return false;
values.push_back(SvNV(*elem));
}
optv->values = values;
} else if (def->type == coInt) {
if (!looks_like_number(value)) return false;
ConfigOptionInt* optv = dynamic_cast<ConfigOptionInt*>(opt);
optv->value = SvIV(value);
} else if (def->type == coInts) {
ConfigOptionInts* optv = dynamic_cast<ConfigOptionInts*>(opt);
std::vector<int> values;
AV* av = (AV*)SvRV(value);
const size_t len = av_len(av)+1;
for (size_t i = 0; i < len; i++) {
SV** elem = av_fetch(av, i, 0);
if (elem == NULL || !looks_like_number(*elem)) return false;
values.push_back(SvIV(*elem));
}
optv->values = values;
} else if (def->type == coString) {
ConfigOptionString* optv = dynamic_cast<ConfigOptionString*>(opt);
optv->value = std::string(SvPV_nolen(value), SvCUR(value));
} else if (def->type == coStrings) {
ConfigOptionStrings* optv = dynamic_cast<ConfigOptionStrings*>(opt);
optv->values.clear();
AV* av = (AV*)SvRV(value);
const size_t len = av_len(av)+1;
for (size_t i = 0; i < len; i++) {
SV** elem = av_fetch(av, i, 0);
if (elem == NULL) return false;
optv->values.push_back(std::string(SvPV_nolen(*elem), SvCUR(*elem)));
}
} else if (def->type == coPoint) {
ConfigOptionPoint* optv = dynamic_cast<ConfigOptionPoint*>(opt);
return optv->value.from_SV_check(value);
} else if (def->type == coPoints) {
ConfigOptionPoints* optv = dynamic_cast<ConfigOptionPoints*>(opt);
std::vector<Pointf> values;
AV* av = (AV*)SvRV(value);
const size_t len = av_len(av)+1;
for (size_t i = 0; i < len; i++) {
SV** elem = av_fetch(av, i, 0);
Pointf point;
if (elem == NULL || !point.from_SV_check(*elem)) return false;
values.push_back(point);
}
optv->values = values;
} else if (def->type == coBool) {
ConfigOptionBool* optv = dynamic_cast<ConfigOptionBool*>(opt);
optv->value = SvTRUE(value);
} else if (def->type == coBools) {
ConfigOptionBools* optv = dynamic_cast<ConfigOptionBools*>(opt);
optv->values.clear();
AV* av = (AV*)SvRV(value);
const size_t len = av_len(av)+1;
for (size_t i = 0; i < len; i++) {
SV** elem = av_fetch(av, i, 0);
if (elem == NULL) return false;
optv->values.push_back(SvTRUE(*elem));
}
} else {
if (!opt->deserialize( std::string(SvPV_nolen(value)) )) return false;
}
return true;
}
/* This method is implemented as a workaround for this typemap bug:
https://rt.cpan.org/Public/Bug/Display.html?id=94110 */
bool
ConfigBase::set_deserialize(const t_config_option_key &opt_key, SV* str) {
size_t len;
const char * c = SvPV(str, len);
std::string value(c, len);
return this->set_deserialize(opt_key, value);
}
void
ConfigBase::set_ifndef(t_config_option_key opt_key, SV* value, bool deserialize)
{
if (!this->has(opt_key)) {
if (deserialize) {
this->set_deserialize(opt_key, value);
} else {
this->set(opt_key, value);
}
}
}
#endif
DynamicConfig& DynamicConfig::operator= (DynamicConfig other)
{
this->swap(other);
@ -491,19 +278,4 @@ StaticConfig::option(const t_config_option_key &opt_key) const
return const_cast<StaticConfig*>(this)->option(opt_key, false);
}
#ifdef SLIC3RXS
bool
StaticConfig::set(t_config_option_key opt_key, SV* value) {
const ConfigOptionDef* optdef = this->def->get(opt_key);
if (!optdef->shortcut.empty()) {
for (std::vector<t_config_option_key>::const_iterator it = optdef->shortcut.begin(); it != optdef->shortcut.end(); ++it) {
if (!this->set(*it, value)) return false;
}
return true;
}
return static_cast<ConfigBase*>(this)->set(opt_key, value);
}
#endif
}

View file

@ -9,7 +9,7 @@
#include <stdexcept>
#include <string>
#include <vector>
#include <myinit.h>
#include "libslic3r.h"
#include "Point.hpp"
namespace Slic3r {
@ -555,18 +555,9 @@ class ConfigBase
t_config_option_keys diff(ConfigBase &other);
std::string serialize(const t_config_option_key &opt_key) const;
bool set_deserialize(const t_config_option_key &opt_key, std::string str);
void set_ifndef(t_config_option_key opt_key, SV* value, bool deserialize = false);
double get_abs_value(const t_config_option_key &opt_key);
double get_abs_value(const t_config_option_key &opt_key, double ratio_over);
void setenv_();
#ifdef SLIC3RXS
SV* as_hash();
SV* get(t_config_option_key opt_key);
SV* get_at(t_config_option_key opt_key, size_t i);
bool set(t_config_option_key opt_key, SV* value);
bool set_deserialize(const t_config_option_key &opt_key, SV* str);
#endif
};
class DynamicConfig : public virtual ConfigBase
@ -596,10 +587,6 @@ class StaticConfig : public virtual ConfigBase
virtual ConfigOption* option(const t_config_option_key &opt_key, bool create = false) = 0;
const ConfigOption* option(const t_config_option_key &opt_key) const;
void set_defaults();
#ifdef SLIC3RXS
bool set(t_config_option_key opt_key, SV* value);
#endif
};
}

View file

@ -425,65 +425,4 @@ ExPolygon::lines() const
return lines;
}
#ifdef SLIC3RXS
REGISTER_CLASS(ExPolygon, "ExPolygon");
SV*
ExPolygon::to_AV() {
const unsigned int num_holes = this->holes.size();
AV* av = newAV();
av_extend(av, num_holes); // -1 +1
av_store(av, 0, perl_to_SV_ref(this->contour));
for (unsigned int i = 0; i < num_holes; i++) {
av_store(av, i+1, perl_to_SV_ref(this->holes[i]));
}
return newRV_noinc((SV*)av);
}
SV*
ExPolygon::to_SV_pureperl() const
{
const unsigned int num_holes = this->holes.size();
AV* av = newAV();
av_extend(av, num_holes); // -1 +1
av_store(av, 0, this->contour.to_SV_pureperl());
for (unsigned int i = 0; i < num_holes; i++) {
av_store(av, i+1, this->holes[i].to_SV_pureperl());
}
return newRV_noinc((SV*)av);
}
void
ExPolygon::from_SV(SV* expoly_sv)
{
AV* expoly_av = (AV*)SvRV(expoly_sv);
const unsigned int num_polygons = av_len(expoly_av)+1;
this->holes.resize(num_polygons-1);
SV** polygon_sv = av_fetch(expoly_av, 0, 0);
this->contour.from_SV(*polygon_sv);
for (unsigned int i = 0; i < num_polygons-1; i++) {
polygon_sv = av_fetch(expoly_av, i+1, 0);
this->holes[i].from_SV(*polygon_sv);
}
}
void
ExPolygon::from_SV_check(SV* expoly_sv)
{
if (sv_isobject(expoly_sv) && (SvTYPE(SvRV(expoly_sv)) == SVt_PVMG)) {
if (!sv_isa(expoly_sv, perl_class_name(this)) && !sv_isa(expoly_sv, perl_class_name_ref(this)))
CONFESS("Not a valid %s object", perl_class_name(this));
// a XS ExPolygon was supplied
*this = *(ExPolygon *)SvIV((SV*)SvRV( expoly_sv ));
} else {
// a Perl arrayref was supplied
this->from_SV(expoly_sv);
}
}
#endif
}

View file

@ -1,6 +1,7 @@
#ifndef slic3r_ExPolygon_hpp_
#define slic3r_ExPolygon_hpp_
#include "libslic3r.h"
#include "Polygon.hpp"
#include "Polyline.hpp"
#include <vector>
@ -40,13 +41,6 @@ class ExPolygon
void triangulate_pp(Polygons* polygons) const;
void triangulate_p2t(Polygons* polygons) const;
Lines lines() const;
#ifdef SLIC3RXS
void from_SV(SV* poly_sv);
void from_SV_check(SV* poly_sv);
SV* to_AV();
SV* to_SV_pureperl() const;
#endif
};
}

View file

@ -128,8 +128,4 @@ ExPolygonCollection::append(const ExPolygons &expp)
this->expolygons.insert(this->expolygons.end(), expp.begin(), expp.end());
}
#ifdef SLIC3RXS
REGISTER_CLASS(ExPolygonCollection, "ExPolygon::Collection");
#endif
}

View file

@ -1,7 +1,7 @@
#ifndef slic3r_ExPolygonCollection_hpp_
#define slic3r_ExPolygonCollection_hpp_
#include <myinit.h>
#include "libslic3r.h"
#include "ExPolygon.hpp"
#include "Line.hpp"
#include "Polyline.hpp"

View file

@ -153,9 +153,4 @@ Extruder::retract_restart_extra_toolchange() const
return this->config->retract_restart_extra_toolchange.get_at(this->id);
}
#ifdef SLIC3RXS
REGISTER_CLASS(Extruder, "Extruder");
#endif
}

View file

@ -1,7 +1,7 @@
#ifndef slic3r_Extruder_hpp_
#define slic3r_Extruder_hpp_
#include <myinit.h>
#include "libslic3r.h"
#include "Point.hpp"
#include "PrintConfig.hpp"

View file

@ -110,10 +110,6 @@ ExtrusionPath::_inflate_collection(const Polylines &polylines, ExtrusionEntityCo
}
}
#ifdef SLIC3RXS
REGISTER_CLASS(ExtrusionPath, "ExtrusionPath");
#endif
Polygons
ExtrusionPath::grow() const
{
@ -339,8 +335,4 @@ ExtrusionLoop::min_mm3_per_mm() const
return min_mm3_per_mm;
}
#ifdef SLIC3RXS
REGISTER_CLASS(ExtrusionLoop, "ExtrusionLoop");
#endif
}

View file

@ -1,7 +1,7 @@
#ifndef slic3r_ExtrusionEntity_hpp_
#define slic3r_ExtrusionEntity_hpp_
#include <myinit.h>
#include "libslic3r.h"
#include "Polygon.hpp"
#include "Polyline.hpp"

View file

@ -227,9 +227,4 @@ ExtrusionEntityCollection::min_mm3_per_mm() const
return min_mm3_per_mm;
}
#ifdef SLIC3RXS
// there is no ExtrusionLoop::Collection or ExtrusionEntity::Collection
REGISTER_CLASS(ExtrusionEntityCollection, "ExtrusionPath::Collection");
#endif
}

View file

@ -1,7 +1,7 @@
#ifndef slic3r_ExtrusionEntityCollection_hpp_
#define slic3r_ExtrusionEntityCollection_hpp_
#include <myinit.h>
#include "libslic3r.h"
#include "ExtrusionEntity.hpp"
namespace Slic3r {

View file

@ -114,8 +114,4 @@ Flow::_width_from_spacing(float spacing, float nozzle_diameter, float height, bo
return spacing + OVERLAP_FACTOR * height * (1 - PI/4.0);
}
#ifdef SLIC3RXS
REGISTER_CLASS(Flow, "Flow");
#endif
}

View file

@ -1,7 +1,7 @@
#ifndef slic3r_Flow_hpp_
#define slic3r_Flow_hpp_
#include <myinit.h>
#include "libslic3r.h"
#include "Config.hpp"
#include "ExtrusionEntity.hpp"

View file

@ -65,10 +65,6 @@ AvoidCrossingPerimeters::travel_to(GCode &gcodegen, Point point)
}
}
#ifdef SLIC3RXS
REGISTER_CLASS(AvoidCrossingPerimeters, "GCode::AvoidCrossingPerimeters");
#endif
OozePrevention::OozePrevention()
: enable(false)
{
@ -125,10 +121,6 @@ OozePrevention::_get_temp(GCode &gcodegen)
: gcodegen.config.temperature.get_at(gcodegen.writer.extruder()->id);
}
#ifdef SLIC3RXS
REGISTER_CLASS(OozePrevention, "GCode::OozePrevention");
#endif
Wipe::Wipe()
: enable(false)
{
@ -202,10 +194,6 @@ Wipe::wipe(GCode &gcodegen, bool toolchange)
return gcode;
}
#ifdef SLIC3RXS
REGISTER_CLASS(Wipe, "GCode::Wipe");
#endif
#define EXTRUDER_CONFIG(OPT) this->config.OPT.get_at(this->writer.extruder()->id)
GCode::GCode()
@ -766,8 +754,4 @@ GCode::point_to_gcode(const Point &point)
);
}
#ifdef SLIC3RXS
REGISTER_CLASS(GCode, "GCode");
#endif
}

View file

@ -1,7 +1,7 @@
#ifndef slic3r_GCode_hpp_
#define slic3r_GCode_hpp_
#include <myinit.h>
#include "libslic3r.h"
#include "ExPolygon.hpp"
#include "GCodeWriter.hpp"
#include "Layer.hpp"

View file

@ -474,11 +474,4 @@ GCodeSender::reset()
}
#ifdef SLIC3RXS
#include <myinit.h>
namespace Slic3r {
__REGISTER_CLASS(GCodeSender, "GCode::Sender");
}
#endif
#endif

View file

@ -2,7 +2,7 @@
#define slic3r_GCodeSender_hpp_
#ifdef BOOST_LIBS
#include <libslic3r/libslic3r.h>
#include "libslic3r.h"
#include <queue>
#include <string>
#include <vector>

View file

@ -520,8 +520,4 @@ GCodeWriter::get_position() const
return this->_pos;
}
#ifdef SLIC3RXS
REGISTER_CLASS(GCodeWriter, "GCode::Writer");
#endif
}

View file

@ -1,7 +1,7 @@
#ifndef slic3r_GCodeWriter_hpp_
#define slic3r_GCodeWriter_hpp_
#include <myinit.h>
#include "libslic3r.h"
#include <string>
#include "Extruder.hpp"
#include "Point.hpp"

View file

@ -1,6 +1,7 @@
#ifndef slic3r_Geometry_hpp_
#define slic3r_Geometry_hpp_
#include "libslic3r.h"
#include "BoundingBox.hpp"
#include "Polygon.hpp"
#include "Polyline.hpp"

View file

@ -245,10 +245,6 @@ Layer::make_perimeters()
}
}
#ifdef SLIC3RXS
REGISTER_CLASS(Layer, "Layer");
#endif
SupportLayer::SupportLayer(size_t id, PrintObject *object, coordf_t height,
coordf_t print_z, coordf_t slice_z)
@ -260,9 +256,5 @@ SupportLayer::~SupportLayer()
{
}
#ifdef SLIC3RXS
REGISTER_CLASS(SupportLayer, "Layer::Support");
#endif
}

View file

@ -1,7 +1,7 @@
#ifndef slic3r_Layer_hpp_
#define slic3r_Layer_hpp_
#include <myinit.h>
#include "libslic3r.h"
#include "Flow.hpp"
#include "SurfaceCollection.hpp"
#include "ExtrusionEntityCollection.hpp"

View file

@ -271,8 +271,4 @@ LayerRegion::infill_area_threshold() const
return ss*ss;
}
#ifdef SLIC3RXS
REGISTER_CLASS(LayerRegion, "Layer::Region");
#endif
}

View file

@ -163,51 +163,6 @@ Line::normal() const
return Vector((this->b.y - this->a.y), -(this->b.x - this->a.x));
}
#ifdef SLIC3RXS
REGISTER_CLASS(Line, "Line");
void
Line::from_SV(SV* line_sv)
{
AV* line_av = (AV*)SvRV(line_sv);
this->a.from_SV_check(*av_fetch(line_av, 0, 0));
this->b.from_SV_check(*av_fetch(line_av, 1, 0));
}
void
Line::from_SV_check(SV* line_sv)
{
if (sv_isobject(line_sv) && (SvTYPE(SvRV(line_sv)) == SVt_PVMG)) {
if (!sv_isa(line_sv, perl_class_name(this)) && !sv_isa(line_sv, perl_class_name_ref(this)))
CONFESS("Not a valid %s object", perl_class_name(this));
*this = *(Line*)SvIV((SV*)SvRV( line_sv ));
} else {
this->from_SV(line_sv);
}
}
SV*
Line::to_AV() {
AV* av = newAV();
av_extend(av, 1);
av_store(av, 0, perl_to_SV_ref(this->a));
av_store(av, 1, perl_to_SV_ref(this->b));
return newRV_noinc((SV*)av);
}
SV*
Line::to_SV_pureperl() const {
AV* av = newAV();
av_extend(av, 1);
av_store(av, 0, this->a.to_SV_pureperl());
av_store(av, 1, this->b.to_SV_pureperl());
return newRV_noinc((SV*)av);
}
#endif
Pointf3
Linef3::intersect_plane(double z) const
{
@ -225,8 +180,4 @@ Linef3::scale(double factor)
this->b.scale(factor);
}
#ifdef SLIC3RXS
REGISTER_CLASS(Linef3, "Linef3");
#endif
}

View file

@ -1,7 +1,7 @@
#ifndef slic3r_Line_hpp_
#define slic3r_Line_hpp_
#include <myinit.h>
#include "libslic3r.h"
#include "Point.hpp"
namespace Slic3r {
@ -39,13 +39,6 @@ class Line
double direction() const;
Vector vector() const;
Vector normal() const;
#ifdef SLIC3RXS
void from_SV(SV* line_sv);
void from_SV_check(SV* line_sv);
SV* to_AV();
SV* to_SV_pureperl() const;
#endif
};
class Linef
@ -66,12 +59,6 @@ class Linef3
explicit Linef3(Pointf3 _a, Pointf3 _b): a(_a), b(_b) {};
Pointf3 intersect_plane(double z) const;
void scale(double factor);
#ifdef SLIC3RXS
void from_SV(SV* line_sv);
void from_SV_check(SV* line_sv);
SV* to_SV_pureperl() const;
#endif
};
}

View file

@ -311,11 +311,6 @@ Model::duplicate_objects_grid(size_t x, size_t y, coordf_t dist)
}
}
#ifdef SLIC3RXS
REGISTER_CLASS(Model, "Model");
#endif
ModelMaterial::ModelMaterial(Model *model) : model(model) {}
ModelMaterial::ModelMaterial(Model *model, const ModelMaterial &other)
: attributes(other.attributes), config(other.config), model(model)
@ -328,11 +323,6 @@ ModelMaterial::apply(const t_model_material_attributes &attributes)
}
#ifdef SLIC3RXS
REGISTER_CLASS(ModelMaterial, "Model::Material");
#endif
ModelObject::ModelObject(Model *model)
: model(model)
{}
@ -711,10 +701,6 @@ ModelObject::split(ModelObjectPtrs* new_objects)
return;
}
#ifdef SLIC3RXS
REGISTER_CLASS(ModelObject, "Model::Object");
#endif
ModelVolume::ModelVolume(ModelObject* object, const TriangleMesh &mesh)
: mesh(mesh), modifier(false), object(object)
@ -765,10 +751,6 @@ ModelVolume::assign_unique_material()
return model->add_material(this->_material_id);
}
#ifdef SLIC3RXS
REGISTER_CLASS(ModelVolume, "Model::Volume");
#endif
ModelInstance::ModelInstance(ModelObject *object)
: rotation(0), scaling_factor(1), object(object)
@ -794,8 +776,4 @@ ModelInstance::transform_polygon(Polygon* polygon) const
polygon->scale(this->scaling_factor); // scale around polygon origin
}
#ifdef SLIC3RXS
REGISTER_CLASS(ModelInstance, "Model::Instance");
#endif
}

View file

@ -1,7 +1,7 @@
#ifndef slic3r_Model_hpp_
#define slic3r_Model_hpp_
#include <myinit.h>
#include "libslic3r.h"
#include "PrintConfig.hpp"
#include "Layer.hpp"
#include "Point.hpp"

View file

@ -391,8 +391,4 @@ MotionPlannerGraph::shortest_path(size_t from, size_t to)
return polyline;
}
#ifdef SLIC3RXS
REGISTER_CLASS(MotionPlanner, "MotionPlanner");
#endif
}

View file

@ -1,7 +1,7 @@
#ifndef slic3r_MotionPlanner_hpp_
#define slic3r_MotionPlanner_hpp_
#include <myinit.h>
#include "libslic3r.h"
#include "ClipperUtils.hpp"
#include "ExPolygonCollection.hpp"
#include "Polyline.hpp"

View file

@ -154,51 +154,4 @@ MultiPoint::_douglas_peucker(const Points &points, const double tolerance)
return results;
}
#ifdef SLIC3RXS
void
MultiPoint::from_SV(SV* poly_sv)
{
AV* poly_av = (AV*)SvRV(poly_sv);
const unsigned int num_points = av_len(poly_av)+1;
this->points.resize(num_points);
for (unsigned int i = 0; i < num_points; i++) {
SV** point_sv = av_fetch(poly_av, i, 0);
this->points[i].from_SV_check(*point_sv);
}
}
void
MultiPoint::from_SV_check(SV* poly_sv)
{
if (sv_isobject(poly_sv) && (SvTYPE(SvRV(poly_sv)) == SVt_PVMG)) {
*this = *(MultiPoint*)SvIV((SV*)SvRV( poly_sv ));
} else {
this->from_SV(poly_sv);
}
}
SV*
MultiPoint::to_AV() {
const unsigned int num_points = this->points.size();
AV* av = newAV();
if (num_points > 0) av_extend(av, num_points-1);
for (unsigned int i = 0; i < num_points; i++) {
av_store(av, i, perl_to_SV_ref(this->points[i]));
}
return newRV_noinc((SV*)av);
}
SV*
MultiPoint::to_SV_pureperl() const {
const unsigned int num_points = this->points.size();
AV* av = newAV();
if (num_points > 0) av_extend(av, num_points-1);
for (unsigned int i = 0; i < num_points; i++) {
av_store(av, i, this->points[i].to_SV_pureperl());
}
return newRV_noinc((SV*)av);
}
#endif
}

View file

@ -1,7 +1,7 @@
#ifndef slic3r_MultiPoint_hpp_
#define slic3r_MultiPoint_hpp_
#include <myinit.h>
#include "libslic3r.h"
#include <algorithm>
#include <vector>
#include "Line.hpp"
@ -38,13 +38,6 @@ class MultiPoint
void append(const Points::const_iterator &begin, const Points::const_iterator &end);
static Points _douglas_peucker(const Points &points, const double tolerance);
#ifdef SLIC3RXS
void from_SV(SV* poly_sv);
void from_SV_check(SV* poly_sv);
SV* to_AV();
SV* to_SV_pureperl() const;
#endif
};
}

View file

@ -497,10 +497,6 @@ PerimeterGenerator::_fill_gaps(double min, double max, double w,
return coll;
}
#ifdef SLIC3RXS
REGISTER_CLASS(PerimeterGenerator, "Layer::PerimeterGenerator");
#endif
bool
PerimeterGeneratorLoop::is_external() const
{

View file

@ -1,7 +1,7 @@
#ifndef slic3r_PerimeterGenerator_hpp_
#define slic3r_PerimeterGenerator_hpp_
#include <myinit.h>
#include "libslic3r.h"
#include <vector>
#include "ExPolygonCollection.hpp"
#include "Flow.hpp"

View file

@ -151,8 +151,4 @@ PlaceholderParser::find_and_replace(std::string &source, std::string const &find
return found;
}
#ifdef SLIC3RXS
REGISTER_CLASS(PlaceholderParser, "GCode::PlaceholderParser");
#endif
}

View file

@ -1,8 +1,7 @@
#ifndef slic3r_PlaceholderParser_hpp_
#define slic3r_PlaceholderParser_hpp_
#include <myinit.h>
#include "libslic3r.h"
#include <map>
#include <string>
#include <vector>

View file

@ -299,46 +299,6 @@ operator*(double scalar, const Point& point2)
return Point(scalar * point2.x, scalar * point2.y);
}
#ifdef SLIC3RXS
REGISTER_CLASS(Point, "Point");
SV*
Point::to_SV_pureperl() const {
AV* av = newAV();
av_fill(av, 1);
av_store(av, 0, newSViv(this->x));
av_store(av, 1, newSViv(this->y));
return newRV_noinc((SV*)av);
}
void
Point::from_SV(SV* point_sv)
{
AV* point_av = (AV*)SvRV(point_sv);
// get a double from Perl and round it, otherwise
// it would get truncated
this->x = lrint(SvNV(*av_fetch(point_av, 0, 0)));
this->y = lrint(SvNV(*av_fetch(point_av, 1, 0)));
}
void
Point::from_SV_check(SV* point_sv)
{
if (sv_isobject(point_sv) && (SvTYPE(SvRV(point_sv)) == SVt_PVMG)) {
if (!sv_isa(point_sv, perl_class_name(this)) && !sv_isa(point_sv, perl_class_name_ref(this)))
CONFESS("Not a valid %s object (got %s)", perl_class_name(this), HvNAME(SvSTASH(SvRV(point_sv))));
*this = *(Point*)SvIV((SV*)SvRV( point_sv ));
} else {
this->from_SV(point_sv);
}
}
REGISTER_CLASS(Point3, "Point3");
#endif
std::ostream&
operator<<(std::ostream &stm, const Pointf &pointf)
{
@ -386,46 +346,6 @@ Pointf::vector_to(const Pointf &point) const
return Vectorf(point.x - this->x, point.y - this->y);
}
#ifdef SLIC3RXS
REGISTER_CLASS(Pointf, "Pointf");
SV*
Pointf::to_SV_pureperl() const {
AV* av = newAV();
av_fill(av, 1);
av_store(av, 0, newSVnv(this->x));
av_store(av, 1, newSVnv(this->y));
return newRV_noinc((SV*)av);
}
bool
Pointf::from_SV(SV* point_sv)
{
AV* point_av = (AV*)SvRV(point_sv);
SV* sv_x = *av_fetch(point_av, 0, 0);
SV* sv_y = *av_fetch(point_av, 1, 0);
if (!looks_like_number(sv_x) || !looks_like_number(sv_y)) return false;
this->x = SvNV(sv_x);
this->y = SvNV(sv_y);
return true;
}
bool
Pointf::from_SV_check(SV* point_sv)
{
if (sv_isobject(point_sv) && (SvTYPE(SvRV(point_sv)) == SVt_PVMG)) {
if (!sv_isa(point_sv, perl_class_name(this)) && !sv_isa(point_sv, perl_class_name_ref(this)))
CONFESS("Not a valid %s object (got %s)", perl_class_name(this), HvNAME(SvSTASH(SvRV(point_sv))));
*this = *(Pointf*)SvIV((SV*)SvRV( point_sv ));
return true;
} else {
return this->from_SV(point_sv);
}
}
#endif
void
Pointf3::scale(double factor)
{
@ -467,8 +387,4 @@ Pointf3::vector_to(const Pointf3 &point) const
return Vectorf3(point.x - this->x, point.y - this->y, point.z - this->z);
}
#ifdef SLIC3RXS
REGISTER_CLASS(Pointf3, "Pointf3");
#endif
}

View file

@ -1,7 +1,7 @@
#ifndef slic3r_Point_hpp_
#define slic3r_Point_hpp_
#include <myinit.h>
#include "libslic3r.h"
#include <vector>
#include <math.h>
#include <string>
@ -60,12 +60,6 @@ class Point
Point projection_onto(const Line &line) const;
Point negative() const;
Vector vector_to(const Point &point) const;
#ifdef SLIC3RXS
void from_SV(SV* point_sv);
void from_SV_check(SV* point_sv);
SV* to_SV_pureperl() const;
#endif
};
Point operator+(const Point& point1, const Point& point2);
@ -98,12 +92,6 @@ class Pointf
void rotate(double angle, const Pointf &center);
Pointf negative() const;
Vectorf vector_to(const Pointf &point) const;
#ifdef SLIC3RXS
bool from_SV(SV* point_sv);
bool from_SV_check(SV* point_sv);
SV* to_SV_pureperl() const;
#endif
};
class Pointf3 : public Pointf

View file

@ -1,4 +1,3 @@
#include <myinit.h>
#include "ClipperUtils.hpp"
#include "Polygon.hpp"
#include "Polyline.hpp"
@ -266,17 +265,4 @@ Polygon::convex_points(double angle) const
return points;
}
#ifdef SLIC3RXS
REGISTER_CLASS(Polygon, "Polygon");
void
Polygon::from_SV_check(SV* poly_sv)
{
if (sv_isobject(poly_sv) && !sv_isa(poly_sv, perl_class_name(this)) && !sv_isa(poly_sv, perl_class_name_ref(this)))
CONFESS("Not a valid %s object", perl_class_name(this));
MultiPoint::from_SV_check(poly_sv);
}
#endif
}

View file

@ -1,7 +1,7 @@
#ifndef slic3r_Polygon_hpp_
#define slic3r_Polygon_hpp_
#include <myinit.h>
#include "libslic3r.h"
#include <vector>
#include <string>
#include "Line.hpp"
@ -42,10 +42,6 @@ class Polygon : public MultiPoint {
std::string wkt() const;
Points concave_points(double angle = PI) const;
Points convex_points(double angle = PI) const;
#ifdef SLIC3RXS
void from_SV_check(SV* poly_sv);
#endif
};
}

View file

@ -247,18 +247,4 @@ Polyline::wkt() const
return wkt.str();
}
#ifdef SLIC3RXS
REGISTER_CLASS(Polyline, "Polyline");
void
Polyline::from_SV_check(SV* poly_sv)
{
if (!sv_isa(poly_sv, perl_class_name(this)) && !sv_isa(poly_sv, perl_class_name_ref(this)))
CONFESS("Not a valid %s object",perl_class_name(this));
MultiPoint::from_SV_check(poly_sv);
}
#endif
}

View file

@ -1,6 +1,7 @@
#ifndef slic3r_Polyline_hpp_
#define slic3r_Polyline_hpp_
#include "libslic3r.h"
#include "Line.hpp"
#include "MultiPoint.hpp"
#include <string>
@ -28,10 +29,6 @@ class Polyline : public MultiPoint {
void split_at(const Point &point, Polyline* p1, Polyline* p2) const;
bool is_straight() const;
std::string wkt() const;
#ifdef SLIC3RXS
void from_SV_check(SV* poly_sv);
#endif
};
}

View file

@ -56,8 +56,4 @@ PolylineCollection::append(const Polylines &pp)
this->polylines.insert(this->polylines.end(), pp.begin(), pp.end());
}
#ifdef SLIC3RXS
REGISTER_CLASS(PolylineCollection, "Polyline::Collection");
#endif
}

View file

@ -1,7 +1,7 @@
#ifndef slic3r_PolylineCollection_hpp_
#define slic3r_PolylineCollection_hpp_
#include <myinit.h>
#include "libslic3r.h"
#include "Polyline.hpp"
namespace Slic3r {

View file

@ -842,10 +842,4 @@ Print::auto_assign_extruders(ModelObject* model_object) const
}
}
#ifdef SLIC3RXS
REGISTER_CLASS(Print, "Print");
#endif
}

View file

@ -1,7 +1,7 @@
#ifndef slic3r_Print_hpp_
#define slic3r_Print_hpp_
#include <myinit.h>
#include "libslic3r.h"
#include <set>
#include <vector>
#include <stdexcept>

View file

@ -1316,13 +1316,4 @@ PrintConfigBase::min_object_distance() const
: duplicate_distance;
}
#ifdef SLIC3RXS
REGISTER_CLASS(DynamicPrintConfig, "Config");
REGISTER_CLASS(PrintObjectConfig, "Config::PrintObject");
REGISTER_CLASS(PrintRegionConfig, "Config::PrintRegion");
REGISTER_CLASS(GCodeConfig, "Config::GCode");
REGISTER_CLASS(PrintConfig, "Config::Print");
REGISTER_CLASS(FullPrintConfig, "Config::Full");
#endif
}

View file

@ -1,6 +1,7 @@
#ifndef slic3r_PrintConfig_hpp_
#define slic3r_PrintConfig_hpp_
#include "libslic3r.h"
#include "Config.hpp"
#define OPT_PTR(KEY) if (opt_key == #KEY) return &this->KEY

View file

@ -485,9 +485,4 @@ PrintObject::bridge_over_infill()
}
}
#ifdef SLIC3RXS
REGISTER_CLASS(PrintObject, "Print::Object");
#endif
}

View file

@ -65,8 +65,4 @@ PrintRegion::flow(FlowRole role, double layer_height, bool bridge, bool first_la
return Flow::new_from_config_width(role, config_width, nozzle_diameter, layer_height, bridge ? (float)this->config.bridge_flow_ratio : 0.0);
}
#ifdef SLIC3RXS
REGISTER_CLASS(PrintRegion, "Print::Region");
#endif
}

View file

@ -1,7 +1,7 @@
#ifndef slic3r_SVG_hpp_
#define slic3r_SVG_hpp_
#include <myinit.h>
#include "libslic3r.h"
#include "ExPolygon.hpp"
#include "Line.hpp"
#include "TriangleMesh.hpp"

View file

@ -54,18 +54,4 @@ Surface::is_bridge() const
|| this->surface_type == stInternalBridge;
}
#ifdef SLIC3RXS
REGISTER_CLASS(Surface, "Surface");
void
Surface::from_SV_check(SV* surface_sv)
{
if (!sv_isa(surface_sv, perl_class_name(this)) && !sv_isa(surface_sv, perl_class_name_ref(this)))
CONFESS("Not a valid %s object", perl_class_name(this));
// a XS Surface was supplied
*this = *(Surface *)SvIV((SV*)SvRV( surface_sv ));
}
#endif
}

View file

@ -1,6 +1,7 @@
#ifndef slic3r_Surface_hpp_
#define slic3r_Surface_hpp_
#include "libslic3r.h"
#include "ExPolygon.hpp"
namespace Slic3r {
@ -28,10 +29,6 @@ class Surface
bool is_internal() const;
bool is_bottom() const;
bool is_bridge() const;
#ifdef SLIC3RXS
void from_SV_check(SV* surface_sv);
#endif
};
typedef std::vector<Surface> Surfaces;

View file

@ -117,8 +117,4 @@ SurfaceCollection::append(const SurfaceCollection &coll)
this->surfaces.insert(this->surfaces.end(), coll.surfaces.begin(), coll.surfaces.end());
}
#ifdef SLIC3RXS
REGISTER_CLASS(SurfaceCollection, "Surface::Collection");
#endif
}

View file

@ -1,6 +1,7 @@
#ifndef slic3r_SurfaceCollection_hpp_
#define slic3r_SurfaceCollection_hpp_
#include "libslic3r.h"
#include "Surface.hpp"
#include <vector>

View file

@ -405,52 +405,6 @@ TriangleMesh::require_shared_vertices()
if (this->stl.v_shared == NULL) stl_generate_shared_vertices(&(this->stl));
}
#ifdef SLIC3RXS
REGISTER_CLASS(TriangleMesh, "TriangleMesh");
SV*
TriangleMesh::to_SV() {
SV* sv = newSV(0);
sv_setref_pv( sv, perl_class_name(this), (void*)this );
return sv;
}
void TriangleMesh::ReadFromPerl(SV* vertices, SV* facets)
{
stl.error = 0;
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 (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 = 0;
facet.normal.y = 0;
facet.normal.z = 0;
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] = 0;
facet.extra[1] = 0;
stl.facet_start[i] = facet;
}
stl_get_size(&(this->stl));
}
#endif
void
TriangleMeshSlicer::slice(const std::vector<float> &z, std::vector<Polygons>* layers)
{

View file

@ -1,7 +1,7 @@
#ifndef slic3r_TriangleMesh_hpp_
#define slic3r_TriangleMesh_hpp_
#include <myinit.h>
#include "libslic3r.h"
#include <admesh/stl.h>
#include <vector>
#include "BoundingBox.hpp"
@ -53,11 +53,6 @@ class TriangleMesh
stl_file stl;
bool repaired;
#ifdef SLIC3RXS
SV* to_SV();
void ReadFromPerl(SV* vertices, SV* facets);
#endif
private:
void require_shared_vertices();
friend class TriangleMeshSlicer;

View file

@ -1,4 +1,4 @@
#include <myinit.h>
#include <xsinit.h>
void
confess_at(const char *file, int line, const char *func,