GPLIB++
writevtk.cpp
Go to the documentation of this file.
1 #include <iostream>
2 #include <string>
3 #include "ThreeDMTModel.h"
4 #include "FatalException.h"
5 #include "Util.h"
6 #include <fstream>
7 
8 using namespace std;
9 using namespace gplib;
10 
11 string version = "$Id: writevtk.cpp 1849 2010-05-07 11:53:45Z mmoorkamp $";
12 
13 /*!
14  * \addtogroup UtilProgs Utility Programs
15  *@{
16  * \file writevtk.cpp
17  * Write a 3D model from WInGLink or Mackie to a .vtk file for plotting with paraview or visit.
18  */
19 
20 
21 int main(void)
22  {
23  cout
24  << " This is writevtk, convert Mackie or WinGlink model files to vtk format for display"
25  << endl;
26  cout
27  << " Output format is legacy VTK format, ending '.vtk' is appended to output"
28  << endl;
29  cout << " This is Version: " << version << endl << endl;
30  ThreeDMTModel Model;
31  string infilename, outfilename;
32 
33  int mode;
34  //get the name of the model file and which format it is stored in
35  infilename = AskFilename("Modelfile: ");
36  cout << "Type 1 for old Mackie, 2 for Winglink: ";
37  cin >> mode;
38  //the start of the name of the output files
39  cout << "Outfile root: ";
40  cin >> outfilename;
41  try
42  {
43  //read in the model in the specified format
44  if (mode == 1)
45  Model.ReadMackie(infilename);
46  else
47  Model.ReadWinGLink(infilename);
48  //write .vtk and netcdf files for the whole model
49  Model.WriteVTK(outfilename + ".vtk");
50  Model.WriteNetCDF(outfilename + ".nc");
51  } catch (const FatalException &e)
52  {
53  cerr << e.what() << endl;
54  }
55  }
56 /*@}*/
void ReadMackie(std::string filename)
Read an ascii file in the format use by Mackie's old code.
void WriteNetCDF(std::string filename)
Write the model in netcdf format.
string version
Definition: writevtk.cpp:11
int main()
Definition: angleavg.cpp:12
The class 3DMTModel manages 3D models for magnetotelluric model calculations, at this point this is o...
Definition: ThreeDMTModel.h:17
void ReadWinGLink(std::string filename)
Read an ascii file in the format written by WinGLink.
void WriteVTK(std::string filename)
Write an ascii file in .vtk format for plotting.
The basic exception class for all errors that arise in gplib.