changeset 122:6d4dc85d7f64

Added the possibility to plot a Mesh object.
author gedeone-octave <marcovass89@hotmail.it>
date Sun, 01 Sep 2013 23:39:51 +0200
parents 82a52945e33b
children 31fb4c16dcb0
files src/fem_plot.cc
diffstat 1 files changed, 26 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/fem_plot.cc	Sun Sep 01 23:39:30 2013 +0200
+++ b/src/fem_plot.cc	Sun Sep 01 23:39:51 2013 +0200
@@ -14,12 +14,15 @@
  You should have received a copy of the GNU General Public License along with
  this program; if not, see <http://www.gnu.org/licenses/>.
 */
+
 #include "function.h"
+#include "mesh.h"
 
 DEFUN_DLD (fem_plot, args, , "-*- texinfo -*-\n\
 @deftypefn {Function File} \
 fem_func (@var{Function})\n\
-The input parameter is the function that you want to plot\n\
+The input parameter is the object that you want to plot\n\
+It can be either a Function or a Mesh \n\
 @seealso{fem_func, fem_save}\n\
 @end deftypefn")
 {
@@ -37,6 +40,14 @@
           function_type_loaded = true;
           mlock ();
         }
+
+      if (! mesh_type_loaded)
+        {
+          mesh::register_type ();
+          mesh_type_loaded = true;
+          mlock ();
+        }
+
       if (args(0).type_id () == function::static_type_id ())
         {
           const function & uo =
@@ -50,6 +61,20 @@
               retval = 0;
             }
         }
+
+      else if (args(0).type_id () == mesh::static_type_id ())
+        {
+          const mesh & msho = static_cast<const mesh&> (args(0).get_rep ());
+
+          if (!error_state)
+            {
+              const boost::shared_ptr<const dolfin::Mesh> & mshd = msho.get_pmsh ();
+              dolfin::plot (*mshd);
+              dolfin::interactive ();
+              retval = 0;
+            }
+        }
+
     }
   return retval;
 }