94fbce
From 7111d0ef96dd1caf5d3cdbc435b8c1820f72e95a Mon Sep 17 00:00:00 2001
94fbce
From: Bart Janssens <bart@bartjanssens.org>
94fbce
Date: Sat, 13 Jan 2018 23:49:34 +0100
94fbce
Subject: [PATCH 06/10] COMP: Fix clang v. 5 compilation on Linux
94fbce
94fbce
Hopefully helps for issue #31
94fbce
---
94fbce
 k3dsdk/gil/boost/uuid/seed_rng.hpp |  2 +-
94fbce
 k3dsdk/utility_gl.h                |  2 +-
94fbce
 modules/nurbs/nurbs_curves.cpp     | 10 +++++-----
94fbce
 modules/stl_io/binary_stl.h        |  8 ++++----
94fbce
 4 files changed, 11 insertions(+), 11 deletions(-)
94fbce
94fbce
diff --git a/k3dsdk/gil/boost/uuid/seed_rng.hpp b/k3dsdk/gil/boost/uuid/seed_rng.hpp
94fbce
index 30901971..6967f3e2 100644
94fbce
--- a/k3dsdk/gil/boost/uuid/seed_rng.hpp
94fbce
+++ b/k3dsdk/gil/boost/uuid/seed_rng.hpp
94fbce
@@ -140,7 +140,7 @@ private:
94fbce
         }
94fbce
 
94fbce
         {
94fbce
-            unsigned int rn[] = { std::rand(), std::rand(), std::rand() };
94fbce
+            unsigned int rn[] = { static_cast<unsigned int="">(std::rand()), static_cast<unsigned int="">(std::rand()), static_cast<unsigned int="">(std::rand()) };
94fbce
             sha.process_bytes( (unsigned char const*)rn, sizeof( rn ) );
94fbce
         }
94fbce
 
94fbce
diff --git a/k3dsdk/utility_gl.h b/k3dsdk/utility_gl.h
94fbce
index 45e7eb32..3809143e 100644
94fbce
--- a/k3dsdk/utility_gl.h
94fbce
+++ b/k3dsdk/utility_gl.h
94fbce
@@ -104,7 +104,7 @@ inline void color3d(const color& Color)
94fbce
 /// Passes a k3d::color to glMaterialfv()
94fbce
 inline void material(GLenum Face, GLenum PName, const color& Color, double Alpha = 1.0)
94fbce
 {
94fbce
-	GLfloat color[] = { Color.red, Color.green, Color.blue, Alpha };
94fbce
+	GLfloat color[] = { static_cast<glfloat>(Color.red), static_cast<glfloat>(Color.green), static_cast<glfloat>(Color.blue), static_cast<glfloat>(Alpha) };
94fbce
 	glMaterialfv(Face, PName, color);
94fbce
 }
94fbce
 
94fbce
diff --git a/modules/nurbs/nurbs_curves.cpp b/modules/nurbs/nurbs_curves.cpp
94fbce
index c3a7fed1..3a2df4c7 100644
94fbce
--- a/modules/nurbs/nurbs_curves.cpp
94fbce
+++ b/modules/nurbs/nurbs_curves.cpp
94fbce
@@ -738,7 +738,7 @@ void elevate_curve_degree(curve_arrays& Curve, const k3d::uint_t Elevations)
94fbce
 					for (int k = power; k >= s; k--)
94fbce
 					{
94fbce
 						k3d::double_t weights[] = {alphas[k - s], (1.0 - alphas[k - s])};
94fbce
-						k3d::uint_t indices[] = {k, k-1};
94fbce
+						k3d::uint_t indices[] = {static_cast<k3d::uint_t>(k), static_cast<k3d::uint_t>(k-1)};
94fbce
 						bpts_self_copier.copy(2, indices, weights, k);
94fbce
 					}
94fbce
 					next_bpts_bpts_copier.copy(power, save);
94fbce
@@ -777,7 +777,7 @@ void elevate_curve_degree(curve_arrays& Curve, const k3d::uint_t Elevations)
94fbce
 						if (i < cind)
94fbce
 						{
94fbce
 							double alf = (ub - new_curve.knots[i]) / (ua - new_curve.knots[i]);
94fbce
-							k3d::uint_t indices[] = {i, i-1};
94fbce
+							k3d::uint_t indices[] = {static_cast<k3d::uint_t>(i), static_cast<k3d::uint_t>(i-1)};
94fbce
 							k3d::double_t weights[] = {alf, (1.0 - alf)};
94fbce
 							new_point_self_copier.copy(2, indices, weights, i);
94fbce
 						}
94fbce
@@ -786,13 +786,13 @@ void elevate_curve_degree(curve_arrays& Curve, const k3d::uint_t Elevations)
94fbce
 							if (j - tr <= kind - power - t + oldr)
94fbce
 							{
94fbce
 								double gam = (ub - new_curve.knots[j - tr]) / den;
94fbce
-								k3d::uint_t indices[] = {kj, kj+1};
94fbce
+								k3d::uint_t indices[] = {static_cast<k3d::uint_t>(kj), static_cast<k3d::uint_t>(kj+1)};
94fbce
 								k3d::double_t weights[] = {gam, 1.0-gam};
94fbce
 								ebpts_self_copier.copy(2, indices, weights, kj);
94fbce
 							}
94fbce
 							else
94fbce
 							{
94fbce
-								k3d::uint_t indices[] = {kj, kj+1};
94fbce
+								k3d::uint_t indices[] = {static_cast<k3d::uint_t>(kj), static_cast<k3d::uint_t>(kj+1)};
94fbce
 								k3d::double_t weights[] = {bet, 1.0-bet};
94fbce
 								ebpts_self_copier.copy(2, indices, weights, kj);
94fbce
 							}
94fbce
@@ -1159,7 +1159,7 @@ void insert_knot(curve_arrays& Curve, const k3d::double_t u, const k3d::uint_t r
94fbce
 		for (k3d::uint_t i = 0; i <= Curve.order - 1 - j - s; i++)
94fbce
 		{
94fbce
 			alpha = (u - Curve.knots[L + i]) / (Curve.knots[i + k + 1] - Curve.knots[L + i]);
94fbce
-			k3d::uint_t indices[] = {i + 1, i};
94fbce
+			k3d::uint_t indices[] = {static_cast<k3d::uint_t>(i + 1), static_cast<k3d::uint_t>(i)};
94fbce
 			k3d::double_t weights[] = {alpha, 1.0 - alpha};
94fbce
 			tmp_self_copier.copy(2, indices, weights, i);
94fbce
 		}
94fbce
diff --git a/modules/stl_io/binary_stl.h b/modules/stl_io/binary_stl.h
94fbce
index 12cc4539..60124fee 100644
94fbce
--- a/modules/stl_io/binary_stl.h
94fbce
+++ b/modules/stl_io/binary_stl.h
94fbce
@@ -68,10 +68,10 @@ struct binary_stl
94fbce
 	/// Magics format constructor, writes material info into the header
94fbce
 	binary_stl(const k3d::color& Color, const k3d::color& Diffuse, const k3d::color& Specular, const k3d::color& Ambient)
94fbce
 	{
94fbce
-		const k3d::uint8_t color[] = {Color.red*255, Color.green*255, Color.blue*255, 0};
94fbce
-		const k3d::uint8_t diffuse[] = {Diffuse.red*255, Diffuse.green*255, Diffuse.blue*255, 0};
94fbce
-		const k3d::uint8_t specular[] = {Specular.red*255, Specular.green*255, Specular.blue*255, 0};
94fbce
-		const k3d::uint8_t ambient[] = {Ambient.red*255, Ambient.green*255, Ambient.blue*255, 0};
94fbce
+		const k3d::uint8_t color[] = {static_cast<k3d::uint8_t>(Color.red*255), static_cast<k3d::uint8_t>(Color.green*255), static_cast<k3d::uint8_t>(Color.blue*255), 0};
94fbce
+		const k3d::uint8_t diffuse[] = {static_cast<k3d::uint8_t>(Diffuse.red*255), static_cast<k3d::uint8_t>(Diffuse.green*255), static_cast<k3d::uint8_t>(Diffuse.blue*255), 0};
94fbce
+		const k3d::uint8_t specular[] = {static_cast<k3d::uint8_t>(Specular.red*255), static_cast<k3d::uint8_t>(Specular.green*255), static_cast<k3d::uint8_t>(Specular.blue*255), 0};
94fbce
+		const k3d::uint8_t ambient[] = {static_cast<k3d::uint8_t>(Ambient.red*255), static_cast<k3d::uint8_t>(Ambient.green*255), static_cast<k3d::uint8_t>(Ambient.blue*255), 0};
94fbce
 		const k3d::string_t color_str(reinterpret_cast<const char*="">(color));
94fbce
 		const k3d::string_t diffuse_str(reinterpret_cast<const char*="">(diffuse));
94fbce
 		const k3d::string_t specular_str(reinterpret_cast<const char*="">(specular));
94fbce
-- 
94fbce
2.14.3
94fbce