Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DOF_ID.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/id/DOF_ID.hh
11 /// @author Phil Bradley
12 
13 
14 #ifndef INCLUDED_core_id_DOF_ID_hh
15 #define INCLUDED_core_id_DOF_ID_hh
16 
17 
18 // Unit headers
19 #include <core/id/DOF_ID.fwd.hh>
20 
21 // Package headers
22 #include <core/id/types.hh>
23 #include <core/id/AtomID.hh>
24 
25 // Numeric headers
26 //#include <numeric/constants.hh>
27 //#include <numeric/numeric.functions.hh>
28 
29 // Utility headers
30 //#include <utility/exit.hh>
31 
32 // C++ header
33 #include <cassert>
34 
35 namespace core {
36 namespace id {
37 
38 
39 /// @brief Kinematics DOF identifier class
40 class DOF_ID
41 {
42 
43 public: // Creation
44 
45  DOF_ID(){};
46 
48  AtomID const & atom_id_in,
49  DOF_Type const & type_in
50  ):
51  atom_id_( atom_id_in ),
52  type_( type_in )
53  {};
54 
55 public: // Properties
56 
57  inline
58  AtomID const &
59  atom_id() const { return atom_id_; }
60 
61  inline
62  Size
63  rsd() const { return atom_id_.rsd(); }
64 
65  inline
66  Size
67  atomno() const { return atom_id_.atomno(); }
68 
69  inline
70  DOF_Type
71  type() const { return type_; }
72 
73 
74  /// @brief Is this DOF_ID valid?
75  /// @note Must return false for BOGUS_TORSION_ID.
76  inline
77  bool
78  valid() const { return atom_id_.valid(); }
79 
80 public: // Friends
81 
82  friend
83  std::ostream &
85  std::ostream & os,
86  DOF_ID const & a
87  );
88 
89  friend
90  inline
91  bool
93  DOF_ID const & a,
94  DOF_ID const & b
95  ) { return a.atom_id_ == b.atom_id_ && a.type_ == b.type_; }
96 
97  friend
98  inline
99  bool
101  DOF_ID const & a,
102  DOF_ID const & b
103  ) { return a.atom_id_ != b.atom_id_ || a.type_ != b.type_; }
104 
105  friend
106  inline
107  bool
109  DOF_ID const & a,
110  DOF_ID const & b
111  )
112  {
113  return ( a.atom_id_ < b.atom_id_ ||
114  ( a.atom_id_ == b.atom_id_ && a.type_ < b.type_ ) );
115  }
116 
117 private: // Fields
118 
119  /// @brief Atom identifier
121 
122  /// @brief DOF type
124 
125 }; // DOF_ID
126 
127 
128 /// @brief Globals
129 extern DOF_ID const BOGUS_DOF_ID;
130 
131 
132 /////////////////////////////////////////////////////////////////////////////
133 // @brief helpful conversion
134 inline
135 DOF_Type
136 get_rb_type( Size const k ) {
137  assert( k>=1 && k<=6 );
138 // return ( k == 1 ? RB1 : ( k==2 ? RB2 : ( k == 3 ? RB3 :
139 // ( k == 4 ? RB4 : ( k==5 ? RB5 : RB6 ) ) ) ) );
140  return DOF_Type( RB1 + k - 1 ); //SGM I think this should work and be a little faster: Requires RB's to be contiguous but that seem safe
141 }
142 
143 
144 /////////////////////////////////////////////////////////////////////////////
145 inline
146 Size
148 // if ( t == PHI || t == THETA || t == D ) return 0;
149 // else {
150 // return ( t == RB1 ? 1 : ( t == RB2 ? 2 : ( t == RB3 ? 3 :
151 // ( t == RB4 ? 4 : t == RB5 ? 5 : 6 ) ) ) );
152 // }
153  return ( ( t >= RB1 ) && ( t <= RB6 ) ? t - RB1 + 1 : 0 ); //SGM I think this should work and be a little faster: Requires RB's to be contiguous but that seem safe
154 }
155 
156 
157 /////////////////////////////////////////////////////////////////////////////
158 inline
159 bool
161 {
162  return ( t >= RB1 && t <= RB6 );
163 }
164 
165 /////////////////////////////////////////////////////////////////////////////
166 // inline
167 // float
168 // subtract_dofs(
169 // float const value1,
170 // float const value2,
171 // DOF_Type const t
172 // )
173 // {
174 // if ( t == D || t == RB1 || t == RB2 || t == RB3 ) {
175 // return value1 - value2;
176 // } else if ( t == PHI || t == THETA || t == RB4 || t == RB5 || t == RB6 ) {
177 // using numeric::mod;
178 // // stolen from subtract_radian_angles:
179 // float const a( value1 - value2 );
180 // float const x( numeric::constants::f::pi_2 );
181 // // stolen from periodic_range:
182 // float const halfx = 0.5f * x;
183 // return ( ( a >= halfx || a < -halfx ) ?
184 // mod( mod( a, x ) + ( x + halfx ), x ) - halfx :
185 // a );
186 // } else {
187 // std::cerr << "bad torsion type for subtract_dofs: " << t << std::endl;
188 // utility_exit();
189 // }
190 // return 0.0;
191 // }
192 
193 
194 } // namespace id
195 } // namespace core
196 
197 
198 #endif // INCLUDED_core_id_DOF_ID_HH