PrusaSlicer-NonPlainar/xs/xsp/Print.xsp
2022-10-27 20:01:55 +02:00

69 lines
2.1 KiB
Plaintext

%module{Slic3r::XS};
%{
#include <xsinit.h>
#include "libslic3r/Print.hpp"
%}
%name{Slic3r::Print} class Print {
Print();
~Print();
Ref<Model> model()
%code%{ RETVAL = const_cast<Model*>(&THIS->model()); %};
Ref<StaticPrintConfig> config()
%code%{ RETVAL = const_cast<GCodeConfig*>(static_cast<const GCodeConfig*>(&THIS->config())); %};
double total_used_filament()
%code%{ RETVAL = THIS->print_statistics().total_used_filament; %};
void auto_assign_extruders(ModelObject* model_object);
std::string output_filepath(std::string path = "")
%code%{
try {
RETVAL = THIS->output_filepath(path);
} catch (std::exception& e) {
croak("%s\n", e.what());
}
%};
bool apply(Model *model, DynamicPrintConfig* config)
%code%{
// Touching every config as the Perl bindings does not correctly export ModelConfig,
// therefore the configs have often invalid timestamps.
for (auto obj : model->objects) {
obj->config.touch();
for (auto vol : obj->volumes)
vol->config.touch();
}
for (auto mat : model->materials)
mat.second->config.touch();
RETVAL = THIS->apply(*model, *config);
%};
std::vector<unsigned int> extruders() const;
int validate() %code%{
std::string err = THIS->validate();
if (! err.empty())
croak("Configuration is not valid: %s\n", err.c_str());
RETVAL = 1;
%};
void set_status_silent();
void process() %code%{
try {
THIS->process();
} catch (std::exception& e) {
croak("%s\n", e.what());
}
%};
void export_gcode(char *path_template) %code%{
try {
THIS->export_gcode(path_template, nullptr);
} catch (std::exception& e) {
croak("%s\n", e.what());
}
%};
};