]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Allow for colorized eps output.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 8 Sep 2003 15:55:59 +0000 (15:55 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 8 Sep 2003 15:55:59 +0000 (15:55 +0000)
git-svn-id: https://svn.dealii.org/trunk@7964 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/grid/grid_out.h
deal.II/deal.II/source/grid/grid_out.all_dimensions.cc
deal.II/deal.II/source/grid/grid_out.cc

index ca3ef483bd15c00ee2dcb4ef28102fc9fc87ecf1..73ab28059e1a8efad5a678f8d1516d5bb809333f 100644 (file)
@@ -207,9 +207,11 @@ namespace GridOutFlags
                                        * units. Default is 0.5.
                                        */
       double line_width;
+      
                                       /**
-                                       * Should lines with a set @p{user_flag}
-                                       * be drawn in a different color?
+                                       * Should lines with a set
+                                       * @p{user_flag} be drawn in a
+                                       * different color (red)?
                                        */
       bool color_lines_on_user_flag;
       
@@ -227,6 +229,19 @@ namespace GridOutFlags
                                        */
       unsigned int n_boundary_face_points;
       
+                                      /**
+                                       * Should lines be colored
+                                       * according to their
+                                       * refinement level?  This
+                                       * overrides
+                                       * color_lines_on_user_flag for
+                                       * all levels except level 0.
+                                       * Colors are: level 0: black,
+                                       * other levels: rainbow scale
+                                       * from blue to red.
+                                       */
+      bool color_lines_level;
+      
                                       /**
                                        * Constructor.
                                        */
@@ -234,7 +249,8 @@ namespace GridOutFlags
                    const unsigned int size       = 300,
                    const double       line_width = 0.5,
                    const bool color_lines_on_user_flag = false,
-                   const unsigned int n_boundary_face_points = 2);
+                   const unsigned int n_boundary_face_points = 2,
+                   const bool color_lines_level = false);
   };
   
   
@@ -331,7 +347,8 @@ namespace GridOutFlags
           const unsigned int n_boundary_face_points = 2,
           const bool         write_cell_numbers = false,
           const bool         write_cell_number_level = true,
-          const bool         write_vertex_numbers = false);
+          const bool         write_vertex_numbers = false,
+          const bool         color_lines_level = false);
   };
   
                                   /**
index 2f582657c4e9272af1ef53adc243f329116ad1a8..e801ba27e26d981e347c56b6fd75ebf0ed67193b 100644 (file)
@@ -51,12 +51,14 @@ namespace GridOutFlags
                              const unsigned int size,
                              const double       line_width,
                              const bool color_lines_on_user_flag,
-                             const unsigned int n_boundary_face_points) :
+                            const unsigned int n_boundary_face_points,
+                            const bool color_lines_level) :
                  size_type (size_type),
                  size (size),
                  line_width (line_width),
                  color_lines_on_user_flag(color_lines_on_user_flag),
-                 n_boundary_face_points(n_boundary_face_points)
+                n_boundary_face_points(n_boundary_face_points),
+                color_lines_level(color_lines_level)
   {}
   
 
@@ -81,11 +83,14 @@ namespace GridOutFlags
               const unsigned int n_boundary_face_points,
               const bool         write_cell_numbers,
               const bool         write_cell_number_level,
-              const bool         write_vertex_numbers)
+             const bool         write_vertex_numbers,
+             const bool         color_lines_level
+      )
                  :
                  EpsFlagsBase(size_type, size, line_width,
                               color_lines_on_user_flag,
-                              n_boundary_face_points),
+                             n_boundary_face_points,
+                             color_lines_level),
                  write_cell_numbers (write_cell_numbers),
                  write_cell_number_level (write_cell_number_level),
                  write_vertex_numbers (write_vertex_numbers)
index c87ead117b2f6d75bd65b40fb4c7b919eabf8d10..9c23fcb1adc799592ca383e183aac648d2b68e94 100644 (file)
@@ -697,9 +697,14 @@ struct LineEntry
     Point<2> first;
     Point<2> second;
     bool colorize;
-    LineEntry(const Point<2>& f, const Point<2>& s, const bool c)
+    unsigned int level;
+    LineEntry (const Point<2>    &f,
+              const Point<2>    &s,
+              const bool         c,
+              const unsigned int l)
                    :
-                   first(f), second(s), colorize(c)
+                   first(f), second(s),
+                   colorize(c), level(l)
       {}
 };
 
@@ -792,7 +797,8 @@ void GridOut::write_eps (const Triangulation<dim> &tria,
                                                    line->vertex(0)(1)),
                                           Point<2>(line->vertex(1)(0),
                                                    line->vertex(1)(1)),
-                                          line->user_flag_set()));
+                                          line->user_flag_set(),
+                                          line->level()));
        
                                         // next if we are to treat
                                         // curved boundaries
@@ -845,7 +851,8 @@ void GridOut::write_eps (const Triangulation<dim> &tria,
                          const Point<2>   p1     (p1_dim(0), p1_dim(1));
                          
                          line_list.push_back (LineEntry(p0, p1,
-                                                        face->user_flag_set()));
+                                                        face->user_flag_set(),
+                                                        face->level() ));
                          p0=p1;
                        }
 
@@ -853,7 +860,8 @@ void GridOut::write_eps (const Triangulation<dim> &tria,
                      const Point<dim> p1_dim (face->vertex(1));
                      const Point<2>   p1     (p1_dim(0), p1_dim(1));
                      line_list.push_back (LineEntry(p0, p1,
-                                                    face->user_flag_set()));
+                                                    face->user_flag_set(),
+                                                    face->level()));
                    };
                };
          };
@@ -919,7 +927,8 @@ void GridOut::write_eps (const Triangulation<dim> &tria,
                                                  line->vertex(0) * unit_vector1),
                                         Point<2>(line->vertex(1) * unit_vector2,
                                                  line->vertex(1) * unit_vector1),
-                                        line->user_flag_set()));
+                                        line->user_flag_set(),
+                                        line->level()));
 
        break;
       };
@@ -937,6 +946,7 @@ void GridOut::write_eps (const Triangulation<dim> &tria,
   double x_max = x_min;
   double y_min = tria.begin_active_line()->vertex(0)(1);
   double y_max = y_min;
+  unsigned int  max_level = line_list.begin()->level;
 
   for (LineList::const_iterator line=line_list.begin();
        line!=line_list.end(); ++line)
@@ -952,6 +962,8 @@ void GridOut::write_eps (const Triangulation<dim> &tria,
 
       y_max = std::max (y_max, line->first(1));
       y_max = std::max (y_max, line->second(1));
+      
+      max_level = std::max (max_level,  line->level);      
     };
 
                                   // scale in x-direction such that
@@ -1003,6 +1015,18 @@ void GridOut::write_eps (const Triangulation<dim> &tria,
          << "/b {0 0 0 setrgbcolor} def" << std::endl
          << "/r {1 0 0 setrgbcolor} def" << std::endl;
 
+                                      // calculate colors for level
+                                      // coloring; level 0 is black,
+                                      // other levels are blue
+                                      // ... red
+      double levelscale  = 0.66666/std::max(1U,(max_level-1));
+      
+      out  << "/l  { neg "
+          << (max_level)
+          << " add "
+          << levelscale
+          << " mul 1 0.8 sethsbcolor} def" << std::endl;
+
                                       // in 2d, we can also plot cell
                                       // and vertex numbers, but this
                                       // requires a somewhat more
@@ -1042,10 +1066,20 @@ void GridOut::write_eps (const Triangulation<dim> &tria,
   
   for (LineList::const_iterator line=line_list.begin();
        line!=line_list.end(); ++line)
-    out << ((line->colorize && eps_flags_base.color_lines_on_user_flag) ? "r " : "b ")
-       << (line->first  - offset) * scale << " m "
-       << (line->second - offset) * scale << " x" << std::endl;
-
+    if (eps_flags_base.color_lines_level && line-> level > 0)
+                                      // lines colored according to
+                                      // refinement level,
+                                      // contributed by Jörg
+                                      // R. Weimar
+      out << line->level
+         << " l "
+         << (line->first  - offset) * scale << " m "
+         << (line->second - offset) * scale << " x" << std::endl;
+    else
+      out << ((line->colorize && eps_flags_base.color_lines_on_user_flag) ? "r " : "b ")
+         << (line->first  - offset) * scale << " m "
+         << (line->second - offset) * scale << " x" << std::endl;
+    
                                   // finally write the cell numbers
                                   // in 2d, if that is desired
   if ((dim == 2) && (eps_flags_2.write_cell_numbers == true))

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.