#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 2024-10-21 13:50:17 +02:00
parent f6ab2f92d3
commit 4f8619d38c
2 changed files with 7 additions and 6 deletions

View File

@ -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 );
}

View File

@ -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 );
}