From 1f576187a8217878e5db104b982c669d75ef129c Mon Sep 17 00:00:00 2001 From: wolf Date: Mon, 8 Sep 2003 15:55:59 +0000 Subject: [PATCH] Allow for colorized eps output. git-svn-id: https://svn.dealii.org/trunk@7964 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/grid/grid_out.h | 25 +++++++-- .../source/grid/grid_out.all_dimensions.cc | 13 +++-- deal.II/deal.II/source/grid/grid_out.cc | 54 +++++++++++++++---- 3 files changed, 74 insertions(+), 18 deletions(-) diff --git a/deal.II/deal.II/include/grid/grid_out.h b/deal.II/deal.II/include/grid/grid_out.h index ca3ef483bd..73ab28059e 100644 --- a/deal.II/deal.II/include/grid/grid_out.h +++ b/deal.II/deal.II/include/grid/grid_out.h @@ -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); }; /** diff --git a/deal.II/deal.II/source/grid/grid_out.all_dimensions.cc b/deal.II/deal.II/source/grid/grid_out.all_dimensions.cc index 2f582657c4..e801ba27e2 100644 --- a/deal.II/deal.II/source/grid/grid_out.all_dimensions.cc +++ b/deal.II/deal.II/source/grid/grid_out.all_dimensions.cc @@ -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) diff --git a/deal.II/deal.II/source/grid/grid_out.cc b/deal.II/deal.II/source/grid/grid_out.cc index c87ead117b..9c23fcb1ad 100644 --- a/deal.II/deal.II/source/grid/grid_out.cc +++ b/deal.II/deal.II/source/grid/grid_out.cc @@ -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 &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 &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 &tria, const Point 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 &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 &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 &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 &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 &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)) -- 2.39.5