2 #include "boost/filesystem/operations.hpp"
3 #include "boost/filesystem/path.hpp"
4 #include "boost/filesystem/convenience.hpp"
10 namespace fs = boost::filesystem;
12 using namespace gplib;
14 int main(
int argc,
char* argv[])
18 string version =
"$Id: ptselect.cpp 1870 2011-04-01 11:55:47Z mmoorkamp $";
20 cout <<
"Program " << version << endl;
22 <<
" Display all phase tensor files in a directory and select good and bad ones "
24 cout <<
" Files are identified by file ending '.ptensor' " << endl;
25 cout <<
" Type 'g' for good or 'b' for bad after data is displayed "
32 const std::string baddir =
"bad";
33 const std::string gooddir =
"good";
34 if (!fs::exists(baddir))
35 fs::create_directory(baddir);
36 if (!fs::exists(gooddir))
37 fs::create_directory(gooddir);
38 fs::path full_path(fs::initial_path());
40 if (!fs::exists(full_path))
42 std::cout <<
"\nNot found: " << full_path
48 std::string mastersite = AskFilename(
"Enter site for permanent display: ");
50 if (GraceOpen(2048) == -1)
52 fprintf(stderr,
"Can't run Grace. \n");
55 fs::directory_iterator end_iter;
59 for (
unsigned int i = 0; i < Data.
GetTensor().size() && GraceIsOpen(); i++)
70 GracePrintf(
"xaxes scale logarithmic");
71 GracePrintf(
"autoscale");
72 GracePrintf(
"redraw");
75 for (fs::directory_iterator dir_itr(full_path);
76 dir_itr != end_iter; ++dir_itr)
78 if (extension(*dir_itr) ==
".ptensor")
80 std::string currentname(dir_itr->path().filename().string());
82 for (
unsigned int i = 0; i < Data.
GetTensor().size()
83 && GraceIsOpen(); i++)
85 GracePrintf(
"g0.s4 point %f, %f", 1.
87 GracePrintf(
"g0.s5 point %f, %f", 1.
89 GracePrintf(
"g0.s6 point %f, %f", 1.
91 GracePrintf(
"g0.s7 point %f, %f", 1.
95 GraceCommand((
"title \" " + currentname +
" \" ").c_str());
96 GracePrintf(
"redraw");
100 fs::rename(currentname, baddir);
101 else if (response ==
"g")
102 fs::rename(currentname, gooddir);
104 cout <<
"Invalid reply, ignoring file !" << endl;
105 GracePrintf(
"KILL g0.s4");
106 GracePrintf(
"KILL g0.s5");
107 GracePrintf(
"KILL g0.s6");
108 GracePrintf(
"KILL g0.s7");
double GetFrequency() const
std::vector< PTensorMTData > & GetTensor()
const PTensorMTData & at(const unsigned int i) const
int main(int argc, char *argv[])
void GetData(const std::string &filename)