]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Changed eps-default behavior
authornauber <nauber@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 11 Jun 1999 07:08:40 +0000 (07:08 +0000)
committernauber <nauber@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 11 Jun 1999 07:08:40 +0000 (07:08 +0000)
git-svn-id: https://svn.dealii.org/trunk@1398 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/numerics/data_io.h
deal.II/deal.II/source/numerics/data_io.cc

index bd032e5815efa4edeabf49d4171a41c0eac43df0..f8aeb411168da1e3156cf7693ac34a51851afe0b 100644 (file)
@@ -190,7 +190,8 @@ class DataIn {
  * in several formats.
  * At present it supports output in UCD (unstructured cell data) and
  * GNUPLOT format. Partly supported are POVRAY and encapsulated postscript.
- * The latter two allow for only one data set and do not support cell data.
+ * POVRAY allows for only one data set and does not support cell data.
+ * Encapsulated Postscript supports Q1-Elements only.
  *
  * It allows the user to attach a degree of freedom handler object
  * (#DoFHandler#) which also gives access to the geometry data of the
@@ -299,6 +300,7 @@ class DataIn {
  * support bilinear quadrilaterals and using polygons as vastly suboptimal in
  * term of memory and speed to the triangle mesh supported by POVRAY.
  *
+ *
  * \subsection{Encapsulated Postscript format}
  *
  * There are two functions for generating encapsulated Postscript
@@ -308,42 +310,60 @@ class DataIn {
  * and #EpsOutputData# now. 
  * #write_eps# can use one data vector for height information and one
  * cell vector for shading information. Control is done through an
- * object of class #EpsOutputData# as follows.
+ * object of class #EpsOutputData# as follows or by default.
  *
  * Vectors are added as usual by #add_data_vector#. Then one has to
  * decide, wether to produce a 2D or 3D plot. This is done by setting
- * #height_type# to 
- * \begin{description}
- *   \item[None] for 2D-Output (or Top-View thats the same by no
+ * #height_info# to 
+ * \begin{description} 
+ *   \item[NoHeight] for 2D-Output (or Top-View thats the same by no
  *     turning is done) or to
- *   \item[Vector] for 3D-Output.
+ *   \item[HeightVector] for 3D-Output. You have to attach a
+ *     dof_data_vector to actually get 3D. If you don't then output
+ *     will be generated in 2D.
+ *   \item[DefaultHeight] is 3D if there is a dof_data_vector and 2D if
+ *     none is present.
  * \end{description}
  * For 3D-Output one has to set #azimuth# and #elevation# for the
  * angle of view and #height_vector# to the number of the #dof_data#
- * vector that provides the height information to be used.
+ * vector that provides the height information to be used. The default
+ * values are analogous to GNUPlot for azimuth and elevation and
+ * vector 0 for the height vector.
  *
- * The cells can be shaded in three different modes, controlled by the
- * attribute #cell_type#:
+ * The cells can be shaded in four different modes, controlled by the
+ * attribute #cell_shading#:
  * \begin{description}
- *   \item[None] provides transparent shading.
- *   \item[Vector] uses a cell vector to do shading. The number of the
- *     cell vector to be uses is provided in #cell_vector#. To scale
- *     the cell vector there is the method #color#. It is called with
- *     the actual value of the cell, the maximum and the minimum value
- *     of a cell in the cell vector. It returns three values for red,
- *     green and blue.
- *   \item[Shaded] just shades the plot. This is controlled by the
- *     vector #light# which stores the direction of the light beams.
+ *   \item[NoShading] provides transparent shading.
+ *   \item[ShadingVector] uses a cell vector to do shading. The number
+ *     of the cell vector to be uses is provided in #cell_vector#. To
+ *     scale the cell vector there is the method #color#. It is called
+ *     with the actual value of the cell, the maximum and the minimum
+ *     value of a cell in the cell vector. It returns three values for
+ *     red, green and blue. If there no cell_data vector than there is
+ *     transparent shading.
+ *   \item[LightShaded] just shades the plot. This is controlled by
+ *     the vector #light# which stores the direction of the light 
+ *     beams. This is done only if there is height information.
+ *   \item[DefaultShading] is controlled by presence of different
+ *     vectors. If there no height information then do no
+ *     shading. Otherwise if there is cell_data use this for shading.
+ *     Otherwise do light shading.
  * \end{description}
  *
  * Finnaly one can choose to mark the cell boundaries by setting
- * #cell_boundary_type#. It can take one of three values:
+ * #cell_boundary_shading#. It can take one of four values:
  * \begin{enumerate}
- *   \item None: for no cell boundaries,
- *   \item Black: for black cell boundaries, and
- *   \item White: for white cell boundaries.
+ *   \item NoBoundary for no cell boundaries,
+ *   \item DefaultBoundary or
+ *   \item BlackBoundary for black cell boundaries,
+ *   \item WhiteBoundary for white cell boundaries, 
  * \end{enumerate}
  *
+ * Another interesting feature is that you can write multiple
+ * eps-pictures to one file by just doing several invocations of
+ * #write_eps#. One than can switch between the different graphics
+ * with the #>># Button in GhostView for example.
+ *
  * @author Wolfgang Bangerth, Guido Kanschat, Stefan Nauber, 1998, 1999
  */
 template <int dim>  
@@ -731,64 +751,125 @@ class DataOut {
 
 
 
+
 /**
  * Structure for the control of encapsulated postscript output. See
  * general documentation of class #DataOut# for description.
+ *
+ * @author Stefan Nauber
  */
 class EpsOutputData{
   public:
-                                    /** 
-                                     * Different types of
-                                     * colorization
+                                    /**
+                                     * Types of height info
                                      */
-    typedef enum {None,Vector,Shaded,Black,White} ColorType;
+    enum HeightInfo {
+         DefaultHeight, NoHeight, HeightVector
+    };
     
                                     /**
-                                     * Type of height information 
+                                     * Types of cell shading
+                                     */
+    enum CellShading {
+         DefaultShading, NoShading, ShadingVector, LightShaded
+    };
+
+                                    /**
+                                     * Types of cell boundary shading
                                      */
-    ColorType height_type;
+    enum CellBoundaryShading {
+         DefaultBoundary, NoBoundary, BlackBoundary, WhiteBoundary
+    };
+
                                     /**
-                                     * Cell shading
+                                     * Where height information comes from
+                                     */
+    HeightInfo height_info;
+
+                                    /** 
+                                     * If and how cells are shaded
                                      */
-    ColorType cell_type;
+    CellShading cell_shading;
+
                                     /**
-                                     * Boundary color
+                                     * Color selection when shading cell
+                                     * boundaries.
                                      */
-    ColorType cell_boundary_type;
+    CellBoundaryShading cell_boundary_shading;
 
                                     /**
-                                     * Vector with height information
+                                     * Number of the vector which is to be
+                                     * used for the height information, within
+                                     * the list of DoF data vectors.
                                      */
     unsigned height_vector;
+
                                     /**
-                                     * Vector with cell shading values
+                                     * Number of the vector which is to be
+                                     * used for the cell shading values, within
+                                     * the list of cell data vectors.
                                      */
     unsigned cell_vector;
+    
                                      /**
-                                     * View angle
+                                     * Azimuth of the spectators position.
+                                     * This defines the position on the
+                                     * x-y-plane and is an angle of rotation
+                                     * around the z-axis. We define that
+                                     * if the azimuth angle is zero, this
+                                     * means that the observer is sitting on
+                                     * (or above or below) the positive y-axis
+                                     * and looks back to the origin (direction
+                                     * of view is always towards the origin).
+                                     * Positive angles denote rotation in
+                                     * clockwise sense (as viewed from the top),
+                                     * i.e. 90 degrees would be sitting on the
+                                     * positive x-axis, etc.
+                                     *
+                                     * Please note that the angle has to be
+                                     * given in radians rather than in degrees.
                                      */
     float azimuth;
 
                                      /**
-                                     * View angle
+                                     * Elevation of the spectators position.
+                                     * This is the angle that the line between
+                                     * the origin and the spectators position
+                                     * forms with the x-y-plane, measured
+                                     * upwards in direction towards the
+                                     * positive z-axis. 
+                                     *
+                                     * Please note that the angle has to be
+                                     * given in radians rather than in degrees.
                                      */
     float elevation;
 
                                     /**
-                                     * Direction of Light
+                                     * Direction of the light beams. 
                                      */
     double light[3];
     
                                     /**
-                                     * Default constructor
+                                     * Default constructor. Sets height and
+                                     * shading flags to their default values,
+                                     * azimut and elevation to 0.2 each, and
+                                     * puts the light source at #(-1,-1,0)#.
                                      */
     EpsOutputData();
 
                                     /**
-                                     * Color scaling
+                                     * Function returning a color value in
+                                     * rgb variables corresponding to the
+                                     * given value #x#. #x# is considered
+                                     * to be a values within the range
+                                     * #xmin...xmax#.
                                      */
-    void color(const float x, const float xmax, const float xmin, 
-              float &r, float &g, float &b) const;
+    void color (const float x,
+               const float xmax,
+               const float xmin, 
+               float      &r,
+               float      &g,
+               float      &b) const;
 };
 
 
index fb7d5a2b96989eef67840bcda5670623d6523bbb..b471f47e5557bcb2b940f562b954252d799b2641 100644 (file)
@@ -1048,7 +1048,7 @@ void DataOut<2>::write_epsgrid (ostream &out) const {
       time_t  time1= time (0);
       tm     *time = localtime(&time1); 
       out << "%!PS-Adobe-2.0 EPSF-1.2" << endl
-         << "%%Title: Deal Output" << endl
+         << "%%Title: deal.II Output" << endl
          << "%%Creator: the deal.II library" << endl
          << "%%Creation Date: " 
          << time->tm_year+1900 << "/"
@@ -1118,7 +1118,7 @@ void DataOut<2>::write_eps (ostream &out, const EpsOutputData &eod) const {
     time_t  time1= time (0);
     tm     *time = localtime(&time1); 
     out << "%!PS-Adobe-2.0 EPSF-1.2" << endl
-       << "%%Title: Deal Output" << endl
+       << "%%Title: deal.II Output" << endl
        << "%%Creator: the deal.II library" << endl
        << "%%Creation Date: " 
        << time->tm_year+1900 << "/"
@@ -1138,7 +1138,45 @@ void DataOut<2>::write_eps (ostream &out, const EpsOutputData &eod) const {
    multiset<DataOut<2>::EpsCellData> cells;
    multiset<DataOut<2>::EpsCellData> cells2;
    
-   bool cell_data_p = ((cell_data.size())>0) && (eod.cell_type == EpsOutputData::Vector);
+   bool height_data_p = (
+                          ((dof_data.size())>0) 
+                         && 
+                         (
+                           ( eod.height_info == EpsOutputData::DefaultHeight)
+                           || 
+                           ( eod.height_info == EpsOutputData::HeightVector)
+                         )
+                       );
+
+                                   // Cells are colored, if there is
+                                   // cell data and the mode is
+                                   // ShadingVector or DefaultShading
+   bool cell_data_p = (
+     ((cell_data.size())>0) 
+     && 
+     (
+       (eod.cell_shading == EpsOutputData::ShadingVector)
+       ||
+       (eod.cell_shading == EpsOutputData::DefaultShading)
+     )
+   );
+
+                                   // Cells are shaded, i.e. light
+                                   // shading, if they are not
+                                   // colored,  there is height
+                                   // information and the mode is
+                                   // Default or Light
+   bool cell_shade_p = (
+     (!cell_data_p)
+     &&
+     (height_data_p)
+     &&
+     (
+       (eod.cell_shading == EpsOutputData::DefaultShading)
+       ||
+       (eod.cell_shading == EpsOutputData::LightShaded)
+     )
+   );
 
    unsigned cell_index;
    DoFHandler<2>::active_cell_iterator cell;
@@ -1147,24 +1185,15 @@ void DataOut<2>::write_eps (ostream &out, const EpsOutputData &eod) const {
        ++cell, ++cell_index)
      {
        EpsCellData cd;
-       for (unsigned int i=0; i<4; ++i)
+       for (unsigned int i=0; i<GeometryInfo<2>::vertices_per_cell; ++i)
         {
           (cd.vertices[i]).x=cell->vertex(i)(0);
           (cd.vertices[i]).y=cell->vertex(i)(1);
-          switch (eod.height_type)
-            {
-              case EpsOutputData::Vector:
-                    (cd.vertices[i]).z=(*dof_data[eod.height_vector].data)(cell->vertex_dof_index(i,0)); 
-                    break;
-              case EpsOutputData::None:
-                    (cd.vertices[i]).z=0;
-                    break;
-              default:
-                    break;
-            };
-              
+          (cd.vertices[i]).z=(height_data_p ? 
+                              (*dof_data[eod.height_vector].data)(cell->vertex_dof_index(i,0))
+                              : 0); 
         };
-       if (eod.height_type==EpsOutputData::Vector)
+       if (height_data_p)
         cd.turn(eod.azimuth,eod.elevation);
 
        if (cell_data_p)
@@ -1210,7 +1239,7 @@ void DataOut<2>::write_eps (ostream &out, const EpsOutputData &eod) const {
 
                                    // If we want shaded output we can
                                    // do the shading now.
-   if (eod.cell_type==EpsOutputData::Shaded)
+   if (cell_shade_p)
      {
        double spann1[3], spann2[3], normal[3];
        double light_norm, normal_norm;
@@ -1290,12 +1319,10 @@ void DataOut<2>::write_eps (ostream &out, const EpsOutputData &eod) const {
 
 
                                    //  Now we are ready to output...
-   cell_data_p = cell_data_p || (eod.cell_type==EpsOutputData::Shaded);
-
    for (typename multiset<DataOut<2>::EpsCellData>::iterator c=cells.begin();
        c!=cells.end(); ++c)
      {
-       if (cell_data_p)
+       if (cell_data_p || cell_shade_p)
         {
           out << c->red << " " << c->green << " " << c->blue << " setrgbcolor "
               << c->vertices[0].x << " " << c->vertices[0].y << " moveto "
@@ -1305,18 +1332,18 @@ void DataOut<2>::write_eps (ostream &out, const EpsOutputData &eod) const {
               << " closepath fill" << endl;
         };
 
-       if (eod.cell_boundary_type == EpsOutputData::Black || 
-          eod.cell_boundary_type == EpsOutputData::White) 
+       if (eod.cell_boundary_shading != EpsOutputData::NoBoundary)
         {
-          switch (eod.cell_boundary_type)
+          switch (eod.cell_boundary_shading)
             {
-              case EpsOutputData::Black: 
+              case EpsOutputData::BlackBoundary:
+              case EpsOutputData::DefaultBoundary:
                     out << "0";
                     break;
-              case EpsOutputData::White:
+              case EpsOutputData::WhiteBoundary:
                     out << "1";
                     break;
-              default:
+              case EpsOutputData::NoBoundary:
                     break;
             };
           out << " setgray " 
@@ -1501,19 +1528,28 @@ void DataOut<dim>::EpsCellData::turn(double azi, double ele)
 
 
 EpsOutputData::EpsOutputData()
-               : height_type(None),
-                 cell_type(None),
-                 cell_boundary_type (Black),
+               : height_info(DefaultHeight),
+                 cell_shading(DefaultShading),
+                 cell_boundary_shading (DefaultBoundary),
                   height_vector(0),
                  cell_vector(0),
-                 azimuth(0.2),
-                 elevation(0.2)
+                 azimuth(2*3.1415926* (180 - 30)/360),
+                 elevation(2*3.1415926* (90-60)/360)
 { 
   light[0]=-1;
   light[1]=-1;
   light[2]=1;
 };
 
+
+
+void EpsOutputData::color(const float x,
+                         const float xmax,
+                         const float xmin, 
+                         float &r,
+                         float &g,
+                         float &b) const
+{
 // A difficult color scale:
 //     xmin          = black  (1)
 // 3/4*xmin+1/4*xmax = blue   (2)
@@ -1541,9 +1577,6 @@ EpsOutputData::EpsOutputData()
 //     { 0                                (3) - (4)
 //     { ( 4*x-  xmin-3*xmax)/(xmax-xmin) (4) - (5)
 
-void EpsOutputData::color(const float x, const float xmax, const float xmin, 
-                           float &r, float &g, float &b) const
-{
   float sum   =   xmax+  xmin;
   float sum13 =   xmin+3*xmax;
   float sum22 = 2*xmin+2*xmax;
@@ -1590,6 +1623,7 @@ void EpsOutputData::color(const float x, const float xmax, const float xmin,
 };
 
 
+
 //explicit instantiations
 
 template class DataIn<deal_II_dimension>;

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.