]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
declare and define RgbValues::is_grey, and use it. Fix another problem when the color...
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 24 Jul 2002 13:34:10 +0000 (13:34 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 24 Jul 2002 13:34:10 +0000 (13:34 +0000)
git-svn-id: https://svn.dealii.org/trunk@6269 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/data_out_base.h
deal.II/base/source/data_out_base.cc
deal.II/doc/news/2002/c-3-4.html

index 3a358780dc3ae83fea61f61c625a7cfc8f7732dd..583149f510d494f0629ed1b1c0f1f448eedc0071 100644 (file)
@@ -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
index 9a0fd33d5aeb0768d01806d309d249342db54beb..2cafaf692924777db6ae7041e909357780efebef 100644 (file)
@@ -1935,6 +1935,23 @@ void DataOutBase::write_eps (const std::vector<Patch<dim,spacedim> > &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<Patch<dim,spacedim> > &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 "
index 0045f64adabfba0bcdbe7ac3b811259102c8c1e3..739cf1fd1146c3d72afdeecca98e99c1380d5528 100644 (file)
@@ -95,6 +95,24 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK
 <h3>base</h3>
 
 <ol>
+  <li> <p> 
+       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.
+       <br>
+       (WB 2002/07/24)
+       </p>
+
+  <li> <p> 
+       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.
+       <br>
+       (WB 2002/07/24)
+       </p>
+
   <li> <p> 
        New: There are now operators to allow multiplication and
        division of <code class="class">Tensor</code> objects by scalar

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.