diff --git a/src/geometry/mesh/TriangleMeshIO.cpp b/src/geometry/mesh/TriangleMeshIO.cpp index 60b737232f5facb0b9e2a534a47764e0db3cc08b..ad3c1349c6f59185eee11386a78b7d171f369b80 100644 --- a/src/geometry/mesh/TriangleMeshIO.cpp +++ b/src/geometry/mesh/TriangleMeshIO.cpp @@ -32,6 +32,7 @@ #include <boost/algorithm/string.hpp> +#include <cmath> #include <fstream> #include <map> #include <sstream> @@ -678,9 +679,9 @@ namespace geometry { os << " "; for( auto it = mesh.getVertexColors().begin(); it != mesh.getVertexColors().end(); ++it ) { - os << static_cast<uint16_t>( (*it)[0] * 255.0f + 0.5f ) << ' ' - << static_cast<uint16_t>( (*it)[1] * 255.0f + 0.5f ) << ' ' - << static_cast<uint16_t>( (*it)[2] * 255.0f + 0.5f ) << ' '; + os << std::lround( (*it)[0] * 255.0f ) << ' ' + << std::lround( (*it)[1] * 255.0f ) << ' ' + << std::lround( (*it)[2] * 255.0f ) << ' '; } os << " </DataArray>\n"; }