Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OccupiedSpaceHash.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 // :noTabs=false:tabSize=4:indentSize=4:
4 //
5 // (c) Copyright Rosetta Commons Member Institutions.
6 // (c) This file is part of the Rosetta software suite and is made available under license.
7 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
8 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
9 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
10 
11 /// @file protocols/match/OccupiedSpaceHash.hh
12 /// @brief Declaration for classes in 6D hasher
13 /// @author Alex Zanghellini (zanghell@u.washington.edu)
14 /// @author Andrew Leaver-Fay (aleaverfay@gmail.com), porting to mini
15 
16 #ifndef INCLUDED_protocols_match_OccupiedSpaceHash_hh
17 #define INCLUDED_protocols_match_OccupiedSpaceHash_hh
18 
19 // Unit headers
21 
22 // Package headers
24 
25 // project headers
26 #include <core/types.hh>
27 
28 // Numeric headers
29 #include <numeric/xyzVector.hh>
30 #include <numeric/geometry/BoundingBox.hh>
31 #include <numeric/geometry/hashing/SixDHasher.hh>
32 
33 // Utility headers
34 #include <utility/pointer/ReferenceCount.hh>
35 #include <utility/fixedsizearray1.hh>
36 // AUTO-REMOVED #include <utility/vector1.hh>
37 
38 
39 /// Boost headers
40 // AUTO-REMOVED #include <boost/cstdint.hpp>
41 #include <boost/unordered_map.hpp>
42 
43 namespace protocols {
44 namespace match {
45 
46 
47 /// @brief This class keeps track of the active voxels "up until now" with 64 hashes.
48 ///
49 /// @details
50 /// Each hash has a slightly shifted definition of the origin, so that points which
51 /// are close in 6D will end up in the same hash voxel in at least one of these 64 hashes.
52 /// The amount of data held in this table is intentionally small: a single boolean (32 bits).
53 /// The meaning is as follows:
54 /// In the first round of matching constraints, "false" is inserted into each of the hashes
55 /// for each non-colliding placement of the downstream partner.
56 /// The map is not altered between the end of the first round and the beginning of the second round.
57 /// At the end of all rounds besides the first round, the Matcher updates the OccupiedSpaceHash
58 /// object for each non-colliding placement of the dowstream partner found during that round:
59 /// for each non-colliding placement of the downstream partner and for
60 /// each of the 64 hashes, the 6Dofs describing the downstream partner are hashed: if the
61 /// hash finds an element in the hash table, that element's value is set to "true".
62 /// At the end of each round past the second round, the entire hash is traversed. Any element
63 /// whose value is "false" represents a voxel that failed to find a match during that round. Such
64 /// elements are deleted from the hash. Any element whose value is "true" DID get a hit from that
65 /// round and should remain in the hash. The element's value is set to "false".
66 /// After the OccupiedSpaceHash has cleared out the elements which failed to find a match for the
67 /// previous round, the Matcher may proceed to "clean up" its older hits (from rounds previous to this one)
68 /// by querying them against the hash map. Any hit in the Matcher that does not have a corresponding element
69 /// in any of the 64 hashes of the OccupiedSpaceHash may be deleted, since it cannot form
70 /// a complete match.
71 ///
72 /// This class is intended to be accessed by multiple threads but in a controlled way:
73 /// read access function "match_possible_for_hit_geometry" is accessible to all threads
74 /// during the "building" stage. However, the functions note_hit_geometry and
75 /// drop_unsatisfied_voxels should be called by single thread only, and no other thread
76 /// should try to access the ActiveVoxelHashes object at that time.
78 public:
79  typedef core::Real Real;
80  typedef core::Size Size;
82  typedef numeric::geometry::BoundingBox< Vector > BoundingBox;
86  typedef boost::unordered_map< boost::uint64_t, boost::uint64_t, numeric::geometry::hashing::bin_index_hasher > ActiveVoxelSet;
87 
88 public:
90  virtual ~OccupiedSpaceHash();
91 
92  void
94  BoundingBox const & bb
95  );
96 
97  void
98  set_uniform_xyz_bin_width( Real bin_width );
99 
100  void
101  set_uniform_euler_angle_bin_width( Real bin_width_degrees );
102 
103  void
104  set_xyz_bin_widths( Vector const & bin_widths );
105 
106  void
107  set_euler_bin_widths( Vector const & euler_bin_widths );
108 
109  //void
110  //set_expected_hash_count();
111 
112  void
113  initialize();
114 
115  void
116  insert_hit_geometry( Real6 const & geom );
117 
118  void
120 
121  void
122  note_hit_geometry( Real6 const & );
123 
124  void
126 
127  bool
129 
130  bool
131  match_possible_for_hit_geometry( Real6 const & ) const;
132 
133  void
135 
136  void write_3Dprojection_kinemage( std::string const & kin_file_name );
137 
138  Size
139  revision_id() const;
140 
141 private:
142 
143  void
144  project_point_to_3d( Real6 const & geom );
145 
146  boost::uint64_t
147  bitmask_for_position( Size pos ) const;
148 
149  boost::uint64_t
150  calc_bin_index( numeric::geometry::hashing::Bin6D const & bin ) const;
151 
152 private:
153 
155 
157 
160  utility::fixedsizearray1< boost::uint64_t, 6 > dim_prods_;
161 
162  utility::fixedsizearray1< Real, 3 > xyz_bin_widths_;
163  utility::fixedsizearray1< Real, 3 > euler_bin_widths_;
164 
165  utility::fixedsizearray1< Real, 3 > xyz_bin_halfwidths_;
166  utility::fixedsizearray1< Real, 3 > euler_bin_halfwidths_;
167 
168  //utility::fixedsizearray1< Real, 3 > xyz_width_root3_;
169 
171 
173 
175 
176 };
177 
178 }
179 }
180 
181 #endif