Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
EtableAtom.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_etable_etrie_EtableAtom_hh
15 #define INCLUDED_core_scoring_etable_etrie_EtableAtom_hh
16 
17 // Unit Headers
19 
20 // Project Headers
23 #include <core/types.hh>
24 
25 // STL Headers
26 #include <iostream>
27 
28 // Numceric Headers
29 #include <numeric/xyzVector.hh>
30 
31 namespace core {
32 namespace scoring {
33 namespace etable {
34 namespace etrie {
35 
37 {
38 public:
40 
41 public:
42  EtableAtom();
43 
44  EtableAtom( conformation::Residue const & res, Size atom_index );
45 
46  /// @brief non-virtual destructor to keep EtableAtom small and lightweight
47  /// as a virtual destructor would add a vtable to the class
48  /// But I fear leaks... do I know how xyzVector dealloates its data?
49  virtual ~EtableAtom();
50 
51  /// @brief deprecated!
52  inline
53  int atom_type() const { return type(); }
54  /// @brief deprecated!
55  inline
56  void atom_type( int setting ) { type( setting ); }
57 
58  /// @brief property required by RotamerTrie class
59  inline
60  bool is_hydrogen() const { return is_hydrogen_; }
61 
62  /// @brief setter method for data required by RotamerTrie class
63  inline
64  void is_hydrogen( bool setting ) { is_hydrogen_ = setting; }
65 
66  /// @brief send a description of the atom to standard out
67  void print() const;
68 
69  /// @brief send a description of the atom to an output stream
70  void print( std::ostream & os ) const;
71 
72  /// @brief compairison operator for sorting
73  inline
74  bool operator < ( EtableAtom const & other ) const
75  {
76  if ( type() == other.type() ) {
77  // Quoting Jack Snoeyink: "Epsilons in code are evil." But whatcha gonna do?
78  // In this case, though, you could get points a, b, and c such that a == b, b == c, but a < c.
79  // In rare cases this would cause the std::sort() insertion sort step
80  // to run off the end of the array/vector and cause a segfault in the trie.
81  for ( int ii = 0; ii< 3; ++ii ) {
82  //Distance diff = std::abs( xyz()[ ii ] - other.xyz()[ ii ] );
83  //if ( diff > EPSILON ) {
84  if ( float(xyz()[ ii ]) != float(other.xyz()[ ii ]) ) {
85  return xyz()[ ii ] < other.xyz()[ ii ];
86  }
87  }
88  } else {
89  return type() < other.type();
90  }
91  return false;
92  }
93 
94  /// @brief equality operator for shared-prefix detection
95  inline
96  bool operator == ( EtableAtom const & other ) const
97  {
98  if ( type() == other.type() ) {
99  for ( int ii = 0; ii< 3; ++ii ) {
100  // Epsilons bad -- see above.
101  //Distance diff = std::abs( xyz()[ ii ] - other.xyz()[ ii ] );
102  //if ( diff > EPSILON ) {
103  if ( float(xyz()[ ii ]) != float(other.xyz()[ ii ]) ) {
104  return false;
105  }
106  }
107  } else {
108  return false;
109  }
110  return true;
111  }
112 
113 
114 private:
115 
117 
118 };
119 
120 std::ostream & operator << ( std::ostream & os, EtableAtom const & atom );
121 
122 } // namespace etrie
123 } // namespace etable
124 } // namespace scoring
125 } // namespace core
126 
127 #endif