mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-23 22:54:08 -06:00
Search for suitable rotation when arranging items larger than the bed
This commit is contained in:
parent
d3233d66fb
commit
49c6ce76d0
2 changed files with 191 additions and 72 deletions
|
@ -379,7 +379,7 @@ public:
|
|||
});
|
||||
|
||||
if (stopcond) m_pck.stopCondition(stopcond);
|
||||
|
||||
|
||||
m_pck.configure(m_pconf);
|
||||
}
|
||||
|
||||
|
@ -472,6 +472,12 @@ template<class S> Radians min_area_boundingbox_rotation(const S &sh)
|
|||
.angleToX();
|
||||
}
|
||||
|
||||
template<class S>
|
||||
Radians fit_into_box_rotation(const S &sh, const _Box<TPoint<S>> &box)
|
||||
{
|
||||
return fitIntoBoxRotation<S, TCompute<S>, boost::rational<LargeInt>>(sh, box);
|
||||
}
|
||||
|
||||
template<class BinT> // Arrange for arbitrary bin type
|
||||
void _arrange(
|
||||
std::vector<Item> & shapes,
|
||||
|
@ -509,10 +515,19 @@ void _arrange(
|
|||
// Use the minimum bounding box rotation as a starting point.
|
||||
// TODO: This only works for convex hull. If we ever switch to concave
|
||||
// polygon nesting, a convex hull needs to be calculated.
|
||||
if (params.allow_rotations)
|
||||
for (auto &itm : shapes)
|
||||
if (params.allow_rotations) {
|
||||
for (auto &itm : shapes) {
|
||||
itm.rotation(min_area_boundingbox_rotation(itm.rawShape()));
|
||||
|
||||
// If the item is too big, try to find a rotation that makes it fit
|
||||
if constexpr (std::is_same_v<BinT, Box>) {
|
||||
auto bb = itm.boundingBox();
|
||||
if (bb.width() >= bin.width() || bb.height() >= bin.height())
|
||||
itm.rotate(fit_into_box_rotation(itm.transformedShape(), bin));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
arranger(inp.begin(), inp.end());
|
||||
for (Item &itm : inp) itm.inflate(-infl);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue