LOOS  v2.3.2
PeriodicBox.hpp
1 /*
2  This file is part of LOOS.
3 
4  LOOS (Lightweight Object-Oriented Structure library)
5  Copyright (c) 2008, Tod D. Romo, Alan Grossfield
6  Department of Biochemistry and Biophysics
7  School of Medicine & Dentistry, University of Rochester
8 
9  This package (LOOS) is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation under version 3 of the License.
12 
13  This package is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
22 
23 
24 
25 
26 #if !defined(LOOS_PERIODICBOX_HPP)
27 #define LOOS_PERIODICBOX_HPP
28 
29 
30 
31 #include <boost/shared_ptr.hpp>
32 
33 #include <loos_defs.hpp>
34 
35 
36 
37 namespace loos {
38 
40 
47  class PeriodicBox {
48  public:
49  PeriodicBox() : thebox(99999,99999,99999), box_set(false) { }
50  explicit PeriodicBox(const GCoord& c) : thebox(c), box_set(true) { }
51 
52  GCoord box(void) const { return(thebox); }
53  void box(const GCoord& c) {
54  thebox = c;
55 
56  // Because of the way boxes are handled elsewhere, setting an
57  // unset box in AtomicGroup can leave PeriodicBox thinking it
58  // has been set, when it's really just the default value. So,
59  // check on set for the magic value and if we find it, then
60  // assume we're being set by an unset box.
61  box_set = (c.x() != 99999 || c.y() != 99999 || c.z() != 99999);
62  }
63 
64  bool isPeriodic(void) const { return(box_set); }
65  void setPeriodic(const bool b) { box_set = b; }
66 
67  private:
68  GCoord thebox;
69  bool box_set;
70  };
71 
72 
74 
82  public:
83  SharedPeriodicBox() : pbox(new PeriodicBox) { }
84  GCoord box(void) const { return(pbox->box()); }
85  void box(const GCoord& c) { pbox->box(c); }
86  bool isPeriodic(void) const { return(pbox->isPeriodic()); }
87 
88 
89  SharedPeriodicBox copy(void) const {
90  SharedPeriodicBox thecopy;
91 
92  if (isPeriodic())
93  thecopy.box(box());
94 
95  return(thecopy);
96  }
97 
98  private:
99  boost::shared_ptr<PeriodicBox> pbox;
100  };
101 
102 }
103 
104 #endif
Class for managing periodic box information.
Definition: PeriodicBox.hpp:47
This class manages a shared Periodicbox.
Definition: PeriodicBox.hpp:81
Namespace for most things not already encapsulated within a class.