PrusaSlicer-NonPlainar/xs/xsp/Print.xsp

107 lines
3.5 KiB
Plaintext
Raw Normal View History

2013-12-20 00:36:42 +00:00
%module{Slic3r::XS};
%{
#include <xsinit.h>
#include "libslic3r/Print.hpp"
2013-12-20 00:36:42 +00:00
%}
%name{Slic3r::Print::Region} class PrintRegion {
// owned by Print, no constructor/destructor
2015-12-16 11:33:19 +00:00
Ref<StaticPrintConfig> config()
%code%{ RETVAL = &THIS->config(); %};
};
%name{Slic3r::Print::Object} class PrintObject {
// owned by Print, no constructor/destructor
Ref<Print> print();
Ref<ModelObject> model_object();
2015-12-16 11:33:19 +00:00
Ref<StaticPrintConfig> config()
%code%{ RETVAL = &THIS->config(); %};
Clone<BoundingBox> bounding_box();
2018-03-23 15:00:00 +00:00
void slice();
};
%name{Slic3r::Print} class Print {
Print();
~Print();
Ref<Model> model()
%code%{ RETVAL = const_cast<Model*>(&THIS->model()); %};
2015-12-16 11:33:19 +00:00
Ref<StaticPrintConfig> config()
2018-09-12 09:59:02 +00:00
%code%{ RETVAL = const_cast<GCodeConfig*>(static_cast<const GCodeConfig*>(&THIS->config())); %};
double total_used_filament()
%code%{ RETVAL = THIS->print_statistics().total_used_filament; %};
double total_extruded_volume()
%code%{ RETVAL = THIS->print_statistics().total_extruded_volume; %};
double total_weight()
%code%{ RETVAL = THIS->print_statistics().total_weight; %};
double total_cost()
%code%{ RETVAL = THIS->print_statistics().total_cost; %};
2018-09-17 13:12:13 +00:00
double total_wipe_tower_cost()
%code%{ RETVAL = THIS->print_statistics().total_wipe_tower_cost; %};
double total_wipe_tower_filament()
%code%{ RETVAL = THIS->print_statistics().total_wipe_tower_filament; %};
int wipe_tower_number_of_toolchanges()
%code%{ RETVAL = THIS->wipe_tower_data().number_of_toolchanges; %};
PrintObjectPtrs* objects()
%code%{ RETVAL = const_cast<PrintObjectPtrs*>(&THIS->objects_mutable()); %};
Ref<PrintObject> get_object(int idx)
%code%{ RETVAL = THIS->objects_mutable()[idx]; %};
size_t object_count()
%code%{ RETVAL = THIS->objects().size(); %};
2015-12-02 17:29:33 +00:00
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)
2020-09-24 14:41:47 +00:00
%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)
2020-09-24 12:52:05 +00:00
mat.second->config.touch();
2020-09-24 14:41:47 +00:00
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;
%};
2017-02-15 10:05:52 +00:00
2018-03-23 15:00:00 +00:00
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());
}
%};
};