From: wolf Date: Thu, 17 May 2001 20:23:12 +0000 (+0000) Subject: Move the flags classes out of GridOut and into a namespace of their own. This was... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=69322d78dc81dfec23b70aea3ef4de8a3337a7f9;p=dealii-svn.git Move the flags classes out of GridOut and into a namespace of their own. This was necessary since C++ does not allow us to explicitely specialize any of these classes, although the present use of this feature was accepted by gcc as an extension. We want to move to more closer C++ compliance, also in order to allow other compilers to translate the library. git-svn-id: https://svn.dealii.org/trunk@4663 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/grid/grid_out.h b/deal.II/deal.II/include/grid/grid_out.h index eb16309f63..d633784bd3 100644 --- a/deal.II/deal.II/include/grid/grid_out.h +++ b/deal.II/deal.II/include/grid/grid_out.h @@ -14,8 +14,6 @@ #define __deal2__grid_out_h -//TODO:[WB]Reorganize GridOut class. Either templatize GridOut or remove template from EpsFlags - #include #include @@ -23,6 +21,281 @@ template class Triangulation; template class Mapping; + +/** + * Within this namespace, we define several structures that are used + * to describe flags that can be given to grid output routines to + * modify the default outfit of the grids written into a file. See the + * different subclasses and the documentation of the @ref{GridOut} + * class for more details. + * + * @author Wolfgang Bangerth, 1998, 2001 + */ +namespace GridOutFlags +{ + /** + * Flags describing the details of + * output in UCD format. + */ + struct Ucd + { + /** + * Write a comment at the beginning + * of the file stating the date of + * creation and some other data. + * While this is supported by the + * UCD format (and the AVS program), + * some other programs get confused + * by this, so you can switch it off + * this way. + * + * Default: @p{true}. + */ + bool write_preamble; + + /** + * When writing a mesh, write boundary + * faces explicitely if their boundary + * indicator is not the default + * boundary indicator, which is zero. + * This is necessary if you later + * want to re-read the grid and want + * to get the same boundary indicators + * for the different parts of the + * boundary of the triangulation. + * + * It is not necessary if you only want + * to write the triangulation to + * view or print it. + * + * Default: @p{false}. + */ + bool write_faces; + + /** + * Constructor. + */ + Ucd (const bool write_preamble = true, + const bool write_faces = false); + }; + + + /** + * Flags describing the details of + * output in GNUPLOT format. + */ + struct Gnuplot + { + /** + * Write the number of each cell into + * the output file before starting + * with the lines it is composed of, + * as a comment. This might be useful + * if you want to find out details + * about the grid, for example the + * position of cells of which you + * know the number. It enlarges + * the size of the output + * significantly, however. + * + * Default: @p{false}. + */ + bool write_cell_numbers; + + /** + * This is the number of + * points on a boundary face, + * that are ploted + * additionally to the + * vertices of the face. + */ + unsigned int n_boundary_face_points; + + /** + * Constructor. + */ + Gnuplot (const bool write_cell_number = false, + const unsigned int n_boundary_face_points = 2); + }; + + /** + * Flags describing the details of + * output for encapsulated postscript. + * In this structure, the flags common + * to all dimensions are listed. Flags + * which are specific to one space + * dimension only are listed in derived + * classes. + * + * By default, the size of the picture + * is scaled such that the width equals + * 300 units. + */ + struct EpsFlagsBase + { + /** + * Enum denoting the possibilities + * whether the scaling should be done + * such that the given @p{size} equals + * the width or the height of + * the resulting picture. + */ + enum SizeType { + width, height + }; + + /** + * See above. Default is @p{width}. + */ + SizeType size_type; + + /** + * Width or height of the output + * as given in postscript units + * This usually is given by the + * strange unit 1/72 inch. Whether + * this is height or width is + * specified by the flag + * @p{size_type}. + * + * Default is 300. + */ + unsigned int size; + + /** + * Width of a line in postscript + * units. Default is 0.5. + */ + double line_width; + /** + * Should lines with a set @p{user_flag} + * be drawn in a different color? + */ + bool color_lines_on_user_flag; + + /** + * This is the number of + * points on a boundary face, + * that are ploted + * additionally to the + * vertices of the face. + * + * This is used if the + * mapping used is not the + * standard @p{MappingQ1} + * mapping. + */ + unsigned int n_boundary_face_points; + + /** + * Constructor. + */ + EpsFlagsBase (const SizeType size_type = width, + 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); + }; + + + /** + * Flags describing the details of + * output for encapsulated postscript + * for all dimensions not explicitely + * specialized below. Some flags that + * are common to all dimensions are + * listed in the base class. + * + * This class does not actually + * exist, we only here declare the + * general template and declare + * explicit specializations below. + */ + template + struct Eps + {}; + + /** + * Flags specific to the output of + * grids in one space dimensions. + */ + template <> + struct Eps<1> : public EpsFlagsBase + { + /** + * Constructor. + */ + Eps (const SizeType size_type = width, + 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); + }; + + + /** + * Flags specific to the output of + * grids in two space dimensions. + */ + template <> + struct Eps<2> : public EpsFlagsBase + { + /** + * Constructor. + */ + Eps (const SizeType size_type = width, + 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); + }; + + /** + * Flags specific to the output of + * grids in three space dimensions. + */ + template <> + struct Eps<3> : public EpsFlagsBase + { + /** + * Angle of the line origin-viewer + * against the z-axis in degrees. + * + * Default is the Gnuplot-default + * of 60. + */ + double azimut_angle; + + /** + * Angle by which the viewers + * position projected onto the + * x-y-plane is rotated around + * the z-axis, in positive sense + * when viewed from above. The + * unit are degrees, and zero + * equals a position above or below + * the negative y-axis. + * + * Default is the Gnuplot-default + * of 30. + */ + double turn_angle; + + /** + * Constructor. + */ + Eps (const SizeType size_type = width, + 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 double azimut_angle = 60, + const double turn_angle = 30); + }; +}; + + + /** * This class provides a means to output a triangulation to a file in different * formats. Presently provided are functions to write it in GNUPLOT and @@ -70,13 +343,14 @@ template class Mapping; * output format supported which it may then pass on to the respective output * function. * - * Rather, we have chosen to let each object of this class @ref{GridOut} have a - * set of parameters for each supported output format. These are collected - * in structures @ref{EpsFlags}, @ref{GnuplotFlags}, etc and you can set your preferred - * flags like this: + * Rather, we have chosen to let each object of this class + * @ref{GridOut} have a set of parameters for each supported output + * format. These are collected in structures @ref{GridOutFlags::Eps}, + * @ref{GridOutFlags::Gnuplot}, etc declared in the @ref{GridOutFlags} + * namespace, and you can set your preferred flags like this: * @begin{verbatim} * GridOut grid_out; - * GridOut::UcdFlags ucd_flags; + * GridOutFlags::Ucd ucd_flags; * ... // set some fields in ucd_flags * grid_out.set_flags (ucd_flags); * ... @@ -85,7 +359,7 @@ template class Mapping; * The respective output function then use the so-set flags. By default, they * are set to reasonable values as described above and in the documentation * of the different flags structures. Resetting the flags can - * be done by calling @p{grid_out.set_flags (GridOut::UcdFlags());}, since the + * be done by calling @p{grid_out.set_flags (GridOutFlags::Ucd());}, since the * default constructor of each of the flags structures sets the parameters * to their initial values. * @@ -107,272 +381,6 @@ template class Mapping; class GridOut { public: - - /** - * Flags describing the details of - * output in UCD format. - */ - struct UcdFlags - { - /** - * Write a comment at the beginning - * of the file stating the date of - * creation and some other data. - * While this is supported by the - * UCD format (and the AVS program), - * some other programs get confused - * by this, so you can switch it off - * this way. - * - * Default: @p{true}. - */ - bool write_preamble; - - /** - * When writing a mesh, write boundary - * faces explicitely if their boundary - * indicator is not the default - * boundary indicator, which is zero. - * This is necessary if you later - * want to re-read the grid and want - * to get the same boundary indicators - * for the different parts of the - * boundary of the triangulation. - * - * It is not necessary if you only want - * to write the triangulation to - * view or print it. - * - * Default: @p{false}. - */ - bool write_faces; - - /** - * Constructor. - */ - UcdFlags (const bool write_preamble = true, - const bool write_faces = false); - }; - - - /** - * Flags describing the details of - * output in GNUPLOT format. - */ - struct GnuplotFlags - { - /** - * Write the number of each cell into - * the output file before starting - * with the lines it is composed of, - * as a comment. This might be useful - * if you want to find out details - * about the grid, for example the - * position of cells of which you - * know the number. It enlarges - * the size of the output - * significantly, however. - * - * Default: @p{false}. - */ - bool write_cell_numbers; - - /** - * This is the number of - * points on a boundary face, - * that are ploted - * additionally to the - * vertices of the face. - */ - unsigned int n_boundary_face_points; - - /** - * Constructor. - */ - GnuplotFlags (const bool write_cell_number = false, - const unsigned int n_boundary_face_points = 2); - }; - - /** - * Flags describing the details of - * output for encapsulated postscript. - * In this structure, the flags common - * to all dimensions are listed. Flags - * which are specific to one space - * dimension only are listed in derived - * classes. - * - * By default, the size of the picture - * is scaled such that the width equals - * 300 units. - */ - struct EpsFlagsBase - { - /** - * Enum denoting the possibilities - * whether the scaling should be done - * such that the given @p{size} equals - * the width or the height of - * the resulting picture. - */ - enum SizeType { - width, height - }; - - /** - * See above. Default is @p{width}. - */ - SizeType size_type; - - /** - * Width or height of the output - * as given in postscript units - * This usually is given by the - * strange unit 1/72 inch. Whether - * this is height or width is - * specified by the flag - * @p{size_type}. - * - * Default is 300. - */ - unsigned int size; - - /** - * Width of a line in postscript - * units. Default is 0.5. - */ - double line_width; - /** - * Should lines with a set @p{user_flag} - * be drawn in a different color? - */ - bool color_lines_on_user_flag; - - /** - * This is the number of - * points on a boundary face, - * that are ploted - * additionally to the - * vertices of the face. - * - * This is used if the - * mapping used is not the - * standard @p{MappingQ1} - * mapping. - */ - unsigned int n_boundary_face_points; - - /** - * Constructor. - */ - EpsFlagsBase (const SizeType size_type = width, - 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); - }; - - - /** - * Flags describing the details of - * output for encapsulated postscript - * for all dimensions not explicitely - * specialized below. Some flags that - * are common to all dimensions are - * listed in the base class - */ - template - struct EpsFlags; -// : public EpsFlagsBase -// { - -// /** -// * Constructor. -// */ -// EpsFlags (const SizeType size_type = width, -// const unsigned int size = 300, -// const double line_width = 0.5, -// bool color_lines_on_user_flag = false, -// const unsigned int n_boundary_face_points = 2); -// }; - -// //#if (__GNUC__==2) && (__GNUC_MINOR__ < 95) -// // template <> - - struct EpsFlags<1> : public EpsFlagsBase - { - - /** - * Constructor. - */ - EpsFlags (const SizeType size_type = width, - const unsigned int size = 300, - const double line_width = 0.5, - bool color_lines_on_user_flag = false, - const unsigned int n_boundary_face_points = 2); - }; - - - struct EpsFlags<2> : public EpsFlagsBase - { - - /** - * Constructor. - */ - EpsFlags (const SizeType size_type = width, - const unsigned int size = 300, - const double line_width = 0.5, - bool color_lines_on_user_flag = false, - const unsigned int n_boundary_face_points = 2); - }; - /** - * Flags specific to the output of - * grids in three space dimensions. - */ - struct EpsFlags<3> : public EpsFlagsBase - { - /** - * Angle of the line origin-viewer - * against the z-axis in degrees. - * - * Default is the Gnuplot-default - * of 60. - */ - double azimut_angle; - - /** - * Angle by which the viewers - * position projected onto the - * x-y-plane is rotated around - * the z-axis, in positive sense - * when viewed from above. The - * unit are degrees, and zero - * equals a position above or below - * the negative y-axis. - * - * Default is the Gnuplot-default - * of 30. - */ - double turn_angle; - - /** - * Constructor. - */ - EpsFlags (const SizeType size_type = width, - 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 double azimut_angle = 60, - const double turn_angle = 30); - }; - - -//#else -//# warning Not implemented for gcc2.95 -//#endif - - /** * Declaration of a name for each of the * different output formats. @@ -436,7 +444,7 @@ class GridOut * flags controlling the output * can be found in the * documentation of the - * @ref{GridOut::GnuplotFlags} class. + * @ref{GridOutFlags::Gnuplot} class. */ template void write_gnuplot (const Triangulation &tria, @@ -456,7 +464,7 @@ class GridOut * only, you can decide through * additional flags (see below, * and the documentation of the - * @ref{GridOut::UcdFlags} class) + * @ref{GridOutFlags::Ucd} class) * whether boundary faces with * non-zero boundary indicator * shall be written to the file @@ -476,7 +484,7 @@ class GridOut * flags controlling the output * can be found in the * documentation of the - * @ref{GridOut::UcdFlags} class. + * @ref{GridOut::Ucd} class. */ template void write_ucd (const Triangulation &tria, @@ -499,7 +507,7 @@ class GridOut * shall fit into is determined * by the output flags (see * below, and the documentation - * of the @ref{GridOut::EpsFlags} + * of the @ref{GridOutFlags::Eps} * class). * * The bounding box is close to @@ -532,7 +540,7 @@ class GridOut * flags controlling the output * can be found in the * documentation of the - * @ref{GridOut::EpsFlags} + * @ref{GridOutFlags::Eps} * class. Especially the * viewpoint for three * dimensional grids is of @@ -559,31 +567,31 @@ class GridOut * Set the flags to be used for output * in UCD format. */ - void set_flags (const UcdFlags &ucd_flags); + void set_flags (const GridOutFlags::Ucd &ucd_flags); /** * Set the flags to be used for output * in GNUPLOT format. */ - void set_flags (const GnuplotFlags &gnuplot_flags); + void set_flags (const GridOutFlags::Gnuplot &gnuplot_flags); /** * Set the flags to be used for output * in 1d EPS output. */ - void set_flags (const EpsFlags<1> &eps_flags); + void set_flags (const GridOutFlags::Eps<1> &eps_flags); /** * Set the flags to be used for output * in 2d EPS output. */ - void set_flags (const EpsFlags<2> &eps_flags); + void set_flags (const GridOutFlags::Eps<2> &eps_flags); /** * Set the flags to be used for output * in 3d EPS output. */ - void set_flags (const EpsFlags<3> &eps_flags); + void set_flags (const GridOutFlags::Eps<3> &eps_flags); /** * Provide a function which tells us which @@ -653,14 +661,14 @@ class GridOut * data. Can be changed by using the * @p{set_flags} function. */ - UcdFlags ucd_flags; + GridOutFlags::Ucd ucd_flags; /** * Flags to be used upon output of GNUPLOT * data. Can be changed by using the * @p{set_flags} function. */ - GnuplotFlags gnuplot_flags; + GridOutFlags::Gnuplot gnuplot_flags; /** * Flags to be used upon output of EPS @@ -668,7 +676,7 @@ class GridOut * changed by using the @p{set_flags} * function. */ - EpsFlags<1> eps_flags_1; + GridOutFlags::Eps<1> eps_flags_1; /** * Flags to be used upon output of EPS @@ -676,7 +684,7 @@ class GridOut * changed by using the @p{set_flags} * function. */ - EpsFlags<2> eps_flags_2; + GridOutFlags::Eps<2> eps_flags_2; /** * Flags to be used upon output of EPS @@ -684,7 +692,7 @@ class GridOut * changed by using the @p{set_flags} * function. */ - EpsFlags<3> eps_flags_3; + GridOutFlags::Eps<3> eps_flags_3; /** 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 7ab0371416..3ac37f64c9 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 @@ -15,102 +15,119 @@ #include -GridOut::UcdFlags::UcdFlags (const bool write_preamble, - const bool write_faces) : - write_preamble (write_preamble), - write_faces (write_faces) -{} - - -GridOut::GnuplotFlags::GnuplotFlags (const bool write_cell_numbers, - const unsigned int n_boundary_face_points) : - write_cell_numbers (write_cell_numbers), - n_boundary_face_points(n_boundary_face_points) -{} - - -GridOut::EpsFlagsBase::EpsFlagsBase (const SizeType size_type, - const unsigned int size, - const double line_width, - const bool color_lines_on_user_flag, - const unsigned int n_boundary_face_points) : - 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) -{} - - - -GridOut::EpsFlags<1>::EpsFlags (const SizeType size_type, - const unsigned int size, - const double line_width, - const bool color_lines_on_user_flag, - const unsigned int n_boundary_face_points): - EpsFlagsBase(size_type, size, line_width, - color_lines_on_user_flag, - n_boundary_face_points) -{} - - -GridOut::EpsFlags<2>::EpsFlags (const SizeType size_type, - const unsigned int size, - const double line_width, - const bool color_lines_on_user_flag, - const unsigned int n_boundary_face_points): - EpsFlagsBase(size_type, size, line_width, - color_lines_on_user_flag, - n_boundary_face_points) -{} - - -GridOut::EpsFlags<3>::EpsFlags (const SizeType size_type, - const unsigned int size, - const double line_width, - const bool color_lines_on_user_flag, - const unsigned int n_boundary_face_points, - const double azimut_angle, - const double turn_angle): - EpsFlagsBase(size_type, size, line_width, - color_lines_on_user_flag, - n_boundary_face_points), - azimut_angle (azimut_angle), - turn_angle (turn_angle) -{} - - -void GridOut::set_flags (const UcdFlags &flags) +namespace GridOutFlags +{ + Ucd::Ucd (const bool write_preamble, + const bool write_faces) : + write_preamble (write_preamble), + write_faces (write_faces) + {}; + + + + Gnuplot::Gnuplot (const bool write_cell_numbers, + const unsigned int n_boundary_face_points) : + write_cell_numbers (write_cell_numbers), + n_boundary_face_points(n_boundary_face_points) + {}; + + + + EpsFlagsBase::EpsFlagsBase (const SizeType size_type, + const unsigned int size, + const double line_width, + const bool color_lines_on_user_flag, + const unsigned int n_boundary_face_points) : + 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) + {}; + + + + Eps<1>::Eps (const SizeType size_type, + const unsigned int size, + const double line_width, + const bool color_lines_on_user_flag, + const unsigned int n_boundary_face_points) + : + EpsFlagsBase(size_type, size, line_width, + color_lines_on_user_flag, + n_boundary_face_points) + {}; + + + + Eps<2>::Eps (const SizeType size_type, + const unsigned int size, + const double line_width, + const bool color_lines_on_user_flag, + const unsigned int n_boundary_face_points) + : + EpsFlagsBase(size_type, size, line_width, + color_lines_on_user_flag, + n_boundary_face_points) + {}; + + + + Eps<3>::Eps (const SizeType size_type, + const unsigned int size, + const double line_width, + const bool color_lines_on_user_flag, + const unsigned int n_boundary_face_points, + const double azimut_angle, + const double turn_angle) + : + EpsFlagsBase(size_type, size, line_width, + color_lines_on_user_flag, + n_boundary_face_points), + azimut_angle (azimut_angle), + turn_angle (turn_angle) + {}; +}; // end namespace GridOutFlags + + + +void GridOut::set_flags (const GridOutFlags::Ucd &flags) { ucd_flags = flags; }; -void GridOut::set_flags (const GnuplotFlags &flags) + +void GridOut::set_flags (const GridOutFlags::Gnuplot &flags) { gnuplot_flags = flags; }; -void GridOut::set_flags (const EpsFlags<1> &flags) + +void GridOut::set_flags (const GridOutFlags::Eps<1> &flags) { eps_flags_1 = flags; }; -void GridOut::set_flags (const EpsFlags<2> &flags) + +void GridOut::set_flags (const GridOutFlags::Eps<2> &flags) { eps_flags_2 = flags; }; -void GridOut::set_flags (const EpsFlags<3> &flags) + +void GridOut::set_flags (const GridOutFlags::Eps<3> &flags) { eps_flags_3 = flags; }; -std::string GridOut::default_suffix (const OutputFormat output_format) + +std::string +GridOut::default_suffix (const OutputFormat output_format) { switch (output_format) { @@ -130,6 +147,7 @@ std::string GridOut::default_suffix (const OutputFormat output_format) }; + GridOut::OutputFormat GridOut::parse_output_format (const std::string &format_name) { @@ -148,12 +166,14 @@ GridOut::parse_output_format (const std::string &format_name) }; + std::string GridOut::get_output_format_names () { return "gnuplot|eps|ucd"; }; + unsigned int GridOut::memory_consumption () const { diff --git a/deal.II/deal.II/source/grid/grid_out.cc b/deal.II/deal.II/source/grid/grid_out.cc index 526673fb67..432ef4f5ca 100644 --- a/deal.II/deal.II/source/grid/grid_out.cc +++ b/deal.II/deal.II/source/grid/grid_out.cc @@ -522,11 +522,12 @@ void GridOut::write_eps (const Triangulation &tria, // in order to avoid the recurring // distinctions between // eps_flags_1, eps_flags_2, ... - const EpsFlagsBase &eps_flags_base = (dim==2 ? - static_cast(eps_flags_2) : - (dim==3 ? - static_cast(eps_flags_3) : - *static_cast(0))); + const GridOutFlags::EpsFlagsBase + &eps_flags_base = (dim==2 ? + static_cast(eps_flags_2) : + (dim==3 ? + static_cast(eps_flags_3) : + *static_cast(0))); AssertThrow (out, ExcIO()); const unsigned int n_points = eps_flags_base.n_boundary_face_points; @@ -753,7 +754,7 @@ void GridOut::write_eps (const Triangulation &tria, // preserve the shape of the // triangulation const double scale = (eps_flags_base.size / - (eps_flags_base.size_type==EpsFlagsBase::width ? + (eps_flags_base.size_type==GridOutFlags::EpsFlagsBase::width ? x_max - x_min : y_min - y_max)); @@ -860,4 +861,4 @@ template void GridOut::write_eps (const Triangulation &, template void GridOut::write (const Triangulation &, std::ostream &, const OutputFormat, - const Mapping *); + const Mapping *); diff --git a/deal.II/doc/news/2001/c-3-1.html b/deal.II/doc/news/2001/c-3-1.html index f0b001a0d0..07e1f8eb37 100644 --- a/deal.II/doc/news/2001/c-3-1.html +++ b/deal.II/doc/news/2001/c-3-1.html @@ -408,6 +408,20 @@ documentation, etc.

deal.II

    +
  1. + Changed: the flags which are given to the GridOut class to modify the appearance of + the output have been moved from local classes of the GridOut class to a namespace names + GridOutFlags and have lost the + trailing Flags part in their name. + This change was necessary as C++ does not allow explicit + specialization of member classes; the previous use in the + library was only accepted by GCC as an extension. +
    + (WB 2001/05/17) +

    +
  2. New: The functions DoFTools::map_dof_to_boundary_indices,