00001
00002
00003
00004
00005
00006
00007
00008
00009
#include <iostream>
00010
#include <fstream>
00011
#include <simion/pa.h>
00012
00013
using namespace std;
00014
using namespace simion;
00015
00016 void print_usage()
00017 {
00018 cerr <<
"usage: pa2text <file>" << endl;
00019 }
00020
00021
00022 int main(
int argc,
char** argv)
00023 {
00024 ifstream is;
00025
00026
if(argc < 2) {
00027
print_usage();
00028
return 1;
00029 }
00030
00031 string filename = argv[1];
00032
00033 ofstream outfile((filename +
".txt").c_str());
00034
00035
PA pa;
00036 pa.
load(filename);
00037
00038 outfile
00039 <<
"file_type=" <<
"simion_pa" << endl;
00040
00041 outfile
00042 <<
"begin_header" << endl
00043 <<
"mode=" << pa.
mode() << endl
00044 <<
"symmetry=" << (pa.
symmetry() ==
CYLINDRICAL ?
00045
"cylindrical" :
"PLANAR") << endl
00046 <<
"max_voltage=" << pa.
max_voltage() << endl
00047 <<
"nx=" << pa.
nx() << endl
00048 <<
"ny=" << pa.
ny() << endl
00049 <<
"nz=" << pa.
nz() << endl
00050 <<
"mirror_x=" << !!(pa.
mirror_x()) << endl
00051 <<
"mirror_y=" << !!(pa.
mirror_y()) << endl
00052 <<
"mirror_z=" << !!(pa.
mirror_z()) << endl
00053 <<
"magnetic_pa=" << pa.
field_string(pa.
field_type()) << endl
00054 <<
"ng=" << pa.
ng() << endl
00055 ;
00056 outfile
00057 <<
"end_header" << endl;
00058
00059
00060
00061 outfile <<
"begin_points" << endl;
00062
00063
for(
int z=0; z<pa.
nz(); z++) {
00064
for(
int y=0; y<pa.
ny(); y++) {
00065
for(
int x=0; x<pa.
nx(); x++) {
00066
PAPoint point = pa.
point(x, y, z);
00067 outfile << point.
electrode <<
"," << point.
potential << endl;
00068 }
00069 }
00070 }
00071 outfile <<
"end_points" << endl;
00072
00073
return 0;
00074 }
00075
00076