13 #include <CGAL/boost/graph/properties.h>
14 #include <boost/foreach.hpp>
42 unsigned int colors_nbr = 256,
48 throw std::invalid_argument(
"make_LUT: h1 and h2 must be different.");
50 throw std::invalid_argument(
"make_LUT: colors_nbr must not be zero.");
56 float max_color_value = 1;
58 max_color_value = 255;
59 float step = (h2 - h1)/colors_nbr;
67 auto f = [](
float h,
float s,
float v,
int n) ->
float
69 float k = std::fmod(n + h/60.0f, 6.0f);
70 return v - v*s*std::max(std::min({k, 4-k, 1.0f}), 0.0f);
74 for(
unsigned int i = 0; i < colors_nbr; i++)
77 rgb_LUT[3 * i] = max_color_value * f(H, S, V, 5);
78 rgb_LUT[3 * i + 1] = max_color_value * f(H, S, V, 3);
79 rgb_LUT[3 * i + 2] = max_color_value * f(H, S, V, 1);
100 template<
typename Descriptor,
101 typename PropertyMap,
103 typename MapType =
typename PropertyMap::value_type >
106 const PropertyMap &prop_map,
107 ColorMap &color_pmap,
108 const MapType min_metric,
109 const MapType max_metric,
112 typedef typename boost::property_traits< ColorMap >::value_type
Color;
116 typedef typename std::remove_reference< decltype(dummy[0]) >::type
124 size_t number_of_colors = colors.size() / 3;
126 if(min_metric != max_metric)
129 MapType val_metric =
get(prop_map, d);
132 val_metric = std::min(val_metric, max_metric);
133 val_metric = std::max(val_metric, min_metric);
136 MapType
id = (val_metric - min_metric) / (max_metric - min_metric);
137 int indice_lut =
static_cast< int >(std::floor((number_of_colors - 1) *
id));
140 Color newcolor(
static_cast< ColorComponent
>(colors[3 * indice_lut]),
141 static_cast< ColorComponent
>(colors[3 * indice_lut + 1]),
142 static_cast< ColorComponent
>(colors[3 * indice_lut + 2]));
143 put(color_pmap, d, newcolor);
148 put(color_pmap, d,
Color(
static_cast< ColorComponent
>(colors[0]),
149 static_cast< ColorComponent
>(colors[1]),
150 static_cast< ColorComponent
>(colors[2])));
167 template<
typename HalfedgeGraph,
168 typename PropertyMap,
170 typename MapType =
typename PropertyMap::value_type >
173 const PropertyMap &prop_map,
174 ColorMap &color_pmap,
175 const MapType min_metric,
176 const MapType max_metric,
179 typedef typename boost::graph_traits< HalfedgeGraph >::face_descriptor
182 BOOST_FOREACH(Face_Descriptor f,
faces(g))
206 template<
typename HalfedgeGraph,
207 typename PropertyMap,
209 typename MapType =
typename PropertyMap::value_type >
212 const PropertyMap &prop_map,
213 ColorMap &color_pmap,
214 const MapType min_metric,
215 const MapType max_metric,
245 template<
typename HalfedgeGraph,
246 typename PropertyMap,
248 typename MapType =
typename PropertyMap::value_type >
251 const PropertyMap &prop_map,
252 ColorMap &color_pmap,
253 const MapType min_metric,
254 const MapType max_metric,
257 typedef typename boost::graph_traits< HalfedgeGraph >::halfedge_descriptor
260 BOOST_FOREACH(Halfedge_Descriptor h, halfedges(g))
288 typename Color =
typename boost::property_traits< ColorMap >::value_type >
291 const BooleanMap &prop_map,
292 ColorMap &color_pmap,
298 put(color_pmap, d, color1);
302 put(color_pmap, d, color2);
319 typename HalfedgeGraph,
322 typename Color =
typename boost::property_traits< ColorMap >::value_type >
325 const BooleanMap &prop_map,
326 ColorMap &color_pmap,
330 typedef typename boost::graph_traits< HalfedgeGraph >::face_descriptor
333 BOOST_FOREACH(Face_Descriptor f,
faces(g))
351 typename HalfedgeGraph,
354 typename Color =
typename boost::property_traits< ColorMap >::value_type >
357 const BooleanMap &prop_map,
358 ColorMap &color_pmap,
383 typename HalfedgeGraph,
386 typename Color =
typename boost::property_traits< ColorMap >::value_type >
389 const BooleanMap &prop_map,
390 ColorMap &color_pmap,
394 typedef typename boost::graph_traits< HalfedgeGraph >::halfedge_descriptor
397 BOOST_FOREACH(Halfedge_Descriptor h, halfedges(g))