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

Print.xsp « xsp « xs - github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b937fe6e8902ac4b3abc5d91fbf2de8655693c53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
%module{Slic3r::XS};

%{
#include <xsinit.h>
#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<StaticPrintConfig> config()
        %code%{ RETVAL = &THIS->config; %};
    Ref<Print> print();
    
    Clone<Flow> 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

    void add_region_volume(int region_id, int volume_id);
    std::vector<int> get_region_volumes(int region_id)
        %code%{
            if (0 <= region_id && region_id < THIS->region_volumes.size())
                RETVAL = THIS->region_volumes[region_id];
        %};
    int region_count()
        %code%{ RETVAL = THIS->print()->regions.size(); %};

    Ref<Print> print();
    Ref<ModelObject> model_object();
    Ref<StaticPrintConfig> config()
        %code%{ RETVAL = &THIS->config; %};
    Points copies();
    t_layer_height_ranges layer_height_ranges()
        %code%{ RETVAL = THIS->layer_height_ranges; %};
    std::vector<double> layer_height_profile()
        %code%{ RETVAL = THIS->layer_height_profile; %};
    Ref<Point3> size()
        %code%{ RETVAL = &THIS->size; %};
    Clone<BoundingBox> bounding_box();
    
    Points _shifted_copies()
        %code%{ RETVAL = THIS->_shifted_copies; %};
    void set_shifted_copies(Points value)
        %code%{ THIS->_shifted_copies = value; %};

    bool add_copy(Pointf* point)
        %code%{ RETVAL = THIS->add_copy(*point); %};
    bool delete_last_copy();
    bool delete_all_copies();
    bool set_copies(Points copies);
    bool reload_model_instances();
    void set_layer_height_ranges(t_layer_height_ranges layer_height_ranges)
        %code%{ THIS->layer_height_ranges = layer_height_ranges; %};
    void set_layer_height_profile(std::vector<double> profile)
        %code%{ THIS->layer_height_profile = profile; %};

    size_t total_layer_count();
    size_t layer_count();
    void clear_layers();
    Ref<Layer> get_layer(int idx);
    Ref<Layer> add_layer(int id, coordf_t height, coordf_t print_z,
        coordf_t slice_z);

    size_t support_layer_count();
    void clear_support_layers();
    Ref<SupportLayer> get_support_layer(int idx);
    Ref<SupportLayer> add_support_layer(int id, coordf_t height, coordf_t print_z);

    bool step_done(PrintObjectStep step)
        %code%{ RETVAL = THIS->state.is_done(step); %};
    void set_step_done(PrintObjectStep step)
        %code%{ THIS->state.set_done(step); %};
    void set_step_started(PrintObjectStep step)
        %code%{ THIS->state.set_started(step); %};

    void _slice();
    std::string _fix_slicing_errors();
    void _simplify_slices(double distance);
    void _prepare_infill();
    void detect_surfaces_type();
    void process_external_surfaces();
    void _make_perimeters();
    void _infill();
    void _generate_support_material();

    std::vector<double> get_layer_height_min_max()
        %code%{ 
            SlicingParameters slicing_params = THIS->slicing_parameters();
            RETVAL.push_back(slicing_params.min_layer_height);
            RETVAL.push_back(slicing_params.max_layer_height);
            RETVAL.push_back(slicing_params.first_print_layer_height);
            RETVAL.push_back(slicing_params.first_object_layer_height);
            RETVAL.push_back(slicing_params.layer_height);
        %};

    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();
    
    int ptr()
        %code%{ RETVAL = (int)(intptr_t)THIS; %};
};


%name{Slic3r::Print} class Print {
    Print();
    ~Print();

    Ref<StaticPrintConfig> config()
        %code%{ RETVAL = &THIS->config; %};
    Ref<StaticPrintConfig> default_object_config()
        %code%{ RETVAL = &THIS->default_object_config; %};
    Ref<StaticPrintConfig> default_region_config()
        %code%{ RETVAL = &THIS->default_region_config; %};
    Ref<PlaceholderParser> placeholder_parser()
        %code%{ RETVAL = &THIS->placeholder_parser; %};
    // TODO: status_cb
    Ref<ExtrusionEntityCollection> skirt()
        %code%{ RETVAL = &THIS->skirt; %};
    Ref<ExtrusionEntityCollection> brim()
        %code%{ RETVAL = &THIS->brim; %};

    PrintObjectPtrs* objects()
        %code%{ RETVAL = &THIS->objects; %};
    void clear_objects();
    Ref<PrintObject> 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<PrintRegion> get_region(int idx);
    Ref<PrintRegion> add_region();
    size_t region_count()
        %code%{ RETVAL = THIS->regions.size(); %};
    
    bool step_done(PrintStep step)
        %code%{ RETVAL = THIS->state.is_done(step); %};
    bool object_step_done(PrintObjectStep step)
        %code%{ RETVAL = THIS->step_done(step); %};
    void set_step_done(PrintStep step)
        %code%{ THIS->state.set_done(step); %};
    void set_step_started(PrintStep step)
        %code%{ THIS->state.set_started(step); %};
    
    void clear_filament_stats()
        %code%{
            THIS->filament_stats.clear();
        %};
    void set_filament_stats(int extruder_id, float length)
        %code%{
            THIS->filament_stats.insert(std::pair<size_t,float>(extruder_id, 0));
            THIS->filament_stats[extruder_id] += length;
        %};
    SV* filament_stats()
        %code%{
            HV* hv = newHV();
            for (std::map<size_t,float>::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);
            }
        %};
    void _simplify_slices(double distance);
    double max_allowed_layer_height() const;
    bool has_support_material() const;
    void auto_assign_extruders(ModelObject* model_object);
    std::string output_filename();
    std::string output_filepath(std::string path = "");
    
    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();
    bool has_skirt();
    std::vector<unsigned int> extruders() const;
    std::string _validate()
        %code%{ RETVAL = THIS->validate(); %};
    Clone<BoundingBox> bounding_box();
    Clone<BoundingBox> total_bounding_box();
    double skirt_first_layer_height();
    Clone<Flow> brim_flow();
    Clone<Flow> skirt_flow();

    void _make_skirt();
    void _make_brim();

    bool has_wipe_tower();
    void _clear_wipe_tower();
    void _make_wipe_tower();

%{

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

%}
};