diff --git a/Polyhedron/demo/Polyhedron/Color_map.h b/Polyhedron/demo/Polyhedron/Color_map.h index 096f2e20720..8d5bf31eb06 100644 --- a/Polyhedron/demo/Polyhedron/Color_map.h +++ b/Polyhedron/demo/Polyhedron/Color_map.h @@ -3,6 +3,16 @@ #include +inline QColor generate_color(double h, double s_min = 0.35) +{ + std::size_t s_max=255; + if(h >0.8 && h < 0,95) //span of ugly pink, desaturates make it less garish IMO + s_max = 160; + std::size_t s = std::rand() % (s_max-static_cast(s_min*255)) +s_min*255; + return QColor::fromHsvF(h,s/255.0,1.0); +} + + template Output_color_iterator compute_color_map(QColor base_color, @@ -12,24 +22,19 @@ compute_color_map(QColor base_color, qreal hue = base_color.hueF(); const qreal step = ((qreal)1) / nb_of_colors; - int s = base_color.saturation(), - v = base_color.value(); - s = s<90 ? s+90 : s; - v = v<90 ? v+90 : v; - float sf=s/256.0f, - vf=v/256.0f; - qreal h = hue==-1 ? 0 :hue; for(unsigned i = 0; i < nb_of_colors; ++i) { if (h!=-1) h += step; if ( h > 1 ) { h -= 1; } -//avoid S and V near 0 to avoid having all the same colors - *out++ = QColor::fromHsvF(h, - sf, - vf); + *out++ = generate_color(h); } return out; } +inline QColor generate_random_color() { + std::size_t h = static_cast(std::rand() % 360); + return generate_color(h/359.0); +} + #endif diff --git a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/VSA_wrapper.cpp b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/VSA_wrapper.cpp index 286be549b39..1d13c7ab82f 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/VSA_wrapper.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/VSA_wrapper.cpp @@ -60,8 +60,7 @@ std::size_t VSA_wrapper::add_one_proxy() { break; } if (nb_added == 1) { - const std::size_t h = (rand_0_310()+ 340)%359, s = rand_70_255(); - m_proxy_colors.push_back(QColor::fromHsvF(h/359.0,s/255.0,1.0)); + m_proxy_colors.push_back(generate_random_color()); } return nb_added; @@ -94,8 +93,7 @@ bool VSA_wrapper::split(const std::size_t px_idx, const std::size_t n, const std } if (splitted) { for (std::size_t i = m_proxy_colors.size(); i < number_of_proxies(); ++i) { - const std::size_t h = (rand_0_310()+ 340)%359,s=rand_70_255(); - m_proxy_colors.push_back(QColor::fromHsvF(h/359.0,s/255.0,1.0)); + m_proxy_colors.push_back(generate_random_color()); } } diff --git a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/VSA_wrapper.h b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/VSA_wrapper.h index 3df3aedf806..f43b6c94d48 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/VSA_wrapper.h +++ b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/VSA_wrapper.h @@ -96,15 +96,6 @@ class VSA_WRAPPER_EXPORT VSA_wrapper { typedef CGAL::Variational_shape_approximation Compact_approx; #endif - - std::size_t rand_0_310() { - return static_cast(std::rand() % 310); - } - - std::size_t rand_70_255() { - return static_cast(std::rand() % 185 + 70); - } - public: @@ -165,8 +156,7 @@ public: m_proxy_colors.reserve(number_of_proxies()); for (std::size_t i = 0; i < number_of_proxies(); ++i) { - const std::size_t h = (rand_0_310()+ 340)%360,s=rand_70_255(); - m_proxy_colors.push_back(QColor::fromHsvF(h/359.0,s/255.0,1.0)); + m_proxy_colors.push_back(generate_random_color()); } m_initialized = true;