From 5b84fed65974e628dae1b99cd85dba3a07119f63 Mon Sep 17 00:00:00 2001
From: Sebastian Eibl <sebastian.eibl@fau.de>
Date: Fri, 28 Sep 2018 12:30:58 +0200
Subject: [PATCH] clang-tidy -checks=-*,bugprone-incorrect-roundings

---
 src/geometry/mesh/TriangleMeshIO.cpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/geometry/mesh/TriangleMeshIO.cpp b/src/geometry/mesh/TriangleMeshIO.cpp
index 60b737232..ad3c1349c 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";
       }
-- 
GitLab