Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsupermerill <merill@free.fr>2021-12-15 21:28:35 +0300
committersupermerill <merill@free.fr>2021-12-15 21:51:00 +0300
commit269ade4859f606da4dde71a6cdfd7b65a897dc9f (patch)
tree536a93717869ff1135d691f1e673f66807a4d926 /src
parent497736affe875d41b809fdfe28931a6932829b32 (diff)
fix div/0 in libnest2D
supermerill/SuperSlicer#2053
Diffstat (limited to 'src')
-rw-r--r--src/libnest2d/include/libnest2d/geometry_traits_nfp.hpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/libnest2d/include/libnest2d/geometry_traits_nfp.hpp b/src/libnest2d/include/libnest2d/geometry_traits_nfp.hpp
index 29a1ccd04..07b34f47d 100644
--- a/src/libnest2d/include/libnest2d/geometry_traits_nfp.hpp
+++ b/src/libnest2d/include/libnest2d/geometry_traits_nfp.hpp
@@ -281,9 +281,10 @@ inline NfpResult<RawShape> nfpConvexOnly(const RawShape& sh,
// cos function. But with the quadrant info we can get the sign back
int sign = q[0] == 1 || q[0] == 2 ? -1 : 1;
+ // supermerill: add safe-check for when two points are on the same position
// If Ratio is an actual rational type, there is no precision loss
- auto pcos1 = Ratio(lcos[0]) / lsq1 * sign * lcos[0];
- auto pcos2 = Ratio(lcos[1]) / lsq2 * sign * lcos[1];
+ auto pcos1 = lsq1 != 0 ? Ratio(lcos[0]) / lsq1 * sign * lcos[0] : 1 * sign * lcos[0];
+ auto pcos2 = lsq2 != 0 ? Ratio(lcos[1]) / lsq2 * sign * lcos[1] : 1 * sign * lcos[1];
return q[0] < 2 ? pcos1 < pcos2 : pcos1 > pcos2;
}