CLI: Ensure that objects are on bed by default, new CLI config option:

'dont-ensure-on-bed' (which allows to override). This was the original
behaviour in Slic3r and Sli3rPE, probably broken long ago when CLI
was ported from  Perl.
Also, --scale-to-fit should now work again (#5772)
This commit is contained in:
Lukas Matena 2021-08-04 12:15:20 +02:00
parent d0d3c5ad16
commit bc81c22ea9
3 changed files with 21 additions and 8 deletions

View file

@ -258,6 +258,7 @@ int CLI::run(int argc, char **argv)
Points bed = get_bed_shape(m_print_config);
ArrangeParams arrange_cfg;
arrange_cfg.min_obj_distance = scaled(min_object_distance(m_print_config));
bool user_ensure_on_bed = true;
for (auto const &opt_key : m_transforms) {
if (opt_key == "merge") {
@ -330,6 +331,10 @@ int CLI::run(int argc, char **argv)
}
} else if (opt_key == "dont_arrange") {
// do nothing - this option alters other transform options
} else if (opt_key == "dont_ensure_on_bed") {
// Remember that we saw this so we don't lift objects from the bed
// after the other transformations are processed.
user_ensure_on_bed = false;
} else if (opt_key == "rotate") {
for (auto &model : m_models)
for (auto &o : model.objects)
@ -432,6 +437,13 @@ int CLI::run(int argc, char **argv)
}
}
// All transforms have been dealt with. Now ensure that the objects are on bed.
// (Unless the user said otherwise.)
if (user_ensure_on_bed)
for (auto &model : m_models)
for (auto &o : model.objects)
o->ensure_on_bed();
// loop through action options
for (auto const &opt_key : m_actions) {
if (opt_key == "help") {

View file

@ -1745,18 +1745,15 @@ void ModelVolume::scale(const Vec3d& scaling_factors)
void ModelObject::scale_to_fit(const Vec3d &size)
{
/*
BoundingBoxf3 instance_bounding_box(size_t instance_idx, bool dont_translate = false) const;
Vec3d orig_size = this->bounding_box().size();
float factor = fminf(
size.x / orig_size.x,
fminf(
size.y / orig_size.y,
size.z / orig_size.z
double factor = std::min(
size.x() / orig_size.x(),
std::min(
size.y() / orig_size.y(),
size.z() / orig_size.z()
)
);
this->scale(factor);
*/
}
void ModelVolume::assign_new_unique_ids_recursive()

View file

@ -4154,6 +4154,10 @@ CLITransformConfigDef::CLITransformConfigDef()
def->label = L("Don't arrange");
def->tooltip = L("Do not rearrange the given models before merging and keep their original XY coordinates.");
def = this->add("dont_ensure_on_bed", coBool);
def->label = L("Don't ensure on bed");
def->tooltip = L("Do not lift the object above the bed when it is partially below.");
def = this->add("duplicate", coInt);
def->label = L("Duplicate");
def->tooltip =L("Multiply copies by this factor.");