]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
determine input format by filename extension
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 3 May 2005 19:52:40 +0000 (19:52 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 3 May 2005 19:52:40 +0000 (19:52 +0000)
git-svn-id: https://svn.dealii.org/trunk@10638 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/source/grid/grid_in.cc

index 8365f8a531addd19aefa98d96828468bd9edf7b3..aa3b0d6f2e6f9ca169a863d687ef77161e1fd826 100644 (file)
@@ -995,8 +995,23 @@ template <int dim>
 void GridIn<dim>::read (const std::string& filename,
                        Format format)
 {
+                                  // Search file class for meshes
   PathSearch search("MESH");
+                                  // Open the file and remember its name
   std::istream& in = search.open(filename.c_str());
+  const std::string& name = search.name();  
+  
+  if (format == Default)
+    {
+      const unsigned int slashpos = name.find_last_of('/');
+      const unsigned int dotpos = name.find_last_of('.');
+      if (dotpos < name.length()
+         && (dotpos > slashpos || slashpos == name.length()))
+       {
+         std::string ext = name.substr(dotpos+1);
+         format = parse_format(ext);
+       }
+    }
   read(in, format);
 }
 
@@ -1066,6 +1081,9 @@ GridIn<dim>::parse_format (const std::string &format_name)
   if (format_name == "msh")
     return msh;
   
+  if (format_name == "inp")
+    return ucd;
+
   if (format_name == "ucd")
     return ucd;
 

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.