Pteros  2.0
Molecular modeling library for human beings!
grid.h
1 /*
2  *
3  * This source code is part of
4  * ******************
5  * *** Pteros ***
6  * ******************
7  * molecular modeling library
8  *
9  * Copyright (c) 2009-2013, Semen Yesylevskyy
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of Artistic License:
13  *
14  * Please note, that Artistic License is slightly more restrictive
15  * then GPL license in terms of distributing the modified versions
16  * of this software (they should be approved first).
17  * Read http://www.opensource.org/licenses/artistic-license-2.0.php
18  * for details. Such license fits scientific software better then
19  * GPL because it prevents the distribution of bugged derivatives.
20  *
21 */
22 
23 #ifndef GRID_H_INCLUDED
24 #define GRID_H_INCLUDED
25 
26 #include <Eigen/Core>
27 #include <vector>
28 #include <deque>
29 #include "pteros/core/selection.h"
30 
31 #define BOOST_DISABLE_ASSERTS
32 #include "boost/multi_array.hpp"
33 
34 namespace pteros {
35 
36  struct Grid_element {
37  int index;
38  Eigen::Vector3f* coor_ptr;
39  Grid_element(int i, Eigen::Vector3f* ptr): index(i),coor_ptr(ptr) {}
40  };
41 
60  class Grid {
61  public:
62  Grid(){}
63  Grid(int X, int Y, int Z){ resize(X,Y,Z); }
64  virtual ~Grid(){}
65 
66  void clear();
67  void resize(int X, int Y, int Z);
68  std::vector<Grid_element>& cell(int i, int j, int k){ return data[i][j][k]; }
69 
71  void populate(const Selection& sel,bool abs_index = false);
72 
73  void populate(const Selection& sel,
74  Vector3f_const_ref min,
75  Vector3f_const_ref max,
76  bool abs_index);
77 
79  void populate_periodic(const Selection& sel,bool abs_index = false);
80 
81  void populate_periodic(const Selection& sel,
82  const Periodic_box& box,
83  bool abs_index);
84  private:
85  boost::multi_array<std::vector<Grid_element>,3> data;
86  // Array of atomic coordinates, which have to be wrapped if periodic.
87  // This is in order not to touch real coordinates of atoms and improve speed.
88  std::deque<Eigen::Vector3f> wrapped_atoms;
89  };
90 
91 }
92 
93 #endif // GRID_H_INCLUDED
Sorting the atoms from given selection into the cells of 3D grid with given dimensions.
Definition: grid.h:60
Pteros namespace.
Definition: options.cpp:32
Selection class.
Definition: atom_proxy.h:57
Class encapsulating all operations with arbitrary triclinic periodic boxes This class stores the peri...
Definition: periodic_box.h:47