IMP logo
IMP Reference Guide  2.13.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-2020 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.
35 /** In Python SparseUnboundedIntGrid3D 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.
49 /** In Python DenseFloatGrid3D and DenseDoubleGrid3D are provided.
50  See IMP_GRID3D_FOREACH_VOXEL() for a useful macro when operating
51  on all voxels of the grid.
52 */
53 template <class VT>
55  : public GridD<3, DenseGridStorageD<3, VT>, VT, DefaultEmbeddingD<3> > {
57  DenseGrid3D(double side, const BoundingBoxD<3> &bb, VT def = VT())
58  : P(side, bb, def) {}
59  DenseGrid3D() {}
60  IMP_ALGEBRA_SWIG_GRID_METHODS(3, VT);
61 };
62 
63 template <int D, class VT>
64 struct DenseGridD
65  : public GridD<D, DenseGridStorageD<D, VT>, VT, DefaultEmbeddingD<D> > {
67  DenseGridD(double side, const BoundingBoxD<D> &bb, VT def = VT())
68  : P(side, bb, def) {}
69  DenseGridD(const VectorD<D> &sides, const BoundingBoxD<D> &bb, VT def = VT())
70  : P(sides, bb, def) {}
71  DenseGridD() {}
72  IMP_ALGEBRA_SWIG_GRID_METHODS(D, VT);
73 };
74 
75 //! A sparse grid of values.
76 /** In Python SparseIntGrid3D is provided. */
77 template <class VT>
79  : public GridD<3, SparseGridStorageD<3, VT, BoundedGridRangeD<3> >, VT,
80  DefaultEmbeddingD<3> > {
83  SparseGrid3D(double side, const BoundingBoxD<3> &bb, VT def = VT())
84  : P(side, bb, def) {}
85  SparseGrid3D(int xd, int yd, int zd, const BoundingBoxD<3> &bb, VT def = VT())
86  : P(xd, yd, zd, bb, def) {}
87  SparseGrid3D() {}
88  IMP_ALGEBRA_SWIG_GRID_METHODS(3, VT);
89 };
90 
91 //! A sparse, infinite grid of values.
92 /** In Python SparseUnboundedIntGrid3D is provided. */
93 template <class VT>
95  : public GridD<3, SparseGridStorageD<3, VT, UnboundedGridRangeD<3> >, VT,
96  DefaultEmbeddingD<3> > {
99  SparseUnboundedGrid3D(double side, const Vector3D &origin, VT def = VT())
100  : P(side, origin, def) {}
101  SparseUnboundedGrid3D(const Vector3D &sides, const Vector3D &origin, VT def = VT())
102  : P(sides, origin, def) {}
104  IMP_ALGEBRA_SWIG_GRID_METHODS(3, VT);
105 };
106 
107 /** A dense grid with logarithmic axes. */
108 struct DenseFloatLogGridKD : public GridD<-1, DenseGridStorageD<-1, float>,
109  float, LogEmbeddingD<-1> > {
110  typedef GridD<-1, DenseGridStorageD<-1, float>, float, LogEmbeddingD<-1> > P;
111  DenseFloatLogGridKD(const Ints &sz, LogEmbeddingD<-1> le) : P(sz, le) {}
112  IMP_ALGEBRA_SWIG_GRID_METHODS(-1, float);
113 };
114 
115 /** A dense grid with logarithmic axes. */
117  : public GridD<3, DenseGridStorageD<3, int>, int, LogEmbeddingD<3> > {
119  DenseIntLogGrid3D(const Ints &sz, LogEmbeddingD<3> le) : P(sz, le) {}
120  IMP_ALGEBRA_SWIG_GRID_METHODS(3, int);
121 };
122 
123 IMPALGEBRA_END_NAMESPACE
124 
125 #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.
Definition: GridD.h:79
A sparse, infinite grid of values.
A Cartesian vector in D-dimensions.
Definition: VectorD.h:52
A class to represent a voxel grid.
A sparse grid of values.
Embed a grid as an evenly spaced axis aligned grid.
VectorD< 3 > Vector3D
Definition: VectorD.h:421
A class to represent a voxel grid.
A dense grid of values.
A sparse, infinite grid of values.