LOOS  v2.3.2
grid2ascii.cpp
1 /*
2  grid2ascii
3 
4  Convert a grid into a serialized ascii representation
5 */
6 
7 
8 /*
9  This file is part of LOOS.
10 
11  LOOS (Lightweight Object-Oriented Structure library)
12  Copyright (c) 2009, Tod D. Romo, Alan Grossfield
13  Department of Biochemistry and Biophysics
14  School of Medicine & Dentistry, University of Rochester
15 
16  This package (LOOS) is free software: you can redistribute it and/or modify
17  it under the terms of the GNU General Public License as published by
18  the Free Software Foundation under version 3 of the License.
19 
20  This package is distributed in the hope that it will be useful,
21  but WITHOUT ANY WARRANTY; without even the implied warranty of
22  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  GNU General Public License for more details.
24 
25  You should have received a copy of the GNU General Public License
26  along with this program. If not, see <http://www.gnu.org/licenses/>.
27 */
28 
29 
30 
31 
32 
33 #include <loos.hpp>
34 #include <DensityGrid.hpp>
35 
36 #include <boost/format.hpp>
37 
38 using namespace std;
39 using namespace loos;
40 using namespace loos::DensityTools;
41 
42 int main(int argc, char *argv[]) {
44 
45  if (argc != 1) {
46  cerr << "Usage- grid2ascii <foo.grid >foo.asc\n"
47  "\n"
48  "Converts a LOOS grid to an ASCII representation. Requires a double precision\n"
49  "floating point grid.\n";
50  exit(-1);
51  }
52 
53  cin >> grid;
54  DensityGridpoint dim = grid.gridDims();
55  GCoord min = grid.minCoord();
56  GCoord max = grid.maxCoord();
57 
58  cout << boost::format("Read in grid of size %s\n") % dim;
59  cout << boost::format("Grid range from %s x %s\n") % min % max;
60 
61  for (int k=0; k<dim.z(); ++k)
62  for (int j=0; j<dim.y(); ++j)
63  for (int i=0; i<dim.x(); ++i)
64  cout << boost::format("(%d,%d,%d) = %f\n") % k % j % i % grid(k,j,i);
65 }
STL namespace.
Namespace for Density package.
Definition: DensityGrid.hpp:48
Namespace for most things not already encapsulated within a class.