42{
43 PartPlateList& plate_list =
m_plater->get_partplate_list();
44
49
51
54 return;
55
56
57 int sel_id =
m_plater->get_selection().get_instance_idx();
58 sel_id = std::max(sel_id, 0);
59
60 int sel_ret = plate_list.select_plate_by_obj(
m_object_idx, sel_id);
61 BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << boost::format(
":select plate obj_id %1%, ins_id %2%, ret %3%}") %
m_object_idx % sel_id % sel_ret;
62
63 PartPlate* plate = plate_list.get_curr_plate();
65 BoundingBox plate_bb = plate->get_bounding_box_crd();
66 int plate_cols = plate_list.get_plate_cols();
67 int cur_plate_index = plate->get_index();
68
70 if (model_object->instances.empty()) return;
71
72 const Slic3r::DynamicPrintConfig& global_config = wxGetApp().preset_bundle->full_config();
73 m_selected.reserve(model_object->instances.size());
74 for (size_t oidx = 0; oidx < model.objects.size(); ++oidx)
75 {
76 ModelObject* mo = model.objects[oidx];
77 for (size_t inst_idx = 0; inst_idx < mo->instances.size(); ++inst_idx)
78 {
80
83 BoundingBox ap_bb = ap.transformed_poly().contour.bounding_box();
84 ap.name = mo->name;
85
86 if (selected)
87 {
88 if (mo->instances[inst_idx]->printable)
89 {
90 ++ap.priority;
93 }
94 else
95 {
96 if (plate_bb.contains(ap_bb))
97 {
98 ap.bed_idx = 0;
100 ap.row = cur_plate_index / plate_cols;
101 ap.col = cur_plate_index % plate_cols;
105 }
106 else
107 {
111 }
112 }
113 }
114 else
115 {
116 if (plate_bb.contains(ap_bb))
117 {
118 ap.bed_idx = 0;
120 ap.row = cur_plate_index / plate_cols;
121 ap.col = cur_plate_index % plate_cols;
125 }
126 else
127 {
131 }
132 }
133 }
134 }
135
136
137
138
139
140
141
142
143
144
146
147 bool enable_wrapping = global_config.
option<ConfigOptionBool>(
"enable_wrapping_detection")->value;
148
149 double scaled_exclusion_gap =
scale_(1);
150 plate_list.preprocess_exclude_areas(
params.excluded_regions, global_config, enable_wrapping, 1, scaled_exclusion_gap);
151 plate_list.preprocess_exclude_areas(
m_unselected, global_config, enable_wrapping);
152
154
155 auto &objects =
m_plater->model().objects;
156
157
158
159
160
161
162
163
164
165
166
167
168
171
173
175 ExPolygon
poly = polys.empty() ?
m_selected.front().poly : polys.front();
178 double unsel_area = std::accumulate(
m_unselected.begin(),
180 [cur_plate_index, &fill_template](double s, const auto &ap) {
181
182 const bool exclusion_applies = !ap.is_bed_exclusion ||
183 bed_exclusion_applies(fill_template, ap);
184 return s + (ap.bed_idx == cur_plate_index && exclusion_applies) * ap.poly.area();
185
186 }) / sc;
187
190
191
192 int needed_items = (bed_area - fixed_area) / poly_area;
193
194
195
196
197 ModelInstance *mi = model_object->instances[sel_id];
200
201 for (int i = 0; i < needed_items; ++i) {
205 ap.itemid = -1;
209 ModelInstance *new_instance = mo->add_instance(*mi);
210 new_instance->apply_arrange_result(p.translation.cast<double>(), p.rotation);
211 } else {
212 ModelObject* newObj =
m_plater->model().add_object(*mo);
213 newObj->name = mo->name +" "+ std::to_string(p.itemid);
214 for (ModelInstance *new_instance : newObj->instances)
215 new_instance->apply_arrange_result(p.translation.cast<double>(), p.rotation);
216 }
217
218 };
220 }
221
223
224
225
226
227
228
229
230
231
232}
ConfigOption * option(const t_config_option_key &opt_key, bool create=false)
Definition Config.hpp:2768
Points m_bedpts
Definition FillBedJob.hpp:26
int m_status_range
Definition FillBedJob.hpp:30
ArrangePolygons m_locked
Definition FillBedJob.hpp:24
ArrangePolygons m_unselected
Definition FillBedJob.hpp:22
arrangement::ArrangeParams params
Definition FillBedJob.hpp:28
static constexpr unsigned int MAX_PLATES_COUNT
Definition PartPlate.hpp:893
static double area(const Points &pts)
Definition Polygon.cpp:65
#define scale_(val)
Definition libslic3r.h:106
std::optional< arrangement::ArrangePolygon > get_wipe_tower_arrangepoly(const Plater &plater)
Definition ArrangeJob.cpp:968
void set_arrange_polygon_bed_exclusion_extruders(ArrangePolygon &polygon, const ModelObject &object, const PartPlate &plate, const DynamicPrintConfig &config)
Definition ArrangeJob.cpp:53
arrangement::ArrangeParams init_arrange_params(Plater *p)
Definition ArrangeJob.cpp:989
double poly_area(const Points &pts)
Definition Arrange.cpp:1187
BoundingBox scaled(const BoundingBoxf &bb)
Definition BoundingBox.hpp:284
ArrangePolygon get_instance_arrange_poly(ModelInstance *instance, const Slic3r::DynamicPrintConfig &config)
Definition ModelArrange.cpp:135
Slic3r::ExPolygons offset_ex(const Slic3r::Polygons &polygons, const float delta, JoinType joinType, double miterLimit)
Definition ClipperUtils.cpp:605
Points get_bed_shape(const DynamicPrintConfig &config, bool use_share)
Definition PrintConfig.cpp:13837
Slic3r::Polygon Polygon
Definition Emboss.cpp:101