Temporarily disable rotations for wipe tower when arranging

It is problematic due to varying interpretation of rotation in arrange and slicer's wipe tower handling 
fixes SPE-1787
This commit is contained in:
tamasmeszaros 2023-08-14 19:54:16 +02:00
parent 5b9d5b55b6
commit 0c0a1af1e9
4 changed files with 27 additions and 36 deletions

View File

@ -225,6 +225,9 @@ void fill_rotations(const Range<It> &items,
return;
for (auto &itm : items) {
if (is_wipe_tower(itm)) // Rotating the wipe tower is currently problematic
continue;
// Use the minimum bounding box rotation as a starting point.
auto minbbr = get_min_area_bounding_box_rotation(itm);
std::vector<double> rotations =

View File

@ -115,20 +115,14 @@ struct ArrangeableWipeTowerBase: public Arrangeable
ObjectID oid;
Polygon poly;
Point pos = Point::Zero();
double rot = 0.;
SelectionPredicate selection_pred;
ArrangeableWipeTowerBase(
const ObjectID &objid,
Polygon shape,
const Point &p,
double r,
SelectionPredicate selection_predicate = [] { return false; })
: oid{objid},
poly{std::move(shape)},
pos{p},
rot{r},
selection_pred{std::move(selection_predicate)}
{}
@ -138,15 +132,12 @@ struct ArrangeableWipeTowerBase: public Arrangeable
ExPolygons full_outline() const override
{
auto cpy = poly;
cpy.translate(pos);
return {ExPolygon{cpy}};
return {ExPolygon{std::move(cpy)}};
}
Polygon convex_outline() const override
{
auto cpy = poly;
cpy.translate(pos);
return cpy;
return poly;
}
bool is_selected() const override

View File

@ -65,29 +65,21 @@ public:
}
};
struct WipeTowerGeometry
static Polygon get_wtpoly(const GLCanvas3D::WipeTowerInfo &wti)
{
Polygon poly;
Point pos = Point::Zero();
double rot = 0.;
};
static WipeTowerGeometry get_wtg(const GLCanvas3D::WipeTowerInfo &wti)
{
WipeTowerGeometry ret;
auto bb = scaled(wti.bounding_box());
ret.poly = Polygon({
Polygon poly = Polygon({
{bb.min},
{bb.max.x(), bb.min.y()},
{bb.max},
{bb.min.x(), bb.max.y()}
});
ret.pos = scaled(wti.pos());
ret.rot = wti.rotation();
poly.rotate(wti.rotation());
poly.translate(scaled(wti.pos()));
return ret;
return poly;
}
// Wipe tower logic based on GLCanvas3D::WipeTowerInfo implements the Arrangeable
@ -95,18 +87,24 @@ static WipeTowerGeometry get_wtg(const GLCanvas3D::WipeTowerInfo &wti)
class ArrangeableWT: public arr2::ArrangeableWipeTowerBase
{
BoundingBox m_xl_bb;
Vec2d m_orig_tr;
double m_orig_rot;
public:
explicit ArrangeableWT(const ObjectID &oid,
const WipeTowerGeometry &wtg,
std::function<bool()> sel_pred,
const BoundingBox xl_bb = {})
: arr2::ArrangeableWipeTowerBase{oid, wtg.poly, wtg.pos, wtg.rot,
std::move(sel_pred)}, m_xl_bb{xl_bb}
explicit ArrangeableWT(const ObjectID &oid,
const GLCanvas3D::WipeTowerInfo &wti,
std::function<bool()> sel_pred,
const BoundingBox xl_bb = {})
: arr2::ArrangeableWipeTowerBase{oid, get_wtpoly(wti), std::move(sel_pred)}
, m_orig_tr{wti.pos()}
, m_orig_rot{wti.rotation()}
, m_xl_bb{xl_bb}
{}
void transform(const Vec2d &transl, double rot) override
// Rotation is disabled for wipe tower in arrangement
void transform(const Vec2d &transl, double /*rot*/) override
{
GLCanvas3D::WipeTowerInfo::apply_wipe_tower(unscaled(pos) + transl, rot);
GLCanvas3D::WipeTowerInfo::apply_wipe_tower(m_orig_tr + transl, m_orig_rot);
}
void imbue_data(arr2::AnyWritable &datastore) const override
@ -142,8 +140,7 @@ struct WTH : public arr2::WipeTowerHandler
template<class Self, class Fn>
static void visit_(Self &&self, Fn &&fn)
{
auto wtg = get_wtg(self.wti);
ArrangeableWT wta{self.oid, wtg, self.sel_pred, self.xl_bb};
ArrangeableWT wta{self.oid, self.wti, self.sel_pred, self.xl_bb};
fn(wta);
}

View File

@ -882,12 +882,12 @@ public:
void visit(std::function<void(Arrangeable &)> fn) override
{
MocWT wt{m_id, Polygon{}, Point::Zero(), 0., m_sel_pred};
MocWT wt{m_id, Polygon{}, m_sel_pred};
fn(wt);
}
void visit(std::function<void(const Arrangeable &)> fn) const override
{
MocWT wt{m_id, Polygon{}, Point::Zero(), 0., m_sel_pred};
MocWT wt{m_id, Polygon{}, m_sel_pred};
fn(wt);
}
void set_selection_predicate(std::function<bool()> pred) override