]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Implement a rudimentary version of output for POVRAY.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 17 Jun 1998 09:48:25 +0000 (09:48 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 17 Jun 1998 09:48:25 +0000 (09:48 +0000)
git-svn-id: https://svn.dealii.org/trunk@407 0785d39b-7218-0410-832d-ea1e28bc413d

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

index 773d4bfa681bc2acbd25243ec784deb378bd86b8..29731534cfbe0d9e38e4d956480e7c95c148ba3e 100644 (file)
@@ -320,6 +320,22 @@ class DataIn {
  * plot of the (#x-2#)th data set. For example, using #x=4# would mean to
  * plot the second data set.
  *
+ *
+ * \subsection{POVRAY format}
+ *
+ * POVRAY is a ray tracing tool in the public domain and poduces high quality
+ * images of three dimensional scenes. Since this tool can handle only one
+ * scene at a time, only the first data vector is output, but this may change
+ * in future versions of this library. For a reference of the data format
+ * and the usage of POVRAY see the extensive manual of that program.
+ *
+ * The POVRAY output format is presently only supported for two spatial
+ * dimensions. It displays every quadrilateral as two triangles, which clearly
+ * is not an optimal solution, but necessary since POVRAY presently does not
+ * support bilinear quadrilaterals and using polygons as vastly suboptimal in
+ * term of memory and speed to the triangle mesh supported by POVRAY.
+ *
+ *
  * @author Wolfgang Bangerth, 1998
  */
 template <int dim>  
@@ -329,7 +345,7 @@ class DataOut {
                                      * Provide a data type specifying the
                                      * presently supported output formats.
                                      */
-    enum OutputFormat { ucd, gnuplot };
+    enum OutputFormat { ucd, gnuplot, povray };
     
                                     /**
                                      * Constructor
@@ -393,6 +409,12 @@ class DataOut {
                                      */
     void write_gnuplot (ostream &out) const;
 
+                                    /**
+                                     * Write data of first vector and grid
+                                     * in POVRAY format.
+                                     */
+    void write_povray (ostream &out) const;
+
                                     /**
                                      * Write data and grid to #out# according
                                      * to the given data format. This function
@@ -409,6 +431,7 @@ class DataOut {
                                      * \begin{itemize}
                                      * \item UCD: #.inp#
                                      * \item GNUPLOT: #.gnuplot#
+                                     * \item POVRAY: #.pov#
                                      * \end{itemize}
                                      *
                                      * Since this function does not need data
index 52bc54b4edf23d64e1614cc47eadf847c4bed0d5..cbb170589048be8c46a8c6d100b1d243959f33d4 100644 (file)
@@ -486,7 +486,7 @@ void DataOut<dim>::write_gnuplot (ostream &out) const {
          << setw(2) << time->tm_min << ":"
          << setw(2) << time->tm_sec << endl
          << "#" << endl
-         << "# For a description of the UCD format see the AVS Developers guide."
+         << "# For a description of the GNUPLOT format see the GNUPLOT manual."
          << endl
          << "#" << endl
          << "# ";
@@ -564,6 +564,99 @@ void DataOut<dim>::write_gnuplot (ostream &out) const {
     };
 };
 
+
+
+template <>
+void DataOut<2>::write_povray (ostream &out) const {
+  Assert (dofs != 0, ExcNoDoFHandlerSelected());
+
+                                  // write preamble
+  if (true) 
+    {
+                                      // block this to have local
+                                      // variables destroyed after
+                                      // use
+      time_t  time1= time (0);
+      tm     *time = localtime(&time1); 
+      out << "/*" << endl
+         << "This file was generated by the deal.II library." << endl
+         << "Date =  "
+         << time->tm_year+1900 << "/"
+         << time->tm_mon+1 << "/"
+         << time->tm_mday << endl
+         << "Time =  "
+         << time->tm_hour << ":"
+         << setw(2) << time->tm_min << ":"
+         << setw(2) << time->tm_sec << endl
+         << endl
+         << "For a description of the POVRAY format see the POVRAY manual."
+         << endl
+         << endl
+         << "*/"
+         << endl << endl;
+    };
+
+                                  // write list of include files
+  out << "#include \"colors.inc\""   << endl
+      << endl;
+
+                                  // declare standard texture
+  out << "#declare default_texture = texture {"         << endl
+      << "        pigment { color rgb<0.2, 0.2, 0.8> }" << endl
+      << "        finish  { ambient 0.2 diffuse 0.5  }" << endl
+      << "}" << endl << endl;                          
+
+                                  // write camera and light sources
+  out << "camera {"                  << endl
+      << "  location <-1, -3, 2>"    << endl
+      << "  look_at  <1.5, 3.5, -2>" << endl
+      << "}"                         << endl
+      << endl
+      << "light_source {"            << endl
+      << "  <-1, 2, 2> White"        << endl
+      << "}"                         << endl
+      << endl;
+      
+      
+                                      // write frame object
+  out << "mesh {" << endl;
+  
+  DoFHandler<2>::active_cell_iterator cell;
+  DoFHandler<2>::active_cell_iterator endc = dofs->end();
+
+  for (cell=dofs->begin_active(); cell!=endc; ++cell) 
+    {
+                                      // write cell as two triangles
+      out << "  triangle { ";
+      out << '<' << cell->vertex(0)(0) << ',' << cell->vertex(0)(1) << ','
+         << (*data[0].data)(cell->vertex_dof_index(0,0))           << '>'
+         << ", "
+         << '<' << cell->vertex(1)(0) << ',' << cell->vertex(1)(1) << ','
+         << (*data[0].data)(cell->vertex_dof_index(1,0))           << '>'
+         << ", "
+         << '<' << cell->vertex(2)(0) << ',' << cell->vertex(2)(1) << ','
+         << (*data[0].data)(cell->vertex_dof_index(2,0))           << '>'
+         << endl
+         << "              texture { default_texture }"   << endl
+         << "           }"
+         << endl;
+      out << "  triangle { ";
+      out << '<' << cell->vertex(0)(0) << ',' << cell->vertex(0)(1) << ','
+         << (*data[0].data)(cell->vertex_dof_index(0,0))           << '>'
+         << ", "
+         << '<' << cell->vertex(2)(0) << ',' << cell->vertex(2)(1) << ','
+         << (*data[0].data)(cell->vertex_dof_index(2,0))           << '>'
+         << ", "
+         << '<' << cell->vertex(3)(0) << ',' << cell->vertex(3)(1) << ','
+         << (*data[0].data)(cell->vertex_dof_index(3,0))           << '>'
+         << endl
+         << "              texture { default_texture }"   << endl
+         << "           }"
+         << endl;
+    };
+  out << "}";     
+};
+
       
 
 template <int dim>
@@ -577,6 +670,9 @@ void DataOut<dim>::write (ostream &out,
       case gnuplot:
            write_gnuplot (out);
            break;
+      case povray:
+           write_povray (out);
+           break;
       default:
            Assert (false, ExcNotImplemented());
     };
@@ -592,6 +688,8 @@ string DataOut<dim>::default_suffix (const OutputFormat output_format) {
            return ".inp";
       case gnuplot:
            return ".gnuplot";
+      case povray:
+           return ".pov";
       default:
            Assert (false, ExcNotImplemented());
            return "";

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.