IMP  2.2.0
The Integrative Modeling Platform
standard_grids.h
Go to the documentation of this file.
1 /**
2  * \file IMP/algebra/standard_grids.h
3  * \brief All grids that are in the python API should be defined here.
4  *
5  * Copyright 2007-2014 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPALGEBRA_STANDARD_GRIDS_H
10 #define IMPALGEBRA_STANDARD_GRIDS_H
11 
12 #include <IMP/algebra/algebra_config.h>
13 #include "GridD.h"
14 #include "grid_ranges.h"
15 #include "grid_storages.h"
16 #include "grid_embeddings.h"
17 IMPALGEBRA_BEGIN_NAMESPACE
18 
19 #ifdef SWIG
20 // swig is getting confused
21 #define IMP_ALGEBRA_SWIG_GRID_METHODS(D, Q) \
22  GridIndexD<D> add_voxel(const ExtendedGridIndexD<D> &i, const Q &q); \
23  Q __getitem__(const GridIndexD<D> i) const; \
24  void __setitem__(const GridIndexD<D> &i, const Q &q); \
25  Q __getitem__(const VectorD<D> i) const; \
26  void __setitem__(const VectorD<D> &i, const Q &q); \
27  BoundingBoxD<D> get_bounding_box(ExtendedGridIndexD<D> v) const; \
28  BoundingBoxD<D> get_bounding_box() const
29 
30 #else
31 #define IMP_ALGEBRA_SWIG_GRID_METHODS(D, VT)
32 #endif
33 
34 /** A sparse, infinite grid of values. In python SparseUnboundedIntGrid3D
35  is provided.*/
36 template <int D, class VT>
38  : public GridD<D, SparseGridStorageD<D, VT, UnboundedGridRangeD<D> >, VT,
39  DefaultEmbeddingD<D> > {
42  SparseUnboundedGridD(double side, const VectorD<D> &origin, VT def = VT())
43  : P(side, origin, def) {}
45  IMP_ALGEBRA_SWIG_GRID_METHODS(D, VT);
46 };
47 
48 /** A dense grid of values. In python DenseFloatGrid3D and DenseDoubleGrid3D are
49  provided. See IMP_GRID3D_FOREACH_VOXEL() for a useful macro when operating
50  on all voxels of the grid.
51 */
52 template <class VT>
54  : public GridD<3, DenseGridStorageD<3, VT>, VT, DefaultEmbeddingD<3> > {
56  DenseGrid3D(double side, const BoundingBoxD<3> &bb, VT def = VT())
57  : P(side, bb, def) {}
58  DenseGrid3D() {}
59  IMP_ALGEBRA_SWIG_GRID_METHODS(3, VT);
60 };
61 
62 /** A sparse grid of values. In python SparseIntGrid3D is provided.*/
63 template <class VT>
65  : public GridD<3, SparseGridStorageD<3, VT, BoundedGridRangeD<3> >, VT,
66  DefaultEmbeddingD<3> > {
69  SparseGrid3D(double side, const BoundingBoxD<3> &bb, VT def = VT())
70  : P(side, bb, def) {}
71  SparseGrid3D(int xd, int yd, int zd, const BoundingBoxD<3> &bb, VT def = VT())
72  : P(xd, yd, zd, bb, def) {}
73  SparseGrid3D() {}
74  IMP_ALGEBRA_SWIG_GRID_METHODS(3, VT);
75 };
76 
77 /** A sparse, infinite grid of values. In python SparseUnboundedIntGrid3D
78  is provided.*/
79 template <class VT>
81  : public GridD<3, SparseGridStorageD<3, VT, UnboundedGridRangeD<3> >, VT,
82  DefaultEmbeddingD<3> > {
85  SparseUnboundedGrid3D(double side, const Vector3D &origin, VT def = VT())
86  : P(side, origin, def) {}
88  IMP_ALGEBRA_SWIG_GRID_METHODS(3, VT);
89 };
90 
91 /** A dense grid with logrythmic axes. */
92 struct DenseFloatLogGridKD : public GridD<-1, DenseGridStorageD<-1, float>,
93  float, LogEmbeddingD<-1> > {
94  typedef GridD<-1, DenseGridStorageD<-1, float>, float, LogEmbeddingD<-1> > P;
95  DenseFloatLogGridKD(const Ints &sz, LogEmbeddingD<-1> le) : P(sz, le) {}
96  IMP_ALGEBRA_SWIG_GRID_METHODS(-1, float);
97 };
98 
99 /** A dense grid with logrythmic axes. */
101  : public GridD<3, DenseGridStorageD<3, int>, int, LogEmbeddingD<3> > {
103  DenseIntLogGrid3D(const Ints &sz, LogEmbeddingD<3> le) : P(sz, le) {}
104  IMP_ALGEBRA_SWIG_GRID_METHODS(3, int);
105 };
106 
107 IMPALGEBRA_END_NAMESPACE
108 
109 #endif /* IMPALGEBRA_STANDARD_GRIDS_H */
A class to represent a voxel grid.
A class to represent a voxel grid.
A voxel grid in d-dimensional space space.
Definition: GridD.h:79
A Cartesian vector in D-dimensions.
Definition: VectorD.h:52
A class to represent a voxel grid.
VectorD< 3 > Vector3D
Definition: VectorD.h:395
A class to represent a voxel grid.