From: wolf Date: Wed, 24 Jul 2002 13:34:10 +0000 (+0000) Subject: declare and define RgbValues::is_grey, and use it. Fix another problem when the color... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=73273369e069a0e4011e330010e0647518075732;p=dealii-svn.git declare and define RgbValues::is_grey, and use it. Fix another problem when the color range is empty. git-svn-id: https://svn.dealii.org/trunk@6269 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/include/base/data_out_base.h b/deal.II/base/include/base/data_out_base.h index 3a358780dc..583149f510 100644 --- a/deal.II/base/include/base/data_out_base.h +++ b/deal.II/base/include/base/data_out_base.h @@ -961,6 +961,16 @@ class DataOutBase float red; float green; float blue; + + /** + * Return @p{true} if the + * color represented by + * the three color values + * is a grey scale, + * i.e. all components + * are equal. + */ + bool is_grey () const; }; /** @@ -2042,4 +2052,16 @@ class DataOutInterface : private DataOutBase }; + +/* -------------------- inline functions ------------------- */ + +inline +bool +DataOutBase::EpsFlags::RgbValues::is_grey () const +{ + return (red == green) && (red == blue); +}; + + + #endif diff --git a/deal.II/base/source/data_out_base.cc b/deal.II/base/source/data_out_base.cc index 9a0fd33d5a..2cafaf6929 100644 --- a/deal.II/base/source/data_out_base.cc +++ b/deal.II/base/source/data_out_base.cc @@ -1935,6 +1935,23 @@ void DataOutBase::write_eps (const std::vector > &patches, out << std::setprecision (5); }; + // check if min and max + // values for the color are + // actually different. If + // that is not the case (such + // things happen, for + // example, in the very first + // time step of a time + // dependent problem, if the + // initial values are zero), + // all values are equal, and + // then we can draw + // everything in an arbitrary + // color. Thus, change one of + // the two values arbitrarily + if (max_color_value == min_color_value) + max_color_value = min_color_value+1; + // now we've got all the information // we need. write the cells. // note: due to the ordering, we @@ -1952,13 +1969,17 @@ void DataOutBase::write_eps (const std::vector > &patches, = (*flags.color_function) (cell->color_value, min_color_value, max_color_value); - - out << rgb_values.red << ' ' - << rgb_values.green << ' ' - << rgb_values.blue << " s "; + + // write out color + if (rgb_values.is_grey()) + out << rgb_values.red << " sg "; + else + out << rgb_values.red << ' ' + << rgb_values.green << ' ' + << rgb_values.blue << " s "; } else - out << "1 1 1 s "; + out << "1 sg "; out << (cell->vertices[0]-offset) * scale << " m " << (cell->vertices[1]-offset) * scale << " l " diff --git a/deal.II/doc/news/2002/c-3-4.html b/deal.II/doc/news/2002/c-3-4.html index 0045f64ada..739cf1fd11 100644 --- a/deal.II/doc/news/2002/c-3-4.html +++ b/deal.II/doc/news/2002/c-3-4.html @@ -95,6 +95,24 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK

base

    +
  1. + Fixed: In EPS output, colors were set to invalid values if the + values of the field that is used for coloring are all + equal. This happens, for example, in the very first time step + of time dependent problems, if initial values are zero. The + color value now used is arbitrary, but valid. +
    + (WB 2002/07/24) +

    + +
  2. + Changed: To save disk space, color values in EPS output are + written as grey scale with only one value instead of three RGB + values if the color so represented is actually a grey scale. +
    + (WB 2002/07/24) +

    +
  3. New: There are now operators to allow multiplication and division of Tensor objects by scalar