#11798 Use type definition from ClipperLib to avoid overflow

When converting a cvf::Vec3d to an integer vector, the platform int type was used as an intermediate variable. This caused overflow for large double values.
This commit is contained in:
Magne Sjaastad committed 2024-10-22 10:39:04 +02:00
1 parent df091336e0
commit da4d4c66b1
2 files changed
+7 -6

No files matched your search

@@ -407,9 +407,10 @@ double clipperConversionFactor = 10000; // For transform to clipper int
ClipperLib::IntPoint toClipperPoint( const cvf::Vec3d& cvfPoint )
{
int xInt = cvfPoint.x() * clipperConversionFactor;
int yInt = cvfPoint.y() * clipperConversionFactor;
int zInt = cvfPoint.z() * clipperConversionFactor;
ClipperLib::cInt xInt = cvfPoint.x() * clipperConversionFactor;
ClipperLib::cInt yInt = cvfPoint.y() * clipperConversionFactor;
ClipperLib::cInt zInt = cvfPoint.z() * clipperConversionFactor;
return ClipperLib::IntPoint( xInt, yInt, zInt );
}
@@ -566,9 +566,9 @@ double clipperConversionFactor2 = 10000; // For transform to clipper int
ClipperLib::IntPoint toClipperEdgePoint( const cvf::Vec3d& cvfPoint )
{
int xInt = cvfPoint.x() * clipperConversionFactor2;
int yInt = cvfPoint.y() * clipperConversionFactor2;
int zInt = cvfPoint.z();
ClipperLib::cInt xInt = cvfPoint.x() * clipperConversionFactor2;
ClipperLib::cInt yInt = cvfPoint.y() * clipperConversionFactor2;
ClipperLib::cInt zInt = cvfPoint.z();
return ClipperLib::IntPoint( xInt, yInt, zInt );
}