%module{Slic3r::XS}; %{ #include #include "libslic3r/Print.hpp" #include "libslic3r/PlaceholderParser.hpp" %} %package{Slic3r::Print::State}; %{ IV _constant() ALIAS: STEP_SLICE = posSlice STEP_PERIMETERS = posPerimeters STEP_PREPARE_INFILL = posPrepareInfill STEP_INFILL = posInfill STEP_SUPPORTMATERIAL = posSupportMaterial STEP_SKIRT = psSkirt STEP_BRIM = psBrim STEP_WIPE_TOWER = psWipeTower PROTOTYPE: CODE: RETVAL = ix; OUTPUT: RETVAL %} %name{Slic3r::Print::Region} class PrintRegion { // owned by Print, no constructor/destructor Ref config() %code%{ RETVAL = &THIS->config; %}; Ref print(); Clone flow(FlowRole role, double layer_height, bool bridge, bool first_layer, double width, PrintObject* object) %code%{ RETVAL = THIS->flow(role, layer_height, bridge, first_layer, width, *object); %}; }; %name{Slic3r::Print::Object} class PrintObject { // owned by Print, no constructor/destructor int region_count() %code%{ RETVAL = THIS->print()->regions.size(); %}; Ref print(); Ref model_object(); Ref config() %code%{ RETVAL = &THIS->config; %}; Points copies(); t_layer_height_ranges layer_height_ranges() %code%{ RETVAL = THIS->layer_height_ranges; %}; std::vector layer_height_profile() %code%{ RETVAL = THIS->layer_height_profile; %}; Ref size() %code%{ RETVAL = &THIS->size; %}; Clone bounding_box(); Points _shifted_copies() %code%{ RETVAL = THIS->_shifted_copies; %}; bool add_copy(Pointf* point) %code%{ RETVAL = THIS->add_copy(*point); %}; bool delete_last_copy(); bool reload_model_instances(); void set_layer_height_ranges(t_layer_height_ranges layer_height_ranges) %code%{ THIS->layer_height_ranges = layer_height_ranges; %}; size_t layer_count(); Ref get_layer(int idx); size_t support_layer_count(); Ref get_support_layer(int idx); bool step_done(PrintObjectStep step) %code%{ RETVAL = THIS->is_step_done(step); %}; void adjust_layer_height_profile(coordf_t z, coordf_t layer_thickness_delta, coordf_t band_width, int action) %code%{ THIS->update_layer_height_profile(THIS->model_object()->layer_height_profile); adjust_layer_height_profile( THIS->slicing_parameters(), THIS->model_object()->layer_height_profile, z, layer_thickness_delta, band_width, LayerHeightEditActionType(action)); THIS->model_object()->layer_height_profile_valid = true; THIS->layer_height_profile_valid = false; %}; void reset_layer_height_profile(); void slice(); }; %name{Slic3r::Print} class Print { Print(); ~Print(); Ref config() %code%{ RETVAL = &THIS->config; %}; Ref placeholder_parser() %code%{ RETVAL = &THIS->placeholder_parser; %}; Ref skirt() %code%{ RETVAL = &THIS->skirt; %}; Ref brim() %code%{ RETVAL = &THIS->brim; %}; std::string estimated_print_time() %code%{ RETVAL = THIS->estimated_print_time; %}; PrintObjectPtrs* objects() %code%{ RETVAL = &THIS->objects; %}; void clear_objects(); Ref get_object(int idx); void delete_object(int idx); void reload_object(int idx); bool reload_model_instances(); size_t object_count() %code%{ RETVAL = THIS->objects.size(); %}; PrintRegionPtrs* regions() %code%{ RETVAL = &THIS->regions; %}; Ref get_region(int idx); Ref add_region(); size_t region_count() %code%{ RETVAL = THIS->regions.size(); %}; bool step_done(PrintStep step) %code%{ RETVAL = THIS->is_step_done(step); %}; bool object_step_done(PrintObjectStep step) %code%{ RETVAL = THIS->is_step_done(step); %}; SV* filament_stats() %code%{ HV* hv = newHV(); for (std::map::const_iterator it = THIS->filament_stats.begin(); it != THIS->filament_stats.end(); ++it) { // stringify extruder_id std::ostringstream ss; ss << it->first; std::string str = ss.str(); (void)hv_store( hv, str.c_str(), str.length(), newSViv(it->second), 0 ); RETVAL = newRV_noinc((SV*)hv); } %}; double max_allowed_layer_height() const; bool has_support_material() const; 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(e.what()); } %}; void add_model_object(ModelObject* model_object, int idx = -1); bool apply_config(DynamicPrintConfig* config) %code%{ RETVAL = THIS->apply_config(*config); %}; bool has_infinite_skirt(); std::vector 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; %}; Clone bounding_box(); Clone total_bounding_box(); void set_callback_event(int evt) %code%{ %}; void set_status_silent(); void process() %code%{ try { THIS->process(); } catch (std::exception& e) { croak(e.what()); } %}; void export_gcode_with_preview_data(char *path_template, GCodePreviewData *preview_data) %code%{ try { THIS->export_gcode(path_template, preview_data); } catch (std::exception& e) { croak(e.what()); } %}; void export_gcode(char *path_template) %code%{ try { THIS->export_gcode(path_template, nullptr); } catch (std::exception& e) { croak(e.what()); } %}; %{ double Print::total_used_filament(...) CODE: if (items > 1) { THIS->total_used_filament = (double)SvNV(ST(1)); } RETVAL = THIS->total_used_filament; OUTPUT: RETVAL double Print::total_extruded_volume(...) CODE: if (items > 1) { THIS->total_extruded_volume = (double)SvNV(ST(1)); } RETVAL = THIS->total_extruded_volume; OUTPUT: RETVAL double Print::total_weight(...) CODE: if (items > 1) { THIS->total_weight = (double)SvNV(ST(1)); } RETVAL = THIS->total_weight; OUTPUT: RETVAL double Print::total_cost(...) CODE: if (items > 1) { THIS->total_cost = (double)SvNV(ST(1)); } RETVAL = THIS->total_cost; OUTPUT: RETVAL %} };