mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-14 09:45:54 +08:00
#449 fix for Autoarrange in MSLA Mode
Forgot to make it printer-type independent when fixing arrange.
This commit is contained in:
parent
31dfe949a7
commit
d3dd002931
@ -417,7 +417,7 @@ int CLI::run(int argc, char **argv)
|
||||
PrintBase *print = (printer_technology == ptFFF) ? static_cast<PrintBase*>(&fff_print) : static_cast<PrintBase*>(&sla_print);
|
||||
if (! m_config.opt_bool("dont_arrange")) {
|
||||
//FIXME make the min_object_distance configurable.
|
||||
model.arrange_objects(fff_print);
|
||||
model.arrange_objects(print);
|
||||
model.center_instances_around_point((! user_center_specified && m_print_config.has("bed_shape")) ?
|
||||
BoundingBoxf(m_print_config.opt<ConfigOptionPoints>("bed_shape")->values).center() :
|
||||
m_config.option<ConfigOptionPoint>("center")->value);
|
||||
|
@ -389,7 +389,7 @@ static bool _arrange(const Pointfs &sizes, coordf_t dist, const BoundingBoxf* bb
|
||||
|
||||
/* arrange objects preserving their instance count
|
||||
but altering their instance positions */
|
||||
bool Model::arrange_objects(const Print &print, const BoundingBoxf* bb)
|
||||
bool Model::arrange_objects(const PrintBase *print, const BoundingBoxf* bb)
|
||||
{
|
||||
size_t count = 0;
|
||||
for (auto obj : objects) count += obj->instances.size();
|
||||
@ -1823,7 +1823,7 @@ void ModelInstance::transform_polygon(Polygon* polygon) const
|
||||
polygon->scale(get_scaling_factor(X), get_scaling_factor(Y)); // scale around polygon origin
|
||||
}
|
||||
|
||||
arrangement::ArrangePolygon ModelInstance::get_arrange_polygon(const Print& print) const
|
||||
arrangement::ArrangePolygon ModelInstance::get_arrange_polygon(const PrintBase *print_base) const
|
||||
{
|
||||
static const double SIMPLIFY_TOLERANCE_MM = 0.1;
|
||||
|
||||
@ -1841,13 +1841,17 @@ arrangement::ArrangePolygon ModelInstance::get_arrange_polygon(const Print& prin
|
||||
// https://github.com/prusa3d/PrusaSlicer/issues/2209
|
||||
if (!p.points.empty()) {
|
||||
Polygons pp{p};
|
||||
//grow
|
||||
double dist = print.config().min_object_distance(&print.full_print_config());
|
||||
std::cout << "min_object_distance = " << dist << "\n";
|
||||
pp = offset(pp, scale_(dist));
|
||||
//simplify
|
||||
if (!pp.empty())
|
||||
pp = pp.front().simplify(scaled<double>(SIMPLIFY_TOLERANCE_MM));
|
||||
if (const Print* print = dynamic_cast<const Print*>(print_base))
|
||||
{
|
||||
//grow
|
||||
double dist = print->config().min_object_distance(&print->full_print_config());
|
||||
std::cout << "min_object_distance = " << dist << "\n";
|
||||
pp = offset(pp, scale_(dist));
|
||||
//simplify
|
||||
if (!pp.empty())
|
||||
pp = pp.front().simplify(scaled<double>(SIMPLIFY_TOLERANCE_MM));
|
||||
}else
|
||||
pp = p.simplify(scaled<double>(SIMPLIFY_TOLERANCE_MM));
|
||||
if (!pp.empty()) p = pp.front();
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,7 @@ class ModelMaterial;
|
||||
class ModelObject;
|
||||
class ModelVolume;
|
||||
class ModelWipeTower;
|
||||
class PrintBase;
|
||||
class Print;
|
||||
class SLAPrint;
|
||||
|
||||
@ -667,7 +668,7 @@ public:
|
||||
bool is_printable() const { return object->printable && printable && (print_volume_state == PVS_Inside); }
|
||||
|
||||
// Getting the input polygon for arrange
|
||||
arrangement::ArrangePolygon get_arrange_polygon(const Print& print) const;
|
||||
arrangement::ArrangePolygon get_arrange_polygon(const PrintBase* print) const;
|
||||
|
||||
// Apply the arrange result on the ModelInstance
|
||||
void apply_arrange_result(const Vec2crd& offs, double rotation)
|
||||
@ -804,7 +805,7 @@ public:
|
||||
bool center_instances_around_point(const Vec2d &point);
|
||||
void translate(coordf_t x, coordf_t y, coordf_t z) { for (ModelObject *o : this->objects) o->translate(x, y, z); }
|
||||
TriangleMesh mesh() const;
|
||||
bool arrange_objects(const Print& print, const BoundingBoxf* bb = NULL);
|
||||
bool arrange_objects(const PrintBase* print, const BoundingBoxf* bb = NULL);
|
||||
// Croaks if the duplicated objects do not fit the print bed.
|
||||
void duplicate(size_t copies_num, coordf_t dist, const BoundingBoxf* bb = NULL);
|
||||
void duplicate_objects(size_t copies_num, coordf_t dist, const BoundingBoxf* bb = NULL);
|
||||
|
@ -1522,7 +1522,7 @@ struct Plater::priv
|
||||
apply_wipe_tower();
|
||||
}
|
||||
|
||||
ArrangePolygon get_arrange_polygon(const Print &print) const
|
||||
ArrangePolygon get_arrange_polygon(const PrintBase *print) const
|
||||
{
|
||||
Polygon p({
|
||||
{coord_t(0), coord_t(0)},
|
||||
@ -1627,7 +1627,8 @@ struct Plater::priv
|
||||
|
||||
// Set up arrange polygon for a ModelInstance and Wipe tower
|
||||
template<class T> ArrangePolygon get_arrange_poly(T *obj) const {
|
||||
ArrangePolygon ap = obj->get_arrange_polygon(this->plater().fff_print);
|
||||
ArrangePolygon ap = obj->get_arrange_polygon(
|
||||
this->plater().printer_technology == ptFFF ? (PrintBase*)&this->plater().fff_print : (PrintBase*)&this->plater().sla_print);
|
||||
ap.priority = 0;
|
||||
ap.bed_idx = ap.translation.x() / bed_stride();
|
||||
ap.setter = [obj, this](const ArrangePolygon &p) {
|
||||
@ -2888,7 +2889,8 @@ void Plater::priv::find_new_position(const ModelInstancePtrs &instances,
|
||||
for (const ModelObject *mo : model.objects)
|
||||
for (const ModelInstance *inst : mo->instances) {
|
||||
auto it = std::find(instances.begin(), instances.end(), inst);
|
||||
auto arrpoly = inst->get_arrange_polygon(this->fff_print);
|
||||
arrangement::ArrangePolygon arrpoly = inst->get_arrange_polygon(
|
||||
this->printer_technology == ptFFF ? (PrintBase*)&this->fff_print : (PrintBase*)&this->sla_print);
|
||||
|
||||
if (it == instances.end())
|
||||
fixed.emplace_back(std::move(arrpoly));
|
||||
@ -2897,7 +2899,8 @@ void Plater::priv::find_new_position(const ModelInstancePtrs &instances,
|
||||
}
|
||||
|
||||
if (updated_wipe_tower())
|
||||
fixed.emplace_back(wipetower.get_arrange_polygon(this->fff_print));
|
||||
fixed.emplace_back(wipetower.get_arrange_polygon(
|
||||
this->printer_technology == ptFFF ? (PrintBase*)&this->fff_print : (PrintBase*)&this->sla_print));
|
||||
|
||||
arrangement::arrange(movable, fixed, min_d, get_bed_shape_hint());
|
||||
|
||||
@ -4660,6 +4663,9 @@ const Print& Plater::fff_print() const { return p->fff_print; }
|
||||
Print& Plater::fff_print() { return p->fff_print; }
|
||||
const SLAPrint& Plater::sla_print() const { return p->sla_print; }
|
||||
SLAPrint& Plater::sla_print() { return p->sla_print; }
|
||||
const PrintBase* Plater::current_print() const {
|
||||
return printer_technology() == ptFFF ? (PrintBase*)&p->fff_print : (PrintBase*)&p->sla_print;
|
||||
}
|
||||
|
||||
void Plater::new_project()
|
||||
{
|
||||
|
@ -25,6 +25,7 @@ namespace Slic3r {
|
||||
|
||||
class Model;
|
||||
class ModelObject;
|
||||
class PrintBase;
|
||||
class Print;
|
||||
class SLAPrint;
|
||||
enum SLAPrintObjectStep : unsigned int;
|
||||
@ -150,6 +151,7 @@ public:
|
||||
Print& fff_print();
|
||||
const SLAPrint& sla_print() const;
|
||||
SLAPrint& sla_print();
|
||||
const PrintBase* current_print() const;
|
||||
|
||||
void new_project();
|
||||
void load_project();
|
||||
|
@ -174,7 +174,7 @@ void init_print(std::vector<TriangleMesh> &&meshes, Slic3r::Print &print, Slic3r
|
||||
}
|
||||
|
||||
print.apply(model, config);
|
||||
model.arrange_objects(print);
|
||||
model.arrange_objects(&print);
|
||||
print.apply(model, config);
|
||||
print.validate();
|
||||
print.set_status_silent();
|
||||
|
@ -42,7 +42,7 @@ SCENARIO("Model construction", "[Model]") {
|
||||
}
|
||||
model_object->add_instance();
|
||||
print.apply(model, config); // apply config for arrange_objects
|
||||
model.arrange_objects(print);
|
||||
model.arrange_objects(&print);
|
||||
model.center_instances_around_point(Slic3r::Vec2d(100, 100));
|
||||
model_object->ensure_on_bed();
|
||||
print.auto_assign_extruders(model_object);
|
||||
|
@ -37,7 +37,7 @@ std::unique_ptr<Print> init_print_with_dist(DynamicPrintConfig &config, float di
|
||||
|
||||
if (distance <= 0) {
|
||||
print->apply(model, config);
|
||||
model.arrange_objects(*print);// print->config().min_object_distance(&print->config(), 999999));
|
||||
model.arrange_objects(&*print);// print->config().min_object_distance(&print->config(), 999999));
|
||||
model.center_instances_around_point(Slic3r::Vec2d(100, 100));
|
||||
}
|
||||
|
||||
|
@ -287,7 +287,7 @@ void init_print(Print& print, std::initializer_list<TestMesh> meshes, Slic3r::Mo
|
||||
}
|
||||
|
||||
print.apply(model, config); // apply config for the arrange_objects
|
||||
model.arrange_objects(print);
|
||||
model.arrange_objects(&print);
|
||||
model.center_instances_around_point(Slic3r::Vec2d(100,100));
|
||||
for (auto* mo : model.objects) {
|
||||
print.auto_assign_extruders(mo);
|
||||
@ -323,7 +323,7 @@ void init_print(Print& print, std::vector<TriangleMesh> meshes, Slic3r::Model& m
|
||||
}
|
||||
|
||||
print.apply(model, config); // apply config for the arrange_objects
|
||||
model.arrange_objects(print);
|
||||
model.arrange_objects(&print);
|
||||
model.center_instances_around_point(Slic3r::Vec2d(100,100));
|
||||
print.apply(model, config);
|
||||
for (ModelObject* mo : model.objects) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user