]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Partial merge from the parallel_mg branch: Improve GridOut::write_xfig.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 5 Nov 2012 00:18:10 +0000 (00:18 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 5 Nov 2012 00:18:10 +0000 (00:18 +0000)
git-svn-id: https://svn.dealii.org/trunk@27375 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/news/changes.h
deal.II/include/deal.II/grid/grid_out.h
deal.II/source/grid/grid_out.cc

index ad8e51d12e50470b80534373028e8d208b85ae02..3b3c5f43f4bfc8432bb3639df84a846f4114cd38 100644 (file)
@@ -154,6 +154,12 @@ DoFHandler, in particular removal of specializations.
 <h3>Specific improvements</h3>
 
 <ol>
+<li> Changed: GridOut::write_xfig has been improved in a number
+of ways. In particular, one can now color cells based on a number
+of different criteria that can be set in GridOutFlags::XFig.
+<br>
+(Guido Kanschat, 2012/11/04)
+
 <li> New: The PETScWrappers::SparseDirectMUMPS class now allows to
 exploit symmetry of the matrix, using the
 PETScWrappers::SparseDirectMUMPS::set_symmetric_mode() function.
index c79fae7bb0238a11c43b66c39ca8f48dacdd29f7..ab84f716289215c9d104a976649475cc9a544255 100644 (file)
@@ -621,7 +621,22 @@ namespace GridOutFlags
                                         * Draw boundary lines. Default is true.
                                         */
       bool draw_boundary;
+                                                                 /**
+                                                                  * An enum used for deciding which field is used for coloring the cells.
+                                                                  */
+      enum Coloring {
+         /// Convert the material id into the cell color
+         material_id,
+         /// Convert the level into the cell color
+         level_number,
+         /// Convert the global subdomain id into the cell color
+         subdomain_id,
+         /// Convert the level subdomain id into the cell color
+         level_subdomain_id
+      } color_by;
                                        /**
+                                        * @deprecated Use the #color_by enum instead. If #color_by is different from #material_id, this flag is ignored.
+                                        *
                                         * Change color depending on
                                         * level. Default is false, therefore,
                                         * color is coded by material or
index fc1d46595501b513f63a333b7dca41ddb948be23..f7a0fbfd869f769a2f006124ce2eacf636ccdad8 100644 (file)
@@ -1080,7 +1080,6 @@ void GridOut::write_xfig (
 
 
 //TODO:[GK] Obey parameters
-//TODO:[GK] Flip y-axis?
 template <>
 void GridOut::write_xfig (
   const Triangulation<2>& tria,
@@ -1095,13 +1094,55 @@ void GridOut::write_xfig (
 
                                    // The following text was copied
                                    // from an existing XFig file.
-  out << "#FIG 3.2\nLandscape\nCenter\nInches" << '\n'
-      << "A4\n100.00\nSingle" << '\n'
+  out << "#FIG 3.2\nLandscape\nCenter\nInches" << std::endl
+      << "A4\n100.00\nSingle" << std::endl
                                      // Background is transparent
-      << "-3" << '\n'
-      << "# generated by deal.II GridOut class" << '\n'
-      << "# reduce first number to scale up image" << '\n'
-      << "1200 2" << '\n';
+      << "-3" << std::endl
+      << "# generated by deal.II GridOut class" << std::endl
+      << "# reduce first number to scale up image" << std::endl
+      << "1200 2" << std::endl;
+  // Write custom palette
+  //grey
+         unsigned int colno = 32;
+         out << "0 " << colno++ << " #ff0000" << std::endl;
+         out << "0 " << colno++ << " #ff8000" << std::endl;
+         out << "0 " << colno++ << " #ffd000" << std::endl;
+         out << "0 " << colno++ << " #ffff00" << std::endl;
+         out << "0 " << colno++ << " #c0ff00" << std::endl;
+         out << "0 " << colno++ << " #80ff00" << std::endl;
+         out << "0 " << colno++ << " #00f000" << std::endl;
+         out << "0 " << colno++ << " #00f0c0" << std::endl;
+         out << "0 " << colno++ << " #00f0ff" << std::endl;
+         out << "0 " << colno++ << " #00c0ff" << std::endl;
+         out << "0 " << colno++ << " #0080ff" << std::endl;
+         out << "0 " << colno++ << " #0040ff" << std::endl;
+         out << "0 " << colno++ << " #0000c0" << std::endl;
+         out << "0 " << colno++ << " #5000ff" << std::endl;
+         out << "0 " << colno++ << " #8000ff" << std::endl;
+         out << "0 " << colno++ << " #b000ff" << std::endl;
+         out << "0 " << colno++ << " #ff00ff" << std::endl;
+         out << "0 " << colno++ << " #ff80ff" << std::endl;
+      // grey
+         for (unsigned int i=0;i<8;++i)
+             out << "0 " << colno++ << " #" << std::hex << 32*i+31 << 32*i+31 << 32*i+31 << std::dec << std::endl;
+         // green
+         for (unsigned int i=1;i<16;++i)
+                 out << "0 " << colno++ << " #00" << std::hex << 16*i+15 << std::dec << "00" << std::endl;
+         // yellow
+         for (unsigned int i=1;i<16;++i)
+                 out << "0 " << colno++ << " #" << std::hex << 16*i+15 << 16*i+15 << std::dec << "00" << std::endl;
+         // red
+         for (unsigned int i=1;i<16;++i)
+                 out << "0 " << colno++ << " #" << std::hex << 16*i+15 << std::dec << "0000" << std::endl;
+         // purple
+         for (unsigned int i=1;i<16;++i)
+                 out << "0 " << colno++ << " #" << std::hex << 16*i+15 << "00" << 16*i+15 << std::dec << std::endl;
+         // blue
+         for (unsigned int i=1;i<16;++i)
+                 out << "0 " << colno++ << " #0000" << std::hex << 16*i+15 << std::dec << std::endl;
+         // cyan
+         for (unsigned int i=1;i<16;++i)
+                 out << "0 " << colno++ << " #00" << std::hex << 16*i+15 << 16*i+15 << std::dec << std::endl;
 
                                    // We write all cells and cells on
                                    // coarser levels are behind cells
@@ -1123,10 +1164,26 @@ void GridOut::write_xfig (
                                          // with black line
           << " 0 ";
                                        // Fill color
-      if (xfig_flags.level_color)
-        out << cell->level() + 8;
-      else
-        out << cell->material_id() + 1;
+       switch(xfig_flags.color_by)
+       {
+//TODO[GK]: Simplify after deprecation period is over
+       case GridOutFlags::XFig::material_id:
+               if (xfig_flags.level_color)
+                       out << cell->level()     + 32;
+                     else
+                       out << cell->material_id() + 32;
+               break;
+       case GridOutFlags::XFig::level_number:
+               out << cell->level() + 8;
+               break;
+       case GridOutFlags::XFig::subdomain_id:
+               out << cell->subdomain_id() + 32;
+               break;
+       case GridOutFlags::XFig::level_subdomain_id:
+               out << cell->level_subdomain_id() + 32;
+               break;
+       }
+
                                        // Depth, unused, fill
       out << ' '
           << (xfig_flags.level_depth
@@ -1137,7 +1194,7 @@ void GridOut::write_xfig (
                                          // some style parameters
           << " 0 0 -1 0 0 "
                                          // number of points
-          << nv+1 << '\n';
+          << nv+1 << std::endl;
 
                                        // For each point, write scaled
                                        // and shifted coordinates
@@ -1151,9 +1208,9 @@ void GridOut::write_xfig (
             {
               int val = (int)(1200 * xfig_flags.scaling(d) *
                               (p(d)-xfig_flags.offset(d)));
-              out << '\t' << val;
+              out << '\t' << ((d==0) ? val : -val);
             }
-          out << '\n';
+          out << std::endl;
         }
                                        // Now write boundary edges
       static const unsigned int face_reorder[4]={2,1,3,0};
@@ -1182,7 +1239,7 @@ void GridOut::write_xfig (
                                                    // some style parameters
                     << " 0 0 -1 0 0 "
                                                    // number of points
-                    << nvf << '\n';
+                    << nvf << std::endl;
 
                                                  // For each point, write scaled
                                                  // and shifted coordinates
@@ -1196,9 +1253,9 @@ void GridOut::write_xfig (
                       {
                         int val = (int)(1200 * xfig_flags.scaling(d) *
                                         (p(d)-xfig_flags.offset(d)));
-                        out << '\t' << val;
+                        out << '\t' << ((d==0) ? val : -val);
                       }
-                    out << '\n';
+                    out << std::endl;
                   }
               }
           }

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.