mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-12 21:28:59 +08:00
SimpleArrangeItem now usable with arrange tasks
For future comparisons and measurements
This commit is contained in:
parent
355b869e0d
commit
183afab8e7
@ -123,7 +123,7 @@ void arrange(SelectionStrategy &&selstrategy,
|
||||
d += corr;
|
||||
|
||||
for (auto &itm : items)
|
||||
if (itm.bed_idx() == static_cast<int>(bedidx) && !is_wipe_tower(itm))
|
||||
if (get_bed_index(itm) == static_cast<int>(bedidx) && !is_wipe_tower(itm))
|
||||
translate(itm, d);
|
||||
}
|
||||
}
|
||||
@ -386,7 +386,8 @@ ArrItem ConvexItemConverter<ArrItem>::convert(const Arrangeable &arrbl,
|
||||
set_priority(ret, arrbl.priority());
|
||||
|
||||
imbue_id(ret, arrbl.id());
|
||||
arrbl.imbue_data(AnyWritableDataStore{ret});
|
||||
if constexpr (IsWritableDataStore<ArrItem>)
|
||||
arrbl.imbue_data(AnyWritableDataStore{ret});
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -401,7 +402,8 @@ ArrItem AdvancedItemConverter<ArrItem>::convert(const Arrangeable &arrbl,
|
||||
set_bed_index(ret, bed_index);
|
||||
set_priority(ret, arrbl.priority());
|
||||
imbue_id(ret, arrbl.id());
|
||||
arrbl.imbue_data(AnyWritableDataStore{ret});
|
||||
if constexpr (IsWritableDataStore<ArrItem>)
|
||||
arrbl.imbue_data(AnyWritableDataStore{ret});
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -1,5 +1,8 @@
|
||||
#include "SimpleArrangeItem.hpp"
|
||||
#include "libslic3r/Arrange/ArrangeImpl.hpp"
|
||||
#include "libslic3r/Arrange/Tasks/ArrangeTaskImpl.hpp"
|
||||
#include "libslic3r/Arrange/Tasks/FillBedTaskImpl.hpp"
|
||||
#include "libslic3r/Arrange/Tasks/MultiplySelectionTaskImpl.hpp"
|
||||
|
||||
namespace Slic3r { namespace arr2 {
|
||||
|
||||
@ -12,4 +15,10 @@ Polygon SimpleArrangeItem::outline() const
|
||||
return ret;
|
||||
}
|
||||
|
||||
template class ArrangeableToItemConverter<SimpleArrangeItem>;
|
||||
template struct ArrangeTask<SimpleArrangeItem>;
|
||||
template struct FillBedTask<SimpleArrangeItem>;
|
||||
template struct MultiplySelectionTask<SimpleArrangeItem>;
|
||||
template class Arranger<SimpleArrangeItem>;
|
||||
|
||||
}} // namespace Slic3r::arr2
|
||||
|
@ -7,6 +7,9 @@
|
||||
#include "libslic3r/Arrange/Core/NFP/NFP.hpp"
|
||||
|
||||
#include "libslic3r/Arrange/Arrange.hpp"
|
||||
#include "libslic3r/Arrange/Tasks/ArrangeTask.hpp"
|
||||
#include "libslic3r/Arrange/Tasks/FillBedTask.hpp"
|
||||
#include "libslic3r/Arrange/Tasks/MultiplySelectionTask.hpp"
|
||||
|
||||
#include "libslic3r/Polygon.hpp"
|
||||
#include "libslic3r/Geometry/ConvexHull.hpp"
|
||||
@ -24,6 +27,7 @@ class SimpleArrangeItem {
|
||||
int m_bed_idx = Unarranged;
|
||||
|
||||
std::vector<double> m_allowed_rotations = {0.};
|
||||
ObjectID m_obj_id;
|
||||
|
||||
public:
|
||||
explicit SimpleArrangeItem(Polygon chull = {}): m_shape{std::move(chull)} {}
|
||||
@ -52,6 +56,9 @@ public:
|
||||
{
|
||||
m_allowed_rotations = std::move(rots);
|
||||
}
|
||||
|
||||
void set_object_id(const ObjectID &id) noexcept { m_obj_id = id; }
|
||||
const ObjectID & get_object_id() const noexcept { return m_obj_id; }
|
||||
};
|
||||
|
||||
template<> struct NFPArrangeItemTraits_<SimpleArrangeItem>
|
||||
@ -183,6 +190,29 @@ struct WritableItemTraits_<SimpleArrangeItem> {
|
||||
}
|
||||
};
|
||||
|
||||
template<> struct ImbueableItemTraits_<SimpleArrangeItem>
|
||||
{
|
||||
static void imbue_id(SimpleArrangeItem &itm, const ObjectID &id)
|
||||
{
|
||||
itm.set_object_id(id);
|
||||
}
|
||||
|
||||
static std::optional<ObjectID> retrieve_id(const SimpleArrangeItem &itm)
|
||||
{
|
||||
std::optional<ObjectID> ret;
|
||||
if (itm.get_object_id().valid())
|
||||
ret = itm.get_object_id();
|
||||
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
extern template class ArrangeableToItemConverter<SimpleArrangeItem>;
|
||||
extern template struct ArrangeTask<SimpleArrangeItem>;
|
||||
extern template struct FillBedTask<SimpleArrangeItem>;
|
||||
extern template struct MultiplySelectionTask<SimpleArrangeItem>;
|
||||
extern template class Arranger<SimpleArrangeItem>;
|
||||
|
||||
}} // namespace Slic3r::arr2
|
||||
|
||||
#endif // SIMPLEARRANGEITEM_HPP
|
||||
|
@ -96,7 +96,7 @@ void set_arbitrary_data(Itm &itm, const std::string &key, T &&data)
|
||||
template<class Itm>
|
||||
void set_allowed_rotations(Itm &itm, const std::vector<double> &rotations)
|
||||
{
|
||||
WritableItemTraits<Itm>::set_arbitrary_data(itm, "rotations", rotations);
|
||||
WritableItemTraits<Itm>::set_allowed_rotations(itm, rotations);
|
||||
}
|
||||
|
||||
template<class ArrItem> int raise_priority(ArrItem &itm)
|
||||
|
Loading…
x
Reference in New Issue
Block a user