mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 16:57:53 -06:00
Merge remote-tracking branch 'remotes/origin/tm_autoplacement'
This commit is contained in:
commit
302a51f6cb
17 changed files with 912 additions and 172 deletions
|
@ -1473,24 +1473,19 @@ std::vector<size_t> Plater::priv::load_model_objects(const ModelObjectPtrs &mode
|
|||
const BoundingBoxf bed_shape = bed_shape_bb();
|
||||
const Vec3d bed_size = Slic3r::to_3d(bed_shape.size().cast<double>(), 1.0) - 2.0 * Vec3d::Ones();
|
||||
|
||||
bool need_arrange = false;
|
||||
bool scaled_down = false;
|
||||
std::vector<size_t> obj_idxs;
|
||||
unsigned int obj_count = model.objects.size();
|
||||
|
||||
ModelInstancePtrs new_instances;
|
||||
for (ModelObject *model_object : model_objects) {
|
||||
auto *object = model.add_object(*model_object);
|
||||
std::string object_name = object->name.empty() ? fs::path(object->input_file).filename().string() : object->name;
|
||||
obj_idxs.push_back(obj_count++);
|
||||
|
||||
if (model_object->instances.empty()) {
|
||||
// if object has no defined position(s) we need to rearrange everything after loading
|
||||
need_arrange = true;
|
||||
|
||||
// add a default instance and center object around origin
|
||||
object->center_around_origin(); // also aligns object to Z = 0
|
||||
ModelInstance* instance = object->add_instance();
|
||||
instance->set_offset(Slic3r::to_3d(bed_shape.center().cast<double>(), -object->origin_translation(2)));
|
||||
object->center_around_origin();
|
||||
new_instances.emplace_back(object->add_instance());
|
||||
}
|
||||
|
||||
const Vec3d size = object->bounding_box().size();
|
||||
|
@ -1518,6 +1513,17 @@ std::vector<size_t> Plater::priv::load_model_objects(const ModelObjectPtrs &mode
|
|||
// print.add_model_object(object);
|
||||
}
|
||||
|
||||
// FIXME distance should be a config value /////////////////////////////////
|
||||
auto min_obj_distance = static_cast<coord_t>(6/SCALING_FACTOR);
|
||||
const auto *bed_shape_opt = config->opt<ConfigOptionPoints>("bed_shape");
|
||||
assert(bed_shape_opt);
|
||||
auto& bedpoints = bed_shape_opt->values;
|
||||
Polyline bed; bed.points.reserve(bedpoints.size());
|
||||
for(auto& v : bedpoints) bed.append(Point::new_scale(v(0), v(1)));
|
||||
|
||||
arr::find_new_position(model, new_instances, min_obj_distance, bed);
|
||||
// /////////////////////////////////////////////////////////////////////////
|
||||
|
||||
if (scaled_down) {
|
||||
GUI::show_info(q,
|
||||
_(L("Your object appears to be too large, so it was automatically scaled down to fit your print bed.")),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue