IMP  2.4.0
The Integrative Modeling Platform
grid.cpp
1 /**
2  * \example grid.cpp
3  * \brief Show some of the basics of using a grid from C++.
4  *
5  * Copyright 2007-2015 IMP Inventors. All rights reserved.
6  *
7  */
11 
12 #include <algorithm>
13 
14 int main(int, char * []) {
16  IMP::algebra::Vector3D(10, 10, 10));
17  // declare a grid covering the space 0 to 100 with a cell size of 1 and
18  // default value of 0
19  // unfortunately, due to swig GridD takes lots of redundant template
20  // parameters
22  double> Grid;
23  Grid grid(1, bb, 0);
24  // fill it with a gradient
25  IMP_FOREACH(Grid::Index i, grid.get_all_indexes()) {
26  IMP::algebra::Vector3D c = grid.get_center(i);
27  grid[i] = IMP::algebra::get_distance(c, IMP::algebra::Vector3D(10, 10, 10));
28  }
29  // we can get smooth values at off-grid points
30  // it is boring below .5
31  std::cout << "Smooth" << std::endl;
32  for (double x = .5; x < 4; x += .1) {
34  grid, IMP::algebra::Vector3D(x, x, x));
35  std::cout << vo << " ";
36  }
37  std::cout << std::endl;
38  // we can get chunky values at off-grid points instead
39  std::cout << "Chunky" << std::endl;
40  for (double x = .5; x < 4; x += .1) {
41  double vo = grid[IMP::algebra::Vector3D(x, x, x)];
42  std::cout << vo << " ";
43  }
44  std::cout << std::endl;
45  return EXIT_SUCCESS;
46 }
A voxel grid in d-dimensional space space.
Definition: GridD.h:79
double get_distance(const Plane3D &pln, const Vector3D &p)
Return the distance between a plane and a point in 3D.
Definition: Plane3D.h:71
Functions to generate vectors.
Value get_linearly_interpolated(const GridD< D, Storage, Value, Embedding > &g, const VectorD< D > &pt)
Definition: grid_utility.h:23
VectorD< 3 > Vector3D
Definition: VectorD.h:395
All grids that are in the Python API should be defined here.
A class to represent a voxel grid.