]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
first results with write_xfig
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 15 Oct 2003 21:16:13 +0000 (21:16 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 15 Oct 2003 21:16:13 +0000 (21:16 +0000)
git-svn-id: https://svn.dealii.org/trunk@8090 0785d39b-7218-0410-832d-ea1e28bc413d

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

index 2b548ac26aadcc2e192049bb2751735f94fe4e4d..55de6a790355b63a97cd8271d5b1ba6147b2c9bd 100644 (file)
@@ -17,6 +17,7 @@
 
 #include <base/config.h>
 #include <base/exceptions.h>
+#include <base/point.h>
 #include <string>
 
 template <int dim> class Triangulation;
index 79985800d16aa5b0b9b74d399ff4354461ac3c1f..0c86df7485d5419f1f9cb76daf195a0cd4e8d763 100644 (file)
@@ -370,8 +370,9 @@ void GridOut::write_ucd (const Triangulation<dim> &tria,
 #if deal_II_dimension != 2
 
 template <int dim>
-void GridOut::write_xfig (const Triangulation<dim> &,
-                         std::ostream             &)
+void GridOut::write_xfig (const Triangulation<dim>&,
+                         std::ostream&,
+                         const Mapping<dim>*)
 {
   Assert (false, ExcNotImplemented());
 }
@@ -379,10 +380,57 @@ void GridOut::write_xfig (const Triangulation<dim> &,
 #else
 
 template <int dim>
-void GridOut::write_xfig (const Triangulation<dim> &,
-                         std::ostream             &)
+void GridOut::write_xfig (const Triangulation<dim>& tria,
+                         std::ostream&             out,
+                         const Mapping<dim>*       mapping)
 {
-  Assert (false, ExcNotImplemented());
+                                  // The following text was copied
+                                  // from an existing XFig file.
+  out << "#FIG 3.2\nLandscape\nCenter\nInches" << std::endl
+      << "A4\n100.00\nSingle" << std::endl
+                                    // Background is transparent
+      << "-3" << std::endl
+      << "1200 2" << std::endl;
+
+                                  // We write all cells and cells on
+                                  // coarser levels are behind cells
+                                  // on finer levels. Level 0
+                                  // corresponds to a depth of 900,
+                                  // each level subtracting 1
+  typename Triangulation<dim>::cell_iterator cell = tria.begin();
+  const typename Triangulation<dim>::cell_iterator end = tria.end();
+
+  for (;cell != end; ++cell)
+    {
+                                      // Code for polygon
+      out << "2 3 "
+                                        // with solid black line thickness 1
+         << " 0 1 0 ";
+                                        // Fill color
+      out << " 6 ";
+                                      // Depth, unused, solid fill
+      out << 900-cell->level() << " 0 20 0.0 "
+                                        // some style parameters
+         << " 0 0 -1 0 0 "
+                                        // number of points
+         << '5' << std::endl;
+
+                                      // For each point, write scaled
+                                      // and shifted coordinates
+                                      // multiplied by 1200
+                                      // (dots/inch)
+      const unsigned int nv = GeometryInfo<dim>::vertices_per_cell;
+      for (unsigned int k=0;k<=nv;++k)
+       {
+         const Point<dim>& p = cell->vertex(k % nv);
+         for (unsigned int d=0;d<dim;++d)
+           {
+             out << '\t'
+                 << 1200 * (p(d)-xfig_flags.offset(d)) * xfig_flags.scaling(d);
+           }
+         out << std::endl;
+       }
+    }
 }
 #endif
 
@@ -1220,7 +1268,11 @@ void GridOut::write (const Triangulation<dim> &tria,
       case eps:
            write_eps (tria, out, mapping);
            return;
-    };
+      case xfig:
+           write_xfig (tria, out, mapping);
+           return;
+   };
 
   Assert (false, ExcInternalError());
 }

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.