From: Wolfgang Bangerth Date: Wed, 17 Jun 1998 09:48:25 +0000 (+0000) Subject: Implement a rudimentary version of output for POVRAY. X-Git-Tag: v8.0.0~22847 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9425429a35b134ce47c9729da2f1eb37bc6ec1ad;p=dealii.git Implement a rudimentary version of output for POVRAY. git-svn-id: https://svn.dealii.org/trunk@407 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/numerics/data_io.h b/deal.II/deal.II/include/numerics/data_io.h index 773d4bfa68..29731534cf 100644 --- a/deal.II/deal.II/include/numerics/data_io.h +++ b/deal.II/deal.II/include/numerics/data_io.h @@ -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 @@ -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 diff --git a/deal.II/deal.II/source/numerics/data_io.cc b/deal.II/deal.II/source/numerics/data_io.cc index 52bc54b4ed..cbb1705890 100644 --- a/deal.II/deal.II/source/numerics/data_io.cc +++ b/deal.II/deal.II/source/numerics/data_io.cc @@ -486,7 +486,7 @@ void DataOut::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::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 @@ -577,6 +670,9 @@ void DataOut::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::default_suffix (const OutputFormat output_format) { return ".inp"; case gnuplot: return ".gnuplot"; + case povray: + return ".pov"; default: Assert (false, ExcNotImplemented()); return "";