]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
default format implemented
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 11 Feb 2000 19:53:58 +0000 (19:53 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 11 Feb 2000 19:53:58 +0000 (19:53 +0000)
git-svn-id: https://svn.dealii.org/trunk@2393 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/data_out_base.h
deal.II/base/source/data_out_base.cc

index ae78bcb3f33c1307fd978bab71d19fe539faa7e6..41ee5fcbb341a7e260e942955046f4b4bf00f585 100644 (file)
@@ -1116,6 +1116,13 @@ class DataOutBase
  * the formats presently implemented. User programs need therefore not
  * be changed whenever a new format is implemented.
  *
+ * Additionally, objects of this class have a default format, which
+ * can be set by the parameter "Output format" of the parameter
+ * file. Within a program, this can be changed by the member function
+ * #set_format#. Using this default format, it is possible to leave
+ * the format selection completely to the parameter file. A suitable
+ * suffic for the output file name can be obtained by #default_suffix#
+ * without arguments.
  *
  * @author Wolfgang Bangerth, 1999
  */
@@ -1127,7 +1134,7 @@ class DataOutInterface : private DataOutBase
                                      * Provide a data type specifying the
                                      * presently supported output formats.
                                      */
-    enum OutputFormat { ucd, gnuplot, povray, eps, gmv };
+    enum OutputFormat { nil, ucd, gnuplot, povray, eps, gmv };
 
                                     /**
                                      * Obtain data through the #get_patches#
@@ -1168,10 +1175,21 @@ class DataOutInterface : private DataOutBase
                                      * Write data and grid to #out# according
                                      * to the given data format. This function
                                      * simply calls the appropriate
-                                     * #write_*# function.
+                                     * #write_*# function. If no output format is
+                                     * requested, the #default_format# is written.
+                                     *
+                                     * An error occurs if no format is provided and
+                                     * the default format is #nil#.
                                      */
-    void write (ostream &out, const OutputFormat output_format) const;
-    
+    void write (ostream &out, const OutputFormat output_format = nil) const;
+
+                                    /**
+                                     * Set the default format. The value set here
+                                     * is used anytime, output for format #nil# is
+                                     * requested.
+                                     */
+    void set_format(const OutputFormat default_format);
+
                                     /**
                                      * Set the flags to be used for output
                                      * in UCD format.
@@ -1216,12 +1234,12 @@ class DataOutInterface : private DataOutBase
                                      * \item #gmv#: #.gmv#.
                                      * \end{itemize}
                                      *
-                                     * Since this function does not need data
-                                     * from this object, it is static and can
-                                     * thus be called without creating an
-                                     * object of this class.
+                                     * If this function is called
+                                     * with no argument or #nil#, the
+                                     * suffix for the
+                                     * #default_format# is returned.
                                      */
-    static string default_suffix (const OutputFormat output_format);
+    string default_suffix (const OutputFormat output_format = nil);
 
                                     /**
                                      * Return the #OutputFormat# value
@@ -1320,6 +1338,14 @@ class DataOutInterface : private DataOutBase
     virtual vector<string> get_dataset_names () const = 0;
 
   private:
+                                    /**
+                                     * Standard output format.
+                                     * Use this format, if output format nil is
+                                     * requested. It can be changed by the #set_format#
+                                     * function or in a parameter file.
+                                     */
+    OutputFormat default_format;
+    
                                     /**
                                      * Flags to be used upon output of UCD
                                      * data. Can be changed by using the
index e8d936b14202eaa87498a8906ff58fdb4209473e..3da07c04ab09a156de1cc37a0955ec1a2a72b501 100644 (file)
@@ -1728,7 +1728,11 @@ void DataOutInterface<dim>::write_gmv (ostream &out) const
 
 template <int dim>
 void DataOutInterface<dim>::write (ostream &out,
-                                  const OutputFormat output_format) const {
+                                  OutputFormat output_format) const
+{
+  if (output_format == nil)
+    output_format = default_format;
+  
   switch (output_format) 
     {
       case ucd:
@@ -1756,6 +1760,11 @@ void DataOutInterface<dim>::write (ostream &out,
     };
 };
 
+template <int dim>
+void DataOutInterface<dim>::set_format(OutputFormat fmt)
+{
+  default_format = fmt;
+}
 
 
 template <int dim>
@@ -1799,8 +1808,11 @@ void DataOutInterface<dim>::set_flags (const GmvFlags &flags)
 
 
 template <int dim>
-string DataOutInterface<dim>::default_suffix (const OutputFormat output_format) 
+string DataOutInterface<dim>::default_suffix (OutputFormat output_format) 
 {
+  if (output_format == nil)
+    output_format = default_format;
+  
   switch (output_format) 
     {
       case ucd:
@@ -1853,64 +1865,68 @@ DataOutInterface<dim>::parse_output_format (const string &format_name) {
 
 
 template <int dim>
-string DataOutInterface<dim>::get_output_format_names () {
+string DataOutInterface<dim>::get_output_format_names ()
+{
   return "ucd|gnuplot|povray|eps|gmv";
-};
+}
 
 
 
 template <int dim>
 void DataOutInterface<dim>::declare_parameters (ParameterHandler &prm) 
 {
+  prm.declare_entry ("Output format", "gnuplot",
+                    Patterns::Selection (get_output_format_names ()));
+
   prm.enter_subsection ("UCD output parameters");
   UcdFlags::declare_parameters (prm);
-  prm.leave_subsection();
+  prm.leave_subsection ();
   
   prm.enter_subsection ("Gnuplot output parameters");
   GnuplotFlags::declare_parameters (prm);
-  prm.leave_subsection();
+  prm.leave_subsection ();
 
   prm.enter_subsection ("Povray output parameters");
   PovrayFlags::declare_parameters (prm);
-  prm.leave_subsection();
+  prm.leave_subsection ();
 
   prm.enter_subsection ("Eps output parameters");
   EpsFlags::declare_parameters (prm);
-  prm.leave_subsection();
+  prm.leave_subsection ();
 
   prm.enter_subsection ("Gmv output parameters");
   GmvFlags::declare_parameters (prm);
-  prm.leave_subsection();
-};
+  prm.leave_subsection ();
+}
 
 
 
 template <int dim>
 void DataOutInterface<dim>::parse_parameters (ParameterHandler &prm) 
 {
+  const string& output_name = prm.get ("Output format");
+  default_format = parse_output_format (output_name);
+
   prm.enter_subsection ("UCD output parameters");
   ucd_flags.parse_parameters (prm);
-  prm.leave_subsection();
+  prm.leave_subsection ();
   
   prm.enter_subsection ("Gnuplot output parameters");
   gnuplot_flags.parse_parameters (prm);
-  prm.leave_subsection();
+  prm.leave_subsection ();
 
   prm.enter_subsection ("Povray output parameters");
   povray_flags.parse_parameters (prm);
-  prm.leave_subsection();
+  prm.leave_subsection ();
 
   prm.enter_subsection ("Eps output parameters");
   eps_flags.parse_parameters (prm);
-  prm.leave_subsection();
+  prm.leave_subsection ();
 
   prm.enter_subsection ("Gmv output parameters");
   gmv_flags.parse_parameters (prm);
-  prm.leave_subsection();
-};
-
-
-
+  prm.leave_subsection ();
+}
 
 
   

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.