VinaLC: Parallel Molecular Docking Program

Biochemical and Biophysical Systems Group
VinaLC version: 1.1.2

grid.h
Go to the documentation of this file.
1 /*
2 
3  Copyright (c) 2006-2010, The Scripps Research Institute
4 
5  Licensed under the Apache License, Version 2.0 (the "License");
6  you may not use this file except in compliance with the License.
7  You may obtain a copy of the License at
8 
9  http://www.apache.org/licenses/LICENSE-2.0
10 
11  Unless required by applicable law or agreed to in writing, software
12  distributed under the License is distributed on an "AS IS" BASIS,
13  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  See the License for the specific language governing permissions and
15  limitations under the License.
16 
17  Author: Dr. Oleg Trott <ot14@columbia.edu>,
18  The Olson Lab,
19  The Scripps Research Institute
20 
21 */
22 
23 #ifndef VINA_GRID_H
24 #define VINA_GRID_H
25 
26 #include "array3d.h"
27 #include "grid_dim.h"
28 #include "curl.h"
29 
30 class grid { // FIXME rm 'm_', consistent with my new style
36 public:
37  array3d<fl> m_data; // FIXME? - make cache a friend, and convert this back to private?
38  grid() : m_init(0, 0, 0), m_range(1, 1, 1), m_factor(1, 1, 1), m_dim_fl_minus_1(-1, -1, -1), m_factor_inv(1, 1, 1) {} // not private
39  grid(const grid_dims& gd) { init(gd); }
40  void init(const grid_dims& gd);
41  vec index_to_argument(sz x, sz y, sz z) const {
42  return vec(m_init[0] + m_factor_inv[0] * x,
43  m_init[1] + m_factor_inv[1] * y,
44  m_init[2] + m_factor_inv[2] * z);
45  }
46  bool initialized() const {
47  return m_data.dim0() > 0 && m_data.dim1() > 0 && m_data.dim2() > 0;
48  }
49  fl evaluate(const vec& location, fl slope, fl c) const { return evaluate_aux(location, slope, c, NULL); }
50  fl evaluate(const vec& location, fl slope, fl c, vec& deriv) const { return evaluate_aux(location, slope, c, &deriv); } // sets deriv
51 private:
52  fl evaluate_aux(const vec& location, fl slope, fl v, vec* deriv) const; // sets *deriv if not NULL
54  template<class Archive>
55  void serialize(Archive& ar, const unsigned version) {
56  ar & m_init;
57  ar & m_data;
58  ar & m_range;
59  ar & m_factor;
60  ar & m_dim_fl_minus_1;
61  ar & m_factor_inv;
62  }
63 };
64 
65 #endif