mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-13 19:25:59 +08:00
Fix wipe tower arrangement
This commit is contained in:
parent
3277b5ee06
commit
d69d477480
@ -45,35 +45,22 @@ void arrange(SelectionStrategy &&selstrategy,
|
||||
RectangleBed{bed.bb}, SelStrategyTag<SelectionStrategy>{});
|
||||
|
||||
std::vector<int> bed_indices = get_bed_indices(items, fixed);
|
||||
|
||||
size_t beds = bed_indices.size();
|
||||
|
||||
auto fixed_is_empty = [&bed_indices](int bidx) {
|
||||
auto it = std::lower_bound(bed_indices.begin(), bed_indices.end(), bidx);
|
||||
return it == bed_indices.end() || *it != bidx;
|
||||
};
|
||||
|
||||
auto set_bed_as_empty = [&bed_indices](int bidx) {
|
||||
auto it = std::lower_bound(bed_indices.begin(), bed_indices.end(), bidx);
|
||||
if (it != bed_indices.end())
|
||||
bed_indices.erase(it);
|
||||
};
|
||||
|
||||
std::vector<BoundingBox> pilebb(bed_indices.size());
|
||||
std::map<int, BoundingBox> pilebb;
|
||||
std::map<int, bool> bed_occupied;
|
||||
|
||||
for (auto &itm : items) {
|
||||
auto bedidx = get_bed_index(itm);
|
||||
if (bedidx >= 0) {
|
||||
pilebb[bedidx].merge(fixed_bounding_box(itm));
|
||||
if (is_wipe_tower(itm))
|
||||
set_bed_as_empty(bedidx);
|
||||
bed_occupied[bedidx] = true;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &fxitm : fixed) {
|
||||
auto bedidx = get_bed_index(fxitm);
|
||||
if (bedidx >= 0 || is_wipe_tower(fxitm))
|
||||
set_bed_as_empty(bedidx);
|
||||
if (bedidx >= 0)
|
||||
bed_occupied[bedidx] = true;
|
||||
}
|
||||
|
||||
auto bedbb = bounding_box(bed);
|
||||
@ -85,8 +72,9 @@ void arrange(SelectionStrategy &&selstrategy,
|
||||
|
||||
Pivots pivot = bed.alignment();
|
||||
|
||||
for (size_t bedidx = 0; bedidx < beds; ++bedidx) {
|
||||
if (! fixed_is_empty(bedidx))
|
||||
for (int bedidx : bed_indices) {
|
||||
if (auto occup_it = bed_occupied.find(bedidx);
|
||||
occup_it != bed_occupied.end() && occup_it->second)
|
||||
continue;
|
||||
|
||||
BoundingBox bb;
|
||||
|
@ -161,6 +161,14 @@ template<class BedFn> void visit_bed(BedFn &&fn, ExtendedBed &bed)
|
||||
boost::apply_visitor(fn, bed);
|
||||
}
|
||||
|
||||
inline BoundingBox bounding_box(const ExtendedBed &bed)
|
||||
{
|
||||
BoundingBox bedbb;
|
||||
visit_bed([&bedbb](auto &rawbed) { bedbb = bounding_box(rawbed); }, bed);
|
||||
|
||||
return bedbb;
|
||||
}
|
||||
|
||||
class Scene;
|
||||
|
||||
// SceneBuilderBase is intended for Scene construction. A simple constructor
|
||||
|
@ -199,6 +199,17 @@ void SceneBuilder::build_arrangeable_slicer_model(ArrangeableSlicerModel &amodel
|
||||
m_wipetower_handler = std::make_unique<MissingWipeTowerHandler>();
|
||||
}
|
||||
|
||||
if (m_fff_print && !m_xl_printer)
|
||||
m_xl_printer = is_XL_printer(m_fff_print->config());
|
||||
|
||||
bool has_wipe_tower = false;
|
||||
m_wipetower_handler->visit(
|
||||
[&has_wipe_tower](const Arrangeable &arrbl) { has_wipe_tower = true; });
|
||||
|
||||
if (m_xl_printer && !has_wipe_tower) {
|
||||
m_bed = XLBed{bounding_box(m_bed)};
|
||||
}
|
||||
|
||||
amodel.m_vbed_handler = std::move(m_vbed_handler);
|
||||
amodel.m_model = std::move(m_model);
|
||||
amodel.m_selmask = std::move(m_selection);
|
||||
@ -443,11 +454,11 @@ SceneBuilder &&SceneBuilder::set_bed(const DynamicPrintConfig &cfg)
|
||||
Points bedpts = get_bed_shape(cfg);
|
||||
|
||||
if (is_XL_printer(cfg)) {
|
||||
m_bed = XLBed{get_extents(bedpts)};
|
||||
} else {
|
||||
m_bed = arr2::to_arrange_bed(bedpts);
|
||||
m_xl_printer = true;
|
||||
}
|
||||
|
||||
m_bed = arr2::to_arrange_bed(bedpts);
|
||||
|
||||
return std::move(*this);
|
||||
}
|
||||
|
||||
|
@ -205,6 +205,7 @@ protected:
|
||||
|
||||
AnyPtr<const SLAPrint> m_sla_print;
|
||||
AnyPtr<const Print> m_fff_print;
|
||||
bool m_xl_printer = false;
|
||||
|
||||
void set_brim_and_skirt();
|
||||
|
||||
@ -498,9 +499,9 @@ class ArrangeableSLAPrint : public ArrangeableSlicerModel {
|
||||
static void visit_arrangeable_(Self &&self, const ObjectID &id, Fn &&fn);
|
||||
|
||||
public:
|
||||
explicit ArrangeableSLAPrint(const SLAPrint *slaprint,
|
||||
SceneBuilder &builder)
|
||||
: m_slaprint{slaprint}, ArrangeableSlicerModel{builder}
|
||||
explicit ArrangeableSLAPrint(const SLAPrint *slaprint, SceneBuilder &builder)
|
||||
: m_slaprint{slaprint}
|
||||
, ArrangeableSlicerModel{builder}
|
||||
{
|
||||
assert(slaprint != nullptr);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user