[cig-commits] r5063 - in long/3D/Gale/trunk: . tools

walter at geodynamics.org walter at geodynamics.org
Tue Oct 17 08:09:39 PDT 2006


Author: walter
Date: 2006-10-17 08:09:39 -0700 (Tue, 17 Oct 2006)
New Revision: 5063

Added:
   long/3D/Gale/trunk/tools/
   long/3D/Gale/trunk/tools/viz.cxx
Modified:
   long/3D/Gale/trunk/
Log:
 r986 at earth:  boo | 2006-10-17 08:03:24 -0700
 Add vtk converter



Property changes on: long/3D/Gale/trunk
___________________________________________________________________
Name: svk:merge
   - 3a629746-de10-0410-b17b-fd6ecaaa963e:/cig:983
   + 3a629746-de10-0410-b17b-fd6ecaaa963e:/cig:986

Added: long/3D/Gale/trunk/tools/viz.cxx
===================================================================
--- long/3D/Gale/trunk/tools/viz.cxx	2006-10-17 14:34:10 UTC (rev 5062)
+++ long/3D/Gale/trunk/tools/viz.cxx	2006-10-17 15:09:39 UTC (rev 5063)
@@ -0,0 +1,52 @@
+#include <fstream>
+#include <vector>
+#include <iostream>
+
+using namespace std;
+
+int main(int argc, char *argv[])
+{
+  if(argc<3)
+    {
+      cerr << "usage: viz step file1 file2 file3 ..." << endl;
+      exit(1);
+    }
+  int step=atoi(argv[1]);
+  for(int j=2; j<argc; ++j)
+    {
+      string input_name=argv[j];
+      vector<double> x,y,z;
+      vector<double> weakening;
+      double temp;
+      ifstream f(input_name.c_str());
+      f >> temp;
+      while(f)
+        {
+          double tx, ty, tz, tw;
+          f >> tx >> ty >> tz >> tw;
+          x.push_back(tx);
+          y.push_back(ty);
+          z.push_back(tz);
+          weakening.push_back(tw);
+          f >> temp;
+        }
+      
+      cout << input_name << " " << x.size()/step << endl;
+      
+      string output_name=(input_name.substr(0,input_name.size()-3)+"vtk").c_str();
+      ofstream vtk_file(output_name.c_str());
+      vtk_file << "# vtk DataFile Version 2.0\nGale\nASCII\nDATASET UNSTRUCTURED_GRID\nPOINTS ";
+      vtk_file << (x.size()-1)/step+1 << " float" << endl;
+      for(int i=0;i<x.size();i+=step)
+        vtk_file << x[i] << " " << y[i] << " " << z[i] << endl;
+      
+      vtk_file << "POINT_DATA " << (x.size()-1)/step+1 << endl
+               << "SCALARS Temperature_Scalars float 1" << endl
+               << "LOOKUP_TABLE default" << endl;
+      
+      for(int i=0; i<weakening.size(); i+=step)
+        vtk_file << weakening[i] << " ";
+      vtk_file << endl;
+    }
+}
+



More information about the cig-commits mailing list