Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessandro Ranellucci <aar@cpan.org>2015-12-08 02:39:54 +0300
committerAlessandro Ranellucci <aar@cpan.org>2015-12-08 02:39:54 +0300
commit4913e90e100c093e81dd77f31e2cf39d844b9055 (patch)
tree2cbb9ded96107eb6db6d0ffdfd12b6ae33501976
parent3fac8cd77e76da982219049629f3d9190cfcfbbf (diff)
Remove any Perl related code from libslic3r
-rw-r--r--xs/Build.PL4
-rw-r--r--xs/MANIFEST10
-rw-r--r--xs/src/libslic3r/BoundingBox.cpp6
-rw-r--r--xs/src/libslic3r/BoundingBox.hpp2
-rw-r--r--xs/src/libslic3r/BridgeDetector.cpp4
-rw-r--r--xs/src/libslic3r/BridgeDetector.hpp2
-rw-r--r--xs/src/libslic3r/ClipperUtils.cpp31
-rw-r--r--xs/src/libslic3r/ClipperUtils.hpp9
-rw-r--r--xs/src/libslic3r/Config.cpp228
-rw-r--r--xs/src/libslic3r/Config.hpp15
-rw-r--r--xs/src/libslic3r/ExPolygon.cpp61
-rw-r--r--xs/src/libslic3r/ExPolygon.hpp8
-rw-r--r--xs/src/libslic3r/ExPolygonCollection.cpp4
-rw-r--r--xs/src/libslic3r/ExPolygonCollection.hpp2
-rw-r--r--xs/src/libslic3r/Extruder.cpp5
-rw-r--r--xs/src/libslic3r/Extruder.hpp2
-rw-r--r--xs/src/libslic3r/ExtrusionEntity.cpp8
-rw-r--r--xs/src/libslic3r/ExtrusionEntity.hpp2
-rw-r--r--xs/src/libslic3r/ExtrusionEntityCollection.cpp5
-rw-r--r--xs/src/libslic3r/ExtrusionEntityCollection.hpp2
-rw-r--r--xs/src/libslic3r/Flow.cpp4
-rw-r--r--xs/src/libslic3r/Flow.hpp2
-rw-r--r--xs/src/libslic3r/GCode.cpp16
-rw-r--r--xs/src/libslic3r/GCode.hpp2
-rw-r--r--xs/src/libslic3r/GCodeSender.cpp7
-rw-r--r--xs/src/libslic3r/GCodeSender.hpp2
-rw-r--r--xs/src/libslic3r/GCodeWriter.cpp4
-rw-r--r--xs/src/libslic3r/GCodeWriter.hpp2
-rw-r--r--xs/src/libslic3r/Geometry.hpp1
-rw-r--r--xs/src/libslic3r/Layer.cpp8
-rw-r--r--xs/src/libslic3r/Layer.hpp2
-rw-r--r--xs/src/libslic3r/LayerRegion.cpp4
-rw-r--r--xs/src/libslic3r/Line.cpp49
-rw-r--r--xs/src/libslic3r/Line.hpp15
-rw-r--r--xs/src/libslic3r/Model.cpp22
-rw-r--r--xs/src/libslic3r/Model.hpp2
-rw-r--r--xs/src/libslic3r/MotionPlanner.cpp4
-rw-r--r--xs/src/libslic3r/MotionPlanner.hpp2
-rw-r--r--xs/src/libslic3r/MultiPoint.cpp47
-rw-r--r--xs/src/libslic3r/MultiPoint.hpp9
-rw-r--r--xs/src/libslic3r/PerimeterGenerator.cpp4
-rw-r--r--xs/src/libslic3r/PerimeterGenerator.hpp2
-rw-r--r--xs/src/libslic3r/PlaceholderParser.cpp4
-rw-r--r--xs/src/libslic3r/PlaceholderParser.hpp3
-rw-r--r--xs/src/libslic3r/Point.cpp84
-rw-r--r--xs/src/libslic3r/Point.hpp14
-rw-r--r--xs/src/libslic3r/Polygon.cpp14
-rw-r--r--xs/src/libslic3r/Polygon.hpp6
-rw-r--r--xs/src/libslic3r/Polyline.cpp14
-rw-r--r--xs/src/libslic3r/Polyline.hpp5
-rw-r--r--xs/src/libslic3r/PolylineCollection.cpp4
-rw-r--r--xs/src/libslic3r/PolylineCollection.hpp2
-rw-r--r--xs/src/libslic3r/Print.cpp6
-rw-r--r--xs/src/libslic3r/Print.hpp2
-rw-r--r--xs/src/libslic3r/PrintConfig.cpp9
-rw-r--r--xs/src/libslic3r/PrintConfig.hpp1
-rw-r--r--xs/src/libslic3r/PrintObject.cpp5
-rw-r--r--xs/src/libslic3r/PrintRegion.cpp4
-rw-r--r--xs/src/libslic3r/SVG.hpp2
-rw-r--r--xs/src/libslic3r/Surface.cpp14
-rw-r--r--xs/src/libslic3r/Surface.hpp5
-rw-r--r--xs/src/libslic3r/SurfaceCollection.cpp4
-rw-r--r--xs/src/libslic3r/SurfaceCollection.hpp1
-rw-r--r--xs/src/libslic3r/TriangleMesh.cpp46
-rw-r--r--xs/src/libslic3r/TriangleMesh.hpp7
-rw-r--r--xs/src/libslic3r/utils.cpp2
-rw-r--r--xs/src/myinit.h49
-rw-r--r--xs/src/perlglue.cpp537
-rw-r--r--xs/src/perlglue.hpp64
-rw-r--r--xs/src/slic3r/GUI/3DScene.cpp4
-rw-r--r--xs/src/slic3r/GUI/3DScene.hpp2
-rw-r--r--xs/src/xsinit.h149
-rw-r--r--xs/xsp/BoundingBox.xsp2
-rw-r--r--xs/xsp/BridgeDetector.xsp2
-rw-r--r--xs/xsp/Clipper.xsp2
-rw-r--r--xs/xsp/Config.xsp112
-rw-r--r--xs/xsp/ExPolygon.xsp12
-rw-r--r--xs/xsp/ExPolygonCollection.xsp8
-rw-r--r--xs/xsp/Extruder.xsp2
-rw-r--r--xs/xsp/ExtrusionEntityCollection.xsp2
-rw-r--r--xs/xsp/ExtrusionLoop.xsp2
-rw-r--r--xs/xsp/ExtrusionPath.xsp12
-rw-r--r--xs/xsp/Flow.xsp2
-rw-r--r--xs/xsp/GCode.xsp2
-rw-r--r--xs/xsp/GCodeWriter.xsp2
-rw-r--r--xs/xsp/GUI.xsp2
-rw-r--r--xs/xsp/GUI_3DScene.xsp2
-rw-r--r--xs/xsp/Geometry.xsp2
-rw-r--r--xs/xsp/Layer.xsp2
-rw-r--r--xs/xsp/Line.xsp14
-rw-r--r--xs/xsp/Model.xsp2
-rw-r--r--xs/xsp/MotionPlanner.xsp2
-rw-r--r--xs/xsp/PerimeterGenerator.xsp2
-rw-r--r--xs/xsp/PlaceholderParser.xsp2
-rw-r--r--xs/xsp/Point.xsp14
-rw-r--r--xs/xsp/Polygon.xsp10
-rw-r--r--xs/xsp/Polyline.xsp12
-rw-r--r--xs/xsp/PolylineCollection.xsp8
-rw-r--r--xs/xsp/Print.xsp2
-rw-r--r--xs/xsp/SupportMaterial.xsp2
-rw-r--r--xs/xsp/Surface.xsp2
-rw-r--r--xs/xsp/SurfaceCollection.xsp2
-rw-r--r--xs/xsp/TriangleMesh.xsp40
-rw-r--r--xs/xsp/XS.xsp2
-rw-r--r--xs/xsp/my.map4
105 files changed, 907 insertions, 1066 deletions
diff --git a/xs/Build.PL b/xs/Build.PL
index d0704a409..9578efc90 100644
--- a/xs/Build.PL
+++ b/xs/Build.PL
@@ -17,8 +17,8 @@ if ($^O eq 'darwin') {
push @ldflags, qw(-framework IOKit -framework CoreFoundation);
}
-my @INC = qw();
-my @LIBS = qw();
+my @INC = qw(-Isrc/libslic3r);
+my @LIBS = qw(-Lsrc/libslic3r);
# search for Boost in a number of places
my @boost_include = my @boost_libs = ();
diff --git a/xs/MANIFEST b/xs/MANIFEST
index 8cdbbb617..0f541515d 100644
--- a/xs/MANIFEST
+++ b/xs/MANIFEST
@@ -78,8 +78,7 @@ src/libslic3r/SVG.hpp
src/libslic3r/TriangleMesh.cpp
src/libslic3r/TriangleMesh.hpp
src/libslic3r/utils.cpp
-src/myinit.h
-src/perlglue.hpp
+src/perlglue.cpp
src/poly2tri/common/shapes.cc
src/poly2tri/common/shapes.h
src/poly2tri/common/utils.h
@@ -95,10 +94,11 @@ src/poly2tri/sweep/sweep_context.h
src/polypartition.cpp
src/polypartition.h
src/ppport.h
-src/slic3r/GUI/GUI.cpp
-src/slic3r/GUI/GUI.hpp
src/slic3r/GUI/3DScene.cpp
src/slic3r/GUI/3DScene.hpp
+src/slic3r/GUI/GUI.cpp
+src/slic3r/GUI/GUI.hpp
+src/xsinit.h
t/01_trianglemesh.t
t/03_point.t
t/04_expolygon.t
@@ -130,8 +130,8 @@ xsp/ExtrusionEntityCollection.xsp
xsp/ExtrusionLoop.xsp
xsp/ExtrusionPath.xsp
xsp/Flow.xsp
-xsp/GCodeSender.xsp
xsp/GCode.xsp
+xsp/GCodeSender.xsp
xsp/GCodeWriter.xsp
xsp/Geometry.xsp
xsp/GUI.xsp
diff --git a/xs/src/libslic3r/BoundingBox.cpp b/xs/src/libslic3r/BoundingBox.cpp
index 16c8acadb..1116d2dcb 100644
--- a/xs/src/libslic3r/BoundingBox.cpp
+++ b/xs/src/libslic3r/BoundingBox.cpp
@@ -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
-
}
diff --git a/xs/src/libslic3r/BoundingBox.hpp b/xs/src/libslic3r/BoundingBox.hpp
index fd106a7a5..533a19b56 100644
--- a/xs/src/libslic3r/BoundingBox.hpp
+++ b/xs/src/libslic3r/BoundingBox.hpp
@@ -1,7 +1,7 @@
#ifndef slic3r_BoundingBox_hpp_
#define slic3r_BoundingBox_hpp_
-#include <myinit.h>
+#include "libslic3r.h"
#include "Point.hpp"
#include "Polygon.hpp"
diff --git a/xs/src/libslic3r/BridgeDetector.cpp b/xs/src/libslic3r/BridgeDetector.cpp
index 24140c7b2..956f51a29 100644
--- a/xs/src/libslic3r/BridgeDetector.cpp
+++ b/xs/src/libslic3r/BridgeDetector.cpp
@@ -327,8 +327,4 @@ BridgeDetector::unsupported_edges(double angle) const
return pp;
}
-#ifdef SLIC3RXS
-REGISTER_CLASS(BridgeDetector, "BridgeDetector");
-#endif
-
}
diff --git a/xs/src/libslic3r/BridgeDetector.hpp b/xs/src/libslic3r/BridgeDetector.hpp
index c3af09542..5b1566b27 100644
--- a/xs/src/libslic3r/BridgeDetector.hpp
+++ b/xs/src/libslic3r/BridgeDetector.hpp
@@ -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>
diff --git a/xs/src/libslic3r/ClipperUtils.cpp b/xs/src/libslic3r/ClipperUtils.cpp
index d9cfd5ff5..d085f6c43 100644
--- a/xs/src/libslic3r/ClipperUtils.cpp
+++ b/xs/src/libslic3r/ClipperUtils.cpp
@@ -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
-
}
diff --git a/xs/src/libslic3r/ClipperUtils.hpp b/xs/src/libslic3r/ClipperUtils.hpp
index e5a3b7da5..7bc8deae9 100644
--- a/xs/src/libslic3r/ClipperUtils.hpp
+++ b/xs/src/libslic3r/ClipperUtils.hpp
@@ -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
diff --git a/xs/src/libslic3r/Config.cpp b/xs/src/libslic3r/Config.cpp
index 102a07a2f..71b38c994 100644
--- a/xs/src/libslic3r/Config.cpp
+++ b/xs/src/libslic3r/Config.cpp
@@ -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
-
}
diff --git a/xs/src/libslic3r/Config.hpp b/xs/src/libslic3r/Config.hpp
index 126049579..d4700d3f4 100644
--- a/xs/src/libslic3r/Config.hpp
+++ b/xs/src/libslic3r/Config.hpp
@@ -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
};
}
diff --git a/xs/src/libslic3r/ExPolygon.cpp b/xs/src/libslic3r/ExPolygon.cpp
index c423c6e0a..4e068f0d1 100644
--- a/xs/src/libslic3r/ExPolygon.cpp
+++ b/xs/src/libslic3r/ExPolygon.cpp
@@ -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
-
}
diff --git a/xs/src/libslic3r/ExPolygon.hpp b/xs/src/libslic3r/ExPolygon.hpp
index 7b7b0b760..18d4d8095 100644
--- a/xs/src/libslic3r/ExPolygon.hpp
+++ b/xs/src/libslic3r/ExPolygon.hpp
@@ -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
};
}
diff --git a/xs/src/libslic3r/ExPolygonCollection.cpp b/xs/src/libslic3r/ExPolygonCollection.cpp
index 45f0df477..bebc1260e 100644
--- a/xs/src/libslic3r/ExPolygonCollection.cpp
+++ b/xs/src/libslic3r/ExPolygonCollection.cpp
@@ -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
-
}
diff --git a/xs/src/libslic3r/ExPolygonCollection.hpp b/xs/src/libslic3r/ExPolygonCollection.hpp
index ffb306c92..ec3cb9522 100644
--- a/xs/src/libslic3r/ExPolygonCollection.hpp
+++ b/xs/src/libslic3r/ExPolygonCollection.hpp
@@ -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"
diff --git a/xs/src/libslic3r/Extruder.cpp b/xs/src/libslic3r/Extruder.cpp
index e254d6806..b9be14661 100644
--- a/xs/src/libslic3r/Extruder.cpp
+++ b/xs/src/libslic3r/Extruder.cpp
@@ -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
-
}
diff --git a/xs/src/libslic3r/Extruder.hpp b/xs/src/libslic3r/Extruder.hpp
index fa91bb42f..76b70df63 100644
--- a/xs/src/libslic3r/Extruder.hpp
+++ b/xs/src/libslic3r/Extruder.hpp
@@ -1,7 +1,7 @@
#ifndef slic3r_Extruder_hpp_
#define slic3r_Extruder_hpp_
-#include <myinit.h>
+#include "libslic3r.h"
#include "Point.hpp"
#include "PrintConfig.hpp"
diff --git a/xs/src/libslic3r/ExtrusionEntity.cpp b/xs/src/libslic3r/ExtrusionEntity.cpp
index be32519f6..54ca91e4a 100644
--- a/xs/src/libslic3r/ExtrusionEntity.cpp
+++ b/xs/src/libslic3r/ExtrusionEntity.cpp
@@ -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
-
}
diff --git a/xs/src/libslic3r/ExtrusionEntity.hpp b/xs/src/libslic3r/ExtrusionEntity.hpp
index c1eef6af3..719c80c15 100644
--- a/xs/src/libslic3r/ExtrusionEntity.hpp
+++ b/xs/src/libslic3r/ExtrusionEntity.hpp
@@ -1,7 +1,7 @@
#ifndef slic3r_ExtrusionEntity_hpp_
#define slic3r_ExtrusionEntity_hpp_
-#include <myinit.h>
+#include "libslic3r.h"
#include "Polygon.hpp"
#include "Polyline.hpp"
diff --git a/xs/src/libslic3r/ExtrusionEntityCollection.cpp b/xs/src/libslic3r/ExtrusionEntityCollection.cpp
index b0f369ec8..dc9b722d3 100644
--- a/xs/src/libslic3r/ExtrusionEntityCollection.cpp
+++ b/xs/src/libslic3r/ExtrusionEntityCollection.cpp
@@ -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
-
}
diff --git a/xs/src/libslic3r/ExtrusionEntityCollection.hpp b/xs/src/libslic3r/ExtrusionEntityCollection.hpp
index 62909c55c..8ee1b3864 100644
--- a/xs/src/libslic3r/ExtrusionEntityCollection.hpp
+++ b/xs/src/libslic3r/ExtrusionEntityCollection.hpp
@@ -1,7 +1,7 @@
#ifndef slic3r_ExtrusionEntityCollection_hpp_
#define slic3r_ExtrusionEntityCollection_hpp_
-#include <myinit.h>
+#include "libslic3r.h"
#include "ExtrusionEntity.hpp"
namespace Slic3r {
diff --git a/xs/src/libslic3r/Flow.cpp b/xs/src/libslic3r/Flow.cpp
index f91caed4b..276f60a6a 100644
--- a/xs/src/libslic3r/Flow.cpp
+++ b/xs/src/libslic3r/Flow.cpp
@@ -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
-
}
diff --git a/xs/src/libslic3r/Flow.hpp b/xs/src/libslic3r/Flow.hpp
index 88cae2477..cb7291266 100644
--- a/xs/src/libslic3r/Flow.hpp
+++ b/xs/src/libslic3r/Flow.hpp
@@ -1,7 +1,7 @@
#ifndef slic3r_Flow_hpp_
#define slic3r_Flow_hpp_
-#include <myinit.h>
+#include "libslic3r.h"
#include "Config.hpp"
#include "ExtrusionEntity.hpp"
diff --git a/xs/src/libslic3r/GCode.cpp b/xs/src/libslic3r/GCode.cpp
index 8f4f98260..f94784450 100644
--- a/xs/src/libslic3r/GCode.cpp
+++ b/xs/src/libslic3r/GCode.cpp
@@ -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
-
}
diff --git a/xs/src/libslic3r/GCode.hpp b/xs/src/libslic3r/GCode.hpp
index f477c779e..29aa7633a 100644
--- a/xs/src/libslic3r/GCode.hpp
+++ b/xs/src/libslic3r/GCode.hpp
@@ -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"
diff --git a/xs/src/libslic3r/GCodeSender.cpp b/xs/src/libslic3r/GCodeSender.cpp
index 5123ccbd2..9d3a45477 100644
--- a/xs/src/libslic3r/GCodeSender.cpp
+++ b/xs/src/libslic3r/GCodeSender.cpp
@@ -474,11 +474,4 @@ GCodeSender::reset()
}
-#ifdef SLIC3RXS
-#include <myinit.h>
-namespace Slic3r {
-__REGISTER_CLASS(GCodeSender, "GCode::Sender");
-}
-#endif
-
#endif
diff --git a/xs/src/libslic3r/GCodeSender.hpp b/xs/src/libslic3r/GCodeSender.hpp
index 6b5af95fe..384d417cc 100644
--- a/xs/src/libslic3r/GCodeSender.hpp
+++ b/xs/src/libslic3r/GCodeSender.hpp
@@ -2,7 +2,7 @@
#define slic3r_GCodeSender_hpp_
#ifdef BOOST_LIBS
-#include <libslic3r/libslic3r.h>
+#include "libslic3r.h"
#include <queue>
#include <string>
#include <vector>
diff --git a/xs/src/libslic3r/GCodeWriter.cpp b/xs/src/libslic3r/GCodeWriter.cpp
index 4055a270a..e6bcb8df8 100644
--- a/xs/src/libslic3r/GCodeWriter.cpp
+++ b/xs/src/libslic3r/GCodeWriter.cpp
@@ -520,8 +520,4 @@ GCodeWriter::get_position() const
return this->_pos;
}
-#ifdef SLIC3RXS
-REGISTER_CLASS(GCodeWriter, "GCode::Writer");
-#endif
-
}
diff --git a/xs/src/libslic3r/GCodeWriter.hpp b/xs/src/libslic3r/GCodeWriter.hpp
index e7b93ac42..21ed8d241 100644
--- a/xs/src/libslic3r/GCodeWriter.hpp
+++ b/xs/src/libslic3r/GCodeWriter.hpp
@@ -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"
diff --git a/xs/src/libslic3r/Geometry.hpp b/xs/src/libslic3r/Geometry.hpp
index b73480725..f64871d2d 100644
--- a/xs/src/libslic3r/Geometry.hpp
+++ b/xs/src/libslic3r/Geometry.hpp
@@ -1,6 +1,7 @@
#ifndef slic3r_Geometry_hpp_
#define slic3r_Geometry_hpp_
+#include "libslic3r.h"
#include "BoundingBox.hpp"
#include "Polygon.hpp"
#include "Polyline.hpp"
diff --git a/xs/src/libslic3r/Layer.cpp b/xs/src/libslic3r/Layer.cpp
index f3d5b1637..dc931923c 100644
--- a/xs/src/libslic3r/Layer.cpp
+++ b/xs/src/libslic3r/Layer.cpp
@@ -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
-
}
diff --git a/xs/src/libslic3r/Layer.hpp b/xs/src/libslic3r/Layer.hpp
index a6f6f9a43..4badb8374 100644
--- a/xs/src/libslic3r/Layer.hpp
+++ b/xs/src/libslic3r/Layer.hpp
@@ -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"
diff --git a/xs/src/libslic3r/LayerRegion.cpp b/xs/src/libslic3r/LayerRegion.cpp
index 4f874a2ea..a2683fa03 100644
--- a/xs/src/libslic3r/LayerRegion.cpp
+++ b/xs/src/libslic3r/LayerRegion.cpp
@@ -271,8 +271,4 @@ LayerRegion::infill_area_threshold() const
return ss*ss;
}
-#ifdef SLIC3RXS
-REGISTER_CLASS(LayerRegion, "Layer::Region");
-#endif
-
}
diff --git a/xs/src/libslic3r/Line.cpp b/xs/src/libslic3r/Line.cpp
index 84ba10a5b..f3b8ff43c 100644
--- a/xs/src/libslic3r/Line.cpp
+++ b/xs/src/libslic3r/Line.cpp
@@ -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
-
}
diff --git a/xs/src/libslic3r/Line.hpp b/xs/src/libslic3r/Line.hpp
index 327ff4d1e..c4438792a 100644
--- a/xs/src/libslic3r/Line.hpp
+++ b/xs/src/libslic3r/Line.hpp
@@ -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
};
}
diff --git a/xs/src/libslic3r/Model.cpp b/xs/src/libslic3r/Model.cpp
index 8bd381dd0..36001b9b2 100644
--- a/xs/src/libslic3r/Model.cpp
+++ b/xs/src/libslic3r/Model.cpp
@@ -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
-
}
diff --git a/xs/src/libslic3r/Model.hpp b/xs/src/libslic3r/Model.hpp
index a2553f6fa..f10707457 100644
--- a/xs/src/libslic3r/Model.hpp
+++ b/xs/src/libslic3r/Model.hpp
@@ -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"
diff --git a/xs/src/libslic3r/MotionPlanner.cpp b/xs/src/libslic3r/MotionPlanner.cpp
index d35a89ec5..836be3e20 100644
--- a/xs/src/libslic3r/MotionPlanner.cpp
+++ b/xs/src/libslic3r/MotionPlanner.cpp
@@ -391,8 +391,4 @@ MotionPlannerGraph::shortest_path(size_t from, size_t to)
return polyline;
}
-#ifdef SLIC3RXS
-REGISTER_CLASS(MotionPlanner, "MotionPlanner");
-#endif
-
}
diff --git a/xs/src/libslic3r/MotionPlanner.hpp b/xs/src/libslic3r/MotionPlanner.hpp
index d49cc8198..8344f74de 100644
--- a/xs/src/libslic3r/MotionPlanner.hpp
+++ b/xs/src/libslic3r/MotionPlanner.hpp
@@ -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"
diff --git a/xs/src/libslic3r/MultiPoint.cpp b/xs/src/libslic3r/MultiPoint.cpp
index 2e7131e6e..0e4ede761 100644
--- a/xs/src/libslic3r/MultiPoint.cpp
+++ b/xs/src/libslic3r/MultiPoint.cpp
@@ -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
-
}
diff --git a/xs/src/libslic3r/MultiPoint.hpp b/xs/src/libslic3r/MultiPoint.hpp
index 63ee3bda7..053709bbd 100644
--- a/xs/src/libslic3r/MultiPoint.hpp
+++ b/xs/src/libslic3r/MultiPoint.hpp
@@ -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
};
}
diff --git a/xs/src/libslic3r/PerimeterGenerator.cpp b/xs/src/libslic3r/PerimeterGenerator.cpp
index 969a85259..5a69f4f20 100644
--- a/xs/src/libslic3r/PerimeterGenerator.cpp
+++ b/xs/src/libslic3r/PerimeterGenerator.cpp
@@ -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
{
diff --git a/xs/src/libslic3r/PerimeterGenerator.hpp b/xs/src/libslic3r/PerimeterGenerator.hpp
index 680790ffd..b25a996a0 100644
--- a/xs/src/libslic3r/PerimeterGenerator.hpp
+++ b/xs/src/libslic3r/PerimeterGenerator.hpp
@@ -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"
diff --git a/xs/src/libslic3r/PlaceholderParser.cpp b/xs/src/libslic3r/PlaceholderParser.cpp
index 4a73cd12b..57220628f 100644
--- a/xs/src/libslic3r/PlaceholderParser.cpp
+++ b/xs/src/libslic3r/PlaceholderParser.cpp
@@ -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
-
}
diff --git a/xs/src/libslic3r/PlaceholderParser.hpp b/xs/src/libslic3r/PlaceholderParser.hpp
index 20c1ace48..0cdf809d5 100644
--- a/xs/src/libslic3r/PlaceholderParser.hpp
+++ b/xs/src/libslic3r/PlaceholderParser.hpp
@@ -1,8 +1,7 @@
#ifndef slic3r_PlaceholderParser_hpp_
#define slic3r_PlaceholderParser_hpp_
-
-#include <myinit.h>
+#include "libslic3r.h"
#include <map>
#include <string>
#include <vector>
diff --git a/xs/src/libslic3r/Point.cpp b/xs/src/libslic3r/Point.cpp
index 51ad8b4d1..35948b7d8 100644
--- a/xs/src/libslic3r/Point.cpp
+++ b/xs/src/libslic3r/Point.cpp
@@ -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
-
}
diff --git a/xs/src/libslic3r/Point.hpp b/xs/src/libslic3r/Point.hpp
index a0e382fb3..1a5bd641e 100644
--- a/xs/src/libslic3r/Point.hpp
+++ b/xs/src/libslic3r/Point.hpp
@@ -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
diff --git a/xs/src/libslic3r/Polygon.cpp b/xs/src/libslic3r/Polygon.cpp
index 93a191acb..102838809 100644
--- a/xs/src/libslic3r/Polygon.cpp
+++ b/xs/src/libslic3r/Polygon.cpp
@@ -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
-
}
diff --git a/xs/src/libslic3r/Polygon.hpp b/xs/src/libslic3r/Polygon.hpp
index bed80e177..ff8ec0d80 100644
--- a/xs/src/libslic3r/Polygon.hpp
+++ b/xs/src/libslic3r/Polygon.hpp
@@ -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
};
}
diff --git a/xs/src/libslic3r/Polyline.cpp b/xs/src/libslic3r/Polyline.cpp
index c0ba0092b..db2a9fdac 100644
--- a/xs/src/libslic3r/Polyline.cpp
+++ b/xs/src/libslic3r/Polyline.cpp
@@ -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
-
}
diff --git a/xs/src/libslic3r/Polyline.hpp b/xs/src/libslic3r/Polyline.hpp
index cf91b7184..ef327cbb3 100644
--- a/xs/src/libslic3r/Polyline.hpp
+++ b/xs/src/libslic3r/Polyline.hpp
@@ -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
};
}
diff --git a/xs/src/libslic3r/PolylineCollection.cpp b/xs/src/libslic3r/PolylineCollection.cpp
index b7e34b670..f3077b0e1 100644
--- a/xs/src/libslic3r/PolylineCollection.cpp
+++ b/xs/src/libslic3r/PolylineCollection.cpp
@@ -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
-
}
diff --git a/xs/src/libslic3r/PolylineCollection.hpp b/xs/src/libslic3r/PolylineCollection.hpp
index d903b35c5..d41e8c465 100644
--- a/xs/src/libslic3r/PolylineCollection.hpp
+++ b/xs/src/libslic3r/PolylineCollection.hpp
@@ -1,7 +1,7 @@
#ifndef slic3r_PolylineCollection_hpp_
#define slic3r_PolylineCollection_hpp_
-#include <myinit.h>
+#include "libslic3r.h"
#include "Polyline.hpp"
namespace Slic3r {
diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp
index 84730dded..19dc63263 100644
--- a/xs/src/libslic3r/Print.cpp
+++ b/xs/src/libslic3r/Print.cpp
@@ -842,10 +842,4 @@ Print::auto_assign_extruders(ModelObject* model_object) const
}
}
-
-#ifdef SLIC3RXS
-REGISTER_CLASS(Print, "Print");
-#endif
-
-
}
diff --git a/xs/src/libslic3r/Print.hpp b/xs/src/libslic3r/Print.hpp
index e5f085ff1..fcf6d0a79 100644
--- a/xs/src/libslic3r/Print.hpp
+++ b/xs/src/libslic3r/Print.hpp
@@ -1,7 +1,7 @@
#ifndef slic3r_Print_hpp_
#define slic3r_Print_hpp_
-#include <myinit.h>
+#include "libslic3r.h"
#include <set>
#include <vector>
#include <stdexcept>
diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp
index 34e3dd747..460b036fb 100644
--- a/xs/src/libslic3r/PrintConfig.cpp
+++ b/xs/src/libslic3r/PrintConfig.cpp
@@ -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
-
}
diff --git a/xs/src/libslic3r/PrintConfig.hpp b/xs/src/libslic3r/PrintConfig.hpp
index 2df6dd8d2..b14e669c6 100644
--- a/xs/src/libslic3r/PrintConfig.hpp
+++ b/xs/src/libslic3r/PrintConfig.hpp
@@ -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
diff --git a/xs/src/libslic3r/PrintObject.cpp b/xs/src/libslic3r/PrintObject.cpp
index ab25be577..23d9e74e1 100644
--- a/xs/src/libslic3r/PrintObject.cpp
+++ b/xs/src/libslic3r/PrintObject.cpp
@@ -485,9 +485,4 @@ PrintObject::bridge_over_infill()
}
}
-
-#ifdef SLIC3RXS
-REGISTER_CLASS(PrintObject, "Print::Object");
-#endif
-
}
diff --git a/xs/src/libslic3r/PrintRegion.cpp b/xs/src/libslic3r/PrintRegion.cpp
index 1807f84bc..e6ef456bc 100644
--- a/xs/src/libslic3r/PrintRegion.cpp
+++ b/xs/src/libslic3r/PrintRegion.cpp
@@ -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
-
}
diff --git a/xs/src/libslic3r/SVG.hpp b/xs/src/libslic3r/SVG.hpp
index cbc546402..def1f13f0 100644
--- a/xs/src/libslic3r/SVG.hpp
+++ b/xs/src/libslic3r/SVG.hpp
@@ -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"
diff --git a/xs/src/libslic3r/Surface.cpp b/xs/src/libslic3r/Surface.cpp
index e7d66c17b..4d2234e4d 100644
--- a/xs/src/libslic3r/Surface.cpp
+++ b/xs/src/libslic3r/Surface.cpp
@@ -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
-
}
diff --git a/xs/src/libslic3r/Surface.hpp b/xs/src/libslic3r/Surface.hpp
index a4a28a2c3..21395bdc6 100644
--- a/xs/src/libslic3r/Surface.hpp
+++ b/xs/src/libslic3r/Surface.hpp
@@ -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;
diff --git a/xs/src/libslic3r/SurfaceCollection.cpp b/xs/src/libslic3r/SurfaceCollection.cpp
index 2e96d4b1e..2cb244c7a 100644
--- a/xs/src/libslic3r/SurfaceCollection.cpp
+++ b/xs/src/libslic3r/SurfaceCollection.cpp
@@ -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
-
}
diff --git a/xs/src/libslic3r/SurfaceCollection.hpp b/xs/src/libslic3r/SurfaceCollection.hpp
index 40e36c5f0..a4a3a7e5d 100644
--- a/xs/src/libslic3r/SurfaceCollection.hpp
+++ b/xs/src/libslic3r/SurfaceCollection.hpp
@@ -1,6 +1,7 @@
#ifndef slic3r_SurfaceCollection_hpp_
#define slic3r_SurfaceCollection_hpp_
+#include "libslic3r.h"
#include "Surface.hpp"
#include <vector>
diff --git a/xs/src/libslic3r/TriangleMesh.cpp b/xs/src/libslic3r/TriangleMesh.cpp
index 6df4eba5c..8bc5f9d00 100644
--- a/xs/src/libslic3r/TriangleMesh.cpp
+++ b/xs/src/libslic3r/TriangleMesh.cpp
@@ -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)
{
diff --git a/xs/src/libslic3r/TriangleMesh.hpp b/xs/src/libslic3r/TriangleMesh.hpp
index 8fd92863c..cf129809a 100644
--- a/xs/src/libslic3r/TriangleMesh.hpp
+++ b/xs/src/libslic3r/TriangleMesh.hpp
@@ -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;
diff --git a/xs/src/libslic3r/utils.cpp b/xs/src/libslic3r/utils.cpp
index d0b1e879b..3f3ed326b 100644
--- a/xs/src/libslic3r/utils.cpp
+++ b/xs/src/libslic3r/utils.cpp
@@ -1,4 +1,4 @@
-#include <myinit.h>
+#include <xsinit.h>
void
confess_at(const char *file, int line, const char *func,
diff --git a/xs/src/myinit.h b/xs/src/myinit.h
deleted file mode 100644
index fd7c5a07d..000000000
--- a/xs/src/myinit.h
+++ /dev/null
@@ -1,49 +0,0 @@
-#ifndef _myinit_h_
-#define _myinit_h_
-
-// undef some macros set by Perl which cause compilation errors on Win32
-#undef read
-#undef seekdir
-#undef bind
-#undef send
-#undef connect
-#undef wait
-#undef accept
-#undef close
-#undef open
-#undef write
-#undef socket
-#undef listen
-#undef shutdown
-#undef ioctl
-#undef getpeername
-#undef rect
-#undef setsockopt
-#undef getsockopt
-#undef getsockname
-#undef gethostname
-#undef select
-#undef socketpair
-#undef recvfrom
-#undef sendto
-
-// these need to be included early for Win32 (listing it in Build.PL is not enough)
-#include <ostream>
-#include <iostream>
-#include <sstream>
-
-#ifdef SLIC3RXS
-extern "C" {
-#include "EXTERN.h"
-#include "perl.h"
-#include "XSUB.h"
-#include "ppport.h"
-#undef do_open
-#undef do_close
-}
-#include "perlglue.hpp"
-#endif
-
-#include "libslic3r/libslic3r.h"
-
-#endif
diff --git a/xs/src/perlglue.cpp b/xs/src/perlglue.cpp
new file mode 100644
index 000000000..22769e774
--- /dev/null
+++ b/xs/src/perlglue.cpp
@@ -0,0 +1,537 @@
+#ifdef SLIC3RXS
+#include <xsinit.h>
+
+namespace Slic3r {
+
+REGISTER_CLASS(ExPolygon, "ExPolygon");
+REGISTER_CLASS(ExPolygonCollection, "ExPolygon::Collection");
+REGISTER_CLASS(Extruder, "Extruder");
+REGISTER_CLASS(ExtrusionPath, "ExtrusionPath");
+REGISTER_CLASS(ExtrusionLoop, "ExtrusionLoop");
+// there is no ExtrusionLoop::Collection or ExtrusionEntity::Collection
+REGISTER_CLASS(ExtrusionEntityCollection, "ExtrusionPath::Collection");
+REGISTER_CLASS(Flow, "Flow");
+REGISTER_CLASS(AvoidCrossingPerimeters, "GCode::AvoidCrossingPerimeters");
+REGISTER_CLASS(OozePrevention, "GCode::OozePrevention");
+REGISTER_CLASS(Wipe, "GCode::Wipe");
+REGISTER_CLASS(GCode, "GCode");
+REGISTER_CLASS(GCodeSender, "GCode::Sender");
+REGISTER_CLASS(GCodeWriter, "GCode::Writer");
+REGISTER_CLASS(Layer, "Layer");
+REGISTER_CLASS(SupportLayer, "Layer::Support");
+REGISTER_CLASS(LayerRegion, "Layer::Region");
+REGISTER_CLASS(Line, "Line");
+REGISTER_CLASS(Linef3, "Linef3");
+REGISTER_CLASS(PerimeterGenerator, "Layer::PerimeterGenerator");
+REGISTER_CLASS(PlaceholderParser, "GCode::PlaceholderParser");
+REGISTER_CLASS(Polygon, "Polygon");
+REGISTER_CLASS(Polyline, "Polyline");
+REGISTER_CLASS(PolylineCollection, "Polyline::Collection");
+REGISTER_CLASS(Print, "Print");
+REGISTER_CLASS(PrintObject, "Print::Object");
+REGISTER_CLASS(PrintRegion, "Print::Region");
+REGISTER_CLASS(Model, "Model");
+REGISTER_CLASS(ModelMaterial, "Model::Material");
+REGISTER_CLASS(ModelObject, "Model::Object");
+REGISTER_CLASS(ModelVolume, "Model::Volume");
+REGISTER_CLASS(ModelInstance, "Model::Instance");
+REGISTER_CLASS(MotionPlanner, "MotionPlanner");
+REGISTER_CLASS(BoundingBox, "Geometry::BoundingBox");
+REGISTER_CLASS(BoundingBoxf, "Geometry::BoundingBoxf");
+REGISTER_CLASS(BoundingBoxf3, "Geometry::BoundingBoxf3");
+REGISTER_CLASS(BridgeDetector, "BridgeDetector");
+REGISTER_CLASS(Point, "Point");
+REGISTER_CLASS(Point3, "Point3");
+REGISTER_CLASS(Pointf, "Pointf");
+REGISTER_CLASS(Pointf3, "Pointf3");
+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");
+REGISTER_CLASS(Surface, "Surface");
+REGISTER_CLASS(SurfaceCollection, "Surface::Collection");
+REGISTER_CLASS(TriangleMesh, "TriangleMesh");
+REGISTER_CLASS(GLVertexArray, "GUI::_3DScene::GLVertexArray");
+
+SV*
+ConfigBase__as_hash(ConfigBase* THIS) {
+ 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(), ConfigBase__get(THIS, *it), 0 );
+
+ return newRV_noinc((SV*)hv);
+}
+
+SV*
+ConfigBase__get(ConfigBase* THIS, const 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(ConfigBase* THIS, const 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(ConfigBase* THIS, const 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 from_SV_check(value, &optv->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 || !from_SV_check(*elem, &point)) 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(ConfigBase* THIS, 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(ConfigBase* THIS, const t_config_option_key &opt_key, SV* value, bool deserialize)
+{
+ if (!THIS->has(opt_key)) {
+ if (deserialize) {
+ ConfigBase__set_deserialize(THIS, opt_key, value);
+ } else {
+ ConfigBase__set(THIS, opt_key, value);
+ }
+ }
+}
+
+bool
+StaticConfig__set(StaticConfig* THIS, const 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 (!StaticConfig__set(THIS, *it, value)) return false;
+ }
+ return true;
+ }
+
+ return ConfigBase__set(THIS, opt_key, value);
+}
+
+SV* to_AV(ExPolygon* expolygon)
+{
+ const unsigned int num_holes = expolygon->holes.size();
+ AV* av = newAV();
+ av_extend(av, num_holes); // -1 +1
+
+ av_store(av, 0, perl_to_SV_ref(expolygon->contour));
+
+ for (unsigned int i = 0; i < num_holes; i++) {
+ av_store(av, i+1, perl_to_SV_ref(expolygon->holes[i]));
+ }
+ return newRV_noinc((SV*)av);
+}
+
+SV* to_SV_pureperl(const ExPolygon* expolygon)
+{
+ const unsigned int num_holes = expolygon->holes.size();
+ AV* av = newAV();
+ av_extend(av, num_holes); // -1 +1
+ av_store(av, 0, to_SV_pureperl(&expolygon->contour));
+ for (unsigned int i = 0; i < num_holes; i++) {
+ av_store(av, i+1, to_SV_pureperl(&expolygon->holes[i]));
+ }
+ return newRV_noinc((SV*)av);
+}
+
+void from_SV(SV* expoly_sv, ExPolygon* expolygon)
+{
+ AV* expoly_av = (AV*)SvRV(expoly_sv);
+ const unsigned int num_polygons = av_len(expoly_av)+1;
+ expolygon->holes.resize(num_polygons-1);
+
+ SV** polygon_sv = av_fetch(expoly_av, 0, 0);
+ from_SV(*polygon_sv, &expolygon->contour);
+ for (unsigned int i = 0; i < num_polygons-1; i++) {
+ polygon_sv = av_fetch(expoly_av, i+1, 0);
+ from_SV(*polygon_sv, &expolygon->holes[i]);
+ }
+}
+
+void from_SV_check(SV* expoly_sv, ExPolygon* expolygon)
+{
+ if (sv_isobject(expoly_sv) && (SvTYPE(SvRV(expoly_sv)) == SVt_PVMG)) {
+ if (!sv_isa(expoly_sv, perl_class_name(expolygon)) && !sv_isa(expoly_sv, perl_class_name_ref(expolygon)))
+ CONFESS("Not a valid %s object", perl_class_name(expolygon));
+ // a XS ExPolygon was supplied
+ *expolygon = *(ExPolygon *)SvIV((SV*)SvRV( expoly_sv ));
+ } else {
+ // a Perl arrayref was supplied
+ from_SV(expoly_sv, expolygon);
+ }
+}
+
+void from_SV(SV* line_sv, Line* THIS)
+{
+ AV* line_av = (AV*)SvRV(line_sv);
+ from_SV_check(*av_fetch(line_av, 0, 0), &THIS->a);
+ from_SV_check(*av_fetch(line_av, 1, 0), &THIS->b);
+}
+
+void from_SV_check(SV* line_sv, Line* THIS)
+{
+ 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 {
+ from_SV(line_sv, THIS);
+ }
+}
+
+SV* to_AV(Line* THIS)
+{
+ 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* to_SV_pureperl(const Line* THIS)
+{
+ AV* av = newAV();
+ av_extend(av, 1);
+ av_store(av, 0, to_SV_pureperl(&THIS->a));
+ av_store(av, 1, to_SV_pureperl(&THIS->b));
+ return newRV_noinc((SV*)av);
+}
+
+void from_SV(SV* poly_sv, MultiPoint* THIS)
+{
+ 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);
+ from_SV_check(*point_sv, &THIS->points[i]);
+ }
+}
+
+void from_SV_check(SV* poly_sv, MultiPoint* THIS)
+{
+ if (sv_isobject(poly_sv) && (SvTYPE(SvRV(poly_sv)) == SVt_PVMG)) {
+ *THIS = *(MultiPoint*)SvIV((SV*)SvRV( poly_sv ));
+ } else {
+ from_SV(poly_sv, THIS);
+ }
+}
+
+SV* to_AV(MultiPoint* THIS)
+{
+ 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* to_SV_pureperl(const MultiPoint* THIS)
+{
+ 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, to_SV_pureperl(&THIS->points[i]));
+ }
+ return newRV_noinc((SV*)av);
+}
+
+void from_SV_check(SV* poly_sv, Polygon* THIS)
+{
+ 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));
+
+ from_SV_check(poly_sv, (MultiPoint*)THIS);
+}
+
+void from_SV_check(SV* poly_sv, Polyline* THIS)
+{
+ 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));
+
+ from_SV_check(poly_sv, (MultiPoint*)THIS);
+}
+
+SV* to_SV_pureperl(const Point* THIS)
+{
+ 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 from_SV(SV* point_sv, Point* point)
+{
+ AV* point_av = (AV*)SvRV(point_sv);
+ // get a double from Perl and round it, otherwise
+ // it would get truncated
+ point->x = lrint(SvNV(*av_fetch(point_av, 0, 0)));
+ point->y = lrint(SvNV(*av_fetch(point_av, 1, 0)));
+}
+
+void from_SV_check(SV* point_sv, Point* point)
+{
+ if (sv_isobject(point_sv) && (SvTYPE(SvRV(point_sv)) == SVt_PVMG)) {
+ if (!sv_isa(point_sv, perl_class_name(point)) && !sv_isa(point_sv, perl_class_name_ref(point)))
+ CONFESS("Not a valid %s object (got %s)", perl_class_name(point), HvNAME(SvSTASH(SvRV(point_sv))));
+ *point = *(Point*)SvIV((SV*)SvRV( point_sv ));
+ } else {
+ from_SV(point_sv, point);
+ }
+}
+
+SV* to_SV_pureperl(const Pointf* point)
+{
+ AV* av = newAV();
+ av_fill(av, 1);
+ av_store(av, 0, newSVnv(point->x));
+ av_store(av, 1, newSVnv(point->y));
+ return newRV_noinc((SV*)av);
+}
+
+bool from_SV(SV* point_sv, Pointf* point)
+{
+ 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;
+
+ point->x = SvNV(sv_x);
+ point->y = SvNV(sv_y);
+ return true;
+}
+
+bool from_SV_check(SV* point_sv, Pointf* point)
+{
+ if (sv_isobject(point_sv) && (SvTYPE(SvRV(point_sv)) == SVt_PVMG)) {
+ if (!sv_isa(point_sv, perl_class_name(point)) && !sv_isa(point_sv, perl_class_name_ref(point)))
+ CONFESS("Not a valid %s object (got %s)", perl_class_name(point), HvNAME(SvSTASH(SvRV(point_sv))));
+ *point = *(Pointf*)SvIV((SV*)SvRV( point_sv ));
+ return true;
+ } else {
+ return from_SV(point_sv, point);
+ }
+}
+
+void from_SV_check(SV* surface_sv, Surface* THIS)
+{
+ 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 ));
+}
+
+SV* to_SV(TriangleMesh* THIS)
+{
+ SV* sv = newSV(0);
+ sv_setref_pv( sv, perl_class_name(THIS), (void*)THIS );
+ return sv;
+}
+
+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
diff --git a/xs/src/perlglue.hpp b/xs/src/perlglue.hpp
deleted file mode 100644
index b10cbcf11..000000000
--- a/xs/src/perlglue.hpp
+++ /dev/null
@@ -1,64 +0,0 @@
-#ifndef slic3r_perlglue_hpp_
-#define slic3r_perlglue_hpp_
-
-namespace Slic3r {
-
-template<class T>
-struct ClassTraits {
- static const char* name;
- static const char* name_ref;
-};
-
-// use this for typedefs for which the forward prototype
-// in REGISTER_CLASS won't work
-#define __REGISTER_CLASS(cname, perlname) \
- template <>const char* ClassTraits<cname>::name = "Slic3r::" perlname; \
- template <>const char* ClassTraits<cname>::name_ref = "Slic3r::" perlname "::Ref";
-
-#define REGISTER_CLASS(cname,perlname) \
- class cname; \
- __REGISTER_CLASS(cname, perlname);
-
-template<class T>
-const char* perl_class_name(const T*) { return ClassTraits<T>::name; }
-template<class T>
-const char* perl_class_name_ref(const T*) { return ClassTraits<T>::name_ref; }
-
-template<class T>
-SV* perl_to_SV_ref(T &t) {
- SV* sv = newSV(0);
- sv_setref_pv( sv, perl_class_name_ref(&t), &t );
- return sv;
-}
-
-template<class T>
-SV* perl_to_SV_clone_ref(const T &t) {
- SV* sv = newSV(0);
- sv_setref_pv( sv, perl_class_name(&t), new T(t) );
- return sv;
-}
-
-template <class T>
-class Ref {
- T* val;
-public:
- Ref() : val(NULL) {}
- Ref(T* t) : val(t) {}
- Ref(const T* t) : val(const_cast<T*>(t)) {}
- operator T*() const { return val; }
- static const char* CLASS() { return ClassTraits<T>::name_ref; }
-};
-
-template <class T>
-class Clone {
- T* val;
-public:
- Clone() : val(NULL) {}
- Clone(T* t) : val(new T(*t)) {}
- Clone(const T& t) : val(new T(t)) {}
- operator T*() const { return val; }
- static const char* CLASS() { return ClassTraits<T>::name; }
-};
-};
-
-#endif
diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp
index 5f61b37b3..e398a1c37 100644
--- a/xs/src/slic3r/GUI/3DScene.cpp
+++ b/xs/src/slic3r/GUI/3DScene.cpp
@@ -241,8 +241,4 @@ GLVertexArray::load_mesh(const TriangleMesh &mesh)
}
}
-#ifdef SLIC3RXS
-REGISTER_CLASS(GLVertexArray, "GUI::_3DScene::GLVertexArray");
-#endif
-
}
diff --git a/xs/src/slic3r/GUI/3DScene.hpp b/xs/src/slic3r/GUI/3DScene.hpp
index 5552b7310..85b6d08ec 100644
--- a/xs/src/slic3r/GUI/3DScene.hpp
+++ b/xs/src/slic3r/GUI/3DScene.hpp
@@ -1,7 +1,7 @@
#ifndef slic3r_3DScene_hpp_
#define slic3r_3DScene_hpp_
-#include <myinit.h>
+#include "../../libslic3r/libslic3r.h"
#include "../../libslic3r/Point.hpp"
#include "../../libslic3r/Line.hpp"
#include "../../libslic3r/TriangleMesh.hpp"
diff --git a/xs/src/xsinit.h b/xs/src/xsinit.h
new file mode 100644
index 000000000..b5b1d83f4
--- /dev/null
+++ b/xs/src/xsinit.h
@@ -0,0 +1,149 @@
+#ifndef _xsinit_h_
+#define _xsinit_h_
+
+// undef some macros set by Perl which cause compilation errors on Win32
+#undef read
+#undef seekdir
+#undef bind
+#undef send
+#undef connect
+#undef wait
+#undef accept
+#undef close
+#undef open
+#undef write
+#undef socket
+#undef listen
+#undef shutdown
+#undef ioctl
+#undef getpeername
+#undef rect
+#undef setsockopt
+#undef getsockopt
+#undef getsockname
+#undef gethostname
+#undef select
+#undef socketpair
+#undef recvfrom
+#undef sendto
+
+// these need to be included early for Win32 (listing it in Build.PL is not enough)
+#include <ostream>
+#include <iostream>
+#include <sstream>
+
+#ifdef SLIC3RXS
+extern "C" {
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+#include "ppport.h"
+#undef do_open
+#undef do_close
+}
+#endif
+
+#include <libslic3r.h>
+#include <ClipperUtils.hpp>
+#include <Config.hpp>
+#include <ExPolygon.hpp>
+#include <MultiPoint.hpp>
+#include <Point.hpp>
+#include <Polygon.hpp>
+#include <Polyline.hpp>
+#include <TriangleMesh.hpp>
+
+namespace Slic3r {
+
+template<class T>
+struct ClassTraits {
+ static const char* name;
+ static const char* name_ref;
+};
+
+// use this for typedefs for which the forward prototype
+// in REGISTER_CLASS won't work
+#define __REGISTER_CLASS(cname, perlname) \
+ template <>const char* ClassTraits<cname>::name = "Slic3r::" perlname; \
+ template <>const char* ClassTraits<cname>::name_ref = "Slic3r::" perlname "::Ref";
+
+#define REGISTER_CLASS(cname,perlname) \
+ class cname; \
+ __REGISTER_CLASS(cname, perlname);
+
+template<class T>
+const char* perl_class_name(const T*) { return ClassTraits<T>::name; }
+template<class T>
+const char* perl_class_name_ref(const T*) { return ClassTraits<T>::name_ref; }
+
+template<class T>
+SV* perl_to_SV_ref(T &t) {
+ SV* sv = newSV(0);
+ sv_setref_pv( sv, perl_class_name_ref(&t), &t );
+ return sv;
+}
+
+template<class T>
+SV* perl_to_SV_clone_ref(const T &t) {
+ SV* sv = newSV(0);
+ sv_setref_pv( sv, perl_class_name(&t), new T(t) );
+ return sv;
+}
+
+template <class T>
+class Ref {
+ T* val;
+public:
+ Ref() : val(NULL) {}
+ Ref(T* t) : val(t) {}
+ Ref(const T* t) : val(const_cast<T*>(t)) {}
+ operator T*() const { return val; }
+ static const char* CLASS() { return ClassTraits<T>::name_ref; }
+};
+
+template <class T>
+class Clone {
+ T* val;
+public:
+ Clone() : val(NULL) {}
+ Clone(T* t) : val(new T(*t)) {}
+ Clone(const T& t) : val(new T(t)) {}
+ operator T*() const { return val; }
+ static const char* CLASS() { return ClassTraits<T>::name; }
+};
+
+SV* ConfigBase__as_hash(ConfigBase* THIS);
+SV* ConfigBase__get(ConfigBase* THIS, const t_config_option_key &opt_key);
+SV* ConfigBase__get_at(ConfigBase* THIS, const t_config_option_key &opt_key, size_t i);
+bool ConfigBase__set(ConfigBase* THIS, const t_config_option_key &opt_key, SV* value);
+bool ConfigBase__set_deserialize(ConfigBase* THIS, const t_config_option_key &opt_key, SV* str);
+void ConfigBase__set_ifndef(ConfigBase* THIS, const t_config_option_key &opt_key, SV* value, bool deserialize = false);
+bool StaticConfig__set(StaticConfig* THIS, const t_config_option_key &opt_key, SV* value);
+SV* to_AV(ExPolygon* expolygon);
+SV* to_SV_pureperl(const ExPolygon* expolygon);
+void from_SV(SV* expoly_sv, ExPolygon* expolygon);
+void from_SV_check(SV* expoly_sv, ExPolygon* expolygon);
+void from_SV(SV* line_sv, Line* THIS);
+void from_SV_check(SV* line_sv, Line* THIS);
+SV* to_AV(Line* THIS);
+SV* to_SV_pureperl(const Line* THIS);
+void from_SV(SV* poly_sv, MultiPoint* THIS);
+void from_SV_check(SV* poly_sv, MultiPoint* THIS);
+SV* to_AV(MultiPoint* THIS);
+SV* to_SV_pureperl(const MultiPoint* THIS);
+void from_SV_check(SV* poly_sv, Polygon* THIS);
+void from_SV_check(SV* poly_sv, Polyline* THIS);
+SV* to_SV_pureperl(const Point* THIS);
+void from_SV(SV* point_sv, Point* point);
+void from_SV_check(SV* point_sv, Point* point);
+SV* to_SV_pureperl(const Pointf* point);
+bool from_SV(SV* point_sv, Pointf* point);
+bool from_SV_check(SV* point_sv, Pointf* point);
+void from_SV_check(SV* surface_sv, Surface* THIS);
+SV* to_SV(TriangleMesh* THIS);
+SV* polynode_children_2_perl(const ClipperLib::PolyNode& node);
+SV* polynode2perl(const ClipperLib::PolyNode& node);
+
+}
+
+#endif
diff --git a/xs/xsp/BoundingBox.xsp b/xs/xsp/BoundingBox.xsp
index 22eb0ea7d..db424ff29 100644
--- a/xs/xsp/BoundingBox.xsp
+++ b/xs/xsp/BoundingBox.xsp
@@ -1,7 +1,7 @@
%module{Slic3r::XS};
%{
-#include <myinit.h>
+#include <xsinit.h>
#include "libslic3r/BoundingBox.hpp"
#include "libslic3r/Point.hpp"
%}
diff --git a/xs/xsp/BridgeDetector.xsp b/xs/xsp/BridgeDetector.xsp
index 0350dae87..9670bda3f 100644
--- a/xs/xsp/BridgeDetector.xsp
+++ b/xs/xsp/BridgeDetector.xsp
@@ -1,7 +1,7 @@
%module{Slic3r::XS};
%{
-#include <myinit.h>
+#include <xsinit.h>
#include "libslic3r/BridgeDetector.hpp"
%}
diff --git a/xs/xsp/Clipper.xsp b/xs/xsp/Clipper.xsp
index d9530f770..7a33ea0c4 100644
--- a/xs/xsp/Clipper.xsp
+++ b/xs/xsp/Clipper.xsp
@@ -1,7 +1,7 @@
%module{Slic3r::XS};
%{
-#include <myinit.h>
+#include <xsinit.h>
#include "clipper.hpp"
#include "libslic3r/ClipperUtils.hpp"
%}
diff --git a/xs/xsp/Config.xsp b/xs/xsp/Config.xsp
index bb8fa7b49..a9de4f49f 100644
--- a/xs/xsp/Config.xsp
+++ b/xs/xsp/Config.xsp
@@ -1,7 +1,7 @@
%module{Slic3r::XS};
%{
-#include <myinit.h>
+#include <xsinit.h>
#include "libslic3r/PrintConfig.hpp"
%}
@@ -9,12 +9,18 @@
DynamicPrintConfig();
~DynamicPrintConfig();
bool has(t_config_option_key opt_key);
- SV* as_hash();
- SV* get(t_config_option_key opt_key);
- SV* get_at(t_config_option_key opt_key, int i);
- bool set(t_config_option_key opt_key, SV* value);
- bool set_deserialize(t_config_option_key opt_key, SV* str);
- void set_ifndef(t_config_option_key opt_key, SV* value, bool deserialize = false);
+ SV* as_hash()
+ %code{% RETVAL = ConfigBase__as_hash(THIS); %};
+ SV* get(t_config_option_key opt_key)
+ %code{% RETVAL = ConfigBase__get(THIS, opt_key); %};
+ SV* get_at(t_config_option_key opt_key, int i)
+ %code{% RETVAL = ConfigBase__get_at(THIS, opt_key, i); %};
+ bool set(t_config_option_key opt_key, SV* value)
+ %code{% RETVAL = ConfigBase__set(THIS, opt_key, value); %};
+ bool set_deserialize(t_config_option_key opt_key, SV* str)
+ %code{% RETVAL = ConfigBase__set_deserialize(THIS, opt_key, str); %};
+ void set_ifndef(t_config_option_key opt_key, SV* value, bool deserialize = false)
+ %code{% ConfigBase__set_ifndef(THIS, opt_key, value, deserialize); %};
std::string serialize(t_config_option_key opt_key);
double get_abs_value(t_config_option_key opt_key);
%name{get_abs_value_over}
@@ -38,12 +44,18 @@
GCodeConfig();
~GCodeConfig();
bool has(t_config_option_key opt_key);
- SV* as_hash();
- SV* get(t_config_option_key opt_key);
- SV* get_at(t_config_option_key opt_key, int i);
- bool set(t_config_option_key opt_key, SV* value);
- bool set_deserialize(t_config_option_key opt_key, SV* str);
- void set_ifndef(t_config_option_key opt_key, SV* value, bool deserialize = false);
+ SV* as_hash()
+ %code{% RETVAL = ConfigBase__as_hash(THIS); %};
+ SV* get(t_config_option_key opt_key)
+ %code{% RETVAL = ConfigBase__get(THIS, opt_key); %};
+ SV* get_at(t_config_option_key opt_key, int i)
+ %code{% RETVAL = ConfigBase__get_at(THIS, opt_key, i); %};
+ bool set(t_config_option_key opt_key, SV* value)
+ %code{% RETVAL = StaticConfig__set(THIS, opt_key, value); %};
+ bool set_deserialize(t_config_option_key opt_key, SV* str)
+ %code{% RETVAL = ConfigBase__set_deserialize(THIS, opt_key, str); %};
+ void set_ifndef(t_config_option_key opt_key, SV* value, bool deserialize = false)
+ %code{% ConfigBase__set_ifndef(THIS, opt_key, value, deserialize); %};
std::string serialize(t_config_option_key opt_key);
double get_abs_value(t_config_option_key opt_key);
%name{get_abs_value_over}
@@ -61,12 +73,18 @@
PrintConfig();
~PrintConfig();
bool has(t_config_option_key opt_key);
- SV* as_hash();
- SV* get(t_config_option_key opt_key);
- SV* get_at(t_config_option_key opt_key, int i);
- bool set(t_config_option_key opt_key, SV* value);
- bool set_deserialize(t_config_option_key opt_key, SV* str);
- void set_ifndef(t_config_option_key opt_key, SV* value, bool deserialize = false);
+ SV* as_hash()
+ %code{% RETVAL = ConfigBase__as_hash(THIS); %};
+ SV* get(t_config_option_key opt_key)
+ %code{% RETVAL = ConfigBase__get(THIS, opt_key); %};
+ SV* get_at(t_config_option_key opt_key, int i)
+ %code{% RETVAL = ConfigBase__get_at(THIS, opt_key, i); %};
+ bool set(t_config_option_key opt_key, SV* value)
+ %code{% RETVAL = StaticConfig__set(THIS, opt_key, value); %};
+ bool set_deserialize(t_config_option_key opt_key, SV* str)
+ %code{% RETVAL = ConfigBase__set_deserialize(THIS, opt_key, str); %};
+ void set_ifndef(t_config_option_key opt_key, SV* value, bool deserialize = false)
+ %code{% ConfigBase__set_ifndef(THIS, opt_key, value, deserialize); %};
std::string serialize(t_config_option_key opt_key);
double get_abs_value(t_config_option_key opt_key);
%name{get_abs_value_over}
@@ -83,12 +101,18 @@
PrintRegionConfig();
~PrintRegionConfig();
bool has(t_config_option_key opt_key);
- SV* as_hash();
- SV* get(t_config_option_key opt_key);
- SV* get_at(t_config_option_key opt_key, int i);
- bool set(t_config_option_key opt_key, SV* value);
- bool set_deserialize(t_config_option_key opt_key, SV* str);
- void set_ifndef(t_config_option_key opt_key, SV* value, bool deserialize = false);
+ SV* as_hash()
+ %code{% RETVAL = ConfigBase__as_hash(THIS); %};
+ SV* get(t_config_option_key opt_key)
+ %code{% RETVAL = ConfigBase__get(THIS, opt_key); %};
+ SV* get_at(t_config_option_key opt_key, int i)
+ %code{% RETVAL = ConfigBase__get_at(THIS, opt_key, i); %};
+ bool set(t_config_option_key opt_key, SV* value)
+ %code{% RETVAL = StaticConfig__set(THIS, opt_key, value); %};
+ bool set_deserialize(t_config_option_key opt_key, SV* str)
+ %code{% RETVAL = ConfigBase__set_deserialize(THIS, opt_key, str); %};
+ void set_ifndef(t_config_option_key opt_key, SV* value, bool deserialize = false)
+ %code{% ConfigBase__set_ifndef(THIS, opt_key, value, deserialize); %};
std::string serialize(t_config_option_key opt_key);
double get_abs_value(t_config_option_key opt_key);
%name{get_abs_value_over}
@@ -105,12 +129,18 @@
PrintObjectConfig();
~PrintObjectConfig();
bool has(t_config_option_key opt_key);
- SV* as_hash();
- SV* get(t_config_option_key opt_key);
- SV* get_at(t_config_option_key opt_key, int i);
- bool set(t_config_option_key opt_key, SV* value);
- bool set_deserialize(t_config_option_key opt_key, SV* str);
- void set_ifndef(t_config_option_key opt_key, SV* value, bool deserialize = false);
+ SV* as_hash()
+ %code{% RETVAL = ConfigBase__as_hash(THIS); %};
+ SV* get(t_config_option_key opt_key)
+ %code{% RETVAL = ConfigBase__get(THIS, opt_key); %};
+ SV* get_at(t_config_option_key opt_key, int i)
+ %code{% RETVAL = ConfigBase__get_at(THIS, opt_key, i); %};
+ bool set(t_config_option_key opt_key, SV* value)
+ %code{% RETVAL = StaticConfig__set(THIS, opt_key, value); %};
+ bool set_deserialize(t_config_option_key opt_key, SV* str)
+ %code{% RETVAL = ConfigBase__set_deserialize(THIS, opt_key, str); %};
+ void set_ifndef(t_config_option_key opt_key, SV* value, bool deserialize = false)
+ %code{% ConfigBase__set_ifndef(THIS, opt_key, value, deserialize); %};
std::string serialize(t_config_option_key opt_key);
double get_abs_value(t_config_option_key opt_key);
%name{get_abs_value_over}
@@ -127,12 +157,18 @@
FullPrintConfig();
~FullPrintConfig();
bool has(t_config_option_key opt_key);
- SV* as_hash();
- SV* get(t_config_option_key opt_key);
- SV* get_at(t_config_option_key opt_key, int i);
- bool set(t_config_option_key opt_key, SV* value);
- bool set_deserialize(t_config_option_key opt_key, SV* str);
- void set_ifndef(t_config_option_key opt_key, SV* value, bool deserialize = false);
+ SV* as_hash()
+ %code{% RETVAL = ConfigBase__as_hash(THIS); %};
+ SV* get(t_config_option_key opt_key)
+ %code{% RETVAL = ConfigBase__get(THIS, opt_key); %};
+ SV* get_at(t_config_option_key opt_key, int i)
+ %code{% RETVAL = ConfigBase__get_at(THIS, opt_key, i); %};
+ bool set(t_config_option_key opt_key, SV* value)
+ %code{% RETVAL = StaticConfig__set(THIS, opt_key, value); %};
+ bool set_deserialize(t_config_option_key opt_key, SV* str)
+ %code{% RETVAL = ConfigBase__set_deserialize(THIS, opt_key, str); %};
+ void set_ifndef(t_config_option_key opt_key, SV* value, bool deserialize = false)
+ %code{% ConfigBase__set_ifndef(THIS, opt_key, value, deserialize); %};
std::string serialize(t_config_option_key opt_key);
double get_abs_value(t_config_option_key opt_key);
%name{get_abs_value_over}
@@ -244,7 +280,7 @@ print_config_def()
(void)hv_stores( hv, "labels", newRV_noinc((SV*)av) );
}
- (void)hv_stores( hv, "default", config.get(opt_key) );
+ (void)hv_stores( hv, "default", ConfigBase__get(&config, opt_key) );
(void)hv_store( options_hv, opt_key.c_str(), opt_key.length(), newRV_noinc((SV*)hv), 0 );
}
diff --git a/xs/xsp/ExPolygon.xsp b/xs/xsp/ExPolygon.xsp
index 75777fa56..d45b7f6b1 100644
--- a/xs/xsp/ExPolygon.xsp
+++ b/xs/xsp/ExPolygon.xsp
@@ -1,7 +1,7 @@
%module{Slic3r::XS};
%{
-#include <myinit.h>
+#include <xsinit.h>
#include "libslic3r/ExPolygon.hpp"
%}
@@ -10,9 +10,9 @@
Clone<ExPolygon> clone()
%code{% RETVAL = THIS; %};
SV* arrayref()
- %code{% RETVAL = THIS->to_AV(); %};
+ %code{% RETVAL = to_AV(THIS); %};
SV* pp()
- %code{% RETVAL = THIS->to_SV_pureperl(); %};
+ %code{% RETVAL = to_SV_pureperl(THIS); %};
Ref<Polygon> contour()
%code{% RETVAL = &(THIS->contour); %};
Polygons* holes()
@@ -46,10 +46,10 @@ ExPolygon::new(...)
CODE:
RETVAL = new ExPolygon ();
// ST(0) is class name, ST(1) is contour and others are holes
- RETVAL->contour.from_SV_check(ST(1));
+ from_SV_check(ST(1), &RETVAL->contour);
RETVAL->holes.resize(items-2);
for (unsigned int i = 2; i < items; i++) {
- RETVAL->holes[i-2].from_SV_check(ST(i));
+ from_SV_check(ST(i), &RETVAL->holes[i-2]);
}
OUTPUT:
RETVAL
@@ -60,7 +60,7 @@ ExPolygon::rotate(angle, center_sv)
SV* center_sv;
CODE:
Point center;
- center.from_SV_check(center_sv);
+ from_SV_check(center_sv, &center);
THIS->rotate(angle, center);
%}
diff --git a/xs/xsp/ExPolygonCollection.xsp b/xs/xsp/ExPolygonCollection.xsp
index 99ef69608..e04d24e12 100644
--- a/xs/xsp/ExPolygonCollection.xsp
+++ b/xs/xsp/ExPolygonCollection.xsp
@@ -1,7 +1,7 @@
%module{Slic3r::XS};
%{
-#include <myinit.h>
+#include <xsinit.h>
#include "libslic3r/ExPolygonCollection.hpp"
%}
@@ -37,7 +37,7 @@ ExPolygonCollection::new(...)
RETVAL->expolygons.resize(items-1);
for (unsigned int i = 1; i < items; i++) {
// Note: a COPY of the input is stored
- RETVAL->expolygons[i-1].from_SV_check(ST(i));
+ from_SV_check(ST(i), &RETVAL->expolygons[i-1]);
}
OUTPUT:
RETVAL
@@ -62,7 +62,7 @@ ExPolygonCollection::pp()
av_fill(av, THIS->expolygons.size()-1);
int i = 0;
for (ExPolygons::iterator it = THIS->expolygons.begin(); it != THIS->expolygons.end(); ++it) {
- av_store(av, i++, (*it).to_SV_pureperl());
+ av_store(av, i++, to_SV_pureperl(&*it));
}
RETVAL = newRV_noinc((SV*)av);
OUTPUT:
@@ -73,7 +73,7 @@ ExPolygonCollection::append(...)
CODE:
for (unsigned int i = 1; i < items; i++) {
ExPolygon expolygon;
- expolygon.from_SV_check( ST(i) );
+ from_SV_check(ST(i), &expolygon);
THIS->expolygons.push_back(expolygon);
}
diff --git a/xs/xsp/Extruder.xsp b/xs/xsp/Extruder.xsp
index aac39c413..57c64d94c 100644
--- a/xs/xsp/Extruder.xsp
+++ b/xs/xsp/Extruder.xsp
@@ -1,7 +1,7 @@
%module{Slic3r::XS};
%{
-#include <myinit.h>
+#include <xsinit.h>
#include "libslic3r/Extruder.hpp"
%}
diff --git a/xs/xsp/ExtrusionEntityCollection.xsp b/xs/xsp/ExtrusionEntityCollection.xsp
index 7570d078a..eb7964c22 100644
--- a/xs/xsp/ExtrusionEntityCollection.xsp
+++ b/xs/xsp/ExtrusionEntityCollection.xsp
@@ -1,7 +1,7 @@
%module{Slic3r::XS};
%{
-#include <myinit.h>
+#include <xsinit.h>
#include "libslic3r/ExtrusionEntityCollection.hpp"
%}
diff --git a/xs/xsp/ExtrusionLoop.xsp b/xs/xsp/ExtrusionLoop.xsp
index 3b7adcd6a..39398cbaf 100644
--- a/xs/xsp/ExtrusionLoop.xsp
+++ b/xs/xsp/ExtrusionLoop.xsp
@@ -1,7 +1,7 @@
%module{Slic3r::XS};
%{
-#include <myinit.h>
+#include <xsinit.h>
#include "libslic3r/ExtrusionEntity.hpp"
%}
diff --git a/xs/xsp/ExtrusionPath.xsp b/xs/xsp/ExtrusionPath.xsp
index ca1b465cb..d9892d10c 100644
--- a/xs/xsp/ExtrusionPath.xsp
+++ b/xs/xsp/ExtrusionPath.xsp
@@ -1,7 +1,7 @@
%module{Slic3r::XS};
%{
-#include <myinit.h>
+#include <xsinit.h>
#include "libslic3r/ExtrusionEntity.hpp"
#include "libslic3r/ExtrusionEntityCollection.hpp"
%}
@@ -9,9 +9,9 @@
%name{Slic3r::ExtrusionPath} class ExtrusionPath {
~ExtrusionPath();
SV* arrayref()
- %code{% RETVAL = THIS->polyline.to_AV(); %};
+ %code{% RETVAL = to_AV(&THIS->polyline); %};
SV* pp()
- %code{% RETVAL = THIS->polyline.to_SV_pureperl(); %};
+ %code{% RETVAL = to_SV_pureperl(&THIS->polyline); %};
void pop_back()
%code{% THIS->polyline.points.pop_back(); %};
void reverse();
@@ -39,7 +39,7 @@ _new(CLASS, polyline_sv, role, mm3_per_mm, width, height)
float height;
CODE:
RETVAL = new ExtrusionPath (role);
- RETVAL->polyline.from_SV_check(polyline_sv);
+ from_SV_check(polyline_sv, &RETVAL->polyline);
RETVAL->mm3_per_mm = mm3_per_mm;
RETVAL->width = width;
RETVAL->height = height;
@@ -50,7 +50,7 @@ Ref<Polyline>
ExtrusionPath::polyline(...)
CODE:
if (items > 1) {
- THIS->polyline.from_SV_check( ST(1) );
+ from_SV_check(ST(1), &THIS->polyline);
}
RETVAL = &(THIS->polyline);
OUTPUT:
@@ -101,7 +101,7 @@ ExtrusionPath::append(...)
CODE:
for (unsigned int i = 1; i < items; i++) {
Point p;
- p.from_SV_check(ST(i));
+ from_SV_check(ST(i), &p);
THIS->polyline.points.push_back(p);
}
diff --git a/xs/xsp/Flow.xsp b/xs/xsp/Flow.xsp
index 805c1a7a1..d09f0b351 100644
--- a/xs/xsp/Flow.xsp
+++ b/xs/xsp/Flow.xsp
@@ -1,7 +1,7 @@
%module{Slic3r::XS};
%{
-#include <myinit.h>
+#include <xsinit.h>
#include "libslic3r/Flow.hpp"
%}
diff --git a/xs/xsp/GCode.xsp b/xs/xsp/GCode.xsp
index 4ab816bb8..8197bb1ac 100644
--- a/xs/xsp/GCode.xsp
+++ b/xs/xsp/GCode.xsp
@@ -1,7 +1,7 @@
%module{Slic3r::XS};
%{
-#include <myinit.h>
+#include <xsinit.h>
#include "libslic3r/GCode.hpp"
%}
diff --git a/xs/xsp/GCodeWriter.xsp b/xs/xsp/GCodeWriter.xsp
index 18ae7b0e2..15a919da8 100644
--- a/xs/xsp/GCodeWriter.xsp
+++ b/xs/xsp/GCodeWriter.xsp
@@ -1,7 +1,7 @@
%module{Slic3r::XS};
%{
-#include <myinit.h>
+#include <xsinit.h>
#include "libslic3r/GCodeWriter.hpp"
%}
diff --git a/xs/xsp/GUI.xsp b/xs/xsp/GUI.xsp
index 24e1fa8b9..a422040e1 100644
--- a/xs/xsp/GUI.xsp
+++ b/xs/xsp/GUI.xsp
@@ -1,7 +1,7 @@
%module{Slic3r::XS};
%{
-#include <myinit.h>
+#include <xsinit.h>
#include "slic3r/GUI/GUI.hpp"
%}
diff --git a/xs/xsp/GUI_3DScene.xsp b/xs/xsp/GUI_3DScene.xsp
index 86694fbaa..4ff101937 100644
--- a/xs/xsp/GUI_3DScene.xsp
+++ b/xs/xsp/GUI_3DScene.xsp
@@ -1,6 +1,6 @@
%module{Slic3r::XS};
-#include <myinit.h>
+#include <xsinit.h>
#include "slic3r/GUI/3DScene.hpp"
%name{Slic3r::GUI::_3DScene::GLVertexArray} class GLVertexArray {
diff --git a/xs/xsp/Geometry.xsp b/xs/xsp/Geometry.xsp
index c5ed0fa5f..718ce5bdf 100644
--- a/xs/xsp/Geometry.xsp
+++ b/xs/xsp/Geometry.xsp
@@ -1,7 +1,7 @@
%module{Slic3r::XS};
%{
-#include <myinit.h>
+#include <xsinit.h>
#include "libslic3r/Geometry.hpp"
%}
diff --git a/xs/xsp/Layer.xsp b/xs/xsp/Layer.xsp
index 543b500b1..e5697ce89 100644
--- a/xs/xsp/Layer.xsp
+++ b/xs/xsp/Layer.xsp
@@ -1,7 +1,7 @@
%module{Slic3r::XS};
%{
-#include <myinit.h>
+#include <xsinit.h>
#include "libslic3r/Layer.hpp"
%}
diff --git a/xs/xsp/Line.xsp b/xs/xsp/Line.xsp
index 7ee644494..461856a1a 100644
--- a/xs/xsp/Line.xsp
+++ b/xs/xsp/Line.xsp
@@ -1,7 +1,7 @@
%module{Slic3r::XS};
%{
-#include <myinit.h>
+#include <xsinit.h>
#include "libslic3r/Line.hpp"
#include "libslic3r/Polyline.hpp"
%}
@@ -11,9 +11,9 @@
Clone<Line> clone()
%code{% RETVAL = THIS; %};
SV* arrayref()
- %code{% RETVAL = THIS->to_AV(); %};
+ %code{% RETVAL = to_AV(THIS); %};
SV* pp()
- %code{% RETVAL = THIS->to_SV_pureperl(); %};
+ %code{% RETVAL = to_SV_pureperl(THIS); %};
Ref<Point> a()
%code{% RETVAL=&THIS->a; %};
Ref<Point> b()
@@ -48,8 +48,8 @@ Line::new(...)
CODE:
RETVAL = new Line ();
// ST(0) is class name, ST(1) and ST(2) are endpoints
- RETVAL->a.from_SV_check( ST(1) );
- RETVAL->b.from_SV_check( ST(2) );
+ from_SV_check(ST(1), &RETVAL->a);
+ from_SV_check(ST(2), &RETVAL->b);
OUTPUT:
RETVAL
@@ -59,7 +59,7 @@ Line::rotate(angle, center_sv)
SV* center_sv;
CODE:
Point center;
- center.from_SV_check(center_sv);
+ from_SV_check(center_sv, &center);
THIS->rotate(angle, center);
bool
@@ -67,7 +67,7 @@ Line::coincides_with(line_sv)
SV* line_sv;
CODE:
Line line;
- line.from_SV_check(line_sv);
+ from_SV_check(line_sv, &line);
RETVAL = THIS->coincides_with(line);
OUTPUT:
RETVAL
diff --git a/xs/xsp/Model.xsp b/xs/xsp/Model.xsp
index 929ae3502..3cc0f5e3b 100644
--- a/xs/xsp/Model.xsp
+++ b/xs/xsp/Model.xsp
@@ -1,7 +1,7 @@
%module{Slic3r::XS};
%{
-#include <myinit.h>
+#include <xsinit.h>
#include "libslic3r/Model.hpp"
#include "libslic3r/PrintConfig.hpp"
%}
diff --git a/xs/xsp/MotionPlanner.xsp b/xs/xsp/MotionPlanner.xsp
index 896923307..d93ed09ea 100644
--- a/xs/xsp/MotionPlanner.xsp
+++ b/xs/xsp/MotionPlanner.xsp
@@ -1,7 +1,7 @@
%module{Slic3r::XS};
%{
-#include <myinit.h>
+#include <xsinit.h>
#include "libslic3r/MotionPlanner.hpp"
%}
diff --git a/xs/xsp/PerimeterGenerator.xsp b/xs/xsp/PerimeterGenerator.xsp
index 351c6f4c0..b5da8156c 100644
--- a/xs/xsp/PerimeterGenerator.xsp
+++ b/xs/xsp/PerimeterGenerator.xsp
@@ -1,7 +1,7 @@
%module{Slic3r::XS};
%{
-#include <myinit.h>
+#include <xsinit.h>
#include "libslic3r/PerimeterGenerator.hpp"
%}
diff --git a/xs/xsp/PlaceholderParser.xsp b/xs/xsp/PlaceholderParser.xsp
index e25aa52f3..7daa638b6 100644
--- a/xs/xsp/PlaceholderParser.xsp
+++ b/xs/xsp/PlaceholderParser.xsp
@@ -1,7 +1,7 @@
%module{Slic3r::XS};
%{
-#include <myinit.h>
+#include <xsinit.h>
#include <vector>
#include "libslic3r/PlaceholderParser.hpp"
%}
diff --git a/xs/xsp/Point.xsp b/xs/xsp/Point.xsp
index 34017a3b4..60a4864e3 100644
--- a/xs/xsp/Point.xsp
+++ b/xs/xsp/Point.xsp
@@ -1,7 +1,7 @@
%module{Slic3r::XS};
%{
-#include <myinit.h>
+#include <xsinit.h>
#include "libslic3r/Point.hpp"
#include "libslic3r/Polygon.hpp"
#include "libslic3r/Polyline.hpp"
@@ -15,9 +15,9 @@
void scale(double factor);
void translate(double x, double y);
SV* arrayref()
- %code{% RETVAL = THIS->to_SV_pureperl(); %};
+ %code{% RETVAL = to_SV_pureperl(THIS); %};
SV* pp()
- %code{% RETVAL = THIS->to_SV_pureperl(); %};
+ %code{% RETVAL = to_SV_pureperl(THIS); %};
long x()
%code{% RETVAL = THIS->x; %};
long y()
@@ -58,7 +58,7 @@ Point::rotate(angle, center_sv)
SV* center_sv;
CODE:
Point center;
- center.from_SV_check(center_sv);
+ from_SV_check(center_sv, &center);
THIS->rotate(angle, center);
bool
@@ -66,7 +66,7 @@ Point::coincides_with(point_sv)
SV* point_sv;
CODE:
Point point;
- point.from_SV_check(point_sv);
+ from_SV_check(point_sv, &point);
RETVAL = THIS->coincides_with(point);
OUTPUT:
RETVAL
@@ -94,9 +94,9 @@ Point::coincides_with(point_sv)
Clone<Pointf> clone()
%code{% RETVAL = THIS; %};
SV* arrayref()
- %code{% RETVAL = THIS->to_SV_pureperl(); %};
+ %code{% RETVAL = to_SV_pureperl(THIS); %};
SV* pp()
- %code{% RETVAL = THIS->to_SV_pureperl(); %};
+ %code{% RETVAL = to_SV_pureperl(THIS); %};
double x()
%code{% RETVAL = THIS->x; %};
double y()
diff --git a/xs/xsp/Polygon.xsp b/xs/xsp/Polygon.xsp
index 824a65310..ec97aabcf 100644
--- a/xs/xsp/Polygon.xsp
+++ b/xs/xsp/Polygon.xsp
@@ -1,7 +1,7 @@
%module{Slic3r::XS};
%{
-#include <myinit.h>
+#include <xsinit.h>
#include "libslic3r/BoundingBox.hpp"
#include "libslic3r/Polygon.hpp"
#include "libslic3r/BoundingBox.hpp"
@@ -12,9 +12,9 @@
Clone<Polygon> clone()
%code{% RETVAL = THIS; %};
SV* arrayref()
- %code{% RETVAL = THIS->to_AV(); %};
+ %code{% RETVAL = to_AV(THIS); %};
SV* pp()
- %code{% RETVAL = THIS->to_SV_pureperl(); %};
+ %code{% RETVAL = to_SV_pureperl(THIS); %};
void scale(double factor);
void translate(double x, double y);
void reverse();
@@ -51,7 +51,7 @@ Polygon::new(...)
// ST(0) is class name, ST(1) is first point
RETVAL->points.resize(items-1);
for (unsigned int i = 1; i < items; i++) {
- RETVAL->points[i-1].from_SV_check( ST(i) );
+ from_SV_check(ST(i), &RETVAL->points[i-1]);
}
OUTPUT:
RETVAL
@@ -62,7 +62,7 @@ Polygon::rotate(angle, center_sv)
SV* center_sv;
CODE:
Point center;
- center.from_SV_check(center_sv);
+ from_SV_check(center_sv, &center);
THIS->rotate(angle, center);
%}
diff --git a/xs/xsp/Polyline.xsp b/xs/xsp/Polyline.xsp
index 98cd44e94..31bd4045e 100644
--- a/xs/xsp/Polyline.xsp
+++ b/xs/xsp/Polyline.xsp
@@ -1,7 +1,7 @@
%module{Slic3r::XS};
%{
-#include <myinit.h>
+#include <xsinit.h>
#include "libslic3r/BoundingBox.hpp"
#include "libslic3r/ClipperUtils.hpp"
#include "libslic3r/Polyline.hpp"
@@ -12,9 +12,9 @@
Clone<Polyline> clone()
%code{% RETVAL = THIS; %};
SV* arrayref()
- %code{% RETVAL = THIS->to_AV(); %};
+ %code{% RETVAL = to_AV(THIS); %};
SV* pp()
- %code{% RETVAL = THIS->to_SV_pureperl(); %};
+ %code{% RETVAL = to_SV_pureperl(THIS); %};
void scale(double factor);
void translate(double x, double y);
void pop_back()
@@ -48,7 +48,7 @@ Polyline::new(...)
// ST(0) is class name, ST(1) is first point
RETVAL->points.resize(items-1);
for (unsigned int i = 1; i < items; i++) {
- RETVAL->points[i-1].from_SV_check( ST(i) );
+ from_SV_check(ST(i), &RETVAL->points[i-1]);
}
OUTPUT:
RETVAL
@@ -58,7 +58,7 @@ Polyline::append(...)
CODE:
for (unsigned int i = 1; i < items; i++) {
Point p;
- p.from_SV_check( ST(i) );
+ from_SV_check(ST(i), &p);
THIS->points.push_back(p);
}
@@ -76,7 +76,7 @@ Polyline::rotate(angle, center_sv)
SV* center_sv;
CODE:
Point center;
- center.from_SV_check(center_sv);
+ from_SV_check(center_sv, &center);
THIS->rotate(angle, center);
Polygons
diff --git a/xs/xsp/PolylineCollection.xsp b/xs/xsp/PolylineCollection.xsp
index f512bbb63..7237be5bb 100644
--- a/xs/xsp/PolylineCollection.xsp
+++ b/xs/xsp/PolylineCollection.xsp
@@ -1,7 +1,7 @@
%module{Slic3r::XS};
%{
-#include <myinit.h>
+#include <xsinit.h>
#include "libslic3r/PolylineCollection.hpp"
%}
@@ -34,7 +34,7 @@ PolylineCollection::new(...)
RETVAL->polylines.resize(items-1);
for (unsigned int i = 1; i < items; i++) {
// Note: a COPY of the input is stored
- RETVAL->polylines[i-1].from_SV_check(ST(i));
+ from_SV_check(ST(i), &RETVAL->polylines[i-1]);
}
OUTPUT:
RETVAL
@@ -59,7 +59,7 @@ PolylineCollection::pp()
av_fill(av, THIS->polylines.size()-1);
int i = 0;
for (Polylines::iterator it = THIS->polylines.begin(); it != THIS->polylines.end(); ++it) {
- av_store(av, i++, (*it).to_SV_pureperl());
+ av_store(av, i++, to_SV_pureperl(&*it));
}
RETVAL = newRV_noinc((SV*)av);
OUTPUT:
@@ -70,7 +70,7 @@ PolylineCollection::append(...)
CODE:
for (unsigned int i = 1; i < items; i++) {
Polyline polyline;
- polyline.from_SV_check( ST(i) );
+ from_SV_check(ST(i), &polyline);
THIS->polylines.push_back(polyline);
}
diff --git a/xs/xsp/Print.xsp b/xs/xsp/Print.xsp
index 925111f76..9e2a19ae7 100644
--- a/xs/xsp/Print.xsp
+++ b/xs/xsp/Print.xsp
@@ -1,7 +1,7 @@
%module{Slic3r::XS};
%{
-#include <myinit.h>
+#include <xsinit.h>
#include "libslic3r/Print.hpp"
#include "libslic3r/PlaceholderParser.hpp"
%}
diff --git a/xs/xsp/SupportMaterial.xsp b/xs/xsp/SupportMaterial.xsp
index a0301f248..470cc3c61 100644
--- a/xs/xsp/SupportMaterial.xsp
+++ b/xs/xsp/SupportMaterial.xsp
@@ -1,6 +1,6 @@
%module{Slic3r::XS};
-#include <myinit.h>
+#include <xsinit.h>
#include "libslic3r/SupportMaterial.hpp"
%package{Slic3r::Print::SupportMaterial};
diff --git a/xs/xsp/Surface.xsp b/xs/xsp/Surface.xsp
index ffde83298..ebacd1795 100644
--- a/xs/xsp/Surface.xsp
+++ b/xs/xsp/Surface.xsp
@@ -1,7 +1,7 @@
%module{Slic3r::XS};
%{
-#include <myinit.h>
+#include <xsinit.h>
#include "libslic3r/Surface.hpp"
#include "libslic3r/ClipperUtils.hpp"
%}
diff --git a/xs/xsp/SurfaceCollection.xsp b/xs/xsp/SurfaceCollection.xsp
index b07bdb3a2..19cf3f828 100644
--- a/xs/xsp/SurfaceCollection.xsp
+++ b/xs/xsp/SurfaceCollection.xsp
@@ -1,7 +1,7 @@
%module{Slic3r::XS};
%{
-#include <myinit.h>
+#include <xsinit.h>
#include "libslic3r/SurfaceCollection.hpp"
%}
diff --git a/xs/xsp/TriangleMesh.xsp b/xs/xsp/TriangleMesh.xsp
index c4f249f34..c7324f98d 100644
--- a/xs/xsp/TriangleMesh.xsp
+++ b/xs/xsp/TriangleMesh.xsp
@@ -1,7 +1,7 @@
%module{Slic3r::XS};
%{
-#include <myinit.h>
+#include <xsinit.h>
#include "libslic3r/TriangleMesh.hpp"
%}
@@ -13,7 +13,6 @@
void ReadSTLFile(char* input_file);
void write_ascii(char* output_file);
void write_binary(char* output_file);
- void ReadFromPerl(SV* vertices, SV* facets);
void repair();
void WriteOBJFile(char* output_file);
void scale(float factor);
@@ -40,6 +39,43 @@
void reset_repair_stats();
%{
+void
+TriangleMesh::ReadFromPerl(vertices, facets)
+ SV* vertices
+ SV* facets
+ CODE:
+ stl_file &stl = THIS->stl;
+ 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(&stl);
+
SV*
TriangleMesh::stats()
CODE:
diff --git a/xs/xsp/XS.xsp b/xs/xsp/XS.xsp
index 3829994e1..c54e06be5 100644
--- a/xs/xsp/XS.xsp
+++ b/xs/xsp/XS.xsp
@@ -1,7 +1,7 @@
%module{Slic3r::XS};
%package{Slic3r::XS};
-#include <myinit.h>
+#include <xsinit.h>
%{
diff --git a/xs/xsp/my.map b/xs/xsp/my.map
index a02004426..609c97fcd 100644
--- a/xs/xsp/my.map
+++ b/xs/xsp/my.map
@@ -355,7 +355,7 @@ T_ARRAYREF
$var.resize(len);
for (unsigned int i = 0; i < len; i++) {
SV** elem = av_fetch(av, i, 0);
- $var\[i].from_SV_check(*elem);
+ from_SV_check(*elem, &$var\[i]);
}
} else
Perl_croak(aTHX_ \"%s: %s is not an array reference\",
@@ -514,7 +514,7 @@ T_PTR_ARRAYREF
if (len > 0) av_extend(av, len-1);
int i = 0;
for (${type}::iterator it = $var.begin(); it != $var.end(); ++it) {
- av_store(av, i++, (*it)->to_SV());
+ av_store(av, i++, to_SV(*it));
}
T_LAYER_HEIGHT_RANGES