5 #include <RMF/FileHandle.h>
10 int get_count(RMF::NodeHandle nh,
int level) {
13 RMF::NodeHandles ch= nh.get_children();
14 for (
unsigned int i=0; i< ch.size(); ++i) {
15 ret+= get_count(ch[i], level-1);
23 int recolor(RMF::NodeHandle nh,
int level,
int total,
24 int so_far, std::string method,
29 RMF::NodeHandles ch= nh.get_children();
30 for (
unsigned int i=0; i< ch.size(); ++i) {
31 so_far= recolor(ch[i], level-1, total, so_far, method,
35 double f=
static_cast<double>(so_far)/total;
42 nh.set_value(red, c.get_red());
43 nh.set_value(green, c.get_green());
44 nh.set_value(blue, c.get_blue());
51 int main(
int argc,
char **argv) {
53 boost::int64_t level=0;
54 std::string colormap=
"jet";
56 "What level to apply the color to in the RMF (0 is root).",
59 "The colormap to use: display, jet",
64 for (
unsigned int i = 0; i < files.size(); ++i) {
65 RMF::FileHandle rh= RMF::open_rmf_file(files[i]);
66 int count= get_count(rh.get_root_node(), level);
67 RMF::Category cat= rh.get_category(
"shape");
69 = rh.get_key<RMF::FloatTraits>(cat,
"rgb color red");
71 = rh.get_key<RMF::FloatTraits>(cat,
"rgb color green");
73 = rh.get_key<RMF::FloatTraits>(cat,
"rgb color blue");
74 recolor(rh.get_root_node(), level, count, 0, colormap, red, green, blue);
77 std::cerr <<
"Error: " << e.what() << std::endl;
79 }
catch (
const std::exception &e) {
80 std::cerr <<
"Error: " << e.what() << std::endl;