Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
util.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/packstat/util.hh
11 ///
12 /// @brief
13 /// @author will sheffler
14 
15 
16 #ifndef INCLUDED_core_scoring_packstat_util_hh
17 #define INCLUDED_core_scoring_packstat_util_hh
18 
21 // AUTO-REMOVED #include "core/scoring/packstat/SimplePDB_Atom.hh"
22 
23 #include "numeric/xyzVector.hh"
24 
25 
26 namespace core {
27 namespace scoring {
28 namespace packstat {
29 
30 // searches for sphere/ball in vector sorted by x value
31 inline size_t search_x( Spheres const & spheres, PackstatReal const x, size_t begin, size_t end ) {
32  if( end - begin < 2 ) return begin;
33  size_t mid = ( end - begin ) / 2 + begin;
34  if( spheres[mid].xyz.x() <= x ) {
35  return search_x( spheres, x, mid, end );
36  } else {
37  return search_x( spheres, x, 1 , mid-1 );
38  }
39 }
40 
41 inline size_t search_x( Spheres const & spheres, PackstatReal const x ) {
42  return search_x( spheres, x, (size_t)1, spheres.size() );
43 }
44 
45 inline size_t search_x( CavBalls const & cbs , PackstatReal const x, size_t begin, size_t end ) {
46  if( end - begin < 2 ) return begin;
47  size_t mid = ( end - begin ) / 2 + begin;
48  if( cbs[mid].xyz().x() <= x ) {
49  return search_x( cbs, x, mid, end );
50  } else {
51  return search_x( cbs, x, 1 , mid-1 );
52  }
53 }
54 
55 inline size_t search_x( CavBalls const & cbs , PackstatReal const x ) {
56  return search_x( cbs, x, (size_t)1, cbs.size() );
57 }
58 
59 inline PackstatReal max_rad( Spheres const & s ) {
60  PackstatReal maxrad = 0;
61  for( SphereCIter i = s.begin(); i != s.end(); ++i ) {
62  if( maxrad < i->radius ) maxrad = i->radius;
63  }
64  return maxrad;
65 }
66 
67 inline PackstatReal max_rad( CavBalls const & s ) {
68  PackstatReal maxrad = 0;
69  for( CavBallCIter i = s.begin(); i != s.end(); ++i ) {
70  if( maxrad < i->radius() ) maxrad = i->radius();
71  }
72  return maxrad;
73 }
74 
75 } // namespace packstat
76 } // namespace scoring
77 } // namespace core
78 
79 #endif