LOOS  v2.3.2
gridinfo.cpp
1 /*
2  gridinfo.cpp
3 
4  Just dump the grid header info...
5 */
6 
7 /*
8  This file is part of LOOS.
9 
10  LOOS (Lightweight Object-Oriented Structure library)
11  Copyright (c) 2009, Tod D. Romo, Alan Grossfield
12  Department of Biochemistry and Biophysics
13  School of Medicine & Dentistry, University of Rochester
14 
15  This package (LOOS) is free software: you can redistribute it and/or modify
16  it under the terms of the GNU General Public License as published by
17  the Free Software Foundation under version 3 of the License.
18 
19  This package is distributed in the hope that it will be useful,
20  but WITHOUT ANY WARRANTY; without even the implied warranty of
21  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  GNU General Public License for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with this program. If not, see <http://www.gnu.org/licenses/>.
26 */
27 
28 
29 #include <loos.hpp>
30 #include <DensityGrid.hpp>
31 
32 
33 using namespace std;
34 using namespace loos;
35 using namespace loos::DensityTools;
36 
37 
38 
39 int main(int argc, char *argv[]) {
40 
42  if (argc == 2) {
43  string fname(argv[1]);
44  if (fname == "--help" || fname == "-h" || fname == "--fullhelp") {
45  cerr << "Usage- gridinfo <foo.grid\n\tgridinfo foo.grid\n";
46  cerr << "\nPrints out basic information about a grid\n";
47  cerr << "Requires a double-precision floating point grid.\n";
48  exit(-1);
49  }
50  ifstream ifs(argv[1]);
51  if (!ifs) {
52  cerr << "Error- cannot open " << argv[1] << endl;
53  exit(-1);
54  }
55 
56  ifs >> grid;
57  } else
58  cin >> grid;
59 
60  loos::GCoord min = grid.minCoord();
61  loos::GCoord max = grid.maxCoord();
62  DensityGridpoint dim = grid.gridDims();
63 
64  cout << "Grid = " << min << " x " << max << " @ " << dim << endl;
65  cout << "Resolution = " << (max.x() - min.x()) / dim.x() << endl;
66  cout << "Metadata: ";
67 
68  SimpleMeta meta = grid.metadata();
69  if (meta.empty())
70  cout << "none\n";
71  else {
72  cout << endl;
73  copy(meta.begin(), meta.end(), ostream_iterator<SimpleMeta::value_type>(cout, "\n"));
74  }
75 }
STL namespace.
Namespace for Density package.
Definition: DensityGrid.hpp:48
Namespace for most things not already encapsulated within a class.
Simple class for handling metadata.
Definition: SimpleMeta.hpp:51
iterator begin()
Allow STL-iteration.
Definition: SimpleMeta.hpp:68