FIX: handle exception of dividing by zero in arranging

jira: none
Change-Id: I0d20464dbe81a80293539100f06d72dee456a27b
(cherry picked from commit 94746ae9bf7f467243849570450567b4fdc78e3a)
This commit is contained in:
Arthur 2024-05-06 14:29:25 +08:00 committed by Lane.Wei
parent 932218e389
commit 96e2147394
1 changed files with 9 additions and 2 deletions

View File

@ -927,8 +927,15 @@ template<class Bin> void remove_large_items(std::vector<Item> &items, Bin &&bin)
template<class S> Radians min_area_boundingbox_rotation(const S &sh)
{
return minAreaBoundingBox<S, TCompute<S>, boost::rational<LargeInt>>(sh)
.angleToX();
try {
return minAreaBoundingBox<S, TCompute<S>, boost::rational<LargeInt>>(sh)
.angleToX();
}
catch (const std::exception& e) {
// min_area_boundingbox_rotation may throw exception of dividing 0 if the object is already perfectly aligned to X
BOOST_LOG_TRIVIAL(error) << "arranging min_area_boundingbox_rotation fails, msg=" << e.what();
return 0.0;
}
}
template<class S>