Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ElecAtom.hh
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file core/scoring/etable/etrie/EtableAtom.hh
11 /// @brief
12 /// @author Andrew Leaver-Fay (aleaverfay@gmail.com)
13 
14 #ifndef INCLUDED_core_scoring_hackelec_ElecAtom_hh
15 #define INCLUDED_core_scoring_hackelec_ElecAtom_hh
16 
17 // Unit Headers
19 
20 // Project Headers
23 #include <core/types.hh>
24 
25 // STL Headers
26 #include <iostream>
27 
28 namespace core {
29 namespace scoring {
30 namespace hackelec {
31 
33 {
34 public:
36 
37 public:
38  ElecAtom();
39 
40  ElecAtom( conformation::Residue const & res, Size atom_index );
41 
42  /// @brief non-virtual destructor to keep ElecAtom small and lightweight
43  /// as a virtual destructor would add a vtable to the class
44  /// But I fear leaks... do I know how xyzVector dealloates its data?
45  virtual ~ElecAtom();
46 
47  /// @brief deprecated!
48  inline
49  int atom_type() const { return type(); }
50  /// @brief deprecated!
51  inline
52  void atom_type( int setting ) { type( setting ); }
53 
54  inline
55  Real charge() const { return charge_; }
56 
57  inline
58  void charge( Real setting ) { charge_ = setting; }
59 
60  /// @brief property required by RotamerTrie class
61  inline
62  bool is_hydrogen() const { return is_hydrogen_; }
63 
64  /// @brief setter method for data required by RotamerTrie class
65  inline
66  void is_hydrogen( bool setting ) { is_hydrogen_ = setting; }
67 
68  /// @brief send a description of the atom to standard out
69  void print() const;
70 
71  /// @brief send a description of the atom to an output stream
72  void print( std::ostream & os ) const;
73 
74  /// @brief compairison operator for sorting
75  inline
76  bool operator < ( ElecAtom const & other ) const
77  {
78  if ( type() == other.type() ) {
79  if ( isbb() == other.isbb() ) {
80  if ( charge_ == other.charge_ ) {
81  // Quoting Jack Snoeyink: "Epsilons in code are evil." But whatcha gonna do?
82  // In this case, though, you could get points a, b, and c such that a == b, b == c, but a < c.
83  // In rare cases this would cause the std::sort() insertion sort step
84  // to run off the end of the array/vector and cause a segfault in the trie.
85  for ( int ii = 0; ii< 3; ++ii ) {
86  //Distance diff = std::abs( xyz()[ ii ] - other.xyz()[ ii ] );
87  //if ( diff > EPSILON ) {
88  if ( float(xyz()[ ii ]) != float(other.xyz()[ ii ]) ) {
89  return xyz()[ ii ] < other.xyz()[ ii ];
90  }
91  }
92  } else {
93  return charge_ < other.charge_;
94  }
95  } else {
96  return isbb() < other.isbb();
97  }
98  } else {
99  return type() < other.type();
100  }
101  return false;
102  }
103 
104  /// @brief equality operator for shared-prefix detection
105  inline
106  bool operator == ( ElecAtom const & other ) const
107  {
108  if ( type() == other.type() && isbb() == other.isbb() ) {
109  if ( charge_ == other.charge_ ) {
110  for ( int ii = 0; ii< 3; ++ii ) {
111  // Epsilons bad -- see above.
112  //Distance diff = std::abs( xyz()[ ii ] - other.xyz()[ ii ] );
113  //if ( diff > EPSILON ) {
114  if ( float(xyz()[ ii ]) != float(other.xyz()[ ii ]) ) {
115  return false;
116  }
117  }
118  } else {
119  return false;
120  }
121  } else {
122  return false;
123  }
124  return true;
125  }
126 
127  bool
128  isbb() const {
129  return isbb_;
130  }
131 
132 private:
133  bool isbb_;
136 
137 };
138 
139 std::ostream & operator << ( std::ostream & os, ElecAtom const & atom );
140 
141 } // namespace hackelec
142 } // namespace scoring
143 } // namespace core
144 
145 #endif